Skip to content

Commit 6eeff85

Browse files
Jim MillerAndroid (Google) Code Review
authored andcommitted
Merge "Remove UID checks from LockPatternUtils" into jb-mr1-dev
2 parents 0a5c556 + 25645d8 commit 6eeff85

File tree

1 file changed

+13
-27
lines changed

1 file changed

+13
-27
lines changed

core/java/com/android/internal/widget/LockPatternUtils.java

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -215,36 +215,26 @@ public void reportSuccessfulPasswordAttempt() {
215215
}
216216

217217
public void setCurrentUser(int userId) {
218-
if (Process.myUid() == Process.SYSTEM_UID) {
219-
mCurrentUserId = userId;
220-
} else {
221-
throw new SecurityException("Only the system process can set the current user");
222-
}
218+
mCurrentUserId = userId;
223219
}
224220

225221
public int getCurrentUser() {
226-
if (Process.myUid() == Process.SYSTEM_UID) {
227-
if (mCurrentUserId != UserHandle.USER_NULL) {
228-
// Someone is regularly updating using setCurrentUser() use that value.
229-
return mCurrentUserId;
230-
}
231-
try {
232-
return ActivityManagerNative.getDefault().getCurrentUser().id;
233-
} catch (RemoteException re) {
234-
return UserHandle.USER_OWNER;
235-
}
236-
} else {
237-
throw new SecurityException("Only the system process can get the current user");
222+
if (mCurrentUserId != UserHandle.USER_NULL) {
223+
// Someone is regularly updating using setCurrentUser() use that value.
224+
return mCurrentUserId;
225+
}
226+
try {
227+
return ActivityManagerNative.getDefault().getCurrentUser().id;
228+
} catch (RemoteException re) {
229+
return UserHandle.USER_OWNER;
238230
}
239231
}
240232

241233
public void removeUser(int userId) {
242-
if (Process.myUid() == Process.SYSTEM_UID) {
243-
try {
244-
getLockSettings().removeUser(userId);
245-
} catch (RemoteException re) {
246-
Log.e(TAG, "Couldn't remove lock settings for user " + userId);
247-
}
234+
try {
235+
getLockSettings().removeUser(userId);
236+
} catch (RemoteException re) {
237+
Log.e(TAG, "Couldn't remove lock settings for user " + userId);
248238
}
249239
}
250240

@@ -591,10 +581,6 @@ public void saveLockPassword(String password, int quality, boolean isFallback, i
591581
// Compute the hash
592582
final byte[] hash = passwordToHash(password);
593583
try {
594-
if (Process.myUid() != Process.SYSTEM_UID && userHandle != UserHandle.myUserId()) {
595-
throw new SecurityException(
596-
"Only the system process can save lock password for another user");
597-
}
598584
getLockSettings().setLockPassword(hash, userHandle);
599585
DevicePolicyManager dpm = getDevicePolicyManager();
600586
KeyStore keyStore = KeyStore.getInstance();

0 commit comments

Comments
 (0)