Merge "[LeBroadcast] Fix the NullPointerException for launching dialog" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e2d4dcf0e5
@@ -303,6 +303,18 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BluetoothLeBroadcastMetadata getLatestBluetoothLeBroadcastMetadata() {
|
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;
|
return mBluetoothLeBroadcastMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +384,12 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LocalBluetoothLeBroadcastMetadata getLocalBluetoothLeBroadcastMetaData() {
|
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() {
|
public boolean isProfileReady() {
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
|||||||
private int mListMaxHeight;
|
private int mListMaxHeight;
|
||||||
private WallpaperColors mWallpaperColors;
|
private WallpaperColors mWallpaperColors;
|
||||||
private Executor mExecutor;
|
private Executor mExecutor;
|
||||||
|
private boolean mShouldLaunchLeBroadcastDialog;
|
||||||
|
|
||||||
MediaOutputBaseAdapter mAdapter;
|
MediaOutputBaseAdapter mAdapter;
|
||||||
|
|
||||||
@@ -399,7 +400,9 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleLeBroadcastStarted() {
|
public void handleLeBroadcastStarted() {
|
||||||
startLeBroadcastDialog();
|
// Waiting for the onBroadcastMetadataChanged. The UI launchs the broadcast dialog when
|
||||||
|
// the metadata is ready.
|
||||||
|
mShouldLaunchLeBroadcastDialog = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleLeBroadcastStartFailed() {
|
public void handleLeBroadcastStartFailed() {
|
||||||
@@ -409,10 +412,15 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleLeBroadcastMetadataChanged() {
|
public void handleLeBroadcastMetadataChanged() {
|
||||||
|
if (mShouldLaunchLeBroadcastDialog) {
|
||||||
|
startLeBroadcastDialog();
|
||||||
|
mShouldLaunchLeBroadcastDialog = false;
|
||||||
|
}
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleLeBroadcastStopped() {
|
public void handleLeBroadcastStopped() {
|
||||||
|
mShouldLaunchLeBroadcastDialog = false;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import com.android.settingslib.RestrictedLockUtilsInternal;
|
|||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||||
|
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastMetadata;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.media.InfoMediaManager;
|
import com.android.settingslib.media.InfoMediaManager;
|
||||||
import com.android.settingslib.media.LocalMediaManager;
|
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");
|
Log.d(TAG, "getBroadcastMetadata: LE Audio Broadcast is null");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return broadcast.getLocalBluetoothLeBroadcastMetaData().convertToQrCodeString();
|
final LocalBluetoothLeBroadcastMetadata metadata =
|
||||||
|
broadcast.getLocalBluetoothLeBroadcastMetaData();
|
||||||
|
return metadata != null ? metadata.convertToQrCodeString() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isActiveRemoteDevice(@NonNull MediaDevice device) {
|
boolean isActiveRemoteDevice(@NonNull MediaDevice device) {
|
||||||
|
|||||||
Reference in New Issue
Block a user