DevicePolicyManager per user

Bug: 7136483

Store device policy information for each user and apply them when user switches.

Global proxy can only be controlled by owner.
Camera restriction applies to all users, if any one has an admin that disables it.
Storage encryption can only be controlled by owner, although other users can query the state.
Wipe data will only remove the user if non-zero, wipe the device, if zero.

Change-Id: I359be46c1bc3828fd13d4be3228f11495081c8f2
diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java
index e7cea57..8fb6948 100644
--- a/core/java/android/app/PendingIntent.java
+++ b/core/java/android/app/PendingIntent.java
@@ -413,6 +413,13 @@
      */
     public static PendingIntent getBroadcast(Context context, int requestCode,
             Intent intent, int flags) {
+        return getBroadcastAsUser(context, requestCode, intent, flags,
+                new UserHandle(UserHandle.myUserId()));
+    }
+
+    /** @hide */
+    public static PendingIntent getBroadcastAsUser(Context context, int requestCode,
+            Intent intent, int flags, UserHandle userHandle) {
         String packageName = context.getPackageName();
         String resolvedType = intent != null ? intent.resolveTypeIfNeeded(
                 context.getContentResolver()) : null;
@@ -423,7 +430,7 @@
                     ActivityManager.INTENT_SENDER_BROADCAST, packageName,
                     null, null, requestCode, new Intent[] { intent },
                     resolvedType != null ? new String[] { resolvedType } : null,
-                    flags, null, UserHandle.myUserId());
+                    flags, null, userHandle.getIdentifier());
             return target != null ? new PendingIntent(target) : null;
         } catch (RemoteException e) {
         }
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 4c55bb3..600d02a 100755
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -29,6 +29,7 @@
 import android.os.RemoteCallback;
 import android.os.RemoteException;
 import android.os.ServiceManager;
+import android.os.UserHandle;
 import android.util.Log;
 
 import java.io.IOException;
