Skip to content

Commit f02b60a

Browse files
author
Dianne Hackborn
committed
Rename UserId to UserHandle.
This is the start of turning this into a formal public API. Change-Id: I5786d2c320f1de41a06ed5d0f65adb68967287a0
1 parent ca34bcf commit f02b60a

File tree

55 files changed

+298
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+298
-297
lines changed

core/java/android/accounts/AccountManagerService.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import android.os.Message;
5151
import android.os.RemoteException;
5252
import android.os.SystemClock;
53-
import android.os.UserId;
53+
import android.os.UserHandle;
5454
import android.os.UserManager;
5555
import android.text.TextUtils;
5656
import android.util.Log;
@@ -354,7 +354,7 @@ private void validateAccountsAndPopulateCache(UserAccounts accounts) {
354354
}
355355

356356
private UserAccounts getUserAccountsForCaller() {
357-
return getUserAccounts(UserId.getCallingUserId());
357+
return getUserAccounts(UserHandle.getCallingUserId());
358358
}
359359

360360
protected UserAccounts getUserAccounts(int userId) {
@@ -1004,7 +1004,7 @@ public void getAuthTokenLabel(IAccountManagerResponse response, final String acc
10041004
if (callingUid != android.os.Process.SYSTEM_UID) {
10051005
throw new SecurityException("can only call from system");
10061006
}
1007-
UserAccounts accounts = getUserAccounts(UserId.getUserId(callingUid));
1007+
UserAccounts accounts = getUserAccounts(UserHandle.getUserId(callingUid));
10081008
long identityToken = clearCallingIdentity();
10091009
try {
10101010
new Session(accounts, response, accountType, false,
@@ -1222,7 +1222,7 @@ private Intent newGrantCredentialsPermissionIntent(Account account, int uid,
12221222
private Integer getCredentialPermissionNotificationId(Account account, String authTokenType,
12231223
int uid) {
12241224
Integer id;
1225-
UserAccounts accounts = getUserAccounts(UserId.getUserId(uid));
1225+
UserAccounts accounts = getUserAccounts(UserHandle.getUserId(uid));
12261226
synchronized (accounts.credentialsPermissionNotificationIds) {
12271227
final Pair<Pair<Account, String>, Integer> key =
12281228
new Pair<Pair<Account, String>, Integer>(
@@ -2269,7 +2269,7 @@ private void grantAppPermission(Account account, String authTokenType, int uid)
22692269
Log.e(TAG, "grantAppPermission: called with invalid arguments", new Exception());
22702270
return;
22712271
}
2272-
UserAccounts accounts = getUserAccounts(UserId.getUserId(uid));
2272+
UserAccounts accounts = getUserAccounts(UserHandle.getUserId(uid));
22732273
synchronized (accounts.cacheLock) {
22742274
final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
22752275
db.beginTransaction();
@@ -2303,7 +2303,7 @@ private void revokeAppPermission(Account account, String authTokenType, int uid)
23032303
Log.e(TAG, "revokeAppPermission: called with invalid arguments", new Exception());
23042304
return;
23052305
}
2306-
UserAccounts accounts = getUserAccounts(UserId.getUserId(uid));
2306+
UserAccounts accounts = getUserAccounts(UserHandle.getUserId(uid));
23072307
synchronized (accounts.cacheLock) {
23082308
final SQLiteDatabase db = accounts.openHelper.getWritableDatabase();
23092309
db.beginTransaction();

core/java/android/app/ActivityManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import android.os.RemoteException;
4141
import android.os.ServiceManager;
4242
import android.os.SystemProperties;
43-
import android.os.UserId;
43+
import android.os.UserHandle;
4444
import android.text.TextUtils;
4545
import android.util.DisplayMetrics;
4646
import android.util.Log;
@@ -529,7 +529,7 @@ public List<RecentTaskInfo> getRecentTasks(int maxNum, int flags)
529529
throws SecurityException {
530530
try {
531531
return ActivityManagerNative.getDefault().getRecentTasks(maxNum,
532-
flags, UserId.myUserId());
532+
flags, UserHandle.myUserId());
533533
} catch (RemoteException e) {
534534
// System dead, we will be dead too soon!
535535
return null;
@@ -1843,12 +1843,12 @@ public static int checkComponentPermission(String permission, int uid,
18431843
return PackageManager.PERMISSION_GRANTED;
18441844
}
18451845
// Isolated processes don't get any permissions.
1846-
if (UserId.isIsolated(uid)) {
1846+
if (UserHandle.isIsolated(uid)) {
18471847
return PackageManager.PERMISSION_DENIED;
18481848
}
18491849
// If there is a uid that owns whatever is being accessed, it has
18501850
// blanket access to it regardless of the permissions it requires.
1851-
if (owningUid >= 0 && UserId.isSameApp(uid, owningUid)) {
1851+
if (owningUid >= 0 && UserHandle.isSameApp(uid, owningUid)) {
18521852
return PackageManager.PERMISSION_GRANTED;
18531853
}
18541854
// If the target is not exported, then nobody else can get to it.

core/java/android/app/ActivityManagerNative.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import android.os.RemoteException;
4040
import android.os.ServiceManager;
4141
import android.os.StrictMode;
42-
import android.os.UserId;
42+
import android.os.UserHandle;
4343
import android.text.TextUtils;
4444
import android.util.Log;
4545
import android.util.Singleton;

core/java/android/app/ActivityThread.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
import android.os.StrictMode;
6363
import android.os.SystemClock;
6464
import android.os.Trace;
65-
import android.os.UserId;
65+
import android.os.UserHandle;
6666
import android.util.AndroidRuntimeException;
6767
import android.util.DisplayMetrics;
6868
import android.util.EventLog;
@@ -1696,7 +1696,7 @@ public final LoadedApk getPackageInfo(String packageName, CompatibilityInfo comp
16961696
ApplicationInfo ai = null;
16971697
try {
16981698
ai = getPackageManager().getApplicationInfo(packageName,
1699-
PackageManager.GET_SHARED_LIBRARY_FILES, UserId.myUserId());
1699+
PackageManager.GET_SHARED_LIBRARY_FILES, UserHandle.myUserId());
17001700
} catch (RemoteException e) {
17011701
// Ignore
17021702
}
@@ -1713,7 +1713,7 @@ public final LoadedApk getPackageInfo(ApplicationInfo ai, CompatibilityInfo comp
17131713
boolean includeCode = (flags&Context.CONTEXT_INCLUDE_CODE) != 0;
17141714
boolean securityViolation = includeCode && ai.uid != 0
17151715
&& ai.uid != Process.SYSTEM_UID && (mBoundApplication != null
1716-
? !UserId.isSameApp(ai.uid, mBoundApplication.appInfo.uid)
1716+
? !UserHandle.isSameApp(ai.uid, mBoundApplication.appInfo.uid)
17171717
: true);
17181718
if ((flags&(Context.CONTEXT_INCLUDE_CODE
17191719
|Context.CONTEXT_IGNORE_SECURITY))

core/java/android/app/ApplicationPackageManager.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import android.net.Uri;
5151
import android.os.Process;
5252
import android.os.RemoteException;
53-
import android.os.UserId;
53+
import android.os.UserHandle;
5454
import android.util.Log;
5555

5656
import java.lang.ref.WeakReference;
@@ -69,7 +69,7 @@ final class ApplicationPackageManager extends PackageManager {
6969
public PackageInfo getPackageInfo(String packageName, int flags)
7070
throws NameNotFoundException {
7171
try {
72-
PackageInfo pi = mPM.getPackageInfo(packageName, flags, UserId.myUserId());
72+
PackageInfo pi = mPM.getPackageInfo(packageName, flags, UserHandle.myUserId());
7373
if (pi != null) {
7474
return pi;
7575
}
@@ -199,7 +199,7 @@ public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
199199
public ApplicationInfo getApplicationInfo(String packageName, int flags)
200200
throws NameNotFoundException {
201201
try {
202-
ApplicationInfo ai = mPM.getApplicationInfo(packageName, flags, UserId.myUserId());
202+
ApplicationInfo ai = mPM.getApplicationInfo(packageName, flags, UserHandle.myUserId());
203203
if (ai != null) {
204204
return ai;
205205
}
@@ -214,7 +214,7 @@ public ApplicationInfo getApplicationInfo(String packageName, int flags)
214214
public ActivityInfo getActivityInfo(ComponentName className, int flags)
215215
throws NameNotFoundException {
216216
try {
217-
ActivityInfo ai = mPM.getActivityInfo(className, flags, UserId.myUserId());
217+
ActivityInfo ai = mPM.getActivityInfo(className, flags, UserHandle.myUserId());
218218
if (ai != null) {
219219
return ai;
220220
}
@@ -229,7 +229,7 @@ public ActivityInfo getActivityInfo(ComponentName className, int flags)
229229
public ActivityInfo getReceiverInfo(ComponentName className, int flags)
230230
throws NameNotFoundException {
231231
try {
232-
ActivityInfo ai = mPM.getReceiverInfo(className, flags, UserId.myUserId());
232+
ActivityInfo ai = mPM.getReceiverInfo(className, flags, UserHandle.myUserId());
233233
if (ai != null) {
234234
return ai;
235235
}
@@ -244,7 +244,7 @@ public ActivityInfo getReceiverInfo(ComponentName className, int flags)
244244
public ServiceInfo getServiceInfo(ComponentName className, int flags)
245245
throws NameNotFoundException {
246246
try {
247-
ServiceInfo si = mPM.getServiceInfo(className, flags, UserId.myUserId());
247+
ServiceInfo si = mPM.getServiceInfo(className, flags, UserHandle.myUserId());
248248
if (si != null) {
249249
return si;
250250
}
@@ -259,7 +259,7 @@ public ServiceInfo getServiceInfo(ComponentName className, int flags)
259259
public ProviderInfo getProviderInfo(ComponentName className, int flags)
260260
throws NameNotFoundException {
261261
try {
262-
ProviderInfo pi = mPM.getProviderInfo(className, flags, UserId.myUserId());
262+
ProviderInfo pi = mPM.getProviderInfo(className, flags, UserHandle.myUserId());
263263
if (pi != null) {
264264
return pi;
265265
}
@@ -424,7 +424,7 @@ public List<PackageInfo> getInstalledPackages(int flags) {
424424
@SuppressWarnings("unchecked")
425425
@Override
426426
public List<ApplicationInfo> getInstalledApplications(int flags) {
427-
int userId = UserId.getUserId(Process.myUid());
427+
int userId = UserHandle.getUserId(Process.myUid());
428428
try {
429429
final List<ApplicationInfo> applicationInfos = new ArrayList<ApplicationInfo>();
430430
ApplicationInfo lastItem = null;
@@ -448,7 +448,7 @@ public ResolveInfo resolveActivity(Intent intent, int flags) {
448448
return mPM.resolveIntent(
449449
intent,
450450
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
451-
flags, UserId.myUserId());
451+
flags, UserHandle.myUserId());
452452
} catch (RemoteException e) {
453453
throw new RuntimeException("Package manager has died", e);
454454
}
@@ -462,7 +462,7 @@ public List<ResolveInfo> queryIntentActivities(Intent intent,
462462
intent,
463463
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
464464
flags,
465-
UserId.myUserId());
465+
UserHandle.myUserId());
466466
} catch (RemoteException e) {
467467
throw new RuntimeException("Package manager has died", e);
468468
}
@@ -494,7 +494,7 @@ public List<ResolveInfo> queryIntentActivityOptions(
494494
try {
495495
return mPM.queryIntentActivityOptions(caller, specifics,
496496
specificTypes, intent, intent.resolveTypeIfNeeded(resolver),
497-
flags, UserId.myUserId());
497+
flags, UserHandle.myUserId());
498498
} catch (RemoteException e) {
499499
throw new RuntimeException("Package manager has died", e);
500500
}
@@ -507,7 +507,7 @@ public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int flags) {
507507
intent,
508508
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
509509
flags,
510-
UserId.myUserId());
510+
UserHandle.myUserId());
511511
} catch (RemoteException e) {
512512
throw new RuntimeException("Package manager has died", e);
513513
}
@@ -520,7 +520,7 @@ public ResolveInfo resolveService(Intent intent, int flags) {
520520
intent,
521521
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
522522
flags,
523-
UserId.myUserId());
523+
UserHandle.myUserId());
524524
} catch (RemoteException e) {
525525
throw new RuntimeException("Package manager has died", e);
526526
}
@@ -533,7 +533,7 @@ public List<ResolveInfo> queryIntentServices(Intent intent, int flags) {
533533
intent,
534534
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
535535
flags,
536-
UserId.myUserId());
536+
UserHandle.myUserId());
537537
} catch (RemoteException e) {
538538
throw new RuntimeException("Package manager has died", e);
539539
}
@@ -543,7 +543,7 @@ public List<ResolveInfo> queryIntentServices(Intent intent, int flags) {
543543
public ProviderInfo resolveContentProvider(String name,
544544
int flags) {
545545
try {
546-
return mPM.resolveContentProvider(name, flags, UserId.myUserId());
546+
return mPM.resolveContentProvider(name, flags, UserHandle.myUserId());
547547
} catch (RemoteException e) {
548548
throw new RuntimeException("Package manager has died", e);
549549
}
@@ -1033,7 +1033,7 @@ public void deletePackage(String packageName, IPackageDeleteObserver observer, i
10331033
public void clearApplicationUserData(String packageName,
10341034
IPackageDataObserver observer) {
10351035
try {
1036-
mPM.clearApplicationUserData(packageName, observer, UserId.myUserId());
1036+
mPM.clearApplicationUserData(packageName, observer, UserHandle.myUserId());
10371037
} catch (RemoteException e) {
10381038
// Should never happen!
10391039
}
@@ -1146,7 +1146,7 @@ public int getPreferredActivities(List<IntentFilter> outFilters,
11461146
public void setComponentEnabledSetting(ComponentName componentName,
11471147
int newState, int flags) {
11481148
try {
1149-
mPM.setComponentEnabledSetting(componentName, newState, flags, UserId.myUserId());
1149+
mPM.setComponentEnabledSetting(componentName, newState, flags, UserHandle.myUserId());
11501150
} catch (RemoteException e) {
11511151
// Should never happen!
11521152
}
@@ -1155,7 +1155,7 @@ public void setComponentEnabledSetting(ComponentName componentName,
11551155
@Override
11561156
public int getComponentEnabledSetting(ComponentName componentName) {
11571157
try {
1158-
return mPM.getComponentEnabledSetting(componentName, UserId.myUserId());
1158+
return mPM.getComponentEnabledSetting(componentName, UserHandle.myUserId());
11591159
} catch (RemoteException e) {
11601160
// Should never happen!
11611161
}
@@ -1166,7 +1166,7 @@ public int getComponentEnabledSetting(ComponentName componentName) {
11661166
public void setApplicationEnabledSetting(String packageName,
11671167
int newState, int flags) {
11681168
try {
1169-
mPM.setApplicationEnabledSetting(packageName, newState, flags, UserId.myUserId());
1169+
mPM.setApplicationEnabledSetting(packageName, newState, flags, UserHandle.myUserId());
11701170
} catch (RemoteException e) {
11711171
// Should never happen!
11721172
}
@@ -1175,7 +1175,7 @@ public void setApplicationEnabledSetting(String packageName,
11751175
@Override
11761176
public int getApplicationEnabledSetting(String packageName) {
11771177
try {
1178-
return mPM.getApplicationEnabledSetting(packageName, UserId.myUserId());
1178+
return mPM.getApplicationEnabledSetting(packageName, UserHandle.myUserId());
11791179
} catch (RemoteException e) {
11801180
// Should never happen!
11811181
}

core/java/android/app/ContextImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
import android.os.Process;
8888
import android.os.RemoteException;
8989
import android.os.ServiceManager;
90-
import android.os.UserId;
90+
import android.os.UserHandle;
9191
import android.os.SystemVibrator;
9292
import android.os.UserManager;
9393
import android.os.storage.StorageManager;
@@ -1259,7 +1259,7 @@ public boolean stopService(Intent service) {
12591259
@Override
12601260
public boolean bindService(Intent service, ServiceConnection conn,
12611261
int flags) {
1262-
return bindService(service, conn, flags, UserId.getUserId(Process.myUid()));
1262+
return bindService(service, conn, flags, UserHandle.getUserId(Process.myUid()));
12631263
}
12641264

12651265
/** @hide */

core/java/android/app/LoadedApk.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import android.os.RemoteException;
3838
import android.os.StrictMode;
3939
import android.os.Trace;
40-
import android.os.UserId;
40+
import android.os.UserHandle;
4141
import android.util.AndroidRuntimeException;
4242
import android.util.Slog;
4343
import android.view.CompatibilityInfoHolder;
@@ -120,8 +120,8 @@ public LoadedApk(ActivityThread activityThread, ApplicationInfo aInfo,
120120
final int myUid = Process.myUid();
121121
mResDir = aInfo.uid == myUid ? aInfo.sourceDir
122122
: aInfo.publicSourceDir;
123-
if (!UserId.isSameUser(aInfo.uid, myUid) && !Process.isIsolated()) {
124-
aInfo.dataDir = PackageManager.getDataDirForUser(UserId.getUserId(myUid),
123+
if (!UserHandle.isSameUser(aInfo.uid, myUid) && !Process.isIsolated()) {
124+
aInfo.dataDir = PackageManager.getDataDirForUser(UserHandle.getUserId(myUid),
125125
mPackageName);
126126
}
127127
mSharedLibraries = aInfo.sharedLibraryFiles;
@@ -195,7 +195,7 @@ private static String[] getLibrariesFor(String packageName) {
195195
ApplicationInfo ai = null;
196196
try {
197197
ai = ActivityThread.getPackageManager().getApplicationInfo(packageName,
198-
PackageManager.GET_SHARED_LIBRARY_FILES, UserId.myUserId());
198+
PackageManager.GET_SHARED_LIBRARY_FILES, UserHandle.myUserId());
199199
} catch (RemoteException e) {
200200
throw new AssertionError(e);
201201
}
@@ -358,7 +358,7 @@ private void initializeJavaContextClassLoader() {
358358
IPackageManager pm = ActivityThread.getPackageManager();
359359
android.content.pm.PackageInfo pi;
360360
try {
361-
pi = pm.getPackageInfo(mPackageName, 0, UserId.myUserId());
361+
pi = pm.getPackageInfo(mPackageName, 0, UserHandle.myUserId());
362362
} catch (RemoteException e) {
363363
throw new AssertionError(e);
364364
}

core/java/android/app/PendingIntent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import android.os.IBinder;
2828
import android.os.Parcel;
2929
import android.os.Parcelable;
30-
import android.os.UserId;
30+
import android.os.UserHandle;
3131
import android.util.AndroidException;
3232

3333
/**
@@ -651,7 +651,7 @@ public int getTargetUserHandle() {
651651
try {
652652
int uid = ActivityManagerNative.getDefault()
653653
.getUidForIntentSender(mTarget);
654-
return uid > 0 ? UserId.getUserId(uid) : -1;
654+
return uid > 0 ? UserHandle.getUserId(uid) : -1;
655655
} catch (RemoteException e) {
656656
// Should never happen.
657657
return -1;

core/java/android/app/SearchManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import android.os.Handler;
3232
import android.os.RemoteException;
3333
import android.os.ServiceManager;
34-
import android.os.UserId;
34+
import android.os.UserHandle;
3535
import android.text.TextUtils;
3636
import android.util.Log;
3737
import android.util.Slog;
@@ -847,7 +847,7 @@ public List<SearchableInfo> getSearchablesInGlobalSearch() {
847847
* @hide
848848
*/
849849
public Intent getAssistIntent(Context context) {
850-
return getAssistIntent(context, UserId.myUserId());
850+
return getAssistIntent(context, UserHandle.myUserId());
851851
}
852852

853853
/**

0 commit comments

Comments
 (0)