am 6eeff850: Merge "Remove UID checks from LockPatternUtils" into jb-mr1-dev

* commit '6eeff850b245bd3be3a0e782cd9f28daadf922dc':
  Remove UID checks from LockPatternUtils
This commit is contained in:
Jim Miller
2012-09-24 09:26:53 -07:00
committed by Android Git Automerger

View File

@@ -215,36 +215,26 @@ public class LockPatternUtils {
}
public void setCurrentUser(int userId) {
if (Process.myUid() == Process.SYSTEM_UID) {
mCurrentUserId = userId;
} else {
throw new SecurityException("Only the system process can set the current user");
}
mCurrentUserId = userId;
}
public int getCurrentUser() {
if (Process.myUid() == Process.SYSTEM_UID) {
if (mCurrentUserId != UserHandle.USER_NULL) {
// Someone is regularly updating using setCurrentUser() use that value.
return mCurrentUserId;
}
try {
return ActivityManagerNative.getDefault().getCurrentUser().id;
} catch (RemoteException re) {
return UserHandle.USER_OWNER;
}
} else {
throw new SecurityException("Only the system process can get the current user");
if (mCurrentUserId != UserHandle.USER_NULL) {
// Someone is regularly updating using setCurrentUser() use that value.
return mCurrentUserId;
}
try {
return ActivityManagerNative.getDefault().getCurrentUser().id;
} catch (RemoteException re) {
return UserHandle.USER_OWNER;
}
}
public void removeUser(int userId) {
if (Process.myUid() == Process.SYSTEM_UID) {
try {
getLockSettings().removeUser(userId);
} catch (RemoteException re) {
Log.e(TAG, "Couldn't remove lock settings for user " + userId);
}
try {
getLockSettings().removeUser(userId);
} catch (RemoteException re) {
Log.e(TAG, "Couldn't remove lock settings for user " + userId);
}
}
@@ -591,10 +581,6 @@ public class LockPatternUtils {
// Compute the hash
final byte[] hash = passwordToHash(password);
try {
if (Process.myUid() != Process.SYSTEM_UID && userHandle != UserHandle.myUserId()) {
throw new SecurityException(
"Only the system process can save lock password for another user");
}
getLockSettings().setLockPassword(hash, userHandle);
DevicePolicyManager dpm = getDevicePolicyManager();
KeyStore keyStore = KeyStore.getInstance();