赞
踩
打开蓝牙时,直接打开蓝牙可见性。如下:
路径:****/packages/apps/Bluetooth/src/com/android/bluetooth/btservice/AdapterProperties.java
- void onBluetoothReady() {
- Log.d(TAG, "ScanMode = " + mScanMode );
- Log.d(TAG, "State = " + getState() );
-
- // When BT is being turned on, all adapter properties will be sent in 1
- // callback. At this stage, set the scan mode.
- synchronized (mObject) {
- if (getState() == BluetoothAdapter.STATE_TURNING_ON &&
- mScanMode == BluetoothAdapter.SCAN_MODE_NONE) {
- /* mDiscoverableTimeout is part of the
- adapterPropertyChangedCallback received before
- onBluetoothReady */
- if (mDiscoverableTimeout != 0)
- //setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE);
- setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
- else /* if timeout == never (0) at startup */
- setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
- /* though not always required, this keeps NV up-to date on first-boot after flash */
- setDiscoverableTimeout(mDiscoverableTimeout);
- }
- }
- }

如上图: 将 setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE); 改为
setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);即可。
路径:******/packages/apps/Settings/src/com/android/settings/bluetooth/BluetoothSettings.java
- @Override
- public void onPause() {
- super.onPause();
- if (mBluetoothEnabler != null) {
- mBluetoothEnabler.pause();
- }
-
- // Make the device only visible to connected devices.
- //mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
-
- if (isUiRestricted()) {
- return;
- }
-
- getActivity().unregisterReceiver(mReceiver);
- }

如上图,在onPause()方法中将mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);注释掉即可。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。