AudioService: fix muteAwaitConnection device check
Add logs for muteAwaitConnection API calls. Fix cancel operation by testing device equality with AudioDeviceAttributes.equalTypeAddress instead of equals as the device passed by the caller may have just been qualified by type and address, and may not contain the actual profiles and descriptors of a connected device. Bug: 229806548 Test: atest com.google.android.gts.audioservice.AudioServiceHostTest#testMuteAwaitConnection Change-Id: Id216e6d88859425f9fa49e45843f51ca83ae9b63
This commit is contained in:
@@ -9123,6 +9123,8 @@ public class AudioService extends IAudioService.Stub
|
||||
if (timeOutMs <= 0 || usages.length == 0) {
|
||||
throw new IllegalArgumentException("Invalid timeOutMs/usagesToMute");
|
||||
}
|
||||
Log.i(TAG, "muteAwaitConnection dev:" + device + " timeOutMs:" + timeOutMs
|
||||
+ " usages:" + usages);
|
||||
|
||||
if (mDeviceBroker.isDeviceConnected(device)) {
|
||||
// not throwing an exception as there could be a race between a connection (server-side,
|
||||
@@ -9166,7 +9168,7 @@ public class AudioService extends IAudioService.Stub
|
||||
Log.i(TAG, "cancelMuteAwaitConnection ignored, no expected device");
|
||||
return;
|
||||
}
|
||||
if (!device.equals(mMutingExpectedDevice)) {
|
||||
if (!device.equalTypeAddress(mMutingExpectedDevice)) {
|
||||
Log.e(TAG, "cancelMuteAwaitConnection ignored, got " + device
|
||||
+ "] but expected device is" + mMutingExpectedDevice);
|
||||
throw new IllegalStateException("cancelMuteAwaitConnection for wrong device");
|
||||
|
||||
@@ -1158,6 +1158,8 @@ public final class PlaybackActivityMonitor
|
||||
//==========================================================================================
|
||||
void muteAwaitConnection(@NonNull int[] usagesToMute,
|
||||
@NonNull AudioDeviceAttributes dev, long timeOutMs) {
|
||||
sEventLogger.loglogi(
|
||||
"muteAwaitConnection() dev:" + dev + " timeOutMs:" + timeOutMs, TAG);
|
||||
synchronized (mPlayerLock) {
|
||||
mutePlayersExpectingDevice(usagesToMute);
|
||||
// schedule timeout (remove previously scheduled first)
|
||||
@@ -1169,6 +1171,7 @@ public final class PlaybackActivityMonitor
|
||||
}
|
||||
|
||||
void cancelMuteAwaitConnection() {
|
||||
sEventLogger.loglogi("cancelMuteAwaitConnection()", TAG);
|
||||
synchronized (mPlayerLock) {
|
||||
// cancel scheduled timeout, ignore device, only one expected device at a time
|
||||
mEventHandler.removeMessages(MSG_L_TIMEOUT_MUTE_AWAIT_CONNECTION);
|
||||
|
||||
Reference in New Issue
Block a user