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

Commit a9d3398d authored by SongFerng Wang's avatar SongFerng Wang Committed by Automerger Merge Worker
Browse files

Merge "[LeBroadcast] Fix the NullPointerException for launching dialog" into...

Merge "[LeBroadcast] Fix the NullPointerException for launching dialog" into tm-qpr-dev am: e2d4dcf0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19378986



Change-Id: I778d41179531c7c1d267c6aa3720088340dc1e6f
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 89c25ce1 e2d4dcf0
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -303,6 +303,18 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
    }

    public BluetoothLeBroadcastMetadata getLatestBluetoothLeBroadcastMetadata() {
        if (mService == null) {
            Log.d(TAG, "The BluetoothLeBroadcast is null");
            return null;
        }
        if (mBluetoothLeBroadcastMetadata == null) {
            final List<BluetoothLeBroadcastMetadata> metadataList =
                    mService.getAllBroadcastMetadata();
            mBluetoothLeBroadcastMetadata = metadataList.stream()
                    .filter(i -> i.getBroadcastId() == mBroadcastId)
                    .findFirst()
                    .orElse(null);
        }
        return mBluetoothLeBroadcastMetadata;
    }

@@ -372,7 +384,12 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
    }

    public LocalBluetoothLeBroadcastMetadata getLocalBluetoothLeBroadcastMetaData() {
        return new LocalBluetoothLeBroadcastMetadata(mBluetoothLeBroadcastMetadata);
        final BluetoothLeBroadcastMetadata metadata = getLatestBluetoothLeBroadcastMetadata();
        if (metadata == null) {
            Log.d(TAG, "The BluetoothLeBroadcastMetadata is null.");
            return null;
        }
        return new LocalBluetoothLeBroadcastMetadata(metadata);
    }

    public boolean isProfileReady() {
+9 −1
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
    private int mListMaxHeight;
    private WallpaperColors mWallpaperColors;
    private Executor mExecutor;
    private boolean mShouldLaunchLeBroadcastDialog;

    MediaOutputBaseAdapter mAdapter;

@@ -399,7 +400,9 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
    }

    public void handleLeBroadcastStarted() {
        startLeBroadcastDialog();
        // Waiting for the onBroadcastMetadataChanged. The UI launchs the broadcast dialog when
        // the metadata is ready.
        mShouldLaunchLeBroadcastDialog = true;
    }

    public void handleLeBroadcastStartFailed() {
@@ -409,10 +412,15 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
    }

    public void handleLeBroadcastMetadataChanged() {
        if (mShouldLaunchLeBroadcastDialog) {
            startLeBroadcastDialog();
            mShouldLaunchLeBroadcastDialog = false;
        }
        refresh();
    }

    public void handleLeBroadcastStopped() {
        mShouldLaunchLeBroadcastDialog = false;
        refresh();
    }

+4 −1
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.Utils;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastMetadata;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.media.InfoMediaManager;
import com.android.settingslib.media.LocalMediaManager;
@@ -834,7 +835,9 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
            Log.d(TAG, "getBroadcastMetadata: LE Audio Broadcast is null");
            return "";
        }
        return broadcast.getLocalBluetoothLeBroadcastMetaData().convertToQrCodeString();
        final LocalBluetoothLeBroadcastMetadata metadata =
                broadcast.getLocalBluetoothLeBroadcastMetaData();
        return metadata != null ? metadata.convertToQrCodeString() : "";
    }

    boolean isActiveRemoteDevice(@NonNull MediaDevice device) {