|
22 | 22 |
|
23 | 23 | import android.app.ActivityManagerNative; |
24 | 24 | import android.app.admin.DevicePolicyManager; |
25 | | -import android.content.BroadcastReceiver; |
26 | 25 | import android.content.ContentResolver; |
27 | 26 | import android.content.Context; |
28 | 27 | import android.content.Intent; |
29 | | -import android.content.IntentFilter; |
30 | 28 | import android.content.pm.PackageManager; |
31 | 29 | import android.os.Binder; |
32 | | -import android.os.FileObserver; |
33 | 30 | import android.os.IBinder; |
34 | 31 | import android.os.Process; |
35 | 32 | import android.os.RemoteException; |
|
45 | 42 | import android.view.View; |
46 | 43 | import android.widget.Button; |
47 | 44 |
|
48 | | -import java.io.File; |
49 | | -import java.io.FileNotFoundException; |
50 | | -import java.io.IOException; |
51 | | -import java.io.RandomAccessFile; |
52 | 45 | import java.security.MessageDigest; |
53 | 46 | import java.security.NoSuchAlgorithmException; |
54 | 47 | import java.security.SecureRandom; |
55 | | -import java.util.Arrays; |
56 | 48 | import java.util.List; |
57 | | -import java.util.concurrent.atomic.AtomicBoolean; |
58 | 49 |
|
59 | 50 | /** |
60 | 51 | * Utilities for the lock pattern and its settings. |
@@ -134,7 +125,7 @@ public class LockPatternUtils { |
134 | 125 | private final ContentResolver mContentResolver; |
135 | 126 | private DevicePolicyManager mDevicePolicyManager; |
136 | 127 | private ILockSettings mLockSettingsService; |
137 | | - private int mCurrentUserId = 0; |
| 128 | + private int mCurrentUserId = UserHandle.USER_NULL; |
138 | 129 |
|
139 | 130 | public DevicePolicyManager getDevicePolicyManager() { |
140 | 131 | if (mDevicePolicyManager == null) { |
@@ -233,10 +224,14 @@ public void setCurrentUser(int userId) { |
233 | 224 |
|
234 | 225 | public int getCurrentUser() { |
235 | 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 | + } |
236 | 231 | try { |
237 | 232 | return ActivityManagerNative.getDefault().getCurrentUser().id; |
238 | 233 | } catch (RemoteException re) { |
239 | | - return mCurrentUserId; |
| 234 | + return UserHandle.USER_OWNER; |
240 | 235 | } |
241 | 236 | } else { |
242 | 237 | throw new SecurityException("Only the system process can get the current user"); |
|
0 commit comments