Merge "AudioService: fix muteAwaitConnection device check" into tm-dev

This commit is contained in:
Jean-Michel Trivi
2022-05-04 15:00:52 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 1 deletions

View File

@@ -9135,6 +9135,8 @@ public class AudioService extends IAudioService.Stub
if (timeOutMs <= 0 || usages.length == 0) { if (timeOutMs <= 0 || usages.length == 0) {
throw new IllegalArgumentException("Invalid timeOutMs/usagesToMute"); throw new IllegalArgumentException("Invalid timeOutMs/usagesToMute");
} }
Log.i(TAG, "muteAwaitConnection dev:" + device + " timeOutMs:" + timeOutMs
+ " usages:" + usages);
if (mDeviceBroker.isDeviceConnected(device)) { if (mDeviceBroker.isDeviceConnected(device)) {
// not throwing an exception as there could be a race between a connection (server-side, // not throwing an exception as there could be a race between a connection (server-side,
@@ -9178,7 +9180,7 @@ public class AudioService extends IAudioService.Stub
Log.i(TAG, "cancelMuteAwaitConnection ignored, no expected device"); Log.i(TAG, "cancelMuteAwaitConnection ignored, no expected device");
return; return;
} }
if (!device.equals(mMutingExpectedDevice)) { if (!device.equalTypeAddress(mMutingExpectedDevice)) {
Log.e(TAG, "cancelMuteAwaitConnection ignored, got " + device Log.e(TAG, "cancelMuteAwaitConnection ignored, got " + device
+ "] but expected device is" + mMutingExpectedDevice); + "] but expected device is" + mMutingExpectedDevice);
throw new IllegalStateException("cancelMuteAwaitConnection for wrong device"); throw new IllegalStateException("cancelMuteAwaitConnection for wrong device");

View File

@@ -1158,6 +1158,8 @@ public final class PlaybackActivityMonitor
//========================================================================================== //==========================================================================================
void muteAwaitConnection(@NonNull int[] usagesToMute, void muteAwaitConnection(@NonNull int[] usagesToMute,
@NonNull AudioDeviceAttributes dev, long timeOutMs) { @NonNull AudioDeviceAttributes dev, long timeOutMs) {
sEventLogger.loglogi(
"muteAwaitConnection() dev:" + dev + " timeOutMs:" + timeOutMs, TAG);
synchronized (mPlayerLock) { synchronized (mPlayerLock) {
mutePlayersExpectingDevice(usagesToMute); mutePlayersExpectingDevice(usagesToMute);
// schedule timeout (remove previously scheduled first) // schedule timeout (remove previously scheduled first)
@@ -1169,6 +1171,7 @@ public final class PlaybackActivityMonitor
} }
void cancelMuteAwaitConnection() { void cancelMuteAwaitConnection() {
sEventLogger.loglogi("cancelMuteAwaitConnection()", TAG);
synchronized (mPlayerLock) { synchronized (mPlayerLock) {
// cancel scheduled timeout, ignore device, only one expected device at a time // cancel scheduled timeout, ignore device, only one expected device at a time
mEventHandler.removeMessages(MSG_L_TIMEOUT_MUTE_AWAIT_CONNECTION); mEventHandler.removeMessages(MSG_L_TIMEOUT_MUTE_AWAIT_CONNECTION);