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

Commit 34ae25d3 authored by Kedar Chitnis's avatar Kedar Chitnis Committed by Android (Google) Code Review
Browse files

Merge "Revert "Guest mode updates to resolve privacy concerns in guest mode""

parents af1fff39 dd5c4408
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1855,6 +1855,7 @@ package android.os {
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public String getUserType();
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public java.util.List<android.content.pm.UserInfo> getUsers(boolean, boolean, boolean);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public boolean hasBaseUserRestriction(@NonNull String, @NonNull android.os.UserHandle);
    method public static boolean isGuestUserEphemeral();
    method public static boolean isSplitSystemUser();
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public android.content.pm.UserInfo preCreateUser(@NonNull String) throws android.os.UserManager.UserOperationException;
  }
+1 −18
Original line number Diff line number Diff line
@@ -141,22 +141,6 @@ public class UserInfo implements Parcelable {
     */
    public static final int FLAG_PROFILE = 0x00001000;

    /**
     * Indicates that this user is created in ephemeral mode via
     * {@link IUserManager} create user.
     *
     * When a user is created with {@link #FLAG_EPHEMERAL}, {@link #FLAG_EPHEMERAL_ON_CREATE}
     * is set internally within the user manager.
     *
     * When {@link #FLAG_EPHEMERAL_ON_CREATE} is set {@link IUserManager.setUserEphemeral}
     * has no effect because a user that was created ephemeral can never be made non-ephemeral.
     *
     * {@link #FLAG_EPHEMERAL_ON_CREATE} should NOT be set by client's of user manager
     *
     * @hide
     */
    public static final int FLAG_EPHEMERAL_ON_CREATE = 0x00002000;

    /**
     * @hide
     */
@@ -173,8 +157,7 @@ public class UserInfo implements Parcelable {
            FLAG_DEMO,
            FLAG_FULL,
            FLAG_SYSTEM,
            FLAG_PROFILE,
            FLAG_EPHEMERAL_ON_CREATE
            FLAG_PROFILE
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface UserInfoFlag {
+0 −1
Original line number Diff line number Diff line
@@ -131,5 +131,4 @@ interface IUserManager {
    String getUserName();
    long getUserStartRealtime();
    long getUserUnlockRealtime();
    boolean setUserEphemeral(int userId, boolean enableEphemeral);
}
+2 −50
Original line number Diff line number Diff line
@@ -1993,21 +1993,12 @@ public class UserManager {
     * @return Whether guest user is always ephemeral
     * @hide
     */
    public static boolean isGuestUserAlwaysEphemeral() {
    @TestApi
    public static boolean isGuestUserEphemeral() {
        return Resources.getSystem()
                .getBoolean(com.android.internal.R.bool.config_guestUserEphemeral);
    }

    /**
     * @return true, when we want to enable user manager API and UX to allow
     *           guest user ephemeral state change based on user input
     * @hide
     */
    public static boolean isGuestUserAllowEphemeralStateChange() {
        return Resources.getSystem()
                .getBoolean(com.android.internal.R.bool.config_guestUserAllowEphemeralStateChange);
    }

    /**
     * Checks whether the device is running in a headless system user mode.
     *
@@ -3429,20 +3420,6 @@ public class UserManager {
            if (guest != null) {
                Settings.Secure.putStringForUser(context.getContentResolver(),
                        Settings.Secure.SKIP_FIRST_USE_HINTS, "1", guest.id);

                if (UserManager.isGuestUserAllowEphemeralStateChange()) {
                    // Mark guest as (changeably) ephemeral if REMOVE_GUEST_ON_EXIT is 1
                    // This is done so that a user via a UI controller can choose to
                    // make a guest as ephemeral or not.
                    // Settings.Global.REMOVE_GUEST_ON_EXIT holds the choice on what the guest state
                    // should be, with default being ephemeral.
                    boolean resetGuestOnExit = Settings.Global.getInt(context.getContentResolver(),
                                                 Settings.Global.REMOVE_GUEST_ON_EXIT, 1) == 1;

                    if (resetGuestOnExit && !guest.isEphemeral()) {
                        setUserEphemeral(guest.id, true);
                    }
                }
            }
            return guest;
        } catch (ServiceSpecificException e) {
@@ -4959,31 +4936,6 @@ public class UserManager {
        }
    }

    /**
     * Set the user as ephemeral or non-ephemeral.
     *
     * If the user was initially created as ephemeral then this
     * method has no effect and false is returned.
     *
     * @param userId the user's integer id
     * @param enableEphemeral true: change user state to ephemeral,
     *                        false: change user state to non-ephemeral
     * @return true: user now has the desired ephemeral state,
     *         false: desired user ephemeral state could not be set
     *
     * @hide
     */
    @RequiresPermission(anyOf = {
            android.Manifest.permission.MANAGE_USERS,
            android.Manifest.permission.CREATE_USERS})
    public boolean setUserEphemeral(@UserIdInt int userId, boolean enableEphemeral) {
        try {
            return mService.setUserEphemeral(userId, enableEphemeral);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Updates the context user's name.
     *
+0 −8
Original line number Diff line number Diff line
@@ -10870,14 +10870,6 @@ public final class Settings {
        @Readable
        public static final String ADD_USERS_WHEN_LOCKED = "add_users_when_locked";
        /**
         * Whether guest user should be removed on exit from guest mode.
         * <p>
         * Type: int
         * @hide
         */
        public static final String REMOVE_GUEST_ON_EXIT = "remove_guest_on_exit";
        /**
         * Whether applying ramping ringer on incoming phone call ringtone.
         * <p>1 = apply ramping ringer
Loading