Loading services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java +2 −8 Original line number Diff line number Diff line Loading @@ -1115,14 +1115,12 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ if (svcConnTracingEnabled()) { logTraceSvcConn("performGlobalAction", "action=" + action); } int currentUserId; synchronized (mLock) { if (!hasRightsToCurrentUserLocked()) { return false; } currentUserId = mSystemSupport.getCurrentUserIdLocked(); } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); final long identity = Binder.clearCallingIdentity(); try { return mSystemActionPerformer.performSystemAction(action); Loading Loading @@ -2791,11 +2789,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ @RequiresNoPermission @Override public void setAnimationScale(float scale) { int currentUserId; synchronized (mLock) { currentUserId = mSystemSupport.getCurrentUserIdLocked(); } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); final long identity = Binder.clearCallingIdentity(); try { Settings.Global.putFloat( Loading services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +5 −21 Original line number Diff line number Diff line Loading @@ -1402,11 +1402,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub @EnforcePermission(MANAGE_ACCESSIBILITY) public void registerSystemAction(RemoteAction action, int actionId) { registerSystemAction_enforcePermission(); int currentUserId; synchronized (mLock) { currentUserId = mCurrentUserId; } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); if (mTraceManager.isA11yTracingEnabledForTypes(FLAGS_ACCESSIBILITY_MANAGER)) { mTraceManager.logTrace(LOG_TAG + ".registerSystemAction", FLAGS_ACCESSIBILITY_MANAGER, "action=" + action + ";actionId=" + actionId); Loading @@ -1423,11 +1419,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub @EnforcePermission(MANAGE_ACCESSIBILITY) public void unregisterSystemAction(int actionId) { unregisterSystemAction_enforcePermission(); int currentUserId; synchronized (mLock) { currentUserId = mCurrentUserId; } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); if (mTraceManager.isA11yTracingEnabledForTypes(FLAGS_ACCESSIBILITY_MANAGER)) { mTraceManager.logTrace(LOG_TAG + ".unregisterSystemAction", FLAGS_ACCESSIBILITY_MANAGER, "actionId=" + actionId); Loading Loading @@ -1759,7 +1751,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub synchronized (mLock) { currentUserId = mCurrentUserId; } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); if (mTraceManager.isA11yTracingEnabledForTypes(FLAGS_ACCESSIBILITY_MANAGER)) { mTraceManager.logTrace(LOG_TAG + ".notifyAccessibilityButtonClicked", FLAGS_ACCESSIBILITY_MANAGER, Loading Loading @@ -1807,11 +1799,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub @EnforcePermission(STATUS_BAR_SERVICE) public void notifyAccessibilityButtonVisibilityChanged(boolean shown) { notifyAccessibilityButtonVisibilityChanged_enforcePermission(); int currentUserId; synchronized (mLock) { currentUserId = mCurrentUserId; } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); if (mTraceManager.isA11yTracingEnabledForTypes(FLAGS_ACCESSIBILITY_MANAGER)) { mTraceManager.logTrace(LOG_TAG + ".notifyAccessibilityButtonVisibilityChanged", FLAGS_ACCESSIBILITY_MANAGER, "shown=" + shown); Loading Loading @@ -5002,11 +4990,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub throws RemoteException { registerProxyForDisplay_enforcePermission(); mSecurityPolicy.checkForAccessibilityPermissionOrRole(); int currentUserId; synchronized (mLock) { currentUserId = mCurrentUserId; } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); if (client == null) { return false; } Loading services/core/java/com/android/server/UiModeManagerService.java +8 −8 Original line number Diff line number Diff line Loading @@ -907,7 +907,7 @@ final class UiModeManagerService extends SystemService { throw new IllegalArgumentException("Unknown mode: " + mode); } enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); final int user = UserHandle.getCallingUserId(); final long ident = Binder.clearCallingIdentity(); Loading Loading @@ -970,7 +970,7 @@ final class UiModeManagerService extends SystemService { @AttentionModeThemeOverlayType int attentionModeThemeOverlayType) { setAttentionModeThemeOverlay_enforcePermission(); enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); synchronized (mLock) { if (mAttentionModeThemeOverlay != attentionModeThemeOverlayType) { Loading Loading @@ -1070,7 +1070,7 @@ final class UiModeManagerService extends SystemService { return false; } enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); // Store the last requested bedtime night mode state so that we don't need to notify // anyone if the user decides to switch to the night mode to bedtime. Loading Loading @@ -1124,7 +1124,7 @@ final class UiModeManagerService extends SystemService { return; } enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); final int user = UserHandle.getCallingUserId(); final long ident = Binder.clearCallingIdentity(); Loading Loading @@ -1155,7 +1155,7 @@ final class UiModeManagerService extends SystemService { return; } enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); final int user = UserHandle.getCallingUserId(); final long ident = Binder.clearCallingIdentity(); Loading @@ -1178,7 +1178,7 @@ final class UiModeManagerService extends SystemService { assertLegit(callingPackage); assertSingleProjectionType(projectionType); enforceProjectionTypePermissions(projectionType); enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); synchronized (mLock) { if (mProjectionHolders == null) { Loading Loading @@ -1224,7 +1224,7 @@ final class UiModeManagerService extends SystemService { assertLegit(callingPackage); assertSingleProjectionType(projectionType); enforceProjectionTypePermissions(projectionType); enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); return releaseProjectionUnchecked(projectionType, callingPackage); } Loading Loading @@ -1266,7 +1266,7 @@ final class UiModeManagerService extends SystemService { return; } enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); synchronized (mLock) { if (mProjectionListeners == null) { Loading services/core/java/com/android/server/pm/UserManagerService.java +10 −8 Original line number Diff line number Diff line Loading @@ -2621,20 +2621,22 @@ public class UserManagerService extends IUserManager.Stub { * Valid user is the current user or the system or in the same profile group as the current * user. Visible background users are not valid calling users. */ public static void enforceCurrentUserIfVisibleBackgroundEnabled(@UserIdInt int currentUserId) { public static void enforceCurrentUserIfVisibleBackgroundEnabled() { if (!UserManager.isVisibleBackgroundUsersEnabled()) { return; } final int callingUserId = UserHandle.getCallingUserId(); final long ident = Binder.clearCallingIdentity(); try { final int currentUserId = ActivityManager.getCurrentUser(); if (DBG) { Slog.d(LOG_TAG, "enforceValidCallingUser: callingUserId=" + callingUserId Slog.d(LOG_TAG, "enforceCurrentUserIfVisibleBackgroundEnabled:" + " callingUserId=" + callingUserId + " isSystemUser=" + (callingUserId == USER_SYSTEM) + " currentUserId=" + currentUserId + " callingPid=" + Binder.getCallingPid() + " callingUid=" + Binder.getCallingUid()); } final long ident = Binder.clearCallingIdentity(); try { if (callingUserId != USER_SYSTEM && callingUserId != currentUserId && !UserManagerService.getInstance() .isSameProfileGroup(callingUserId, currentUserId)) { Loading Loading
services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java +2 −8 Original line number Diff line number Diff line Loading @@ -1115,14 +1115,12 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ if (svcConnTracingEnabled()) { logTraceSvcConn("performGlobalAction", "action=" + action); } int currentUserId; synchronized (mLock) { if (!hasRightsToCurrentUserLocked()) { return false; } currentUserId = mSystemSupport.getCurrentUserIdLocked(); } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); final long identity = Binder.clearCallingIdentity(); try { return mSystemActionPerformer.performSystemAction(action); Loading Loading @@ -2791,11 +2789,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ @RequiresNoPermission @Override public void setAnimationScale(float scale) { int currentUserId; synchronized (mLock) { currentUserId = mSystemSupport.getCurrentUserIdLocked(); } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); final long identity = Binder.clearCallingIdentity(); try { Settings.Global.putFloat( Loading
services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +5 −21 Original line number Diff line number Diff line Loading @@ -1402,11 +1402,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub @EnforcePermission(MANAGE_ACCESSIBILITY) public void registerSystemAction(RemoteAction action, int actionId) { registerSystemAction_enforcePermission(); int currentUserId; synchronized (mLock) { currentUserId = mCurrentUserId; } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); if (mTraceManager.isA11yTracingEnabledForTypes(FLAGS_ACCESSIBILITY_MANAGER)) { mTraceManager.logTrace(LOG_TAG + ".registerSystemAction", FLAGS_ACCESSIBILITY_MANAGER, "action=" + action + ";actionId=" + actionId); Loading @@ -1423,11 +1419,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub @EnforcePermission(MANAGE_ACCESSIBILITY) public void unregisterSystemAction(int actionId) { unregisterSystemAction_enforcePermission(); int currentUserId; synchronized (mLock) { currentUserId = mCurrentUserId; } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); if (mTraceManager.isA11yTracingEnabledForTypes(FLAGS_ACCESSIBILITY_MANAGER)) { mTraceManager.logTrace(LOG_TAG + ".unregisterSystemAction", FLAGS_ACCESSIBILITY_MANAGER, "actionId=" + actionId); Loading Loading @@ -1759,7 +1751,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub synchronized (mLock) { currentUserId = mCurrentUserId; } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); if (mTraceManager.isA11yTracingEnabledForTypes(FLAGS_ACCESSIBILITY_MANAGER)) { mTraceManager.logTrace(LOG_TAG + ".notifyAccessibilityButtonClicked", FLAGS_ACCESSIBILITY_MANAGER, Loading Loading @@ -1807,11 +1799,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub @EnforcePermission(STATUS_BAR_SERVICE) public void notifyAccessibilityButtonVisibilityChanged(boolean shown) { notifyAccessibilityButtonVisibilityChanged_enforcePermission(); int currentUserId; synchronized (mLock) { currentUserId = mCurrentUserId; } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); if (mTraceManager.isA11yTracingEnabledForTypes(FLAGS_ACCESSIBILITY_MANAGER)) { mTraceManager.logTrace(LOG_TAG + ".notifyAccessibilityButtonVisibilityChanged", FLAGS_ACCESSIBILITY_MANAGER, "shown=" + shown); Loading Loading @@ -5002,11 +4990,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub throws RemoteException { registerProxyForDisplay_enforcePermission(); mSecurityPolicy.checkForAccessibilityPermissionOrRole(); int currentUserId; synchronized (mLock) { currentUserId = mCurrentUserId; } enforceCurrentUserIfVisibleBackgroundEnabled(currentUserId); enforceCurrentUserIfVisibleBackgroundEnabled(); if (client == null) { return false; } Loading
services/core/java/com/android/server/UiModeManagerService.java +8 −8 Original line number Diff line number Diff line Loading @@ -907,7 +907,7 @@ final class UiModeManagerService extends SystemService { throw new IllegalArgumentException("Unknown mode: " + mode); } enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); final int user = UserHandle.getCallingUserId(); final long ident = Binder.clearCallingIdentity(); Loading Loading @@ -970,7 +970,7 @@ final class UiModeManagerService extends SystemService { @AttentionModeThemeOverlayType int attentionModeThemeOverlayType) { setAttentionModeThemeOverlay_enforcePermission(); enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); synchronized (mLock) { if (mAttentionModeThemeOverlay != attentionModeThemeOverlayType) { Loading Loading @@ -1070,7 +1070,7 @@ final class UiModeManagerService extends SystemService { return false; } enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); // Store the last requested bedtime night mode state so that we don't need to notify // anyone if the user decides to switch to the night mode to bedtime. Loading Loading @@ -1124,7 +1124,7 @@ final class UiModeManagerService extends SystemService { return; } enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); final int user = UserHandle.getCallingUserId(); final long ident = Binder.clearCallingIdentity(); Loading Loading @@ -1155,7 +1155,7 @@ final class UiModeManagerService extends SystemService { return; } enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); final int user = UserHandle.getCallingUserId(); final long ident = Binder.clearCallingIdentity(); Loading @@ -1178,7 +1178,7 @@ final class UiModeManagerService extends SystemService { assertLegit(callingPackage); assertSingleProjectionType(projectionType); enforceProjectionTypePermissions(projectionType); enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); synchronized (mLock) { if (mProjectionHolders == null) { Loading Loading @@ -1224,7 +1224,7 @@ final class UiModeManagerService extends SystemService { assertLegit(callingPackage); assertSingleProjectionType(projectionType); enforceProjectionTypePermissions(projectionType); enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); return releaseProjectionUnchecked(projectionType, callingPackage); } Loading Loading @@ -1266,7 +1266,7 @@ final class UiModeManagerService extends SystemService { return; } enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser); enforceCurrentUserIfVisibleBackgroundEnabled(); synchronized (mLock) { if (mProjectionListeners == null) { Loading
services/core/java/com/android/server/pm/UserManagerService.java +10 −8 Original line number Diff line number Diff line Loading @@ -2621,20 +2621,22 @@ public class UserManagerService extends IUserManager.Stub { * Valid user is the current user or the system or in the same profile group as the current * user. Visible background users are not valid calling users. */ public static void enforceCurrentUserIfVisibleBackgroundEnabled(@UserIdInt int currentUserId) { public static void enforceCurrentUserIfVisibleBackgroundEnabled() { if (!UserManager.isVisibleBackgroundUsersEnabled()) { return; } final int callingUserId = UserHandle.getCallingUserId(); final long ident = Binder.clearCallingIdentity(); try { final int currentUserId = ActivityManager.getCurrentUser(); if (DBG) { Slog.d(LOG_TAG, "enforceValidCallingUser: callingUserId=" + callingUserId Slog.d(LOG_TAG, "enforceCurrentUserIfVisibleBackgroundEnabled:" + " callingUserId=" + callingUserId + " isSystemUser=" + (callingUserId == USER_SYSTEM) + " currentUserId=" + currentUserId + " callingPid=" + Binder.getCallingPid() + " callingUid=" + Binder.getCallingUid()); } final long ident = Binder.clearCallingIdentity(); try { if (callingUserId != USER_SYSTEM && callingUserId != currentUserId && !UserManagerService.getInstance() .isSameProfileGroup(callingUserId, currentUserId)) { Loading