From fe322bdca3bfc2c42ffd477109ff815d45339058 Mon Sep 17 00:00:00 2001 From: Yi Jiang Date: Mon, 24 May 2021 14:54:50 -0700 Subject: [PATCH] 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 --- .../RemoteRotationResolverService.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/rotationresolver/RemoteRotationResolverService.java b/services/core/java/com/android/server/rotationresolver/RemoteRotationResolverService.java index 35aff8dc70ce6..a58291425d4c7 100644 --- a/services/core/java/com/android/server/rotationresolver/RemoteRotationResolverService.java +++ b/services/core/java/com/android/server/rotationresolver/RemoteRotationResolverService.java @@ -126,14 +126,12 @@ class RemoteRotationResolverService extends ServiceConnector.Impl { synchronized (mLock) { + if (mIsFulfilled) { + return; + } + mIsFulfilled = true; try { if (mCancellation != null) { mCancellation.cancel();