Merge "Remove UID checks from LockPatternUtils" into jb-mr1-dev
This commit is contained in:
@@ -215,36 +215,26 @@ public class LockPatternUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentUser(int userId) {
|
public void setCurrentUser(int userId) {
|
||||||
if (Process.myUid() == Process.SYSTEM_UID) {
|
mCurrentUserId = userId;
|
||||||
mCurrentUserId = userId;
|
|
||||||
} else {
|
|
||||||
throw new SecurityException("Only the system process can set the current user");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentUser() {
|
public int getCurrentUser() {
|
||||||
if (Process.myUid() == Process.SYSTEM_UID) {
|
if (mCurrentUserId != UserHandle.USER_NULL) {
|
||||||
if (mCurrentUserId != UserHandle.USER_NULL) {
|
// Someone is regularly updating using setCurrentUser() use that value.
|
||||||
// Someone is regularly updating using setCurrentUser() use that value.
|
return mCurrentUserId;
|
||||||
return mCurrentUserId;
|
}
|
||||||
}
|
try {
|
||||||
try {
|
return ActivityManagerNative.getDefault().getCurrentUser().id;
|
||||||
return ActivityManagerNative.getDefault().getCurrentUser().id;
|
} catch (RemoteException re) {
|
||||||
} catch (RemoteException re) {
|
return UserHandle.USER_OWNER;
|
||||||
return UserHandle.USER_OWNER;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new SecurityException("Only the system process can get the current user");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeUser(int userId) {
|
public void removeUser(int userId) {
|
||||||
if (Process.myUid() == Process.SYSTEM_UID) {
|
try {
|
||||||
try {
|
getLockSettings().removeUser(userId);
|
||||||
getLockSettings().removeUser(userId);
|
} catch (RemoteException re) {
|
||||||
} catch (RemoteException re) {
|
Log.e(TAG, "Couldn't remove lock settings for user " + userId);
|
||||||
Log.e(TAG, "Couldn't remove lock settings for user " + userId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -591,10 +581,6 @@ public class LockPatternUtils {
|
|||||||
// Compute the hash
|
// Compute the hash
|
||||||
final byte[] hash = passwordToHash(password);
|
final byte[] hash = passwordToHash(password);
|
||||||
try {
|
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);
|
getLockSettings().setLockPassword(hash, userHandle);
|
||||||
DevicePolicyManager dpm = getDevicePolicyManager();
|
DevicePolicyManager dpm = getDevicePolicyManager();
|
||||||
KeyStore keyStore = KeyStore.getInstance();
|
KeyStore keyStore = KeyStore.getInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user