diff options
Diffstat (limited to 'core/java')
23 files changed, 107 insertions, 106 deletions
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java index 935d647d435f..a4d28b04f439 100644 --- a/core/java/android/accounts/AccountManagerService.java +++ b/core/java/android/accounts/AccountManagerService.java @@ -50,7 +50,7 @@ import android.os.Looper; import android.os.Message; import android.os.RemoteException; import android.os.SystemClock; -import android.os.UserId; +import android.os.UserHandle; import android.os.UserManager; import android.text.TextUtils; import android.util.Log; @@ -354,7 +354,7 @@ public class AccountManagerService } private UserAccounts getUserAccountsForCaller() { - return getUserAccounts(UserId.getCallingUserId()); + return getUserAccounts(UserHandle.getCallingUserId()); } protected UserAccounts getUserAccounts(int userId) { @@ -1004,7 +1004,7 @@ public class AccountManagerService if (callingUid != android.os.Process.SYSTEM_UID) { throw new SecurityException("can only call from system"); } - UserAccounts accounts = getUserAccounts(UserId.getUserId(callingUid)); + UserAccounts accounts = getUserAccounts(UserHandle.getUserId(callingUid)); long identityToken = clearCallingIdentity(); try { new Session(accounts, response, accountType, false, @@ -1222,7 +1222,7 @@ public class AccountManagerService private Integer getCredentialPermissionNotificationId(Account account, String authTokenType, int uid) { Integer id; - UserAccounts accounts = getUserAccounts(UserId.getUserId(uid)); + UserAccounts accounts = getUserAccounts(UserHandle.getUserId(uid)); synchronized (accounts.credentialsPermissionNotificationIds) { final Pair<Pair<Account, String>, Integer> key = new Pair<Pair<Account, String>, Integer>( @@ -2269,7 +2269,7 @@ public class AccountManagerService Log.e(TAG, "grantAppPermission: called with invalid arguments", new Exception()); return; } - UserAccounts accounts = getUserAccounts(UserId.getUserId(uid)); + UserAccounts accounts = getUserAccounts(UserHandle.getUserId(uid)); synchronized (accounts.cacheLock) { final SQLiteDatabase db = accounts.openHelper.getWritableDatabase(); db.beginTransaction(); @@ -2303,7 +2303,7 @@ public class AccountManagerService Log.e(TAG, "revokeAppPermission: called with invalid arguments", new Exception()); return; } - UserAccounts accounts = getUserAccounts(UserId.getUserId(uid)); + UserAccounts accounts = getUserAccounts(UserHandle.getUserId(uid)); synchronized (accounts.cacheLock) { final SQLiteDatabase db = accounts.openHelper.getWritableDatabase(); db.beginTransaction(); diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index c74f823d7579..2c6d5d989b2d 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -40,7 +40,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; -import android.os.UserId; +import android.os.UserHandle; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; @@ -529,7 +529,7 @@ public class ActivityManager { throws SecurityException { try { return ActivityManagerNative.getDefault().getRecentTasks(maxNum, - flags, UserId.myUserId()); + flags, UserHandle.myUserId()); } catch (RemoteException e) { // System dead, we will be dead too soon! return null; @@ -1843,12 +1843,12 @@ public class ActivityManager { return PackageManager.PERMISSION_GRANTED; } // Isolated processes don't get any permissions. - if (UserId.isIsolated(uid)) { + if (UserHandle.isIsolated(uid)) { return PackageManager.PERMISSION_DENIED; } // If there is a uid that owns whatever is being accessed, it has // blanket access to it regardless of the permissions it requires. - if (owningUid >= 0 && UserId.isSameApp(uid, owningUid)) { + if (owningUid >= 0 && UserHandle.isSameApp(uid, owningUid)) { return PackageManager.PERMISSION_GRANTED; } // If the target is not exported, then nobody else can get to it. diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 88e7344700f4..3197a6319c59 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -39,7 +39,7 @@ import android.os.Parcelable; import android.os.RemoteException; import android.os.ServiceManager; import android.os.StrictMode; -import android.os.UserId; +import android.os.UserHandle; import android.text.TextUtils; import android.util.Log; import android.util.Singleton; diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 0789c60ffa3d..7eb86f41c4b5 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -62,7 +62,7 @@ import android.os.ServiceManager; import android.os.StrictMode; import android.os.SystemClock; import android.os.Trace; -import android.os.UserId; +import android.os.UserHandle; import android.util.AndroidRuntimeException; import android.util.DisplayMetrics; import android.util.EventLog; @@ -1696,7 +1696,7 @@ public final class ActivityThread { ApplicationInfo ai = null; try { ai = getPackageManager().getApplicationInfo(packageName, - PackageManager.GET_SHARED_LIBRARY_FILES, UserId.myUserId()); + PackageManager.GET_SHARED_LIBRARY_FILES, UserHandle.myUserId()); } catch (RemoteException e) { // Ignore } @@ -1713,7 +1713,7 @@ public final class ActivityThread { boolean includeCode = (flags&Context.CONTEXT_INCLUDE_CODE) != 0; boolean securityViolation = includeCode && ai.uid != 0 && ai.uid != Process.SYSTEM_UID && (mBoundApplication != null - ? !UserId.isSameApp(ai.uid, mBoundApplication.appInfo.uid) + ? !UserHandle.isSameApp(ai.uid, mBoundApplication.appInfo.uid) : true); if ((flags&(Context.CONTEXT_INCLUDE_CODE |Context.CONTEXT_IGNORE_SECURITY)) diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 9b59e2ce1017..115c867e44c1 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -50,7 +50,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Process; import android.os.RemoteException; -import android.os.UserId; +import android.os.UserHandle; import android.util.Log; import java.lang.ref.WeakReference; @@ -69,7 +69,7 @@ final class ApplicationPackageManager extends PackageManager { public PackageInfo getPackageInfo(String packageName, int flags) throws NameNotFoundException { try { - PackageInfo pi = mPM.getPackageInfo(packageName, flags, UserId.myUserId()); + PackageInfo pi = mPM.getPackageInfo(packageName, flags, UserHandle.myUserId()); if (pi != null) { return pi; } @@ -199,7 +199,7 @@ final class ApplicationPackageManager extends PackageManager { public ApplicationInfo getApplicationInfo(String packageName, int flags) throws NameNotFoundException { try { - ApplicationInfo ai = mPM.getApplicationInfo(packageName, flags, UserId.myUserId()); + ApplicationInfo ai = mPM.getApplicationInfo(packageName, flags, UserHandle.myUserId()); if (ai != null) { return ai; } @@ -214,7 +214,7 @@ final class ApplicationPackageManager extends PackageManager { public ActivityInfo getActivityInfo(ComponentName className, int flags) throws NameNotFoundException { try { - ActivityInfo ai = mPM.getActivityInfo(className, flags, UserId.myUserId()); + ActivityInfo ai = mPM.getActivityInfo(className, flags, UserHandle.myUserId()); if (ai != null) { return ai; } @@ -229,7 +229,7 @@ final class ApplicationPackageManager extends PackageManager { public ActivityInfo getReceiverInfo(ComponentName className, int flags) throws NameNotFoundException { try { - ActivityInfo ai = mPM.getReceiverInfo(className, flags, UserId.myUserId()); + ActivityInfo ai = mPM.getReceiverInfo(className, flags, UserHandle.myUserId()); if (ai != null) { return ai; } @@ -244,7 +244,7 @@ final class ApplicationPackageManager extends PackageManager { public ServiceInfo getServiceInfo(ComponentName className, int flags) throws NameNotFoundException { try { - ServiceInfo si = mPM.getServiceInfo(className, flags, UserId.myUserId()); + ServiceInfo si = mPM.getServiceInfo(className, flags, UserHandle.myUserId()); if (si != null) { return si; } @@ -259,7 +259,7 @@ final class ApplicationPackageManager extends PackageManager { public ProviderInfo getProviderInfo(ComponentName className, int flags) throws NameNotFoundException { try { - ProviderInfo pi = mPM.getProviderInfo(className, flags, UserId.myUserId()); + ProviderInfo pi = mPM.getProviderInfo(className, flags, UserHandle.myUserId()); if (pi != null) { return pi; } @@ -424,7 +424,7 @@ final class ApplicationPackageManager extends PackageManager { @SuppressWarnings("unchecked") @Override public List<ApplicationInfo> getInstalledApplications(int flags) { - int userId = UserId.getUserId(Process.myUid()); + int userId = UserHandle.getUserId(Process.myUid()); try { final List<ApplicationInfo> applicationInfos = new ArrayList<ApplicationInfo>(); ApplicationInfo lastItem = null; @@ -448,7 +448,7 @@ final class ApplicationPackageManager extends PackageManager { return mPM.resolveIntent( intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), - flags, UserId.myUserId()); + flags, UserHandle.myUserId()); } catch (RemoteException e) { throw new RuntimeException("Package manager has died", e); } @@ -462,7 +462,7 @@ final class ApplicationPackageManager extends PackageManager { intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, - UserId.myUserId()); + UserHandle.myUserId()); } catch (RemoteException e) { throw new RuntimeException("Package manager has died", e); } @@ -494,7 +494,7 @@ final class ApplicationPackageManager extends PackageManager { try { return mPM.queryIntentActivityOptions(caller, specifics, specificTypes, intent, intent.resolveTypeIfNeeded(resolver), - flags, UserId.myUserId()); + flags, UserHandle.myUserId()); } catch (RemoteException e) { throw new RuntimeException("Package manager has died", e); } @@ -507,7 +507,7 @@ final class ApplicationPackageManager extends PackageManager { intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, - UserId.myUserId()); + UserHandle.myUserId()); } catch (RemoteException e) { throw new RuntimeException("Package manager has died", e); } @@ -520,7 +520,7 @@ final class ApplicationPackageManager extends PackageManager { intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, - UserId.myUserId()); + UserHandle.myUserId()); } catch (RemoteException e) { throw new RuntimeException("Package manager has died", e); } @@ -533,7 +533,7 @@ final class ApplicationPackageManager extends PackageManager { intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, - UserId.myUserId()); + UserHandle.myUserId()); } catch (RemoteException e) { throw new RuntimeException("Package manager has died", e); } @@ -543,7 +543,7 @@ final class ApplicationPackageManager extends PackageManager { public ProviderInfo resolveContentProvider(String name, int flags) { try { - return mPM.resolveContentProvider(name, flags, UserId.myUserId()); + return mPM.resolveContentProvider(name, flags, UserHandle.myUserId()); } catch (RemoteException e) { throw new RuntimeException("Package manager has died", e); } @@ -1033,7 +1033,7 @@ final class ApplicationPackageManager extends PackageManager { public void clearApplicationUserData(String packageName, IPackageDataObserver observer) { try { - mPM.clearApplicationUserData(packageName, observer, UserId.myUserId()); + mPM.clearApplicationUserData(packageName, observer, UserHandle.myUserId()); } catch (RemoteException e) { // Should never happen! } @@ -1146,7 +1146,7 @@ final class ApplicationPackageManager extends PackageManager { public void setComponentEnabledSetting(ComponentName componentName, int newState, int flags) { try { - mPM.setComponentEnabledSetting(componentName, newState, flags, UserId.myUserId()); + mPM.setComponentEnabledSetting(componentName, newState, flags, UserHandle.myUserId()); } catch (RemoteException e) { // Should never happen! } @@ -1155,7 +1155,7 @@ final class ApplicationPackageManager extends PackageManager { @Override public int getComponentEnabledSetting(ComponentName componentName) { try { - return mPM.getComponentEnabledSetting(componentName, UserId.myUserId()); + return mPM.getComponentEnabledSetting(componentName, UserHandle.myUserId()); } catch (RemoteException e) { // Should never happen! } @@ -1166,7 +1166,7 @@ final class ApplicationPackageManager extends PackageManager { public void setApplicationEnabledSetting(String packageName, int newState, int flags) { try { - mPM.setApplicationEnabledSetting(packageName, newState, flags, UserId.myUserId()); + mPM.setApplicationEnabledSetting(packageName, newState, flags, UserHandle.myUserId()); } catch (RemoteException e) { // Should never happen! } @@ -1175,7 +1175,7 @@ final class ApplicationPackageManager extends PackageManager { @Override public int getApplicationEnabledSetting(String packageName) { try { - return mPM.getApplicationEnabledSetting(packageName, UserId.myUserId()); + return mPM.getApplicationEnabledSetting(packageName, UserHandle.myUserId()); } catch (RemoteException e) { // Should never happen! } diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index fd4c304e19ca..ed4f0a7d942a 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -87,7 +87,7 @@ import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; -import android.os.UserId; +import android.os.UserHandle; import android.os.SystemVibrator; import android.os.UserManager; import android.os.storage.StorageManager; @@ -1259,7 +1259,7 @@ class ContextImpl extends Context { @Override public boolean bindService(Intent service, ServiceConnection conn, int flags) { - return bindService(service, conn, flags, UserId.getUserId(Process.myUid())); + return bindService(service, conn, flags, UserHandle.getUserId(Process.myUid())); } /** @hide */ diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index f4195d68794a..1e89bb2f1a98 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -37,7 +37,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.StrictMode; import android.os.Trace; -import android.os.UserId; +import android.os.UserHandle; import android.util.AndroidRuntimeException; import android.util.Slog; import android.view.CompatibilityInfoHolder; @@ -120,8 +120,8 @@ public final class LoadedApk { final int myUid = Process.myUid(); mResDir = aInfo.uid == myUid ? aInfo.sourceDir : aInfo.publicSourceDir; - if (!UserId.isSameUser(aInfo.uid, myUid) && !Process.isIsolated()) { - aInfo.dataDir = PackageManager.getDataDirForUser(UserId.getUserId(myUid), + if (!UserHandle.isSameUser(aInfo.uid, myUid) && !Process.isIsolated()) { + aInfo.dataDir = PackageManager.getDataDirForUser(UserHandle.getUserId(myUid), mPackageName); } mSharedLibraries = aInfo.sharedLibraryFiles; @@ -195,7 +195,7 @@ public final class LoadedApk { ApplicationInfo ai = null; try { ai = ActivityThread.getPackageManager().getApplicationInfo(packageName, - PackageManager.GET_SHARED_LIBRARY_FILES, UserId.myUserId()); + PackageManager.GET_SHARED_LIBRARY_FILES, UserHandle.myUserId()); } catch (RemoteException e) { throw new AssertionError(e); } @@ -358,7 +358,7 @@ public final class LoadedApk { IPackageManager pm = ActivityThread.getPackageManager(); android.content.pm.PackageInfo pi; try { - pi = pm.getPackageInfo(mPackageName, 0, UserId.myUserId()); + pi = pm.getPackageInfo(mPackageName, 0, UserHandle.myUserId()); } catch (RemoteException e) { throw new AssertionError(e); } diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java index c320ee399606..f638f7e034c1 100644 --- a/core/java/android/app/PendingIntent.java +++ b/core/java/android/app/PendingIntent.java @@ -27,7 +27,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; -import android.os.UserId; +import android.os.UserHandle; import android.util.AndroidException; /** @@ -651,7 +651,7 @@ public final class PendingIntent implements Parcelable { try { int uid = ActivityManagerNative.getDefault() .getUidForIntentSender(mTarget); - return uid > 0 ? UserId.getUserId(uid) : -1; + return uid > 0 ? UserHandle.getUserId(uid) : -1; } catch (RemoteException e) { // Should never happen. return -1; diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java index b8c99373e407..43a163dcf067 100644 --- a/core/java/android/app/SearchManager.java +++ b/core/java/android/app/SearchManager.java @@ -31,7 +31,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.RemoteException; import android.os.ServiceManager; -import android.os.UserId; +import android.os.UserHandle; import android.text.TextUtils; import android.util.Log; import android.util.Slog; @@ -847,7 +847,7 @@ public class SearchManager * @hide */ public Intent getAssistIntent(Context context) { - return getAssistIntent(context, UserId.myUserId()); + return getAssistIntent(context, UserHandle.myUserId()); } /** diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java index b22179e71843..8a69c3af17c8 100644 --- a/core/java/android/content/ContentProvider.java +++ b/core/java/android/content/ContentProvider.java @@ -35,7 +35,7 @@ import android.os.OperationCanceledException; import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.RemoteException; -import android.os.UserId; +import android.os.UserHandle; import android.util.Log; import java.io.File; diff --git a/core/java/android/content/ContentService.java b/core/java/android/content/ContentService.java index 1a07504f2fbe..472fe9480bfa 100644 --- a/core/java/android/content/ContentService.java +++ b/core/java/android/content/ContentService.java @@ -26,7 +26,7 @@ import android.os.IBinder; import android.os.Parcel; import android.os.RemoteException; import android.os.ServiceManager; -import android.os.UserId; +import android.os.UserHandle; import android.util.Log; import android.util.SparseIntArray; import android.Manifest; @@ -168,7 +168,7 @@ public final class ContentService extends IContentService.Stub { + ", syncToNetwork " + syncToNetwork); } - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); // This makes it so that future permission checks will be in the context of this // process rather than the caller's process. We will restore this before returning. long identityToken = clearCallingIdentity(); @@ -236,7 +236,7 @@ public final class ContentService extends IContentService.Stub { public void requestSync(Account account, String authority, Bundle extras) { ContentResolver.validateSyncExtrasBundle(extras); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); // This makes it so that future permission checks will be in the context of this // process rather than the caller's process. We will restore this before returning. @@ -259,7 +259,7 @@ public final class ContentService extends IContentService.Stub { * @param authority filter the pending and active syncs to cancel using this authority */ public void cancelSync(Account account, String authority) { - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); // This makes it so that future permission checks will be in the context of this // process rather than the caller's process. We will restore this before returning. @@ -294,7 +294,7 @@ public final class ContentService extends IContentService.Stub { public boolean getSyncAutomatically(Account account, String providerName) { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -312,7 +312,7 @@ public final class ContentService extends IContentService.Stub { public void setSyncAutomatically(Account account, String providerName, boolean sync) { mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -330,7 +330,7 @@ public final class ContentService extends IContentService.Stub { long pollFrequency) { mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -344,7 +344,7 @@ public final class ContentService extends IContentService.Stub { public void removePeriodicSync(Account account, String authority, Bundle extras) { mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -358,7 +358,7 @@ public final class ContentService extends IContentService.Stub { public List<PeriodicSync> getPeriodicSyncs(Account account, String providerName) { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -372,7 +372,7 @@ public final class ContentService extends IContentService.Stub { public int getIsSyncable(Account account, String providerName) { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -390,7 +390,7 @@ public final class ContentService extends IContentService.Stub { public void setIsSyncable(Account account, String providerName, int syncable) { mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -407,7 +407,7 @@ public final class ContentService extends IContentService.Stub { public boolean getMasterSyncAutomatically() { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -424,7 +424,7 @@ public final class ContentService extends IContentService.Stub { public void setMasterSyncAutomatically(boolean flag) { mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -440,7 +440,7 @@ public final class ContentService extends IContentService.Stub { public boolean isSyncActive(Account account, String authority) { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS, "no permission to read the sync stats"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -458,7 +458,7 @@ public final class ContentService extends IContentService.Stub { public List<SyncInfo> getCurrentSyncs() { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS, "no permission to read the sync stats"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -471,7 +471,7 @@ public final class ContentService extends IContentService.Stub { public SyncStatusInfo getSyncStatus(Account account, String authority) { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS, "no permission to read the sync stats"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { @@ -489,7 +489,7 @@ public final class ContentService extends IContentService.Stub { public boolean isSyncPending(Account account, String authority) { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS, "no permission to read the sync stats"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { diff --git a/core/java/android/content/IntentSender.java b/core/java/android/content/IntentSender.java index 961864564be5..18014886491b 100644 --- a/core/java/android/content/IntentSender.java +++ b/core/java/android/content/IntentSender.java @@ -27,7 +27,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; -import android.os.UserId; +import android.os.UserHandle; import android.util.AndroidException; @@ -257,7 +257,7 @@ public class IntentSender implements Parcelable { try { int uid = ActivityManagerNative.getDefault() .getUidForIntentSender(mTarget); - return uid > 0 ? UserId.getUserId(uid) : -1; + return uid > 0 ? UserHandle.getUserId(uid) : -1; } catch (RemoteException e) { // Should never happen. return -1; diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java index e6303b9544db..3d3ff51a1f85 100644 --- a/core/java/android/content/SyncManager.java +++ b/core/java/android/content/SyncManager.java @@ -52,7 +52,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemProperties; -import android.os.UserId; +import android.os.UserHandle; import android.os.UserManager; import android.os.WorkSource; import android.provider.Settings; @@ -174,7 +174,7 @@ public class SyncManager implements OnAccountsUpdateListener { Log.v(TAG, "Internal storage is low."); } mStorageIsLow = true; - cancelActiveSync(null /* any account */, UserId.USER_ALL, + cancelActiveSync(null /* any account */, UserHandle.USER_ALL, null /* any authority */); } else if (Intent.ACTION_DEVICE_STORAGE_OK.equals(action)) { if (Log.isLoggable(TAG, Log.VERBOSE)) { @@ -195,7 +195,7 @@ public class SyncManager implements OnAccountsUpdateListener { private BroadcastReceiver mBackgroundDataSettingChanged = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { if (getConnectivityManager().getBackgroundDataSetting()) { - scheduleSync(null /* account */, UserId.USER_ALL, null /* authority */, + scheduleSync(null /* account */, UserHandle.USER_ALL, null /* authority */, new Bundle(), 0 /* delay */, false /* onlyThoseWithUnknownSyncableState */); } @@ -287,7 +287,7 @@ public class SyncManager implements OnAccountsUpdateListener { // a chance to set their syncable state. boolean onlyThoseWithUnkownSyncableState = justBootedUp; - scheduleSync(null, UserId.USER_ALL, null, null, 0 /* no delay */, + scheduleSync(null, UserHandle.USER_ALL, null, null, 0 /* no delay */, onlyThoseWithUnkownSyncableState); } } @@ -371,7 +371,7 @@ public class SyncManager implements OnAccountsUpdateListener { mSyncAdapters.setListener(new RegisteredServicesCacheListener<SyncAdapterType>() { public void onServiceChanged(SyncAdapterType type, boolean removed) { if (!removed) { - scheduleSync(null, UserId.USER_ALL, type.authority, null, 0 /* no delay */, + scheduleSync(null, UserHandle.USER_ALL, type.authority, null, 0 /* no delay */, false /* onlyThoseWithUnkownSyncableState */); } } @@ -517,7 +517,7 @@ public class SyncManager implements OnAccountsUpdateListener { } AccountAndUser[] accounts; - if (requestedAccount != null && userId != UserId.USER_ALL) { + if (requestedAccount != null && userId != UserHandle.USER_ALL) { accounts = new AccountAndUser[] { new AccountAndUser(requestedAccount, userId) }; } else { // if the accounts aren't configured yet then we can't support an account-less @@ -2180,7 +2180,7 @@ public class SyncManager implements OnAccountsUpdateListener { } } // check if the userid matches - if (userId != UserId.USER_ALL + if (userId != UserHandle.USER_ALL && userId != activeSyncContext.mSyncOperation.userId) { continue; } diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index d906401bc0bb..ac750401a64e 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -28,7 +28,7 @@ import android.os.Binder; import android.os.Build; import android.os.Bundle; import android.os.PatternMatcher; -import android.os.UserId; +import android.os.UserHandle; import android.util.AttributeSet; import android.util.Base64; import android.util.DisplayMetrics; @@ -249,7 +249,7 @@ public class PackageParser { return generatePackageInfo(p, gids, flags, firstInstallTime, lastUpdateTime, grantedPermissions, false, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, - UserId.getCallingUserId()); + UserHandle.getCallingUserId()); } /** @@ -263,7 +263,7 @@ public class PackageParser { HashSet<String> grantedPermissions, boolean stopped, int enabledState) { return generatePackageInfo(p, gids, flags, firstInstallTime, lastUpdateTime, - grantedPermissions, stopped, enabledState, UserId.getCallingUserId()); + grantedPermissions, stopped, enabledState, UserHandle.getCallingUserId()); } public static PackageInfo generatePackageInfo(PackageParser.Package p, @@ -3478,7 +3478,7 @@ public class PackageParser { public static ApplicationInfo generateApplicationInfo(Package p, int flags, boolean stopped, int enabledState) { - return generateApplicationInfo(p, flags, stopped, enabledState, UserId.getCallingUserId()); + return generateApplicationInfo(p, flags, stopped, enabledState, UserHandle.getCallingUserId()); } public static ApplicationInfo generateApplicationInfo(Package p, int flags, @@ -3508,7 +3508,7 @@ public class PackageParser { // Make shallow copy so we can store the metadata/libraries safely ApplicationInfo ai = new ApplicationInfo(p.applicationInfo); if (userId != 0) { - ai.uid = UserId.getUid(userId, ai.uid); + ai.uid = UserHandle.getUid(userId, ai.uid); ai.dataDir = PackageManager.getDataDirForUser(userId, ai.packageName); } if ((flags & PackageManager.GET_META_DATA) != 0) { @@ -3616,7 +3616,7 @@ public class PackageParser { int enabledState, int userId) { if (s == null) return null; if (!copyNeeded(flags, s.owner, enabledState, s.metaData) - && userId == UserId.getUserId(s.info.applicationInfo.uid)) { + && userId == UserHandle.getUserId(s.info.applicationInfo.uid)) { return s.info; } // Make shallow copies so we can store the metadata safely diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index 7b51119c1657..5d404568591e 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -82,7 +82,7 @@ public class Binder implements IBinder { * @hide */ public static final int getOrigCallingUid() { - if (UserId.MU_ENABLED) { + if (UserHandle.MU_ENABLED) { return getOrigCallingUidNative(); } else { return getCallingUid(); @@ -97,7 +97,7 @@ public class Binder implements IBinder { * @hide */ public static final int getOrigCallingUser() { - return UserId.getUserId(getOrigCallingUid()); + return UserHandle.getUserId(getOrigCallingUid()); } /** diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 93860aa859a7..5118f1af520a 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -654,7 +654,7 @@ public class Process { * distinct apps running under it each with their own uid. */ public static final int myUserHandle() { - return UserId.getUserId(myUid()); + return UserHandle.getUserId(myUid()); } /** @@ -662,7 +662,7 @@ public class Process { * @hide */ public static final boolean isIsolated() { - int uid = UserId.getAppId(myUid()); + int uid = UserHandle.getAppId(myUid()); return uid >= FIRST_ISOLATED_UID && uid <= LAST_ISOLATED_UID; } diff --git a/core/java/android/os/UserId.java b/core/java/android/os/UserHandle.java index 18a3062df575..577a8c61c57f 100644 --- a/core/java/android/os/UserId.java +++ b/core/java/android/os/UserHandle.java @@ -17,9 +17,10 @@ package android.os; /** + * Representation of a user on the device. * @hide */ -public final class UserId { +public final class UserHandle { /** * Range of IDs allocated for a user. * @@ -70,7 +71,7 @@ public final class UserId { public static boolean isApp(int uid) { if (uid > 0) { - uid = UserId.getAppId(uid); + uid = UserHandle.getAppId(uid); return uid >= Process.FIRST_APPLICATION_UID && uid <= Process.LAST_APPLICATION_UID; } else { return false; diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index e08ec1ffbcfa..6dbba4674d0d 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -41,7 +41,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; -import android.os.UserId; +import android.os.UserHandle; import android.speech.tts.TextToSpeech; import android.text.TextUtils; import android.util.AndroidException; @@ -2336,7 +2336,7 @@ public final class Settings { if (sLockSettings != null && !sIsSystemProcess && MOVED_TO_LOCK_SETTINGS.contains(name)) { try { - return sLockSettings.getString(name, "0", UserId.getCallingUserId()); + return sLockSettings.getString(name, "0", UserHandle.getCallingUserId()); } catch (RemoteException re) { // Fall through } diff --git a/core/java/android/server/search/SearchManagerService.java b/core/java/android/server/search/SearchManagerService.java index b4f5e121d208..df85b2f8c61d 100644 --- a/core/java/android/server/search/SearchManagerService.java +++ b/core/java/android/server/search/SearchManagerService.java @@ -37,7 +37,7 @@ import android.database.ContentObserver; import android.os.Binder; import android.os.Process; import android.os.RemoteException; -import android.os.UserId; +import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.util.Log; @@ -186,45 +186,45 @@ public class SearchManagerService extends ISearchManager.Stub { Log.e(TAG, "getSearchableInfo(), activity == null"); return null; } - return getSearchables(UserId.getCallingUserId()).getSearchableInfo(launchActivity); + return getSearchables(UserHandle.getCallingUserId()).getSearchableInfo(launchActivity); } /** * Returns a list of the searchable activities that can be included in global search. */ public List<SearchableInfo> getSearchablesInGlobalSearch() { - return getSearchables(UserId.getCallingUserId()).getSearchablesInGlobalSearchList(); + return getSearchables(UserHandle.getCallingUserId()).getSearchablesInGlobalSearchList(); } public List<ResolveInfo> getGlobalSearchActivities() { - return getSearchables(UserId.getCallingUserId()).getGlobalSearchActivities(); + return getSearchables(UserHandle.getCallingUserId()).getGlobalSearchActivities(); } /** * Gets the name of the global search activity. */ public ComponentName getGlobalSearchActivity() { - return getSearchables(UserId.getCallingUserId()).getGlobalSearchActivity(); + return getSearchables(UserHandle.getCallingUserId()).getGlobalSearchActivity(); } /** * Gets the name of the web search activity. */ public ComponentName getWebSearchActivity() { - return getSearchables(UserId.getCallingUserId()).getWebSearchActivity(); + return getSearchables(UserHandle.getCallingUserId()).getWebSearchActivity(); } @Override public ComponentName getAssistIntent(int userHandle) { try { - if (userHandle != UserId.getCallingUserId()) { + if (userHandle != UserHandle.getCallingUserId()) { // Requesting a different user, make sure that they have the permission if (ActivityManager.checkComponentPermission( android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, Binder.getCallingUid(), -1, true) == PackageManager.PERMISSION_GRANTED) { // Translate to the current user id, if caller wasn't aware - if (userHandle == UserId.USER_CURRENT) { + if (userHandle == UserHandle.USER_CURRENT) { long identity = Binder.clearCallingIdentity(); userHandle = ActivityManagerNative.getDefault().getCurrentUser().id; Binder.restoreCallingIdentity(identity); @@ -232,7 +232,7 @@ public class SearchManagerService extends ISearchManager.Stub { } else { String msg = "Permission Denial: " + "Request to getAssistIntent for " + userHandle - + " but is calling from user " + UserId.getCallingUserId() + + " but is calling from user " + UserHandle.getCallingUserId() + "; this requires " + android.Manifest.permission.INTERACT_ACROSS_USERS_FULL; Slog.w(TAG, msg); diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index 84fe8cefa784..e63c57f47d80 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -37,7 +37,7 @@ import android.os.Bundle; import android.os.PatternMatcher; import android.os.Process; import android.os.RemoteException; -import android.os.UserId; +import android.os.UserHandle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -133,7 +133,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte mAdapter = new ResolveListAdapter(this, intent, initialIntents, rList, mLaunchedFromUid); int count = mAdapter.getCount(); - if (mLaunchedFromUid < 0 || UserId.isIsolated(mLaunchedFromUid)) { + if (mLaunchedFromUid < 0 || UserHandle.isIsolated(mLaunchedFromUid)) { // Gulp! finish(); return; diff --git a/core/java/com/android/internal/statusbar/StatusBarNotification.java b/core/java/com/android/internal/statusbar/StatusBarNotification.java index 540d134937e8..cb87ac4729a5 100644 --- a/core/java/com/android/internal/statusbar/StatusBarNotification.java +++ b/core/java/com/android/internal/statusbar/StatusBarNotification.java @@ -19,7 +19,7 @@ package com.android.internal.statusbar; import android.app.Notification; import android.os.Parcel; import android.os.Parcelable; -import android.os.UserId; +import android.os.UserHandle; import android.widget.RemoteViews; @@ -136,7 +136,7 @@ public class StatusBarNotification implements Parcelable { /** Returns a userHandle for the instance of the app that posted this notification. */ public int getUserId() { - return UserId.getUserId(this.uid); + return UserHandle.getUserId(this.uid); } } diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index f77e8f3c6b96..4777c1621ae5 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -34,7 +34,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; -import android.os.UserId; +import android.os.UserHandle; import android.os.storage.IMountService; import android.provider.Settings; import android.security.KeyStore; @@ -246,7 +246,7 @@ public class LockPatternUtils { if (callingUid == android.os.Process.SYSTEM_UID) { return mCurrentUserId; } else { - return UserId.getUserId(callingUid); + return UserHandle.getUserId(callingUid); } } diff --git a/core/java/com/android/internal/widget/LockSettingsService.java b/core/java/com/android/internal/widget/LockSettingsService.java index 2fb81ac7b069..350e006d3595 100644 --- a/core/java/com/android/internal/widget/LockSettingsService.java +++ b/core/java/com/android/internal/widget/LockSettingsService.java @@ -25,7 +25,7 @@ import android.database.sqlite.SQLiteOpenHelper; import android.os.Binder; import android.os.RemoteException; import android.os.SystemProperties; -import android.os.UserId; +import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings.Secure; import android.text.TextUtils; @@ -97,7 +97,7 @@ public class LockSettingsService extends ILockSettings.Stub { private static final void checkWritePermission(int userId) { final int callingUid = Binder.getCallingUid(); - if (UserId.getAppId(callingUid) != android.os.Process.SYSTEM_UID) { + if (UserHandle.getAppId(callingUid) != android.os.Process.SYSTEM_UID) { throw new SecurityException("uid=" + callingUid + " not authorized to write lock settings"); } @@ -105,7 +105,7 @@ public class LockSettingsService extends ILockSettings.Stub { private static final void checkPasswordReadPermission(int userId) { final int callingUid = Binder.getCallingUid(); - if (UserId.getAppId(callingUid) != android.os.Process.SYSTEM_UID) { + if (UserHandle.getAppId(callingUid) != android.os.Process.SYSTEM_UID) { throw new SecurityException("uid=" + callingUid + " not authorized to read lock password"); } @@ -113,8 +113,8 @@ public class LockSettingsService extends ILockSettings.Stub { private static final void checkReadPermission(int userId) { final int callingUid = Binder.getCallingUid(); - if (UserId.getAppId(callingUid) != android.os.Process.SYSTEM_UID - && UserId.getUserId(callingUid) != userId) { + if (UserHandle.getAppId(callingUid) != android.os.Process.SYSTEM_UID + && UserHandle.getUserId(callingUid) != userId) { throw new SecurityException("uid=" + callingUid + " not authorized to read settings of user " + userId); } |
