diff options
| author | 2023-04-25 16:25:50 +0000 | |
|---|---|---|
| committer | 2023-04-25 16:25:50 +0000 | |
| commit | ff92cb0df3846356ed1d544815ee88481a2754d9 (patch) | |
| tree | 3e684fff8b89a855df13a2cbc4ad79a054578153 | |
| parent | e618d251ac6dd734e4a4647d932d969dec193f77 (diff) | |
| parent | 34dbe6899048965d44a5bb79acdb990705252dc2 (diff) | |
Merge "Let the contrast API support multiple users" into udc-dev
| -rw-r--r-- | services/core/java/com/android/server/UiModeManagerService.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java index 7c32627dd1b1..55e805ab4ad0 100644 --- a/services/core/java/com/android/server/UiModeManagerService.java +++ b/services/core/java/com/android/server/UiModeManagerService.java @@ -28,6 +28,7 @@ import static android.app.UiModeManager.MODE_NIGHT_YES; import static android.app.UiModeManager.PROJECTION_TYPE_AUTOMOTIVE; import static android.app.UiModeManager.PROJECTION_TYPE_NONE; import static android.os.UserHandle.USER_SYSTEM; +import static android.os.UserHandle.getCallingUserId; import static android.provider.Settings.Secure.CONTRAST_LEVEL; import static android.util.TimeUtils.isTimeBetween; @@ -199,8 +200,8 @@ final class UiModeManagerService extends SystemService { private PowerManagerInternal mLocalPowerManager; @GuardedBy("mLock") - private final RemoteCallbackList<IUiModeManagerCallback> mUiModeManagerCallbacks = - new RemoteCallbackList<IUiModeManagerCallback>(); + private final SparseArray<RemoteCallbackList<IUiModeManagerCallback>> mUiModeManagerCallbacks = + new SparseArray<>(); @GuardedBy("mLock") @Nullable @@ -371,8 +372,9 @@ final class UiModeManagerService extends SystemService { synchronized (mLock) { if (updateContrastLocked()) { float contrast = getContrastLocked(); - mUiModeManagerCallbacks.broadcast(ignoreRemoteException(callback -> - callback.notifyContrastChanged(contrast))); + mUiModeManagerCallbacks.get(mCurrentUser, new RemoteCallbackList<>()) + .broadcast(ignoreRemoteException( + callback -> callback.notifyContrastChanged(contrast))); } } } @@ -664,8 +666,12 @@ final class UiModeManagerService extends SystemService { private final IUiModeManager.Stub mService = new IUiModeManager.Stub() { @Override public void addCallback(IUiModeManagerCallback callback) { + int userId = getCallingUserId(); synchronized (mLock) { - mUiModeManagerCallbacks.register(callback); + if (!mUiModeManagerCallbacks.contains(userId)) { + mUiModeManagerCallbacks.put(userId, new RemoteCallbackList<>()); + } + mUiModeManagerCallbacks.get(userId).register(callback); } } |