diff options
author | Hemant Gupta <hemantg@codeaurora.org> | 2014-05-01 17:29:38 +0530 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:21:08 -0600 |
commit | 6f5528f4cb61d5619f7ddf3cd1ae8c74fe1de0da (patch) | |
tree | ea5b7759ff0d96378315fec11f94e58e0bd057f4 /src | |
parent | babc6b4611384abc484beee4cdda1228197c501b (diff) | |
download | packages_apps_Settings-6f5528f4cb61d5619f7ddf3cd1ae8c74fe1de0da.zip packages_apps_Settings-6f5528f4cb61d5619f7ddf3cd1ae8c74fe1de0da.tar.gz packages_apps_Settings-6f5528f4cb61d5619f7ddf3cd1ae8c74fe1de0da.tar.bz2 |
Bluetooth: Fix resource leak in OPP (2/3)
This patch handles onPause in DevicePickerFragment class, which
would be called when user presses back button and does not select
any device. This will send intent to class that called
DevicePickerFragment that no device is selected.
CRs-Fixed: 662147, 706665
Change-Id: I3dcf2811b300e44c0f3cb713c1397b5d334e8284
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/bluetooth/DevicePickerFragment.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/com/android/settings/bluetooth/DevicePickerFragment.java b/src/com/android/settings/bluetooth/DevicePickerFragment.java index 9441626..cbcc337 100644 --- a/src/com/android/settings/bluetooth/DevicePickerFragment.java +++ b/src/com/android/settings/bluetooth/DevicePickerFragment.java @@ -48,6 +48,7 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment { private String mLaunchPackage; private String mLaunchClass; private boolean mStartScanOnResume; + private boolean mDeviceSelected; @Override void addPreferencesForActivity() { @@ -103,6 +104,7 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment { public void onResume() { super.onResume(); addCachedDevices(); + mDeviceSelected = false; if (mStartScanOnResume) { mLocalAdapter.startScanning(true); mStartScanOnResume = false; @@ -110,6 +112,21 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment { } @Override + public void onDestroy() { + super.onDestroy(); + /* Check if any device was selected, if no device selected + * send ACTION_DEVICE_NOT_SELECTED intent, otherwise + * don;t do anything */ + if (!mDeviceSelected) { + Intent intent = new Intent(BluetoothDevicePicker.ACTION_DEVICE_NOT_SELECTED); + if (mLaunchPackage != null && mLaunchClass != null) { + intent.setClassName(mLaunchPackage, mLaunchClass); + } + getActivity().sendBroadcast(intent); + } + } + + @Override void onDevicePreferenceClick(BluetoothDevicePreference btPreference) { mLocalAdapter.stopScanning(); LocalBluetoothPreferences.persistSelectedDeviceInPicker( @@ -144,6 +161,7 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment { } private void sendDevicePickedIntent(BluetoothDevice device) { + mDeviceSelected = true; Intent intent = new Intent(BluetoothDevicePicker.ACTION_DEVICE_SELECTED); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); if (mLaunchPackage != null && mLaunchClass != null) { |