diff options
author | PauloftheWest <paulofthewest@google.com> | 2014-09-08 21:00:11 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-09-08 21:00:11 +0000 |
commit | 5fe30ea841d0512c414059c814a0d1e0590b7eeb (patch) | |
tree | 94d281992a12277fe0b938e4e468a45aa4a88e2e /src/com/android/settings/bluetooth/BluetoothSettings.java | |
parent | 01f3a15e89f80d88ba8600a53f5722468fecd4c9 (diff) | |
parent | 469c8128786154cb8c0408709545f7adc6beaeb7 (diff) | |
download | packages_apps_Settings-5fe30ea841d0512c414059c814a0d1e0590b7eeb.zip packages_apps_Settings-5fe30ea841d0512c414059c814a0d1e0590b7eeb.tar.gz packages_apps_Settings-5fe30ea841d0512c414059c814a0d1e0590b7eeb.tar.bz2 |
Merge "Turning Bluetooth on will make the device discoverable." into lmp-dev
Diffstat (limited to 'src/com/android/settings/bluetooth/BluetoothSettings.java')
-rwxr-xr-x | src/com/android/settings/bluetooth/BluetoothSettings.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index e29ccc9..a752fd9 100755 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -83,6 +83,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem private boolean mAvailableDevicesCategoryIsPresent; private boolean mInitialScanStarted; + private boolean mInitiateDiscoverable; private TextView mEmptyView; private SwitchBar mSwitchBar; @@ -119,6 +120,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mInitialScanStarted = (savedInstanceState != null); // don't auto start scan after rotation + mInitiateDiscoverable = true; mEmptyView = (TextView) getView().findViewById(android.R.id.empty); getListView().setEmptyView(mEmptyView); @@ -153,8 +155,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem } super.onResume(); - // Make the device visible to other devices. - mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE); + mInitiateDiscoverable = true; if (isUiRestricted()) { setDeviceListGroup(getPreferenceScreen()); @@ -325,6 +326,14 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem preferenceScreen.addPreference(mMyDevicePreference); getActivity().invalidateOptionsMenu(); + + // mLocalAdapter.setScanMode is internally synchronized so it is okay for multiple + // threads to execute. + if (mInitiateDiscoverable) { + // Make the device visible to other devices. + mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE); + mInitiateDiscoverable = false; + } return; // not break case BluetoothAdapter.STATE_TURNING_OFF: |