summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorAlexandra Gherghina <alexgherghina@google.com>2014-04-09 13:54:39 +0100
committerAlexandra Gherghina <alexgherghina@google.com>2014-05-01 11:34:27 +0100
commitdf35d570ed25257c6782e632ab1bae5e1603855a (patch)
treeac137caafe620218393e973206ded3f20ac58302 /core/java/android
parent7f89c9b8e6724e4316c294eb9f0dde4a46b61e87 (diff)
downloadframeworks_base-df35d570ed25257c6782e632ab1bae5e1603855a.zip
frameworks_base-df35d570ed25257c6782e632ab1bae5e1603855a.tar.gz
frameworks_base-df35d570ed25257c6782e632ab1bae5e1603855a.tar.bz2
Adds an enabled state in UserInfo instead of DevicePolicyManager
Bug: 14377459 Change-Id: Ib4ec43d87da96c3dddaf9b7ae1796f261863a182
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java23
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl1
-rw-r--r--core/java/android/content/pm/UserInfo.java13
-rw-r--r--core/java/android/os/IUserManager.aidl1
-rw-r--r--core/java/android/os/UserManager.java16
5 files changed, 29 insertions, 25 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 68ab611..e437edb 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -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.
*/
@@ -1834,27 +1834,6 @@ public class DevicePolicyManager {
/**
* @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
* one is not set.
* @throws IllegalArgumentException if the userId is invalid.
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 72b3c20..51ea7b1 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -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);
diff --git a/core/java/android/content/pm/UserInfo.java b/core/java/android/content/pm/UserInfo.java
index f53aa4c..c0383a3 100644
--- a/core/java/android/content/pm/UserInfo.java
+++ b/core/java/android/content/pm/UserInfo.java
@@ -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.
**/
diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl
index c3f7370..899a958 100644
--- a/core/java/android/os/IUserManager.aidl
+++ b/core/java/android/os/IUserManager.aidl
@@ -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);
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 1fe9337..b6a872a 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -437,6 +437,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.
*/
public int getUserCount() {