@@ -131,7 +132,7 @@
     public boolean isAdminActive(ComponentName who) {
         if (mService != null) {
             try {
-                return mService.isAdminActive(who);
+                return mService.isAdminActive(who, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -147,7 +148,7 @@
     public List<ComponentName> getActiveAdmins() {
         if (mService != null) {
             try {
-                return mService.getActiveAdmins();
+                return mService.getActiveAdmins(UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -156,12 +157,14 @@
     }
 
     /**
+     * Used by package administration code to determine if a package can be stopped
+     * or uninstalled.
      * @hide
      */
     public boolean packageHasActiveAdmins(String packageName) {
         if (mService != null) {
             try {
-                return mService.packageHasActiveAdmins(packageName);
+                return mService.packageHasActiveAdmins(packageName, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -178,7 +181,7 @@
     public void removeActiveAdmin(ComponentName who) {
         if (mService != null) {
             try {
-                mService.removeActiveAdmin(who);
+                mService.removeActiveAdmin(who, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -197,7 +200,7 @@
     public boolean hasGrantedPolicy(ComponentName admin, int usesPolicy) {
         if (mService != null) {
             try {
-                return mService.hasGrantedPolicy(admin, usesPolicy);
+                return mService.hasGrantedPolicy(admin, usesPolicy, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -289,7 +292,7 @@
     public void setPasswordQuality(ComponentName admin, int quality) {
         if (mService != null) {
             try {
-                mService.setPasswordQuality(admin, quality);
+                mService.setPasswordQuality(admin, quality, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -303,9 +306,14 @@
      * all admins.
      */
     public int getPasswordQuality(ComponentName admin) {
+        return getPasswordQuality(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getPasswordQuality(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getPasswordQuality(admin);
+                return mService.getPasswordQuality(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -337,7 +345,7 @@
     public void setPasswordMinimumLength(ComponentName admin, int length) {
         if (mService != null) {
             try {
-                mService.setPasswordMinimumLength(admin, length);
+                mService.setPasswordMinimumLength(admin, length, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -351,9 +359,14 @@
      * all admins.
      */
     public int getPasswordMinimumLength(ComponentName admin) {
+        return getPasswordMinimumLength(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getPasswordMinimumLength(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getPasswordMinimumLength(admin);
+                return mService.getPasswordMinimumLength(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -386,7 +399,7 @@
     public void setPasswordMinimumUpperCase(ComponentName admin, int length) {
         if (mService != null) {
             try {
-                mService.setPasswordMinimumUpperCase(admin, length);
+                mService.setPasswordMinimumUpperCase(admin, length, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -406,9 +419,14 @@
      *         password.
      */
     public int getPasswordMinimumUpperCase(ComponentName admin) {
+        return getPasswordMinimumUpperCase(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getPasswordMinimumUpperCase(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getPasswordMinimumUpperCase(admin);
+                return mService.getPasswordMinimumUpperCase(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -441,7 +459,7 @@
     public void setPasswordMinimumLowerCase(ComponentName admin, int length) {
         if (mService != null) {
             try {
-                mService.setPasswordMinimumLowerCase(admin, length);
+                mService.setPasswordMinimumLowerCase(admin, length, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -461,9 +479,14 @@
      *         password.
      */
     public int getPasswordMinimumLowerCase(ComponentName admin) {
+        return getPasswordMinimumLowerCase(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getPasswordMinimumLowerCase(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getPasswordMinimumLowerCase(admin);
+                return mService.getPasswordMinimumLowerCase(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -495,7 +518,7 @@
     public void setPasswordMinimumLetters(ComponentName admin, int length) {
         if (mService != null) {
             try {
-                mService.setPasswordMinimumLetters(admin, length);
+                mService.setPasswordMinimumLetters(admin, length, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -514,9 +537,14 @@
      * @return The minimum number of letters required in the password.
      */
     public int getPasswordMinimumLetters(ComponentName admin) {
+        return getPasswordMinimumLetters(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getPasswordMinimumLetters(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getPasswordMinimumLetters(admin);
+                return mService.getPasswordMinimumLetters(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -548,7 +576,7 @@
     public void setPasswordMinimumNumeric(ComponentName admin, int length) {
         if (mService != null) {
             try {
-                mService.setPasswordMinimumNumeric(admin, length);
+                mService.setPasswordMinimumNumeric(admin, length, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -567,9 +595,14 @@
      * @return The minimum number of numerical digits required in the password.
      */
     public int getPasswordMinimumNumeric(ComponentName admin) {
+        return getPasswordMinimumNumeric(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getPasswordMinimumNumeric(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getPasswordMinimumNumeric(admin);
+                return mService.getPasswordMinimumNumeric(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -601,7 +634,7 @@
     public void setPasswordMinimumSymbols(ComponentName admin, int length) {
         if (mService != null) {
             try {
-                mService.setPasswordMinimumSymbols(admin, length);
+                mService.setPasswordMinimumSymbols(admin, length, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -620,9 +653,14 @@
      * @return The minimum number of symbols required in the password.
      */
     public int getPasswordMinimumSymbols(ComponentName admin) {
+        return getPasswordMinimumSymbols(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getPasswordMinimumSymbols(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getPasswordMinimumSymbols(admin);
+                return mService.getPasswordMinimumSymbols(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -654,7 +692,7 @@
     public void setPasswordMinimumNonLetter(ComponentName admin, int length) {
         if (mService != null) {
             try {
-                mService.setPasswordMinimumNonLetter(admin, length);
+                mService.setPasswordMinimumNonLetter(admin, length, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -673,9 +711,14 @@
      * @return The minimum number of letters required in the password.
      */
     public int getPasswordMinimumNonLetter(ComponentName admin) {
+        return getPasswordMinimumNonLetter(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getPasswordMinimumNonLetter(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getPasswordMinimumNonLetter(admin);
+                return mService.getPasswordMinimumNonLetter(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -708,7 +751,7 @@
     public void setPasswordHistoryLength(ComponentName admin, int length) {
         if (mService != null) {
             try {
-                mService.setPasswordHistoryLength(admin, length);
+                mService.setPasswordHistoryLength(admin, length, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -737,7 +780,7 @@
     public void setPasswordExpirationTimeout(ComponentName admin, long timeout) {
         if (mService != null) {
             try {
-                mService.setPasswordExpirationTimeout(admin, timeout);
+                mService.setPasswordExpirationTimeout(admin, timeout, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -756,7 +799,7 @@
     public long getPasswordExpirationTimeout(ComponentName admin) {
         if (mService != null) {
             try {
-                return mService.getPasswordExpirationTimeout(admin);
+                return mService.getPasswordExpirationTimeout(admin, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -776,7 +819,7 @@
     public long getPasswordExpiration(ComponentName admin) {
         if (mService != null) {
             try {
-                return mService.getPasswordExpiration(admin);
+                return mService.getPasswordExpiration(admin, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -792,9 +835,14 @@
      * @return The length of the password history
      */
     public int getPasswordHistoryLength(ComponentName admin) {
+        return getPasswordHistoryLength(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getPasswordHistoryLength(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getPasswordHistoryLength(admin);
+                return mService.getPasswordHistoryLength(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -828,7 +876,7 @@
     public boolean isActivePasswordSufficient() {
         if (mService != null) {
             try {
-                return mService.isActivePasswordSufficient();
+                return mService.isActivePasswordSufficient(UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -847,7 +895,7 @@
     public int getCurrentFailedPasswordAttempts() {
         if (mService != null) {
             try {
-                return mService.getCurrentFailedPasswordAttempts();
+                return mService.getCurrentFailedPasswordAttempts(UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -877,7 +925,7 @@
     public void setMaximumFailedPasswordsForWipe(ComponentName admin, int num) {
         if (mService != null) {
             try {
-                mService.setMaximumFailedPasswordsForWipe(admin, num);
+                mService.setMaximumFailedPasswordsForWipe(admin, num, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -892,9 +940,14 @@
      * all admins.
      */
     public int getMaximumFailedPasswordsForWipe(ComponentName admin) {
+        return getMaximumFailedPasswordsForWipe(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getMaximumFailedPasswordsForWipe(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getMaximumFailedPasswordsForWipe(admin);
+                return mService.getMaximumFailedPasswordsForWipe(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -933,7 +986,7 @@
     public boolean resetPassword(String password, int flags) {
         if (mService != null) {
             try {
-                return mService.resetPassword(password, flags);
+                return mService.resetPassword(password, flags, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -957,7 +1010,7 @@
     public void setMaximumTimeToLock(ComponentName admin, long timeMs) {
         if (mService != null) {
             try {
-                mService.setMaximumTimeToLock(admin, timeMs);
+                mService.setMaximumTimeToLock(admin, timeMs, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -971,9 +1024,14 @@
      * all admins.
      */
     public long getMaximumTimeToLock(ComponentName admin) {
+        return getMaximumTimeToLock(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public long getMaximumTimeToLock(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getMaximumTimeToLock(admin);
+                return mService.getMaximumTimeToLock(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1021,7 +1079,7 @@
     public void wipeData(int flags) {
         if (mService != null) {
             try {
-                mService.wipeData(flags);
+                mService.wipeData(flags, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1090,7 +1148,7 @@
                     }
                     android.net.Proxy.validate(hostName, Integer.toString(port), exclSpec);
                 }
-                return mService.setGlobalProxy(admin, hostSpec, exclSpec);
+                return mService.setGlobalProxy(admin, hostSpec, exclSpec, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1107,7 +1165,7 @@
     public ComponentName getGlobalProxyAdmin() {
         if (mService != null) {
             try {
-                return mService.getGlobalProxyAdmin();
+                return mService.getGlobalProxyAdmin(UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1199,7 +1257,7 @@
     public int setStorageEncryption(ComponentName admin, boolean encrypt) {
         if (mService != null) {
             try {
-                return mService.setStorageEncryption(admin, encrypt);
+                return mService.setStorageEncryption(admin, encrypt, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1219,7 +1277,7 @@
     public boolean getStorageEncryption(ComponentName admin) {
         if (mService != null) {
             try {
-                return mService.getStorageEncryption(admin);
+                return mService.getStorageEncryption(admin, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1244,9 +1302,14 @@
      * {@link #ENCRYPTION_STATUS_ACTIVATING}, or{@link #ENCRYPTION_STATUS_ACTIVE}.
      */
     public int getStorageEncryptionStatus() {
+        return getStorageEncryptionStatus(UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getStorageEncryptionStatus(int userHandle) {
         if (mService != null) {
             try {
-                return mService.getStorageEncryptionStatus();
+                return mService.getStorageEncryptionStatus(userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1269,7 +1332,7 @@
     public void setCameraDisabled(ComponentName admin, boolean disabled) {
         if (mService != null) {
             try {
-                mService.setCameraDisabled(admin, disabled);
+                mService.setCameraDisabled(admin, disabled, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1283,9 +1346,14 @@
      * have disabled the camera
      */
     public boolean getCameraDisabled(ComponentName admin) {
+        return getCameraDisabled(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public boolean getCameraDisabled(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getCameraDisabled(admin);
+                return mService.getCameraDisabled(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1309,7 +1377,7 @@
     public void setKeyguardWidgetsDisabled(ComponentName admin, int which) {
         if (mService != null) {
             try {
-                mService.setKeyguardWidgetsDisabled(admin, which);
+                mService.setKeyguardWidgetsDisabled(admin, which, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1323,9 +1391,14 @@
      * have disabled widgets in keyguard.
      */
     public int getKeyguardWidgetsDisabled(ComponentName admin) {
+        return getKeyguardWidgetsDisabled(admin, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public int getKeyguardWidgetsDisabled(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getKeyguardWidgetsDisabled(admin);
+                return mService.getKeyguardWidgetsDisabled(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1339,7 +1412,7 @@
     public void setActiveAdmin(ComponentName policyReceiver, boolean refreshing) {
         if (mService != null) {
             try {
-                mService.setActiveAdmin(policyReceiver, refreshing);
+                mService.setActiveAdmin(policyReceiver, refreshing, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1380,7 +1453,7 @@
     public void getRemoveWarning(ComponentName admin, RemoteCallback result) {
         if (mService != null) {
             try {
-                mService.getRemoveWarning(admin, result);
+                mService.getRemoveWarning(admin, result, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1391,11 +1464,11 @@
      * @hide
      */
     public void setActivePasswordState(int quality, int length, int letters, int uppercase,
-            int lowercase, int numbers, int symbols, int nonletter) {
+            int lowercase, int numbers, int symbols, int nonletter, int userHandle) {
         if (mService != null) {
             try {
                 mService.setActivePasswordState(quality, length, letters, uppercase, lowercase,
-                        numbers, symbols, nonletter);
+                        numbers, symbols, nonletter, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1405,10 +1478,10 @@
     /**
      * @hide
      */
-    public void reportFailedPasswordAttempt() {
+    public void reportFailedPasswordAttempt(int userHandle) {
         if (mService != null) {
             try {
-                mService.reportFailedPasswordAttempt();
+                mService.reportFailedPasswordAttempt(userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1418,14 +1491,13 @@
     /**
      * @hide
      */
-    public void reportSuccessfulPasswordAttempt() {
+    public void reportSuccessfulPasswordAttempt(int userHandle) {
         if (mService != null) {
             try {
-                mService.reportSuccessfulPasswordAttempt();
+                mService.reportSuccessfulPasswordAttempt(userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
         }
     }
-
 }
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 0b7ec12..bdfb177 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -25,76 +25,76 @@
  * {@hide}
  */
 interface IDevicePolicyManager {
-    void setPasswordQuality(in ComponentName who, int quality);
-    int getPasswordQuality(in ComponentName who);
+    void setPasswordQuality(in ComponentName who, int quality, int userHandle);
+    int getPasswordQuality(in ComponentName who, int userHandle);
 
-    void setPasswordMinimumLength(in ComponentName who, int length);
-    int getPasswordMinimumLength(in ComponentName who);
+    void setPasswordMinimumLength(in ComponentName who, int length, int userHandle);
+    int getPasswordMinimumLength(in ComponentName who, int userHandle);
 
-    void setPasswordMinimumUpperCase(in ComponentName who, int length);
-    int getPasswordMinimumUpperCase(in ComponentName who);
+    void setPasswordMinimumUpperCase(in ComponentName who, int length, int userHandle);
+    int getPasswordMinimumUpperCase(in ComponentName who, int userHandle);
 
-    void setPasswordMinimumLowerCase(in ComponentName who, int length);
-    int getPasswordMinimumLowerCase(in ComponentName who);
+    void setPasswordMinimumLowerCase(in ComponentName who, int length, int userHandle);
+    int getPasswordMinimumLowerCase(in ComponentName who, int userHandle);
 
-    void setPasswordMinimumLetters(in ComponentName who, int length);
-    int getPasswordMinimumLetters(in ComponentName who);
+    void setPasswordMinimumLetters(in ComponentName who, int length, int userHandle);
+    int getPasswordMinimumLetters(in ComponentName who, int userHandle);
 
-    void setPasswordMinimumNumeric(in ComponentName who, int length);
-    int getPasswordMinimumNumeric(in ComponentName who);
+    void setPasswordMinimumNumeric(in ComponentName who, int length, int userHandle);
+    int getPasswordMinimumNumeric(in ComponentName who, int userHandle);
 
-    void setPasswordMinimumSymbols(in ComponentName who, int length);
-    int getPasswordMinimumSymbols(in ComponentName who);
+    void setPasswordMinimumSymbols(in ComponentName who, int length, int userHandle);
+    int getPasswordMinimumSymbols(in ComponentName who, int userHandle);
 
-    void setPasswordMinimumNonLetter(in ComponentName who, int length);
-    int getPasswordMinimumNonLetter(in ComponentName who);
+    void setPasswordMinimumNonLetter(in ComponentName who, int length, int userHandle);
+    int getPasswordMinimumNonLetter(in ComponentName who, int userHandle);
 
-    void setPasswordHistoryLength(in ComponentName who, int length);
-    int getPasswordHistoryLength(in ComponentName who);
+    void setPasswordHistoryLength(in ComponentName who, int length, int userHandle);
+    int getPasswordHistoryLength(in ComponentName who, int userHandle);
 
-    void setPasswordExpirationTimeout(in ComponentName who, long expiration);
-    long getPasswordExpirationTimeout(in ComponentName who);
+    void setPasswordExpirationTimeout(in ComponentName who, long expiration, int userHandle);
+    long getPasswordExpirationTimeout(in ComponentName who, int userHandle);
 
-    long getPasswordExpiration(in ComponentName who);
+    long getPasswordExpiration(in ComponentName who, int userHandle);
 
-    boolean isActivePasswordSufficient();
-    int getCurrentFailedPasswordAttempts();
+    boolean isActivePasswordSufficient(int userHandle);
+    int getCurrentFailedPasswordAttempts(int userHandle);
 
-    void setMaximumFailedPasswordsForWipe(in ComponentName admin, int num);
-    int getMaximumFailedPasswordsForWipe(in ComponentName admin);
+    void setMaximumFailedPasswordsForWipe(in ComponentName admin, int num, int userHandle);
+    int getMaximumFailedPasswordsForWipe(in ComponentName admin, int userHandle);
 
-    boolean resetPassword(String password, int flags);
+    boolean resetPassword(String password, int flags, int userHandle);
 
-    void setMaximumTimeToLock(in ComponentName who, long timeMs);
-    long getMaximumTimeToLock(in ComponentName who);
+    void setMaximumTimeToLock(in ComponentName who, long timeMs, int userHandle);
+    long getMaximumTimeToLock(in ComponentName who, int userHandle);
 
     void lockNow();
 
-    void wipeData(int flags);
+    void wipeData(int flags, int userHandle);
 
-    ComponentName setGlobalProxy(in ComponentName admin, String proxySpec, String exclusionList);
-    ComponentName getGlobalProxyAdmin();
+    ComponentName setGlobalProxy(in ComponentName admin, String proxySpec, String exclusionList, int userHandle);
+    ComponentName getGlobalProxyAdmin(int userHandle);
 
-    int setStorageEncryption(in ComponentName who, boolean encrypt);
-    boolean getStorageEncryption(in ComponentName who);
-    int getStorageEncryptionStatus();
+    int setStorageEncryption(in ComponentName who, boolean encrypt, int userHandle);
+    boolean getStorageEncryption(in ComponentName who, int userHandle);
+    int getStorageEncryptionStatus(int userHandle);
 
-    void setCameraDisabled(in ComponentName who, boolean disabled);
-    boolean getCameraDisabled(in ComponentName who);
+    void setCameraDisabled(in ComponentName who, boolean disabled, int userHandle);
+    boolean getCameraDisabled(in ComponentName who, int userHandle);
 
-    void setKeyguardWidgetsDisabled(in ComponentName who, int which);
-    int getKeyguardWidgetsDisabled(in ComponentName who);
+    void setKeyguardWidgetsDisabled(in ComponentName who, int which, int userHandle);
+    int getKeyguardWidgetsDisabled(in ComponentName who, int userHandle);
 
-    void setActiveAdmin(in ComponentName policyReceiver, boolean refreshing);
-    boolean isAdminActive(in ComponentName policyReceiver);
-    List<ComponentName> getActiveAdmins();
-    boolean packageHasActiveAdmins(String packageName);
-    void getRemoveWarning(in ComponentName policyReceiver, in RemoteCallback result);
-    void removeActiveAdmin(in ComponentName policyReceiver);
-    boolean hasGrantedPolicy(in ComponentName policyReceiver, int usesPolicy);
+    void setActiveAdmin(in ComponentName policyReceiver, boolean refreshing, int userHandle);
+    boolean isAdminActive(in ComponentName policyReceiver, int userHandle);
+    List<ComponentName> getActiveAdmins(int userHandle);
+    boolean packageHasActiveAdmins(String packageName, int userHandle);
+    void getRemoveWarning(in ComponentName policyReceiver, in RemoteCallback result, int userHandle);
+    void removeActiveAdmin(in ComponentName policyReceiver, int userHandle);
+    boolean hasGrantedPolicy(in ComponentName policyReceiver, int usesPolicy, int userHandle);
 
     void setActivePasswordState(int quality, int length, int letters, int uppercase, int lowercase,
-        int numbers, int symbols, int nonletter);
-    void reportFailedPasswordAttempt();
-    void reportSuccessfulPasswordAttempt();
+        int numbers, int symbols, int nonletter, int userHandle);
+    void reportFailedPasswordAttempt(int userHandle);
+    void reportSuccessfulPasswordAttempt(int userHandle);
 }