Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac5e6d9b authored by Mayank Garg's avatar Mayank Garg Committed by Android (Google) Code Review
Browse files

Merge "Clearing binder identity before getting the current User" into main

parents 363219db 3119b9a6
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -16961,17 +16961,25 @@ public class ActivityManagerService extends IActivityManager.Stub
        int userId = UserHandle.getCallingUserId();
        if (UserManager.isVisibleBackgroundUsersEnabled() && userId != getCurrentUserId()) {
            // The check is added mainly for auto devices. On auto devices, it is possible that
            // multiple users are visible simultaneously using visible background users.
            // In such cases, it is desired that only the current user (not the visible background
            // user) can change the locale and other persistent settings of the device.
            Slog.w(TAG, "Only current user is allowed to update persistent configuration if "
                    + "visible background users are enabled. Current User" + getCurrentUserId()
                    + ". Calling User: " + userId);
        if (UserManager.isVisibleBackgroundUsersEnabled()) {
            final long origId = Binder.clearCallingIdentity();
            try {
                if (userId != getCurrentUserId()) {
                    // The check is added mainly for auto devices. On auto devices, it is
                    // possible that multiple users are visible simultaneously using visible
                    // background users. In such cases, it is desired that only the current user
                    // (not the visible background user) can change the locale and other persistent
                    // settings of the device.
                    Slog.w(TAG, "Only current user is allowed to update persistent configuration "
                            + "if visible background users are enabled. Current User"
                            + getCurrentUserId() + ". Calling User: " + userId);
                    throw new SecurityException("Only current user is allowed to update persistent "
                            + "configuration.");
                }
            } finally {
                Binder.restoreCallingIdentity(origId);
            }
        }
        mActivityTaskManager.updatePersistentConfiguration(values, userId);
    }