Merge "Fix stuck screen from display change timeout" am: 2421332152 am: a63a9cacab

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2388832

Change-Id: I855e5959b187b17d2619c1c78abdc9748fcfb961
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Nick Chameyev
2023-04-28 14:24:29 +00:00
committed by Automerger Merge Worker

View File

@@ -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();
}
}