Ensures RotationRequest#mLock can only accquried by main thread.

There are 2 locks in RRMS and RotationRequest class. UI thread and main
thread both needs to acquire these lock which introduce risk of
deadlocking.

This change fixes the issue by only letting the main thread get the lock of
RotationRequest.

Test: presubmit
Bug: 188932757
Change-Id: I8fd0beb094356636096155eabeef8c9d24fa0da1
This commit is contained in:
Yi Jiang
2021-05-24 14:54:50 -07:00
parent e1d0701069
commit fe322bdca3

View File

@@ -126,14 +126,12 @@ class RemoteRotationResolverService extends ServiceConnector.Impl<IRotationResol
void cancelInternal() {
synchronized (mLock) {
if (mIsFulfilled) {
return;
}
mIsFulfilled = true;
}
Handler.getMain().post(() -> {
synchronized (mLock) {
if (mIsFulfilled) {
return;
}
mIsFulfilled = true;
try {
if (mCancellation != null) {
mCancellation.cancel();