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

Commit 7ec10189 authored by Hemant Gupta's avatar Hemant Gupta Committed by Gerrit - the friendly Code Review server
Browse files

Bluetooth: Handle onPause in DevicePickerFragment class

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.

Change-Id: Ib3965d7dea8d59b244abdc6ffe61ef21109346fb
CRs-Fixed: 662147
parent 666a5427
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -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,12 +104,28 @@ public final class DevicePickerFragment extends DeviceListPreferenceFragment {
    public void onResume() {
        super.onResume();
        addCachedDevices();
        mDeviceSelected = false;
        if (mStartScanOnResume) {
            mLocalAdapter.startScanning(true);
            mStartScanOnResume = false;
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        /* 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();
@@ -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) {