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

Commit 3f2b4197 authored by Mayank Garg's avatar Mayank Garg
Browse files

Persistent configuration should only be updated by currentUser

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 (and not the visible background user) can change the locale and other persistent settings of the device.

Bug: 322229751
Test: atest LocalePickerTest
Test: atest --user-type secondary_user_on_secondary_display LocalePickerTest
Test: atest --user-type secondary_user LocalePickerTest
Change-Id: I11d86e2f7cb9ba0f16b34cdf629557abea3a29ce
parent 443ac02e
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -16946,6 +16946,18 @@ 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);
            throw new SecurityException("Only current user is allowed to update persistent "
                    + "configuration.");
        }
        mActivityTaskManager.updatePersistentConfiguration(values, userId);
    }