summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tommy Webb <tommy@calyxinstitute.org> 2023-01-12 19:25:20 -0500
committer t-m-w <tommy@calyxinstitute.org> 2023-01-24 22:46:56 +0000
commit1e022839cae76e1d88893842c1bf685edba3e09a (patch)
treefc8217708cf331254715461056d2ed6c2c5824b3
parent123221ff83f63b640fa09b22a2de1508fa958a05 (diff)
Fix stuck screen from display change timeout
Occasionally, a remote display change is not processed within the timeout period. One prominent example is when a device is not able to complete its rotation from landscape back to portrait in time after the display is turned off. When this happens, and the callback is called after the timeout instead, DisplayContent#sendNewConfiguration abandons its effort when it sees there are pending display changes, but this callback itself might be the pending display change, and it does not expect itself to be included as part of this decision. Remove all callbacks before calling the last one to prevent this. Test: Manual: Build and run with REMOTE_DISPLAY_CHANGE_TIMEOUT_MS = 50, or some other low value. Enter landscape mode, e.g. by playing a video. Turn off the screen. Wait 3 seconds. Turn the screen back on. The lock screen will appear as normal. Previously, the screen would remain black until a restart or `adb shell wm` change interaction. Bug: 266535056 Change-Id: I53659d5580cdd70b4c7138dcca770b11f5397194
-rw-r--r--services/core/java/com/android/server/wm/RemoteDisplayChangeController.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/wm/RemoteDisplayChangeController.java b/services/core/java/com/android/server/wm/RemoteDisplayChangeController.java
index 43baebc7255a..e646f14a3e13 100644
--- a/services/core/java/com/android/server/wm/RemoteDisplayChangeController.java
+++ b/services/core/java/com/android/server/wm/RemoteDisplayChangeController.java
@@ -114,9 +114,15 @@ public class RemoteDisplayChangeController {
// timed-out, so run all continue callbacks and clear the list
synchronized (mService.mGlobalLock) {
for (int i = 0; i < mCallbacks.size(); ++i) {
- mCallbacks.get(i).onContinueRemoteDisplayChange(null /* transaction */);
+ final ContinueRemoteDisplayChangeCallback callback = mCallbacks.get(i);
+ if (i == mCallbacks.size() - 1) {
+ // Clear all callbacks before calling the last one, so that if the callback
+ // itself calls {@link #isWaitingForRemoteDisplayChange()}, it will get
+ // {@code false}. After all, there is nothing pending after this one.
+ mCallbacks.clear();
+ }
+ callback.onContinueRemoteDisplayChange(null /* transaction */);
}
- mCallbacks.clear();
}
}