Skip to content

Commit f426ace

Browse files
Amith YamasaniAndroid (Google) Code Review
authored andcommitted
Merge "Only wipe device if primary user (for failed password attempts)" into jb-mr1.1-dev
2 parents 09a526f + 32f0742 commit f426ace

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

services/java/com/android/server/DevicePolicyManagerService.java

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,28 +1875,32 @@ public void wipeData(int flags, final int userHandle) {
18751875
DeviceAdminInfo.USES_POLICY_WIPE_DATA);
18761876
long ident = Binder.clearCallingIdentity();
18771877
try {
1878-
if (userHandle == UserHandle.USER_OWNER) {
1879-
wipeDataLocked(flags);
1880-
} else {
1881-
lockNowUnchecked();
1882-
mHandler.post(new Runnable() {
1883-
public void run() {
1884-
try {
1885-
ActivityManagerNative.getDefault().switchUser(0);
1886-
((UserManager) mContext.getSystemService(Context.USER_SERVICE))
1887-
.removeUser(userHandle);
1888-
} catch (RemoteException re) {
1889-
// Shouldn't happen
1890-
}
1891-
}
1892-
});
1893-
}
1878+
wipeDeviceOrUserLocked(flags, userHandle);
18941879
} finally {
18951880
Binder.restoreCallingIdentity(ident);
18961881
}
18971882
}
18981883
}
18991884

1885+
private void wipeDeviceOrUserLocked(int flags, final int userHandle) {
1886+
if (userHandle == UserHandle.USER_OWNER) {
1887+
wipeDataLocked(flags);
1888+
} else {
1889+
lockNowUnchecked();
1890+
mHandler.post(new Runnable() {
1891+
public void run() {
1892+
try {
1893+
ActivityManagerNative.getDefault().switchUser(0);
1894+
((UserManager) mContext.getSystemService(Context.USER_SERVICE))
1895+
.removeUser(userHandle);
1896+
} catch (RemoteException re) {
1897+
// Shouldn't happen
1898+
}
1899+
}
1900+
});
1901+
}
1902+
}
1903+
19001904
public void getRemoveWarning(ComponentName comp, final RemoteCallback result, int userHandle) {
19011905
enforceCrossUserPermission(userHandle);
19021906
mContext.enforceCallingOrSelfPermission(
@@ -1996,7 +2000,7 @@ public void reportFailedPasswordAttempt(int userHandle) {
19962000
saveSettingsLocked(userHandle);
19972001
int max = getMaximumFailedPasswordsForWipe(null, userHandle);
19982002
if (max > 0 && policy.mFailedPasswordAttempts >= max) {
1999-
wipeDataLocked(0);
2003+
wipeDeviceOrUserLocked(0, userHandle);
20002004
}
20012005
sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_FAILED,
20022006
DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, userHandle);

0 commit comments

Comments
 (0)