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

Commit 0b417d6b authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Bluetooth: Handle onPause in DevicePickerFragment class"

parents e8cb0a93 7ec10189
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) {