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

Commit 98dddda7 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android (Google) Code Review
Browse files

Merge "Remove permission requirement for some UserManager calls" into jb-mr1-dev

parents 6479ecd1 19526374
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ public class UserManager {

    /**
     * Returns the user name of the user making this call.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     * @return the user name
     */
    public String getUserName() {
@@ -69,6 +70,7 @@ public class UserManager {

    /**
     * Returns the UserInfo object describing a specific user.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     * @param userHandle the user handle of the user whose information is being requested.
     * @return the UserInfo object for a specific user.
     * @hide
@@ -84,6 +86,7 @@ public class UserManager {

    /**
     * Creates a user with the specified name and options.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     *
     * @param name the user's name
     * @param flags flags that identify the type of user and other properties.
@@ -103,6 +106,7 @@ public class UserManager {

    /**
     * Returns information for all users on this device.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     * @return the list of users that were created.
     * @hide
     */
@@ -117,6 +121,7 @@ public class UserManager {

    /**
     * Removes a user and all associated data.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     * @param userHandle the integer handle of the user, where 0 is the primary user.
     * @hide
     */
@@ -131,6 +136,7 @@ public class UserManager {

    /**
     * Updates the user's name.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     *
     * @param userHandle the user's integer handle
     * @param name the new name for the user
@@ -162,6 +168,7 @@ public class UserManager {
    /**
     * Enable or disable the use of a guest account. If disabled, the existing guest account
     * will be wiped.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     * @param enable whether to enable a guest account.
     * @hide
     */
@@ -175,6 +182,7 @@ public class UserManager {

    /**
     * Checks if a guest user is enabled for this device.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     * @return whether a guest user is enabled
     * @hide
     */
@@ -189,6 +197,7 @@ public class UserManager {

    /**
     * Wipes all the data for a user, but doesn't remove the user.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     * @param userHandle
     * @hide
     */
+1 −1
Original line number Diff line number Diff line
@@ -790,7 +790,7 @@
         third party applications. -->
    <permission android:name="android.permission.MANAGE_USERS"
        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
        android:protectionLevel="signature"
        android:protectionLevel="signature|system"
        android:label="@string/permlab_manageUsers"
        android:description="@string/permdesc_manageUsers" />
    
+21 −12
Original line number Diff line number Diff line
@@ -137,11 +137,17 @@ public class UserManagerService extends IUserManager.Stub {
    public UserInfo getUserInfo(int userId) {
        checkManageUsersPermission("query user");
        synchronized (mUsers) {
            UserInfo info = mUsers.get(userId);
            return info;
            return getUserInfoLocked(userId);
        }
    }

    /*
     * Should be locked on mUsers before calling this.
     */
    private UserInfo getUserInfoLocked(int userId) {
        return mUsers.get(userId);
    }

    public boolean exists(int userId) {
        synchronized (mUsers) {
            return ArrayUtils.contains(mUserIds, userId);
@@ -212,8 +218,9 @@ public class UserManagerService extends IUserManager.Stub {
    }

    /**
     * Enforces that only the system UID or root's UID can call a method exposed
     * via Binder.
     * Enforces that only the system UID or root's UID or apps that have the
     * {@link android.Manifest.permission.MANAGE_USERS MANAGE_USERS}
     * permission can make certain calls to the UserManager.
     *
     * @param message used as message if SecurityException is thrown
     * @throws SecurityException if the caller is not system or root
@@ -534,7 +541,7 @@ public class UserManagerService extends IUserManager.Stub {
    public int getUserSerialNumber(int userHandle) {
        synchronized (mUsers) {
            if (!exists(userHandle)) return -1;
            return getUserInfo(userHandle).serialNumber;
            return getUserInfoLocked(userHandle).serialNumber;
        }
    }

@@ -542,7 +549,7 @@ public class UserManagerService extends IUserManager.Stub {
    public int getUserHandle(int userSerialNumber) {
        synchronized (mUsers) {
            for (int userId : mUserIds) {
                if (getUserInfo(userId).serialNumber == userSerialNumber) return userId;
                if (getUserInfoLocked(userId).serialNumber == userSerialNumber) return userId;
            }
            // Not found
            return -1;
@@ -617,6 +624,7 @@ public class UserManagerService extends IUserManager.Stub {
     * @return
     */
    private int getNextAvailableId() {
        synchronized (mUsers) {
            int i = 0;
            while (i < Integer.MAX_VALUE) {
                if (mUsers.indexOfKey(i) < 0) {
@@ -626,6 +634,7 @@ public class UserManagerService extends IUserManager.Stub {
            }
            return i;
        }
    }

    private boolean createPackageFolders(int id, File userPath) {
        // mInstaller may not be available for unit-tests.
+2 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
    <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.MANAGE_USERS" />
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
    
    <application>
        <uses-library android:name="android.test.runner" />