diff options
author | Tommy Webb <tommy@calyxinstitute.org> | 2023-01-12 19:25:20 -0500 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2023-04-20 00:08:54 +0800 |
commit | fdc7ab510cbebd0b0514e457acc82a3c41ececb7 (patch) | |
tree | 86db0e0583d5aecf6034c77204652a9ccd1e5cf4 | |
parent | adb51c01410cb5a26082e4759adb1ff14dac8d15 (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.
Issue: calyxos#1392
Change-Id: I53659d5580cdd70b4c7138dcca770b11f5397194
-rw-r--r-- | services/core/java/com/android/server/wm/RemoteDisplayChangeController.java | 10 |
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(); } } |