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

Commit df35d570 authored by Alexandra Gherghina's avatar Alexandra Gherghina
Browse files

Adds an enabled state in UserInfo instead of DevicePolicyManager

Bug: 14377459
Change-Id: Ib4ec43d87da96c3dddaf9b7ae1796f261863a182
parent 7f89c9b8
Loading
Loading
Loading
Loading
+1 −22
Original line number Diff line number Diff line
@@ -1778,7 +1778,7 @@ public class DevicePolicyManager {
     * Sets the enabled state of the profile. A profile should be enabled only once it is ready to
     * be used. Only the profile owner can call this.
     *
     * @see #isPRofileOwnerApp
     * @see #isProfileOwnerApp
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     */
@@ -1832,27 +1832,6 @@ public class DevicePolicyManager {
        return null;
    }

    /**
     * @hide
     * @param userId the userId of a managed profile profile.
     *
     * @return whether or not the managed profile is enabled.
     * @throws IllegalArgumentException if the userId is invalid.
     */
    public boolean isProfileEnabled(int userId) throws IllegalArgumentException {
        if (mService != null) {
            try {
                return mService.isProfileEnabled(userId);
            } catch (RemoteException re) {
                Log.w(TAG, "Failed to get status for owner profile.");
                throw new IllegalArgumentException(
                        "Failed to get status for owner profile.", re);
            }
        }
        return true;
    }


    /**
     * @hide
     * @return the human readable name of the organisation associated with this DPM or null if
+0 −1
Original line number Diff line number Diff line
@@ -109,7 +109,6 @@ interface IDevicePolicyManager {
    String getProfileOwner(int userHandle);
    String getProfileOwnerName(int userHandle);
    void setProfileEnabled(in ComponentName who);
    boolean isProfileEnabled(int userHandle);

    boolean installCaCert(in byte[] certBuffer);
    void uninstallCaCert(in byte[] certBuffer);
+11 −2
Original line number Diff line number Diff line
@@ -27,8 +27,8 @@ import android.os.UserHandle;
 */
public class UserInfo implements Parcelable {

    /** 6 bits for user type */
    public static final int FLAG_MASK_USER_TYPE = 0x0000003F;
    /** 8 bits for user type */
    public static final int FLAG_MASK_USER_TYPE = 0x000000FF;

    /**
     * *************************** NOTE ***************************
@@ -70,6 +70,11 @@ public class UserInfo implements Parcelable {
     */
    public static final int FLAG_MANAGED_PROFILE = 0x00000020;

    /**
     * Indicates that this user is disabled.
     */
    public static final int FLAG_DISABLED = 0x00000040;


    public static final int NO_PROFILE_GROUP_ID = -1;

@@ -117,6 +122,10 @@ public class UserInfo implements Parcelable {
        return (flags & FLAG_MANAGED_PROFILE) == FLAG_MANAGED_PROFILE;
    }

    public boolean isEnabled() {
        return (flags & FLAG_DISABLED) != FLAG_DISABLED;
    }

    /**
     * @return true if this user can be switched to.
     **/
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.graphics.Bitmap;
interface IUserManager {
    UserInfo createUser(in String name, int flags);
    UserInfo createProfileForUser(in String name, int flags, int userHandle);
    void setUserEnabled(int userHandle);
    boolean removeUser(int userHandle);
    void setUserName(int userHandle, String name);
    void setUserIcon(int userHandle, in Bitmap icon);
+16 −0
Original line number Diff line number Diff line
@@ -436,6 +436,22 @@ public class UserManager {
        }
    }

    /**
     * Sets the user as enabled, if such an user exists.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     * Note that the default is true, it's only that managed profiles might not be enabled.
     *
     * @param userHandle the id of the profile to enable
     * @hide
     */
    public void setUserEnabled(int userHandle) {
        try {
            mService.setUserEnabled(userHandle);
        } catch (RemoteException e) {
            Log.w(TAG, "Could not enable the profile", e);
        }
    }

    /**
     * Return the number of users currently created on the device.
     */
Loading