@@ -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