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

Commit 280dfac8 authored by SongFerngWang's avatar SongFerngWang Committed by SongFerng Wang
Browse files

Fix the NullPointerException

Add the checking of null point for LocalBluetoothProfileManager

Bug: 296442243
Test: [pass]make RunSettingsRoboTests ROBOTEST_FILTER=MediaOutputIndicatorWorkerTest
Change-Id: Ieb38feec0a8a6b1f28c3ebd256ae7482c96fdf55
parent 67d5cb42
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -167,12 +167,20 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements

    /** Check if this device supports LE Audio Broadcast feature */
    public boolean isBroadcastSupported() {
        if (mLocalBluetoothManager == null) {
            Log.e(TAG, "isBroadcastSupported: Bluetooth is not supported on this device");
            return false;
        }
        LocalBluetoothLeBroadcast broadcast =
                mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile();
        return broadcast != null ? true : false;
    }

    public boolean isDeviceBroadcasting() {
        if (mLocalBluetoothManager == null) {
            Log.e(TAG, "isDeviceBroadcasting: Bluetooth is not supported on this device");
            return false;
        }
        LocalBluetoothLeBroadcast broadcast =
                mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile();
        if (broadcast == null) {
+14 −0
Original line number Diff line number Diff line
@@ -313,4 +313,18 @@ public class MediaOutputIndicatorWorkerTest {

        assertThat(mMediaOutputIndicatorWorker.isBroadcastSupported()).isTrue();
    }

    @Test
    public void isBroadcastSupported_noLocalMediaManager_returnFalse() {
        mMediaOutputIndicatorWorker.mLocalMediaManager = null;

        assertThat(mMediaOutputIndicatorWorker.isBroadcastSupported()).isFalse();
    }

    @Test
    public void isDeviceBroadcasting_noLocalMediaManager_returnFalse() {
        mMediaOutputIndicatorWorker.mLocalMediaManager = null;

        assertThat(mMediaOutputIndicatorWorker.isDeviceBroadcasting()).isFalse();
    }
}