diff options
| author | 2021-11-20 06:39:15 +0000 | |
|---|---|---|
| committer | 2021-11-22 17:27:22 +0000 | |
| commit | 7567f970d6b086f67995cce96bb0d28a84535298 (patch) | |
| tree | 1d3778c8146d520fb0f283e22c707dff2e08a27e | |
| parent | 26409be79ebac04a1fa77a62ddb12d2f1450bedf (diff) | |
Prevent recomputeDisableFlags from clobbering the system disable flags
- The disable() call on the binder thread can race with this call on
the main thread due to this 1) fetching the old values on the main
thread, then 2) trying to synchronize on mLock by calling disable()
(which the binder thread is currently holding) and then 3) applying
the previous flags immediately after the fresh disable flags are set
by the binder call.
Bug: 205921118
Test: atest SystemUITests
Change-Id: I5dd4d2d248b6c1ab6d1677e2bb915100cd3e4f4e
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java index 6676901997bf..5876703a800e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java @@ -513,9 +513,13 @@ public class CommandQueue extends IStatusBar.Stub implements * @param animate {@code true} to show animations. */ public void recomputeDisableFlags(int displayId, boolean animate) { - int disabled1 = getDisabled1(displayId); - int disabled2 = getDisabled2(displayId); - disable(displayId, disabled1, disabled2, animate); + // This must update holding the lock otherwise it can clobber the disabled flags set on the + // binder thread from the disable() call + synchronized (mLock) { + int disabled1 = getDisabled1(displayId); + int disabled2 = getDisabled2(displayId); + disable(displayId, disabled1, disabled2, animate); + } } private void setDisabled(int displayId, int disabled1, int disabled2) { |