AudioService: make setAccessibilityServiceUids async
Call AudioSystem.setA11yServicesUids() in the AudioService message handler thread to avoid potential cross deadlock with AccessibilityService. Bug: 156421041 Test: atest AudioManagerTest Change-Id: I1608bd613d97661083d3a72f61dbc0fc2e9d4414
This commit is contained in:
@@ -300,6 +300,7 @@ public class AudioService extends IAudioService.Stub
|
||||
private static final int MSG_STREAM_DEVICES_CHANGED = 32;
|
||||
private static final int MSG_UPDATE_VOLUME_STATES_FOR_DEVICE = 33;
|
||||
private static final int MSG_REINIT_VOLUMES = 34;
|
||||
private static final int MSG_UPDATE_A11Y_SERVICE_UIDS = 35;
|
||||
// start of messages handled under wakelock
|
||||
// these messages can only be queued, i.e. sent with queueMsgUnderWakeLock(),
|
||||
// and not with sendMsg(..., ..., SENDMSG_QUEUE, ...)
|
||||
@@ -699,8 +700,9 @@ public class AudioService extends IAudioService.Stub
|
||||
private long mLoweredFromNormalToVibrateTime;
|
||||
|
||||
// Array of Uids of valid accessibility services to check if caller is one of them
|
||||
private int[] mAccessibilityServiceUids;
|
||||
private final Object mAccessibilityServiceUidsLock = new Object();
|
||||
@GuardedBy("mAccessibilityServiceUidsLock")
|
||||
private int[] mAccessibilityServiceUids;
|
||||
|
||||
// Uid of the active input method service to check if caller is the one or not.
|
||||
private int mInputMethodServiceUid = android.os.Process.INVALID_UID;
|
||||
@@ -7082,6 +7084,10 @@ public class AudioService extends IAudioService.Stub
|
||||
case MSG_REINIT_VOLUMES:
|
||||
onReinitVolumes((String) msg.obj);
|
||||
break;
|
||||
case MSG_UPDATE_A11Y_SERVICE_UIDS:
|
||||
onUpdateAccessibilityServiceUids();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8153,6 +8159,9 @@ public class AudioService extends IAudioService.Stub
|
||||
+ " FromRestrictions=" + mMicMuteFromRestrictions
|
||||
+ " FromApi=" + mMicMuteFromApi
|
||||
+ " from system=" + mMicMuteFromSystemCached);
|
||||
pw.print("\n mAssistantUid="); pw.println(mAssistantUid);
|
||||
pw.print(" mCurrentImeUid="); pw.println(mCurrentImeUid);
|
||||
dumpAccessibilityServiceUids(pw);
|
||||
|
||||
dumpAudioPolicies(pw);
|
||||
mDynPolicyLogger.dump(pw);
|
||||
@@ -8186,6 +8195,19 @@ public class AudioService extends IAudioService.Stub
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpAccessibilityServiceUids(PrintWriter pw) {
|
||||
synchronized (mSupportedSystemUsagesLock) {
|
||||
if (mAccessibilityServiceUids != null && mAccessibilityServiceUids.length > 0) {
|
||||
pw.println(" Accessibility service Uids:");
|
||||
for (int uid : mAccessibilityServiceUids) {
|
||||
pw.println(" - " + uid);
|
||||
}
|
||||
} else {
|
||||
pw.println(" No accessibility service Uids.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Audio Analytics ids.
|
||||
*/
|
||||
@@ -8489,7 +8511,8 @@ public class AudioService extends IAudioService.Stub
|
||||
mAccessibilityServiceUids = uids.toArray();
|
||||
}
|
||||
}
|
||||
AudioSystem.setA11yServicesUids(mAccessibilityServiceUids);
|
||||
sendMsg(mAudioHandler, MSG_UPDATE_A11Y_SERVICE_UIDS, SENDMSG_REPLACE,
|
||||
0, 0, null, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8507,6 +8530,14 @@ public class AudioService extends IAudioService.Stub
|
||||
}
|
||||
}
|
||||
|
||||
private void onUpdateAccessibilityServiceUids() {
|
||||
int[] accessibilityServiceUids;
|
||||
synchronized (mAccessibilityServiceUidsLock) {
|
||||
accessibilityServiceUids = mAccessibilityServiceUids;
|
||||
}
|
||||
AudioSystem.setA11yServicesUids(accessibilityServiceUids);
|
||||
}
|
||||
|
||||
//==========================================================================================
|
||||
// Audio policy management
|
||||
//==========================================================================================
|
||||
|
||||
Reference in New Issue
Block a user