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

Commit 59287d40 authored by ryanywlin's avatar ryanywlin
Browse files

2nd attempt handle BT is not supported on emulator

Error handle before using LocalBluetoothManager in the onStart
and onStop

Bug: 80491267
Test: make RunSettingsRoboTests ROBOTEST_FILTER="AudioOutputSwitchPreferenceControllerTest" -j42
Change-Id: I47f7d3b7cddc2fbbafb8fb5cf0fb6adb2d0d2d55
parent ee96c3a2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -170,12 +170,20 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont

    @Override
    public void onStart() {
        if (mLocalBluetoothManager == null) {
            Log.e(TAG, "Bluetooth is not supported on this device");
            return;
        }
        mLocalBluetoothManager.setForegroundActivity(mContext);
        register();
    }

    @Override
    public void onStop() {
        if (mLocalBluetoothManager == null) {
            Log.e(TAG, "Bluetooth is not supported on this device");
            return;
        }
        mLocalBluetoothManager.setForegroundActivity(null);
        unregister();
    }
+2 −0
Original line number Diff line number Diff line
@@ -186,6 +186,8 @@ public class AudioOutputSwitchPreferenceControllerTest {

        AudioSwitchPreferenceController controller = new AudioSwitchPreferenceControllerTestable(
                mContext, TEST_KEY);
        controller.onStart();
        controller.onStop();

        assertThat(mLocalBluetoothManager).isNull();
    }