am f426ace9: Merge "Only wipe device if primary user (for failed password attempts)" into jb-mr1.1-dev

* commit 'f426ace9dab65c88b36a047bf921070edcf8cf61':
  Only wipe device if primary user (for failed password attempts)
This commit is contained in:
Amith Yamasani
2012-11-27 15:40:36 -08:00
committed by Android Git Automerger

View File

@@ -1875,28 +1875,32 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
DeviceAdminInfo.USES_POLICY_WIPE_DATA); DeviceAdminInfo.USES_POLICY_WIPE_DATA);
long ident = Binder.clearCallingIdentity(); long ident = Binder.clearCallingIdentity();
try { try {
if (userHandle == UserHandle.USER_OWNER) { wipeDeviceOrUserLocked(flags, userHandle);
wipeDataLocked(flags);
} else {
lockNowUnchecked();
mHandler.post(new Runnable() {
public void run() {
try {
ActivityManagerNative.getDefault().switchUser(0);
((UserManager) mContext.getSystemService(Context.USER_SERVICE))
.removeUser(userHandle);
} catch (RemoteException re) {
// Shouldn't happen
}
}
});
}
} finally { } finally {
Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident);
} }
} }
} }
private void wipeDeviceOrUserLocked(int flags, final int userHandle) {
if (userHandle == UserHandle.USER_OWNER) {
wipeDataLocked(flags);
} else {
lockNowUnchecked();
mHandler.post(new Runnable() {
public void run() {
try {
ActivityManagerNative.getDefault().switchUser(0);
((UserManager) mContext.getSystemService(Context.USER_SERVICE))
.removeUser(userHandle);
} catch (RemoteException re) {
// Shouldn't happen
}
}
});
}
}
public void getRemoveWarning(ComponentName comp, final RemoteCallback result, int userHandle) { public void getRemoveWarning(ComponentName comp, final RemoteCallback result, int userHandle) {
enforceCrossUserPermission(userHandle); enforceCrossUserPermission(userHandle);
mContext.enforceCallingOrSelfPermission( mContext.enforceCallingOrSelfPermission(
@@ -1996,7 +2000,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
saveSettingsLocked(userHandle); saveSettingsLocked(userHandle);
int max = getMaximumFailedPasswordsForWipe(null, userHandle); int max = getMaximumFailedPasswordsForWipe(null, userHandle);
if (max > 0 && policy.mFailedPasswordAttempts >= max) { if (max > 0 && policy.mFailedPasswordAttempts >= max) {
wipeDataLocked(0); wipeDeviceOrUserLocked(0, userHandle);
} }
sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_FAILED, sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_FAILED,
DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, userHandle); DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, userHandle);