Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33c7e03b authored by Hemant Gupta's avatar Hemant Gupta Committed by Myles Watson
Browse files

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
parent ec6da667
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -103,12 +103,24 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment {
    public void onStart() {
        super.onStart();
        addCachedDevices();
        mSelectedDevice = null;
        if (mStartScanOnStart) {
            mLocalAdapter.startScanning(true);
            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
    void onDevicePreferenceClick(BluetoothDevicePreference btPreference) {
        mLocalAdapter.stopScanning();