Bluetooth: Fix Resource Leak in OPP (1/2)
Handle onDestroy 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. Test: Performed the usecase overnight and see if no crash is observed. Bug: 35626275 Change-Id: Ib3965d7dea8d59b244abdc6ffe61ef21109346fb
This commit is contained in:
committed by
Myles Watson
parent
ec6da66728
commit
33c7e03b6a
@@ -103,12 +103,24 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment {
|
|||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
addCachedDevices();
|
addCachedDevices();
|
||||||
|
mSelectedDevice = null;
|
||||||
if (mStartScanOnStart) {
|
if (mStartScanOnStart) {
|
||||||
mLocalAdapter.startScanning(true);
|
mLocalAdapter.startScanning(true);
|
||||||
mStartScanOnStart = false;
|
mStartScanOnStart = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
/* Check if any device was selected, if no device selected
|
||||||
|
* send ACTION_DEVICE_SELECTED with a null device, otherwise
|
||||||
|
* don't do anything */
|
||||||
|
if (mSelectedDevice == null) {
|
||||||
|
sendDevicePickedIntent(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onDevicePreferenceClick(BluetoothDevicePreference btPreference) {
|
void onDevicePreferenceClick(BluetoothDevicePreference btPreference) {
|
||||||
mLocalAdapter.stopScanning();
|
mLocalAdapter.stopScanning();
|
||||||
|
Reference in New Issue
Block a user