summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/ActivityManagerInternal.java37
-rw-r--r--core/java/android/content/Intent.java4
-rw-r--r--core/java/android/os/UserHandle.java11
-rw-r--r--core/java/android/os/UserManager.java116
-rw-r--r--core/java/android/os/UserManagerInternal.java2
-rw-r--r--services/core/java/com/android/server/SystemService.java10
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java16
-rw-r--r--services/core/java/com/android/server/am/UserController.java89
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java37
-rw-r--r--services/core/java/com/android/server/pm/UserManagerService.java351
10 files changed, 339 insertions, 334 deletions
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java
index 1fd7e52314e3..92aabb591e03 100644
--- a/core/java/android/app/ActivityManagerInternal.java
+++ b/core/java/android/app/ActivityManagerInternal.java
@@ -18,6 +18,7 @@ package android.app;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.UserIdInt;
import android.content.ComponentName;
import android.content.IIntentReceiver;
import android.content.IIntentSender;
@@ -30,7 +31,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.os.TransactionTooLargeException;
-import android.view.RemoteAnimationAdapter;
import java.util.ArrayList;
import java.util.List;
@@ -51,12 +51,12 @@ public abstract class ActivityManagerInternal {
/**
* Verify that calling app has access to the given provider.
*/
- public abstract String checkContentProviderAccess(String authority, int userId);
+ public abstract String checkContentProviderAccess(String authority, @UserIdInt int userId);
/**
* Verify that calling UID has access to the given provider.
*/
- public abstract int checkContentProviderUriPermission(Uri uri, int userId,
+ public abstract int checkContentProviderUriPermission(Uri uri, @UserIdInt int userId,
int callingUid, int modeFlags);
// Called by the power manager.
@@ -71,7 +71,7 @@ public abstract class ActivityManagerInternal {
/**
* Kill foreground apps from the specified user.
*/
- public abstract void killForegroundAppsForUser(int userHandle);
+ public abstract void killForegroundAppsForUser(@UserIdInt int userId);
/**
* Sets how long a {@link PendingIntent} can be temporarily whitelist to by bypass restrictions
@@ -174,7 +174,7 @@ public abstract class ActivityManagerInternal {
* Checks to see if the calling pid is allowed to handle the user. Returns adjusted user id as
* needed.
*/
- public abstract int handleIncomingUser(int callingPid, int callingUid, int userId,
+ public abstract int handleIncomingUser(int callingPid, int callingUid, @UserIdInt int userId,
boolean allowAll, int allowMode, String name, String callerPackage);
/** Checks if the calling binder pid as the permission. */
@@ -184,7 +184,7 @@ public abstract class ActivityManagerInternal {
public abstract int getCurrentUserId();
/** Returns true if the user is running. */
- public abstract boolean isUserRunning(int userId, int flags);
+ public abstract boolean isUserRunning(@UserIdInt int userId, int flags);
/** Trims memory usage in the system by removing/stopping unused application processes. */
public abstract void trimApplications();
@@ -211,7 +211,7 @@ public abstract class ActivityManagerInternal {
* @param started
*/
public abstract void updateBatteryStats(
- ComponentName activity, int uid, int userId, boolean resumed);
+ ComponentName activity, int uid, @UserIdInt int userId, boolean resumed);
/**
* Update UsageStats of the activity.
@@ -222,23 +222,23 @@ public abstract class ActivityManagerInternal {
* @param taskRoot TaskRecord's root
*/
public abstract void updateActivityUsageStats(
- ComponentName activity, int userId, int event, IBinder appToken,
+ ComponentName activity, @UserIdInt int userId, int event, IBinder appToken,
ComponentName taskRoot);
public abstract void updateForegroundTimeIfOnBattery(
String packageName, int uid, long cpuTimeDiff);
- public abstract void sendForegroundProfileChanged(int userId);
+ public abstract void sendForegroundProfileChanged(@UserIdInt int userId);
/**
* Returns whether the given user requires credential entry at this time. This is used to
* intercept activity launches for work apps when the Work Challenge is present.
*/
- public abstract boolean shouldConfirmCredentials(int userId);
+ public abstract boolean shouldConfirmCredentials(@UserIdInt int userId);
public abstract int[] getCurrentProfileIds();
public abstract UserInfo getCurrentUser();
- public abstract void ensureNotSpecialUser(int userId);
- public abstract boolean isCurrentProfile(int userId);
- public abstract boolean hasStartedUserState(int userId);
+ public abstract void ensureNotSpecialUser(@UserIdInt int userId);
+ public abstract boolean isCurrentProfile(@UserIdInt int userId);
+ public abstract boolean hasStartedUserState(@UserIdInt int userId);
public abstract void finishUserSwitch(Object uss);
/** Schedule the execution of all pending app GCs. */
@@ -261,15 +261,16 @@ public abstract class ActivityManagerInternal {
public abstract int broadcastIntentInPackage(String packageName, int uid, int realCallingUid,
int realCallingPid, Intent intent, String resolvedType, IIntentReceiver resultTo,
int resultCode, String resultData, Bundle resultExtras, String requiredPermission,
- Bundle bOptions, boolean serialized, boolean sticky, int userId,
+ Bundle bOptions, boolean serialized, boolean sticky, @UserIdInt int userId,
boolean allowBackgroundActivityStarts);
public abstract ComponentName startServiceInPackage(int uid, Intent service,
- String resolvedType, boolean fgRequired, String callingPackage, int userId,
+ String resolvedType, boolean fgRequired, String callingPackage, @UserIdInt int userId,
boolean allowBackgroundActivityStarts) throws TransactionTooLargeException;
public abstract void disconnectActivityFromServices(Object connectionHolder, Object conns);
- public abstract void cleanUpServices(int userId, ComponentName component, Intent baseIntent);
- public abstract ActivityInfo getActivityInfoForUser(ActivityInfo aInfo, int userId);
+ public abstract void cleanUpServices(@UserIdInt int userId, ComponentName component,
+ Intent baseIntent);
+ public abstract ActivityInfo getActivityInfoForUser(ActivityInfo aInfo, @UserIdInt int userId);
public abstract void ensureBootCompleted();
public abstract void updateOomLevelsForDisplay(int displayId);
public abstract boolean isActivityStartsLoggingEnabled();
@@ -328,7 +329,7 @@ public abstract class ActivityManagerInternal {
public abstract boolean isAppBad(ApplicationInfo info);
/** Remove pending backup for the given userId. */
- public abstract void clearPendingBackup(int userId);
+ public abstract void clearPendingBackup(@UserIdInt int userId);
/**
* When power button is very long pressed, call this interface to do some pre-shutdown work
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 2a17800dd446..3418b7be42d6 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -5413,8 +5413,8 @@ public class Intent implements Parcelable, Cloneable {
"android.intent.extra.ALLOW_MULTIPLE";
/**
- * The integer userHandle carried with broadcast intents related to addition, removal and
- * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
+ * The integer userHandle (i.e. userId) carried with broadcast intents related to addition,
+ * removal and switching of users and managed profiles - {@link #ACTION_USER_ADDED},
* {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
*
* @hide
diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java
index 4e17f7e92013..0754dc78a629 100644
--- a/core/java/android/os/UserHandle.java
+++ b/core/java/android/os/UserHandle.java
@@ -128,8 +128,9 @@ public final class UserHandle implements Parcelable {
@UnsupportedAppUsage
public static final int AID_CACHE_GID_START = android.os.Process.FIRST_APPLICATION_CACHE_GID;
+ /** The userId represented by this UserHandle. */
@UnsupportedAppUsage
- final int mHandle;
+ final @UserIdInt int mHandle;
/**
* Checks to see if the user id is the same for the two uids, i.e., they belong to the same
@@ -270,7 +271,7 @@ public final class UserHandle implements Parcelable {
}
/** @hide */
- public static int getSharedAppGid(int userId, int appId) {
+ public static int getSharedAppGid(@UserIdInt int userId, @AppIdInt int appId) {
if (appId >= AID_APP_START && appId <= AID_APP_END) {
return (appId - AID_APP_START) + AID_SHARED_GID_START;
} else if (appId >= AID_ROOT && appId <= AID_APP_START) {
@@ -300,7 +301,7 @@ public final class UserHandle implements Parcelable {
}
/** @hide */
- public static int getCacheAppGid(int userId, int appId) {
+ public static int getCacheAppGid(@UserIdInt int userId, @AppIdInt int appId) {
if (appId >= AID_APP_START && appId <= AID_APP_END) {
return getUid(userId, (appId - AID_APP_START) + AID_CACHE_GID_START);
} else {
@@ -432,8 +433,8 @@ public final class UserHandle implements Parcelable {
/** @hide */
@UnsupportedAppUsage
- public UserHandle(int h) {
- mHandle = h;
+ public UserHandle(@UserIdInt int userId) {
+ mHandle = userId;
}
/**
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index a7fa96bc1d90..baf748f4a20d 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -1794,14 +1794,14 @@ public class UserManager {
/**
* Returns the UserInfo object describing a specific user.
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
- * @param userHandle the user handle of the user whose information is being requested.
+ * @param userId the user handle of the user whose information is being requested.
* @return the UserInfo object for a specific user.
* @hide
*/
@UnsupportedAppUsage
- public UserInfo getUserInfo(@UserIdInt int userHandle) {
+ public UserInfo getUserInfo(@UserIdInt int userId) {
try {
- return mService.getUserInfo(userHandle);
+ return mService.getUserInfo(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2066,15 +2066,15 @@ public class UserManager {
*
* @param name the user's name
* @param flags flags that identify the type of user and other properties.
- * @param userHandle new user will be a profile of this user.
+ * @param userId new user will be a profile of this user.
*
* @return the {@link UserInfo} object for the created user, or null if the user
* could not be created.
* @hide
*/
@UnsupportedAppUsage
- public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userHandle) {
- return createProfileForUser(name, flags, userHandle, null);
+ public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userId) {
+ return createProfileForUser(name, flags, userId, null);
}
/**
@@ -2084,17 +2084,17 @@ public class UserManager {
*
* @param name the user's name
* @param flags flags that identify the type of user and other properties.
- * @param userHandle new user will be a profile of this user.
+ * @param userId new user will be a profile of this user.
* @param disallowedPackages packages that will not be installed in the profile being created.
*
* @return the {@link UserInfo} object for the created user, or null if the user
* could not be created.
* @hide
*/
- public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userHandle,
+ public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userId,
String[] disallowedPackages) {
try {
- return mService.createProfileForUser(name, flags, userHandle, disallowedPackages);
+ return mService.createProfileForUser(name, flags, userId, disallowedPackages);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2109,9 +2109,9 @@ public class UserManager {
* @hide
*/
public UserInfo createProfileForUserEvenWhenDisallowed(String name, int flags,
- @UserIdInt int userHandle, String[] disallowedPackages) {
+ @UserIdInt int userId, String[] disallowedPackages) {
try {
- return mService.createProfileForUserEvenWhenDisallowed(name, flags, userHandle,
+ return mService.createProfileForUserEvenWhenDisallowed(name, flags, userId,
disallowedPackages);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
@@ -2280,12 +2280,12 @@ public class UserManager {
* @hide
* Marks the guest user for deletion to allow a new guest to be created before deleting
* the current user who is a guest.
- * @param userHandle
+ * @param userId
* @return
*/
- public boolean markGuestForDeletion(@UserIdInt int userHandle) {
+ public boolean markGuestForDeletion(@UserIdInt int userId) {
try {
- return mService.markGuestForDeletion(userHandle);
+ return mService.markGuestForDeletion(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2317,16 +2317,16 @@ public class UserManager {
* <p>Requires {@link android.Manifest.permission#MANAGE_USERS} and
* {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permissions.
*
- * @param userHandle the id of the user to become admin
+ * @param userId the id of the user to become admin
* @hide
*/
@RequiresPermission(allOf = {
Manifest.permission.INTERACT_ACROSS_USERS_FULL,
Manifest.permission.MANAGE_USERS
})
- public void setUserAdmin(@UserIdInt int userHandle) {
+ public void setUserAdmin(@UserIdInt int userId) {
try {
- mService.setUserAdmin(userHandle);
+ mService.setUserAdmin(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2337,9 +2337,9 @@ public class UserManager {
*
* @hide
*/
- public void evictCredentialEncryptionKey(@UserIdInt int userHandle) {
+ public void evictCredentialEncryptionKey(@UserIdInt int userId) {
try {
- mService.evictCredentialEncryptionKey(userHandle);
+ mService.evictCredentialEncryptionKey(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2400,9 +2400,9 @@ public class UserManager {
Manifest.permission.INTERACT_ACROSS_USERS_FULL,
Manifest.permission.MANAGE_USERS
})
- public @Nullable String getUserAccount(@UserIdInt int userHandle) {
+ public @Nullable String getUserAccount(@UserIdInt int userId) {
try {
- return mService.getUserAccount(userHandle);
+ return mService.getUserAccount(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2416,9 +2416,9 @@ public class UserManager {
Manifest.permission.INTERACT_ACROSS_USERS_FULL,
Manifest.permission.MANAGE_USERS
})
- public void setUserAccount(@UserIdInt int userHandle, @Nullable String accountName) {
+ public void setUserAccount(@UserIdInt int userId, @Nullable String accountName) {
try {
- mService.setUserAccount(userHandle, accountName);
+ mService.setUserAccount(userId, accountName);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2477,20 +2477,19 @@ public class UserManager {
}
/**
- * Returns list of the profiles of userHandle including
- * userHandle itself.
+ * Returns list of the profiles of userId including userId itself.
* Note that this returns both enabled and not enabled profiles. See
* {@link #getEnabledProfiles(int)} if you need only the enabled ones.
*
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
- * @param userHandle profiles of this user will be returned.
+ * @param userId profiles of this user will be returned.
* @return the list of profiles.
* @hide
*/
@UnsupportedAppUsage
- public List<UserInfo> getProfiles(@UserIdInt int userHandle) {
+ public List<UserInfo> getProfiles(@UserIdInt int userId) {
try {
- return mService.getProfiles(userHandle, false /* enabledOnly */);
+ return mService.getProfiles(userId, false /* enabledOnly */);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2512,19 +2511,18 @@ public class UserManager {
}
/**
- * Returns list of the profiles of userHandle including
- * userHandle itself.
+ * Returns list of the profiles of userId including userId itself.
* Note that this returns only enabled.
*
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
- * @param userHandle profiles of this user will be returned.
+ * @param userId profiles of this user will be returned.
* @return the list of profiles.
* @hide
*/
@UnsupportedAppUsage
- public List<UserInfo> getEnabledProfiles(@UserIdInt int userHandle) {
+ public List<UserInfo> getEnabledProfiles(@UserIdInt int userId) {
try {
- return mService.getProfiles(userHandle, true /* enabledOnly */);
+ return mService.getProfiles(userId, true /* enabledOnly */);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2584,14 +2582,14 @@ public class UserManager {
/**
* Returns the device credential owner id of the profile from
- * which this method is called, or userHandle if called from a user that
+ * which this method is called, or userId if called from a user that
* is not a profile.
*
* @hide
*/
- public int getCredentialOwnerProfile(@UserIdInt int userHandle) {
+ public int getCredentialOwnerProfile(@UserIdInt int userId) {
try {
- return mService.getCredentialOwnerProfile(userHandle);
+ return mService.getCredentialOwnerProfile(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2604,9 +2602,9 @@ public class UserManager {
* @hide
*/
@UnsupportedAppUsage
- public UserInfo getProfileParent(@UserIdInt int userHandle) {
+ public UserInfo getProfileParent(@UserIdInt int userId) {
try {
- return mService.getProfileParent(userHandle);
+ return mService.getProfileParent(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2785,13 +2783,13 @@ public class UserManager {
/**
* Removes a user and all associated data.
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
- * @param userHandle the integer handle of the user, where 0 is the primary user.
+ * @param userId the integer handle of the user.
* @hide
*/
@UnsupportedAppUsage
- public boolean removeUser(@UserIdInt int userHandle) {
+ public boolean removeUser(@UserIdInt int userId) {
try {
- return mService.removeUser(userHandle);
+ return mService.removeUser(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2823,9 +2821,9 @@ public class UserManager {
* @see {@link #removeUser(int)}
* @hide
*/
- public boolean removeUserEvenWhenDisallowed(@UserIdInt int userHandle) {
+ public boolean removeUserEvenWhenDisallowed(@UserIdInt int userId) {
try {
- return mService.removeUserEvenWhenDisallowed(userHandle);
+ return mService.removeUserEvenWhenDisallowed(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2835,13 +2833,13 @@ public class UserManager {
* Updates the user's name.
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
*
- * @param userHandle the user's integer handle
+ * @param userId the user's integer id
* @param name the new name for the user
* @hide
*/
- public void setUserName(@UserIdInt int userHandle, String name) {
+ public void setUserName(@UserIdInt int userId, String name) {
try {
- mService.setUserName(userHandle, name);
+ mService.setUserName(userId, name);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2862,13 +2860,13 @@ public class UserManager {
/**
* Sets the user's photo.
- * @param userHandle the user for whom to change the photo.
+ * @param userId the user for whom to change the photo.
* @param icon the bitmap to set as the photo.
* @hide
*/
- public void setUserIcon(@UserIdInt int userHandle, Bitmap icon) {
+ public void setUserIcon(@UserIdInt int userId, Bitmap icon) {
try {
- mService.setUserIcon(userHandle, icon);
+ mService.setUserIcon(userId, icon);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2889,15 +2887,15 @@ public class UserManager {
/**
* Returns a file descriptor for the user's photo. PNG data can be read from this file.
- * @param userHandle the user whose photo we want to read.
+ * @param userId the user whose photo we want to read.
* @return a {@link Bitmap} of the user's photo, or null if there's no photo.
* @see com.android.internal.util.UserIcons#getDefaultUserIcon for a default.
* @hide
*/
@UnsupportedAppUsage
- public Bitmap getUserIcon(@UserIdInt int userHandle) {
+ public Bitmap getUserIcon(@UserIdInt int userId) {
try {
- ParcelFileDescriptor fd = mService.getUserIcon(userHandle);
+ ParcelFileDescriptor fd = mService.getUserIcon(userId);
if (fd != null) {
try {
return BitmapFactory.decodeFileDescriptor(fd.getFileDescriptor());
@@ -2999,27 +2997,27 @@ public class UserManager {
}
/**
- * Returns a serial number on this device for a given userHandle. User handles can be recycled
+ * Returns a serial number on this device for a given userId. User handles can be recycled
* when deleting and creating users, but serial numbers are not reused until the device is wiped.
- * @param userHandle
- * @return a serial number associated with that user, or -1 if the userHandle is not valid.
+ * @param userId
+ * @return a serial number associated with that user, or -1 if the userId is not valid.
* @hide
*/
@UnsupportedAppUsage
- public int getUserSerialNumber(@UserIdInt int userHandle) {
+ public int getUserSerialNumber(@UserIdInt int userId) {
try {
- return mService.getUserSerialNumber(userHandle);
+ return mService.getUserSerialNumber(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
}
/**
- * Returns a userHandle on this device for a given user serial number. User handles can be
+ * Returns a userId on this device for a given user serial number. User handles can be
* recycled when deleting and creating users, but serial numbers are not reused until the device
* is wiped.
* @param userSerialNumber
- * @return the userHandle associated with that user serial number, or -1 if the serial number
+ * @return the userId associated with that user serial number, or -1 if the serial number
* is not valid.
* @hide
*/
diff --git a/core/java/android/os/UserManagerInternal.java b/core/java/android/os/UserManagerInternal.java
index f302263f23ce..b6540d2cf6a9 100644
--- a/core/java/android/os/UserManagerInternal.java
+++ b/core/java/android/os/UserManagerInternal.java
@@ -136,7 +136,7 @@ public abstract class UserManagerInternal {
String[] disallowedPackages);
/**
- * Same as {@link UserManager#removeUser(int userHandle)}, but bypasses the check for
+ * Same as {@link UserManager#removeUser(int userId)}, but bypasses the check for
* {@link UserManager#DISALLOW_REMOVE_USER} and
* {@link UserManager#DISALLOW_REMOVE_MANAGED_PROFILE} and does not require the
* {@link android.Manifest.permission#MANAGE_USERS} permission.
diff --git a/services/core/java/com/android/server/SystemService.java b/services/core/java/com/android/server/SystemService.java
index 4facf4ea62a2..a311b3fc0332 100644
--- a/services/core/java/com/android/server/SystemService.java
+++ b/services/core/java/com/android/server/SystemService.java
@@ -154,7 +154,7 @@ public abstract class SystemService {
* calls this method).
*/
@Deprecated
- public void onStartUser(@UserIdInt int userHandle) {}
+ public void onStartUser(@UserIdInt int userId) {}
/**
* Called when a new user is starting, for system services to initialize any per-user
@@ -172,7 +172,7 @@ public abstract class SystemService {
* default calls this method).
*/
@Deprecated
- public void onUnlockUser(@UserIdInt int userHandle) {}
+ public void onUnlockUser(@UserIdInt int userId) {}
/**
* Called when an existing user is in the process of being unlocked. This
@@ -198,7 +198,7 @@ public abstract class SystemService {
* default calls this method).
*/
@Deprecated
- public void onSwitchUser(@UserIdInt int userHandle) {}
+ public void onSwitchUser(@UserIdInt int userId) {}
/**
* Called when switching to a different foreground user, for system services that have
@@ -217,7 +217,7 @@ public abstract class SystemService {
* calls this method).
*/
@Deprecated
- public void onStopUser(@UserIdInt int userHandle) {}
+ public void onStopUser(@UserIdInt int userId) {}
/**
* Called when an existing user is stopping, for system services to finalize any per-user
@@ -239,7 +239,7 @@ public abstract class SystemService {
* default calls this method).
*/
@Deprecated
- public void onCleanupUser(@UserIdInt int userHandle) {}
+ public void onCleanupUser(@UserIdInt int userId) {}
/**
* Called when an existing user is stopping, for system services to finalize any per-user
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 5c0fe4e8bcc2..b06d222f497f 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -6097,16 +6097,16 @@ public class ActivityManagerService extends IActivityManager.Stub
return ptw != null ? ptw.tag : null;
}
- private ProviderInfo getProviderInfoLocked(String authority, int userHandle, int pmFlags) {
+ private ProviderInfo getProviderInfoLocked(String authority, @UserIdInt int userId,
+ int pmFlags) {
ProviderInfo pi = null;
- ContentProviderRecord cpr = mProviderMap.getProviderByName(authority, userHandle);
+ ContentProviderRecord cpr = mProviderMap.getProviderByName(authority, userId);
if (cpr != null) {
pi = cpr.info;
} else {
try {
pi = AppGlobals.getPackageManager().resolveContentProvider(
- authority, PackageManager.GET_URI_PERMISSION_PATTERNS | pmFlags,
- userHandle);
+ authority, PackageManager.GET_URI_PERMISSION_PATTERNS | pmFlags, userId);
} catch (RemoteException ex) {
}
}
@@ -15296,11 +15296,11 @@ public class ActivityManagerService extends IActivityManager.Stub
intent.getAction());
final String[] packageNames = intent.getStringArrayExtra(
Intent.EXTRA_CHANGED_PACKAGE_LIST);
- final int userHandle = intent.getIntExtra(
+ final int userIdExtra = intent.getIntExtra(
Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
mAtmInternal.onPackagesSuspendedChanged(packageNames, suspended,
- userHandle);
+ userIdExtra);
break;
}
break;
@@ -18019,7 +18019,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public void killForegroundAppsForUser(int userHandle) {
+ public void killForegroundAppsForUser(@UserIdInt int userId) {
synchronized (ActivityManagerService.this) {
final ArrayList<ProcessRecord> procs = new ArrayList<>();
final int NP = mProcessList.mProcessNames.getMap().size();
@@ -18034,7 +18034,7 @@ public class ActivityManagerService extends IActivityManager.Stub
continue;
}
if (app.removed
- || (app.userId == userHandle && app.hasForegroundActivities())) {
+ || (app.userId == userId && app.hasForegroundActivities())) {
procs.add(app);
}
}
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index d4ceb5a86946..70b6c8a2a3db 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -841,7 +841,7 @@ class UserController implements Handler.Callback {
* @return user id to lock. UserHandler.USER_NULL will be returned if no user should be locked.
*/
@GuardedBy("mLock")
- private int updateUserToLockLU(int userId) {
+ private int updateUserToLockLU(@UserIdInt int userId) {
int userIdToLock = userId;
if (mDelayUserDataLocking && !getUserInfo(userId).isEphemeral()
&& !hasUserRestriction(UserManager.DISALLOW_RUN_IN_BACKGROUND, userId)) {
@@ -869,7 +869,7 @@ class UserController implements Handler.Callback {
* {@code userId}. The returned list includes {@code userId}.
*/
@GuardedBy("mLock")
- private @NonNull int[] getUsersToStopLU(int userId) {
+ private @NonNull int[] getUsersToStopLU(@UserIdInt int userId) {
int startedUsersSize = mStartedUsers.size();
IntArray userIds = new IntArray();
userIds.add(userId);
@@ -892,7 +892,7 @@ class UserController implements Handler.Callback {
return userIds.toArray();
}
- private void forceStopUser(int userId, String reason) {
+ private void forceStopUser(@UserIdInt int userId, String reason) {
mInjector.activityManagerForceStopPackage(userId, reason);
Intent intent = new Intent(Intent.ACTION_USER_STOPPED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
@@ -965,7 +965,7 @@ class UserController implements Handler.Callback {
}
}
- boolean startUser(final int userId, final boolean foreground) {
+ boolean startUser(final @UserIdInt int userId, final boolean foreground) {
return startUser(userId, foreground, null);
}
@@ -1002,7 +1002,7 @@ class UserController implements Handler.Callback {
* @return true if the user has been successfully started
*/
boolean startUser(
- final int userId,
+ final @UserIdInt int userId,
final boolean foreground,
@Nullable IProgressListener unlockListener) {
@@ -1018,7 +1018,7 @@ class UserController implements Handler.Callback {
}
}
- private boolean startUserInternal(int userId, boolean foreground,
+ private boolean startUserInternal(@UserIdInt int userId, boolean foreground,
@Nullable IProgressListener unlockListener, @NonNull TimingsTraceAndSlog t) {
Slog.i(TAG, "Starting userid:" + userId + " fg:" + foreground);
@@ -1257,7 +1257,8 @@ class UserController implements Handler.Callback {
}
}
- boolean unlockUser(final int userId, byte[] token, byte[] secret, IProgressListener listener) {
+ boolean unlockUser(final @UserIdInt int userId, byte[] token, byte[] secret,
+ IProgressListener listener) {
checkCallingPermission(INTERACT_ACROSS_USERS_FULL, "unlockUser");
final long binderToken = Binder.clearCallingIdentity();
try {
@@ -1273,12 +1274,12 @@ class UserController implements Handler.Callback {
* when the credential-encrypted storage isn't tied to a user-provided
* PIN or pattern.
*/
- private boolean maybeUnlockUser(final int userId) {
+ private boolean maybeUnlockUser(final @UserIdInt int userId) {
// Try unlocking storage using empty token
return unlockUserCleared(userId, null, null, null);
}
- private static void notifyFinished(int userId, IProgressListener listener) {
+ private static void notifyFinished(@UserIdInt int userId, IProgressListener listener) {
if (listener == null) return;
try {
listener.onFinished(userId, null);
@@ -1286,7 +1287,7 @@ class UserController implements Handler.Callback {
}
}
- private boolean unlockUserCleared(final int userId, byte[] token, byte[] secret,
+ private boolean unlockUserCleared(final @UserIdInt int userId, byte[] token, byte[] secret,
IProgressListener listener) {
UserState uss;
if (!StorageManager.isUserKeyUnlocked(userId)) {
@@ -1385,7 +1386,7 @@ class UserController implements Handler.Callback {
getSwitchingFromSystemUserMessage(), getSwitchingToSystemUserMessage());
}
- private void dispatchForegroundProfileChanged(int userId) {
+ private void dispatchForegroundProfileChanged(@UserIdInt int userId) {
final int observerCount = mUserSwitchObservers.beginBroadcast();
for (int i = 0; i < observerCount; i++) {
try {
@@ -1398,7 +1399,7 @@ class UserController implements Handler.Callback {
}
/** Called on handler thread */
- void dispatchUserSwitchComplete(int userId) {
+ void dispatchUserSwitchComplete(@UserIdInt int userId) {
mInjector.getWindowManager().setSwitchingUser(false);
final int observerCount = mUserSwitchObservers.beginBroadcast();
for (int i = 0; i < observerCount; i++) {
@@ -1410,7 +1411,7 @@ class UserController implements Handler.Callback {
mUserSwitchObservers.finishBroadcast();
}
- private void dispatchLockedBootComplete(int userId) {
+ private void dispatchLockedBootComplete(@UserIdInt int userId) {
final int observerCount = mUserSwitchObservers.beginBroadcast();
for (int i = 0; i < observerCount; i++) {
try {
@@ -1597,7 +1598,7 @@ class UserController implements Handler.Callback {
}
- int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll,
+ int handleIncomingUser(int callingPid, int callingUid, @UserIdInt int userId, boolean allowAll,
int allowMode, String name, String callerPackage) {
final int callingUserId = UserHandle.getUserId(callingUid);
if (callingUserId == userId) {
@@ -1683,12 +1684,12 @@ class UserController implements Handler.Callback {
return targetUserId;
}
- int unsafeConvertIncomingUser(int userId) {
+ int unsafeConvertIncomingUser(@UserIdInt int userId) {
return (userId == UserHandle.USER_CURRENT || userId == UserHandle.USER_CURRENT_OR_SELF)
? getCurrentUserId(): userId;
}
- void ensureNotSpecialUser(int userId) {
+ void ensureNotSpecialUser(@UserIdInt int userId) {
if (userId >= 0) {
return;
}
@@ -1701,7 +1702,7 @@ class UserController implements Handler.Callback {
mUserSwitchObservers.register(observer, name);
}
- void sendForegroundProfileChanged(int userId) {
+ void sendForegroundProfileChanged(@UserIdInt int userId) {
mHandler.removeMessages(FOREGROUND_PROFILE_CHANGED_MSG);
mHandler.obtainMessage(FOREGROUND_PROFILE_CHANGED_MSG, userId, 0).sendToTarget();
}
@@ -1710,13 +1711,13 @@ class UserController implements Handler.Callback {
mUserSwitchObservers.unregister(observer);
}
- UserState getStartedUserState(int userId) {
+ UserState getStartedUserState(@UserIdInt int userId) {
synchronized (mLock) {
return mStartedUsers.get(userId);
}
}
- boolean hasStartedUserState(int userId) {
+ boolean hasStartedUserState(@UserIdInt int userId) {
synchronized (mLock) {
return mStartedUsers.get(userId) != null;
}
@@ -1793,7 +1794,7 @@ class UserController implements Handler.Callback {
}
}
- boolean isUserRunning(int userId, int flags) {
+ boolean isUserRunning(@UserIdInt int userId, int flags) {
UserState state = getStartedUserState(userId);
if (state == null) {
return false;
@@ -1909,7 +1910,7 @@ class UserController implements Handler.Callback {
}
@GuardedBy("mLock")
- private boolean isCurrentUserLU(int userId) {
+ private boolean isCurrentUserLU(@UserIdInt int userId) {
return userId == getCurrentOrTargetUserIdLU();
}
@@ -1918,7 +1919,7 @@ class UserController implements Handler.Callback {
return ums != null ? ums.getUserIds() : new int[] { 0 };
}
- private UserInfo getUserInfo(int userId) {
+ private UserInfo getUserInfo(@UserIdInt int userId) {
return mInjector.getUserManager().getUserInfo(userId);
}
@@ -1932,7 +1933,7 @@ class UserController implements Handler.Callback {
*
* It doesn't handle other special user IDs such as {@link UserHandle#USER_CURRENT}.
*/
- int[] expandUserId(int userId) {
+ int[] expandUserId(@UserIdInt int userId) {
if (userId != UserHandle.USER_ALL) {
return new int[] {userId};
} else {
@@ -1940,7 +1941,7 @@ class UserController implements Handler.Callback {
}
}
- boolean exists(int userId) {
+ boolean exists(@UserIdInt int userId) {
return mInjector.getUserManager().exists(userId);
}
@@ -1956,16 +1957,16 @@ class UserController implements Handler.Callback {
}
}
- private void enforceShellRestriction(String restriction, int userHandle) {
+ private void enforceShellRestriction(String restriction, @UserIdInt int userId) {
if (Binder.getCallingUid() == SHELL_UID) {
- if (userHandle < 0 || hasUserRestriction(restriction, userHandle)) {
+ if (userId < 0 || hasUserRestriction(restriction, userId)) {
throw new SecurityException("Shell does not have permission to access user "
- + userHandle);
+ + userId);
}
}
}
- boolean hasUserRestriction(String restriction, int userId) {
+ boolean hasUserRestriction(String restriction, @UserIdInt int userId) {
return mInjector.getUserManager().hasUserRestriction(restriction, userId);
}
@@ -1983,7 +1984,7 @@ class UserController implements Handler.Callback {
}
}
- boolean isUserOrItsParentRunning(int userId) {
+ boolean isUserOrItsParentRunning(@UserIdInt int userId) {
synchronized (mLock) {
if (isUserRunning(userId, 0)) {
return true;
@@ -1996,7 +1997,7 @@ class UserController implements Handler.Callback {
}
}
- boolean isCurrentProfile(int userId) {
+ boolean isCurrentProfile(@UserIdInt int userId) {
synchronized (mLock) {
return ArrayUtils.contains(mCurrentProfileIds, userId);
}
@@ -2008,7 +2009,7 @@ class UserController implements Handler.Callback {
}
}
- void onUserRemoved(int userId) {
+ void onUserRemoved(@UserIdInt int userId) {
synchronized (mLock) {
int size = mUserProfileGroupIds.size();
for (int i = size - 1; i >= 0; i--) {
@@ -2026,7 +2027,7 @@ class UserController implements Handler.Callback {
* Returns whether the given user requires credential entry at this time. This is used to
* intercept activity launches for work apps when the Work Challenge is present.
*/
- protected boolean shouldConfirmCredentials(int userId) {
+ protected boolean shouldConfirmCredentials(@UserIdInt int userId) {
synchronized (mLock) {
if (mStartedUsers.get(userId) == null) {
return false;
@@ -2254,7 +2255,7 @@ class UserController implements Handler.Callback {
IIntentReceiver resultTo, int resultCode, String resultData,
Bundle resultExtras, String[] requiredPermissions, int appOp, Bundle bOptions,
boolean ordered, boolean sticky, int callingPid, int callingUid, int realCallingUid,
- int realCallingPid, int userId) {
+ int realCallingPid, @UserIdInt int userId) {
// TODO b/64165549 Verify that mLock is not held before calling AMS methods
synchronized (mService) {
return mService.broadcastIntentLocked(null, null, intent, resolvedType, resultTo,
@@ -2271,11 +2272,11 @@ class UserController implements Handler.Callback {
WindowManagerService getWindowManager() {
return mService.mWindowManager;
}
- void activityManagerOnUserStopped(int userId) {
+ void activityManagerOnUserStopped(@UserIdInt int userId) {
LocalServices.getService(ActivityTaskManagerInternal.class).onUserStopped(userId);
}
- void systemServiceManagerCleanupUser(int userId) {
+ void systemServiceManagerCleanupUser(@UserIdInt int userId) {
mService.mSystemServiceManager.cleanupUser(userId);
}
@@ -2319,7 +2320,7 @@ class UserController implements Handler.Callback {
}
}
- void sendPreBootBroadcast(int userId, boolean quiet, final Runnable onFinish) {
+ void sendPreBootBroadcast(@UserIdInt int userId, boolean quiet, final Runnable onFinish) {
new PreBootBroadcaster(mService, userId, null, quiet) {
@Override
public void onFinished() {
@@ -2328,7 +2329,7 @@ class UserController implements Handler.Callback {
}.sendNext();
}
- void activityManagerForceStopPackage(int userId, String reason) {
+ void activityManagerForceStopPackage(@UserIdInt int userId, String reason) {
synchronized (mService) {
mService.forceStopPackageLocked(null, -1, false, false, true, false, false,
userId, reason);
@@ -2340,11 +2341,11 @@ class UserController implements Handler.Callback {
return mService.checkComponentPermission(permission, pid, uid, owningUid, exported);
}
- protected void startHomeActivity(int userId, String reason) {
+ protected void startHomeActivity(@UserIdInt int userId, String reason) {
mService.mAtmInternal.startHomeActivity(userId, reason);
}
- void startUserWidgets(int userId) {
+ void startUserWidgets(@UserIdInt int userId) {
AppWidgetManagerInternal awm = LocalServices.getService(AppWidgetManagerInternal.class);
if (awm != null) {
// Out of band, because this is called during a sequence with
@@ -2359,13 +2360,13 @@ class UserController implements Handler.Callback {
mService.mAtmInternal.updateUserConfiguration();
}
- void clearBroadcastQueueForUser(int userId) {
+ void clearBroadcastQueueForUser(@UserIdInt int userId) {
synchronized (mService) {
mService.clearBroadcastQueueForUserLocked(userId);
}
}
- void loadUserRecents(int userId) {
+ void loadUserRecents(@UserIdInt int userId) {
mService.mAtmInternal.loadRecentTasksForUser(userId);
}
@@ -2373,7 +2374,7 @@ class UserController implements Handler.Callback {
mService.startPersistentApps(matchFlags);
}
- void installEncryptionUnawareProviders(int userId) {
+ void installEncryptionUnawareProviders(@UserIdInt int userId) {
mService.installEncryptionUnawareProviders(userId);
}
@@ -2406,11 +2407,11 @@ class UserController implements Handler.Callback {
}
}
- void stackSupervisorRemoveUser(int userId) {
+ void stackSupervisorRemoveUser(@UserIdInt int userId) {
mService.mAtmInternal.removeUser(userId);
}
- protected boolean stackSupervisorSwitchUser(int userId, UserState uss) {
+ protected boolean stackSupervisorSwitchUser(@UserIdInt int userId, UserState uss) {
return mService.mAtmInternal.switchUser(userId, uss);
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 15a3a725d69d..b69ca28982a7 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -113,6 +113,7 @@ import static com.android.server.pm.PackageManagerServiceUtils.logCriticalInfo;
import static com.android.server.pm.PackageManagerServiceUtils.verifySignatures;
import android.Manifest;
+import android.annotation.AppIdInt;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -12048,11 +12049,12 @@ public class PackageManagerService extends IPackageManager.Stub
| IntentFilter.MATCH_ADJUSTMENT_NORMAL;
}
- private void killApplication(String pkgName, int appId, String reason) {
+ private void killApplication(String pkgName, @AppIdInt int appId, String reason) {
killApplication(pkgName, appId, UserHandle.USER_ALL, reason);
}
- private void killApplication(String pkgName, int appId, int userId, String reason) {
+ private void killApplication(String pkgName, @AppIdInt int appId,
+ @UserIdInt int userId, String reason) {
// Request the ActivityManager to kill the process(only for existing packages)
// so that we do not end up in a confused state while the user is still using the older
// version of the application while the new one gets installed.
@@ -12427,7 +12429,7 @@ public class PackageManagerService extends IPackageManager.Stub
@Override
public void sendPackageAddedForNewUsers(String packageName, boolean sendBootCompleted,
- boolean includeStopped, int appId, int[] userIds, int[] instantUserIds) {
+ boolean includeStopped, @AppIdInt int appId, int[] userIds, int[] instantUserIds) {
if (ArrayUtils.isEmpty(userIds) && ArrayUtils.isEmpty(instantUserIds)) {
return;
}
@@ -18882,7 +18884,8 @@ public class PackageManagerService extends IPackageManager.Stub
* Remove entries from the keystore daemon. Will only remove it if the
* {@code appId} is valid.
*/
- private static void removeKeystoreDataIfNeeded(UserManagerInternal um, int userId, int appId) {
+ private static void removeKeystoreDataIfNeeded(UserManagerInternal um, @UserIdInt int userId,
+ @AppIdInt int appId) {
if (appId < 0) {
return;
}
@@ -18968,7 +18971,7 @@ public class PackageManagerService extends IPackageManager.Stub
}
@Override
- public void getPackageSizeInfo(final String packageName, int userHandle,
+ public void getPackageSizeInfo(final String packageName, int userId,
final IPackageStatsObserver observer) {
throw new UnsupportedOperationException(
"Shame on you for calling the hidden API getPackageSizeInfo(). Shame!");
@@ -22473,24 +22476,24 @@ public class PackageManagerService extends IPackageManager.Stub
}
/** Called by UserManagerService */
- void cleanUpUser(UserManagerService userManager, int userHandle) {
+ void cleanUpUser(UserManagerService userManager, @UserIdInt int userId) {
synchronized (mLock) {
- mDirtyUsers.remove(userHandle);
- mUserNeedsBadging.delete(userHandle);
- mSettings.removeUserLPw(userHandle);
- mPendingBroadcasts.remove(userHandle);
- mInstantAppRegistry.onUserRemovedLPw(userHandle);
- removeUnusedPackagesLPw(userManager, userHandle);
+ mDirtyUsers.remove(userId);
+ mUserNeedsBadging.delete(userId);
+ mSettings.removeUserLPw(userId);
+ mPendingBroadcasts.remove(userId);
+ mInstantAppRegistry.onUserRemovedLPw(userId);
+ removeUnusedPackagesLPw(userManager, userId);
}
}
/**
- * We're removing userHandle and would like to remove any downloaded packages
+ * We're removing userId and would like to remove any downloaded packages
* that are no longer in use by any other user.
- * @param userHandle the user being removed
+ * @param userId the user being removed
*/
@GuardedBy("mLock")
- private void removeUnusedPackagesLPw(UserManagerService userManager, final int userHandle) {
+ private void removeUnusedPackagesLPw(UserManagerService userManager, final int userId) {
final boolean DEBUG_CLEAN_APKS = false;
int [] users = userManager.getUserIds();
Iterator<PackageSetting> psit = mSettings.mPackages.values().iterator();
@@ -22514,7 +22517,7 @@ public class PackageManagerService extends IPackageManager.Stub
}
} else {
for (int i = 0; i < users.length; i++) {
- if (users[i] != userHandle && ps.getInstalled(users[i])) {
+ if (users[i] != userId && ps.getInstalled(users[i])) {
keep = true;
if (DEBUG_CLEAN_APKS) {
Slog.i(TAG, " Keeping package " + packageName + " for user "
@@ -22530,7 +22533,7 @@ public class PackageManagerService extends IPackageManager.Stub
}
//end run
mHandler.post(() -> deletePackageX(packageName, PackageManager.VERSION_CODE_HIGHEST,
- userHandle, 0));
+ userId, 0));
}
}
}
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 1fe551222a06..bece25000990 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -404,10 +404,10 @@ public class UserManagerService extends IUserManager.Stub {
return;
}
final IntentSender target = intent.getParcelableExtra(Intent.EXTRA_INTENT);
- final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_ID, UserHandle.USER_NULL);
+ final int userId = intent.getIntExtra(Intent.EXTRA_USER_ID, UserHandle.USER_NULL);
// Call setQuietModeEnabled on bg thread to avoid ANR
BackgroundThread.getHandler().post(() ->
- setQuietModeEnabled(userHandle, false, target, /* callingPackage */ null));
+ setQuietModeEnabled(userId, false, target, /* callingPackage */ null));
}
};
@@ -482,9 +482,9 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void onStartUser(int userHandle) {
+ public void onStartUser(@UserIdInt int userId) {
synchronized (mUms.mUsersLock) {
- final UserData user = mUms.getUserDataLU(userHandle);
+ final UserData user = mUms.getUserDataLU(userId);
if (user != null) {
user.startRealtime = SystemClock.elapsedRealtime();
}
@@ -492,9 +492,9 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void onUnlockUser(int userHandle) {
+ public void onUnlockUser(@UserIdInt int userId) {
synchronized (mUms.mUsersLock) {
- final UserData user = mUms.getUserDataLU(userHandle);
+ final UserData user = mUms.getUserDataLU(userId);
if (user != null) {
user.unlockRealtime = SystemClock.elapsedRealtime();
}
@@ -502,9 +502,9 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void onStopUser(int userHandle) {
+ public void onStopUser(@UserIdInt int userId) {
synchronized (mUms.mUsersLock) {
- final UserData user = mUms.getUserDataLU(userHandle);
+ final UserData user = mUms.getUserDataLU(userId);
if (user != null) {
user.startRealtime = 0;
user.unlockRealtime = 0;
@@ -610,7 +610,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public String getUserAccount(int userId) {
+ public String getUserAccount(@UserIdInt int userId) {
checkManageUserAndAcrossUsersFullPermission("get user account");
synchronized (mUsersLock) {
return mUsers.get(userId).account;
@@ -618,7 +618,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void setUserAccount(int userId, String accountName) {
+ public void setUserAccount(@UserIdInt int userId, String accountName) {
checkManageUserAndAcrossUsersFullPermission("set user account");
UserData userToUpdate = null;
synchronized (mPackagesLock) {
@@ -676,7 +676,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public List<UserInfo> getProfiles(int userId, boolean enabledOnly) {
+ public List<UserInfo> getProfiles(@UserIdInt int userId, boolean enabledOnly) {
boolean returnFullInfo = true;
if (userId != UserHandle.getCallingUserId()) {
checkManageOrCreateUsersPermission("getting profiles related to user " + userId);
@@ -694,7 +694,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public int[] getProfileIds(int userId, boolean enabledOnly) {
+ public int[] getProfileIds(@UserIdInt int userId, boolean enabledOnly) {
if (userId != UserHandle.getCallingUserId()) {
checkManageOrCreateUsersPermission("getting profiles related to user " + userId);
}
@@ -710,7 +710,8 @@ public class UserManagerService extends IUserManager.Stub {
/** Assume permissions already checked and caller's identity cleared */
@GuardedBy("mUsersLock")
- private List<UserInfo> getProfilesLU(int userId, boolean enabledOnly, boolean fullInfo) {
+ private List<UserInfo> getProfilesLU(@UserIdInt int userId, boolean enabledOnly,
+ boolean fullInfo) {
IntArray profileIds = getProfileIdsLU(userId, enabledOnly);
ArrayList<UserInfo> users = new ArrayList<>(profileIds.size());
for (int i = 0; i < profileIds.size(); i++) {
@@ -733,7 +734,7 @@ public class UserManagerService extends IUserManager.Stub {
* Assume permissions already checked and caller's identity cleared
*/
@GuardedBy("mUsersLock")
- private IntArray getProfileIdsLU(int userId, boolean enabledOnly) {
+ private IntArray getProfileIdsLU(@UserIdInt int userId, boolean enabledOnly) {
UserInfo user = getUserInfoLU(userId);
IntArray result = new IntArray(mUsers.size());
if (user == null) {
@@ -761,28 +762,28 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public int getCredentialOwnerProfile(int userHandle) {
+ public int getCredentialOwnerProfile(@UserIdInt int userId) {
checkManageUsersPermission("get the credential owner");
- if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(userHandle)) {
+ if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {
synchronized (mUsersLock) {
- UserInfo profileParent = getProfileParentLU(userHandle);
+ UserInfo profileParent = getProfileParentLU(userId);
if (profileParent != null) {
return profileParent.id;
}
}
}
- return userHandle;
+ return userId;
}
@Override
- public boolean isSameProfileGroup(int userId, int otherUserId) {
+ public boolean isSameProfileGroup(@UserIdInt int userId, int otherUserId) {
if (userId == otherUserId) return true;
checkManageUsersPermission("check if in the same profile group");
return isSameProfileGroupNoChecks(userId, otherUserId);
}
- private boolean isSameProfileGroupNoChecks(int userId, int otherUserId) {
+ private boolean isSameProfileGroupNoChecks(@UserIdInt int userId, int otherUserId) {
synchronized (mUsersLock) {
UserInfo userInfo = getUserInfoLU(userId);
if (userInfo == null || userInfo.profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) {
@@ -798,27 +799,27 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public UserInfo getProfileParent(int userHandle) {
+ public UserInfo getProfileParent(@UserIdInt int userId) {
checkManageUsersPermission("get the profile parent");
synchronized (mUsersLock) {
- return getProfileParentLU(userHandle);
+ return getProfileParentLU(userId);
}
}
@Override
- public int getProfileParentId(int userHandle) {
+ public int getProfileParentId(@UserIdInt int userId) {
checkManageUsersPermission("get the profile parent");
- return mLocalService.getProfileParentId(userHandle);
+ return mLocalService.getProfileParentId(userId);
}
@GuardedBy("mUsersLock")
- private UserInfo getProfileParentLU(int userHandle) {
- UserInfo profile = getUserInfoLU(userHandle);
+ private UserInfo getProfileParentLU(@UserIdInt int userId) {
+ UserInfo profile = getUserInfoLU(userId);
if (profile == null) {
return null;
}
int parentUserId = profile.profileGroupId;
- if (parentUserId == userHandle || parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
+ if (parentUserId == userId || parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
return null;
} else {
return getUserInfoLU(parentUserId);
@@ -848,7 +849,7 @@ public class UserManagerService extends IUserManager.Stub {
@Override
public boolean requestQuietModeEnabled(@NonNull String callingPackage, boolean enableQuietMode,
- int userHandle, @Nullable IntentSender target) {
+ @UserIdInt int userId, @Nullable IntentSender target) {
Preconditions.checkNotNull(callingPackage);
if (enableQuietMode && target != null) {
@@ -862,17 +863,17 @@ public class UserManagerService extends IUserManager.Stub {
boolean result = false;
if (enableQuietMode) {
setQuietModeEnabled(
- userHandle, true /* enableQuietMode */, target, callingPackage);
+ userId, true /* enableQuietMode */, target, callingPackage);
result = true;
} else {
boolean needToShowConfirmCredential =
- mLockPatternUtils.isSecure(userHandle)
- && !StorageManager.isUserKeyUnlocked(userHandle);
+ mLockPatternUtils.isSecure(userId)
+ && !StorageManager.isUserKeyUnlocked(userId);
if (needToShowConfirmCredential) {
- showConfirmCredentialToDisableQuietMode(userHandle, target);
+ showConfirmCredentialToDisableQuietMode(userId, target);
} else {
setQuietModeEnabled(
- userHandle, false /* enableQuietMode */, target, callingPackage);
+ userId, false /* enableQuietMode */, target, callingPackage);
result = true;
}
}
@@ -922,16 +923,16 @@ public class UserManagerService extends IUserManager.Stub {
+ "default launcher nor has MANAGE_USERS/MODIFY_QUIET_MODE permission");
}
- private void setQuietModeEnabled(int userHandle, boolean enableQuietMode,
+ private void setQuietModeEnabled(@UserIdInt int userId, boolean enableQuietMode,
IntentSender target, @Nullable String callingPackage) {
final UserInfo profile, parent;
final UserData profileUserData;
synchronized (mUsersLock) {
- profile = getUserInfoLU(userHandle);
- parent = getProfileParentLU(userHandle);
+ profile = getUserInfoLU(userId);
+ parent = getProfileParentLU(userId);
if (profile == null || !profile.isManagedProfile()) {
- throw new IllegalArgumentException("User " + userHandle + " is not a profile");
+ throw new IllegalArgumentException("User " + userId + " is not a profile");
}
if (profile.isQuietModeEnabled() == enableQuietMode) {
Slog.i(LOG_TAG, "Quiet mode is already " + enableQuietMode);
@@ -945,17 +946,17 @@ public class UserManagerService extends IUserManager.Stub {
}
try {
if (enableQuietMode) {
- ActivityManager.getService().stopUser(userHandle, /* force */true, null);
+ ActivityManager.getService().stopUser(userId, /* force */true, null);
LocalServices.getService(ActivityManagerInternal.class)
- .killForegroundAppsForUser(userHandle);
+ .killForegroundAppsForUser(userId);
} else {
IProgressListener callback = target != null
? new DisableQuietModeUserUnlockedCallback(target)
: null;
ActivityManager.getService().startUserInBackgroundWithListener(
- userHandle, callback);
+ userId, callback);
}
- logQuietModeEnabled(userHandle, enableQuietMode, callingPackage);
+ logQuietModeEnabled(userId, enableQuietMode, callingPackage);
} catch (RemoteException e) {
// Should not happen, same process.
e.rethrowAsRuntimeException();
@@ -964,11 +965,11 @@ public class UserManagerService extends IUserManager.Stub {
enableQuietMode);
}
- private void logQuietModeEnabled(int userHandle, boolean enableQuietMode,
+ private void logQuietModeEnabled(@UserIdInt int userId, boolean enableQuietMode,
@Nullable String callingPackage) {
UserData userData;
synchronized (mUsersLock) {
- userData = getUserDataLU(userHandle);
+ userData = getUserDataLU(userId);
}
if (userData == null) {
return;
@@ -987,11 +988,11 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean isQuietModeEnabled(int userHandle) {
+ public boolean isQuietModeEnabled(@UserIdInt int userId) {
synchronized (mPackagesLock) {
UserInfo info;
synchronized (mUsersLock) {
- info = getUserInfoLU(userHandle);
+ info = getUserInfoLU(userId);
}
if (info == null || !info.isManagedProfile()) {
return false;
@@ -1004,15 +1005,14 @@ public class UserManagerService extends IUserManager.Stub {
* Show confirm credential screen to unlock user in order to turn off quiet mode.
*/
private void showConfirmCredentialToDisableQuietMode(
- @UserIdInt int userHandle, @Nullable IntentSender target) {
+ @UserIdInt int userId, @Nullable IntentSender target) {
// otherwise, we show a profile challenge to trigger decryption of the user
final KeyguardManager km = (KeyguardManager) mContext.getSystemService(
Context.KEYGUARD_SERVICE);
- // We should use userHandle not credentialOwnerUserId here, as even if it is unified
+ // We should use userId not credentialOwnerUserId here, as even if it is unified
// lock, confirm screenlock page will know and show personal challenge, and unlock
// work profile when personal challenge is correct
- final Intent unlockIntent = km.createConfirmDeviceCredentialIntent(null, null,
- userHandle);
+ final Intent unlockIntent = km.createConfirmDeviceCredentialIntent(null, null, userId);
if (unlockIntent == null) {
return;
}
@@ -1021,7 +1021,7 @@ public class UserManagerService extends IUserManager.Stub {
if (target != null) {
callBackIntent.putExtra(Intent.EXTRA_INTENT, target);
}
- callBackIntent.putExtra(Intent.EXTRA_USER_ID, userHandle);
+ callBackIntent.putExtra(Intent.EXTRA_USER_ID, userId);
callBackIntent.setPackage(mContext.getPackageName());
callBackIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
final PendingIntent pendingIntent = PendingIntent.getBroadcast(
@@ -1039,7 +1039,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void setUserEnabled(int userId) {
+ public void setUserEnabled(@UserIdInt int userId) {
checkManageUsersPermission("enable user");
synchronized (mPackagesLock) {
UserInfo info;
@@ -1054,7 +1054,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void setUserAdmin(int userId) {
+ public void setUserAdmin(@UserIdInt int userId) {
checkManageUserAndAcrossUsersFullPermission("set user admin");
synchronized (mPackagesLock) {
@@ -1097,7 +1097,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public UserInfo getUserInfo(int userId) {
+ public UserInfo getUserInfo(@UserIdInt int userId) {
checkManageOrCreateUsersPermission("query user");
synchronized (mUsersLock) {
return userWithName(getUserInfoLU(userId));
@@ -1128,7 +1128,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean isManagedProfile(int userId) {
+ public boolean isManagedProfile(@UserIdInt int userId) {
checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isManagedProfile");
synchronized (mUsersLock) {
UserInfo userInfo = getUserInfoLU(userId);
@@ -1137,19 +1137,19 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean isUserUnlockingOrUnlocked(int userId) {
+ public boolean isUserUnlockingOrUnlocked(@UserIdInt int userId) {
checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserUnlockingOrUnlocked");
return mLocalService.isUserUnlockingOrUnlocked(userId);
}
@Override
- public boolean isUserUnlocked(int userId) {
+ public boolean isUserUnlocked(@UserIdInt int userId) {
checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserUnlocked");
return mLocalService.isUserUnlocked(userId);
}
@Override
- public boolean isUserRunning(int userId) {
+ public boolean isUserRunning(@UserIdInt int userId) {
checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserRunning");
return mLocalService.isUserRunning(userId);
}
@@ -1190,7 +1190,8 @@ public class UserManagerService extends IUserManager.Stub {
}
}
- private void checkManageOrInteractPermIfCallerInOtherProfileGroup(int userId, String name) {
+ private void checkManageOrInteractPermIfCallerInOtherProfileGroup(@UserIdInt int userId,
+ String name) {
int callingUserId = UserHandle.getCallingUserId();
if (callingUserId == userId || isSameProfileGroupNoChecks(callingUserId, userId) ||
hasManageUsersPermission()) {
@@ -1204,7 +1205,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean isDemoUser(int userId) {
+ public boolean isDemoUser(@UserIdInt int userId) {
int callingUserId = UserHandle.getCallingUserId();
if (callingUserId != userId && !hasManageUsersPermission()) {
throw new SecurityException("You need MANAGE_USERS permission to query if u=" + userId
@@ -1224,7 +1225,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean canHaveRestrictedProfile(int userId) {
+ public boolean canHaveRestrictedProfile(@UserIdInt int userId) {
checkManageUsersPermission("canHaveRestrictedProfile");
synchronized (mUsersLock) {
final UserInfo userInfo = getUserInfoLU(userId);
@@ -1260,7 +1261,7 @@ public class UserManagerService extends IUserManager.Stub {
* Should be locked on mUsers before calling this.
*/
@GuardedBy("mUsersLock")
- private UserInfo getUserInfoLU(int userId) {
+ private UserInfo getUserInfoLU(@UserIdInt int userId) {
final UserData userData = mUsers.get(userId);
// If it is partial and not in the process of being removed, return as unknown user.
if (userData != null && userData.info.partial && !mRemovingUserIds.get(userId)) {
@@ -1271,7 +1272,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@GuardedBy("mUsersLock")
- private UserData getUserDataLU(int userId) {
+ private UserData getUserDataLU(@UserIdInt int userId) {
final UserData userData = mUsers.get(userId);
// If it is partial and not in the process of being removed, return as unknown user.
if (userData != null && userData.info.partial && !mRemovingUserIds.get(userId)) {
@@ -1284,7 +1285,7 @@ public class UserManagerService extends IUserManager.Stub {
* Obtains {@link #mUsersLock} and return UserInfo from mUsers.
* <p>No permissions checking or any addition checks are made</p>
*/
- private UserInfo getUserInfoNoChecks(int userId) {
+ private UserInfo getUserInfoNoChecks(@UserIdInt int userId) {
synchronized (mUsersLock) {
final UserData userData = mUsers.get(userId);
return userData != null ? userData.info : null;
@@ -1295,19 +1296,19 @@ public class UserManagerService extends IUserManager.Stub {
* Obtains {@link #mUsersLock} and return UserData from mUsers.
* <p>No permissions checking or any addition checks are made</p>
*/
- private UserData getUserDataNoChecks(int userId) {
+ private UserData getUserDataNoChecks(@UserIdInt int userId) {
synchronized (mUsersLock) {
return mUsers.get(userId);
}
}
/** Called by PackageManagerService */
- public boolean exists(int userId) {
+ public boolean exists(@UserIdInt int userId) {
return mLocalService.exists(userId);
}
@Override
- public void setUserName(int userId, String name) {
+ public void setUserName(@UserIdInt int userId, String name) {
checkManageUsersPermission("rename users");
boolean changed = false;
synchronized (mPackagesLock) {
@@ -1333,7 +1334,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void setUserIcon(int userId, Bitmap bitmap) {
+ public void setUserIcon(@UserIdInt int userId, Bitmap bitmap) {
checkManageUsersPermission("update users");
if (hasUserRestriction(UserManager.DISALLOW_SET_USER_ICON, userId)) {
Log.w(LOG_TAG, "Cannot set user icon. DISALLOW_SET_USER_ICON is enabled.");
@@ -1344,7 +1345,7 @@ public class UserManagerService extends IUserManager.Stub {
- private void sendUserInfoChangedBroadcast(int userId) {
+ private void sendUserInfoChangedBroadcast(@UserIdInt int userId) {
Intent changedIntent = new Intent(Intent.ACTION_USER_INFO_CHANGED);
changedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
changedIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
@@ -1389,7 +1390,7 @@ public class UserManagerService extends IUserManager.Stub {
return null;
}
- public void makeInitialized(int userId) {
+ public void makeInitialized(@UserIdInt int userId) {
checkManageUsersPermission("makeInitialized");
boolean scheduleWriteUser = false;
UserData userData;
@@ -1447,8 +1448,8 @@ public class UserManagerService extends IUserManager.Stub {
/**
* See {@link UserManagerInternal#setDevicePolicyUserRestrictions}
*/
- private void setDevicePolicyUserRestrictionsInner(int userId, @Nullable Bundle restrictions,
- boolean isDeviceOwner, int cameraRestrictionScope) {
+ private void setDevicePolicyUserRestrictionsInner(@UserIdInt int userId,
+ @Nullable Bundle restrictions, boolean isDeviceOwner, int cameraRestrictionScope) {
final Bundle global = new Bundle();
final Bundle local = new Bundle();
@@ -1505,8 +1506,8 @@ public class UserManagerService extends IUserManager.Stub {
* empty, record is removed from the array.
* @return whether restrictions bundle is different from the old one.
*/
- private boolean updateRestrictionsIfNeededLR(int userId, @Nullable Bundle restrictions,
- SparseArray<Bundle> restrictionsArray) {
+ private boolean updateRestrictionsIfNeededLR(@UserIdInt int userId,
+ @Nullable Bundle restrictions, SparseArray<Bundle> restrictionsArray) {
final boolean changed =
!UserRestrictionsUtils.areEqual(restrictionsArray.get(userId), restrictions);
if (changed) {
@@ -1520,7 +1521,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@GuardedBy("mRestrictionsLock")
- private Bundle computeEffectiveUserRestrictionsLR(int userId) {
+ private Bundle computeEffectiveUserRestrictionsLR(@UserIdInt int userId) {
final Bundle baseRestrictions =
UserRestrictionsUtils.nonNull(mBaseUserRestrictions.get(userId));
final Bundle global = UserRestrictionsUtils.mergeAll(mDevicePolicyGlobalUserRestrictions);
@@ -1538,14 +1539,14 @@ public class UserManagerService extends IUserManager.Stub {
}
@GuardedBy("mRestrictionsLock")
- private void invalidateEffectiveUserRestrictionsLR(int userId) {
+ private void invalidateEffectiveUserRestrictionsLR(@UserIdInt int userId) {
if (DBG) {
Log.d(LOG_TAG, "invalidateEffectiveUserRestrictions userId=" + userId);
}
mCachedEffectiveUserRestrictions.remove(userId);
}
- private Bundle getEffectiveUserRestrictions(int userId) {
+ private Bundle getEffectiveUserRestrictions(@UserIdInt int userId) {
synchronized (mRestrictionsLock) {
Bundle restrictions = mCachedEffectiveUserRestrictions.get(userId);
if (restrictions == null) {
@@ -1558,7 +1559,7 @@ public class UserManagerService extends IUserManager.Stub {
/** @return a specific user restriction that's in effect currently. */
@Override
- public boolean hasUserRestriction(String restrictionKey, int userId) {
+ public boolean hasUserRestriction(String restrictionKey, @UserIdInt int userId) {
return mLocalService.hasUserRestriction(restrictionKey, userId);
}
@@ -1593,7 +1594,7 @@ public class UserManagerService extends IUserManager.Stub {
* and {@link UserManager#RESTRICTION_SOURCE_PROFILE_OWNER}
*/
@Override
- public int getUserRestrictionSource(String restrictionKey, int userId) {
+ public int getUserRestrictionSource(String restrictionKey, @UserIdInt int userId) {
List<EnforcingUser> enforcingUsers = getUserRestrictionSources(restrictionKey, userId);
// Get "bitwise or" of restriction sources for all enforcing users.
int result = UserManager.RESTRICTION_NOT_SET;
@@ -1652,12 +1653,12 @@ public class UserManagerService extends IUserManager.Stub {
* {@link Bundle}.
*/
@Override
- public Bundle getUserRestrictions(int userId) {
+ public Bundle getUserRestrictions(@UserIdInt int userId) {
return UserRestrictionsUtils.clone(getEffectiveUserRestrictions(userId));
}
@Override
- public boolean hasBaseUserRestriction(String restrictionKey, int userId) {
+ public boolean hasBaseUserRestriction(String restrictionKey, @UserIdInt int userId) {
checkManageUsersPermission("hasBaseUserRestriction");
if (!UserRestrictionsUtils.isValidRestriction(restrictionKey)) {
return false;
@@ -1669,7 +1670,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void setUserRestriction(String key, boolean value, int userId) {
+ public void setUserRestriction(String key, boolean value, @UserIdInt int userId) {
checkManageUsersPermission("setUserRestriction");
if (!UserRestrictionsUtils.isValidRestriction(key)) {
return;
@@ -1695,7 +1696,7 @@ public class UserManagerService extends IUserManager.Stub {
*/
@GuardedBy("mRestrictionsLock")
private void updateUserRestrictionsInternalLR(
- @Nullable Bundle newBaseRestrictions, int userId) {
+ @Nullable Bundle newBaseRestrictions, @UserIdInt int userId) {
final Bundle prevAppliedRestrictions = UserRestrictionsUtils.nonNull(
mAppliedUserRestrictions.get(userId));
@@ -1779,7 +1780,7 @@ public class UserManagerService extends IUserManager.Stub {
// Package private for the inner class.
@GuardedBy("mRestrictionsLock")
- void applyUserRestrictionsLR(int userId) {
+ void applyUserRestrictionsLR(@UserIdInt int userId) {
updateUserRestrictionsInternalLR(null, userId);
}
@@ -1831,7 +1832,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean canAddMoreManagedProfiles(int userId, boolean allowedToRemoveOne) {
+ public boolean canAddMoreManagedProfiles(@UserIdInt int userId, boolean allowedToRemoveOne) {
checkManageUsersPermission("check if more managed profiles can be added.");
if (ActivityManager.isLowRamDeviceStatic()) {
return false;
@@ -2661,7 +2662,7 @@ public class UserManagerService extends IUserManager.Stub {
/**
* Removes the app restrictions file for a specific package and user id, if it exists.
*/
- private static void cleanAppRestrictionsForPackageLAr(String pkg, int userId) {
+ private static void cleanAppRestrictionsForPackageLAr(String pkg, @UserIdInt int userId) {
File dir = Environment.getUserSystemDirectory(userId);
File resFile = new File(dir, packageToRestrictionsFileName(pkg));
if (resFile.exists()) {
@@ -2670,23 +2671,23 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public UserInfo createProfileForUser(String name, int flags, int userId,
+ public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userId,
String[] disallowedPackages) {
checkManageOrCreateUsersPermission(flags);
return createUserInternal(name, flags, userId, disallowedPackages);
}
@Override
- public UserInfo createProfileForUserEvenWhenDisallowed(String name, int flags, int userId,
- String[] disallowedPackages) {
+ public UserInfo createProfileForUserEvenWhenDisallowed(String name, int flags,
+ @UserIdInt int userId, String[] disallowedPackages) {
checkManageOrCreateUsersPermission(flags);
return createUserInternalUnchecked(name, flags, userId, disallowedPackages);
}
@Override
- public boolean removeUserEvenWhenDisallowed(@UserIdInt int userHandle) {
+ public boolean removeUserEvenWhenDisallowed(@UserIdInt int userId) {
checkManageOrCreateUsersPermission("Only the system can remove users");
- return removeUserUnchecked(userHandle);
+ return removeUserUnchecked(userId);
}
@Override
@@ -2871,7 +2872,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@VisibleForTesting
- void removeUserInfo(int userId) {
+ void removeUserInfo(@UserIdInt int userId) {
synchronized (mUsers) {
mUsers.remove(userId);
}
@@ -2923,11 +2924,11 @@ public class UserManagerService extends IUserManager.Stub {
/**
* Mark this guest user for deletion to allow us to create another guest
* and switch to that user before actually removing this guest.
- * @param userHandle the userid of the current guest
+ * @param userId the userid of the current guest
* @return whether the user could be marked for deletion
*/
@Override
- public boolean markGuestForDeletion(int userHandle) {
+ public boolean markGuestForDeletion(@UserIdInt int userId) {
checkManageUsersPermission("Only the system can remove users");
if (getUserRestrictions(UserHandle.getCallingUserId()).getBoolean(
UserManager.DISALLOW_REMOVE_USER, false)) {
@@ -2940,8 +2941,8 @@ public class UserManagerService extends IUserManager.Stub {
final UserData userData;
synchronized (mPackagesLock) {
synchronized (mUsersLock) {
- userData = mUsers.get(userHandle);
- if (userHandle == 0 || userData == null || mRemovingUserIds.get(userHandle)) {
+ userData = mUsers.get(userId);
+ if (userId == 0 || userData == null || mRemovingUserIds.get(userId)) {
return false;
}
}
@@ -2968,16 +2969,16 @@ public class UserManagerService extends IUserManager.Stub {
/**
* Removes a user and all data directories created for that user. This method should be called
* after the user's processes have been terminated.
- * @param userHandle the user's id
+ * @param userId the user's id
*/
@Override
- public boolean removeUser(int userHandle) {
- Slog.i(LOG_TAG, "removeUser u" + userHandle);
+ public boolean removeUser(@UserIdInt int userId) {
+ Slog.i(LOG_TAG, "removeUser u" + userId);
checkManageOrCreateUsersPermission("Only the system can remove users");
final boolean isManagedProfile;
synchronized (mUsersLock) {
- UserInfo userInfo = getUserInfoLU(userHandle);
+ UserInfo userInfo = getUserInfoLU(userId);
isManagedProfile = userInfo != null && userInfo.isManagedProfile();
}
String restriction = isManagedProfile
@@ -2986,39 +2987,39 @@ public class UserManagerService extends IUserManager.Stub {
Log.w(LOG_TAG, "Cannot remove user. " + restriction + " is enabled.");
return false;
}
- return removeUserUnchecked(userHandle);
+ return removeUserUnchecked(userId);
}
- private boolean removeUserUnchecked(int userHandle) {
+ private boolean removeUserUnchecked(@UserIdInt int userId) {
long ident = Binder.clearCallingIdentity();
try {
final UserData userData;
int currentUser = ActivityManager.getCurrentUser();
- if (currentUser == userHandle) {
+ if (currentUser == userId) {
Log.w(LOG_TAG, "Current user cannot be removed.");
return false;
}
synchronized (mPackagesLock) {
synchronized (mUsersLock) {
- userData = mUsers.get(userHandle);
- if (userHandle == UserHandle.USER_SYSTEM) {
+ userData = mUsers.get(userId);
+ if (userId == UserHandle.USER_SYSTEM) {
Log.e(LOG_TAG, "System user cannot be removed.");
return false;
}
if (userData == null) {
Log.e(LOG_TAG, String.format(
- "Cannot remove user %d, invalid user id provided.", userHandle));
+ "Cannot remove user %d, invalid user id provided.", userId));
return false;
}
- if (mRemovingUserIds.get(userHandle)) {
+ if (mRemovingUserIds.get(userId)) {
Log.e(LOG_TAG, String.format(
- "User %d is already scheduled for removal.", userHandle));
+ "User %d is already scheduled for removal.", userId));
return false;
}
- addRemovingUserIdLocked(userHandle);
+ addRemovingUserIdLocked(userId);
}
// Set this to a partially created user, so that the user will be purged
@@ -3031,7 +3032,7 @@ public class UserManagerService extends IUserManager.Stub {
writeUserLP(userData);
}
try {
- mAppOpsService.removeUser(userHandle);
+ mAppOpsService.removeUser(userId);
} catch (RemoteException e) {
Log.w(LOG_TAG, "Unable to notify AppOpsService of removing user.", e);
}
@@ -3043,17 +3044,17 @@ public class UserManagerService extends IUserManager.Stub {
sendProfileRemovedBroadcast(userData.info.profileGroupId, userData.info.id);
}
- if (DBG) Slog.i(LOG_TAG, "Stopping user " + userHandle);
+ if (DBG) Slog.i(LOG_TAG, "Stopping user " + userId);
int res;
try {
- res = ActivityManager.getService().stopUser(userHandle, /* force= */ true,
+ res = ActivityManager.getService().stopUser(userId, /* force= */ true,
new IStopUserCallback.Stub() {
@Override
- public void userStopped(int userId) {
- finishRemoveUser(userId);
+ public void userStopped(int userIdParam) {
+ finishRemoveUser(userIdParam);
}
@Override
- public void userStopAborted(int userId) {
+ public void userStopAborted(int userIdParam) {
}
});
} catch (RemoteException e) {
@@ -3068,7 +3069,7 @@ public class UserManagerService extends IUserManager.Stub {
@GuardedBy("mUsersLock")
@VisibleForTesting
- void addRemovingUserIdLocked(int userId) {
+ void addRemovingUserIdLocked(@UserIdInt int userId) {
// We remember deleted user IDs to prevent them from being
// reused during the current boot; they can still be reused
// after a reboot or recycling of userIds.
@@ -3080,14 +3081,14 @@ public class UserManagerService extends IUserManager.Stub {
}
}
- void finishRemoveUser(final int userHandle) {
- if (DBG) Slog.i(LOG_TAG, "finishRemoveUser " + userHandle);
+ void finishRemoveUser(final @UserIdInt int userId) {
+ if (DBG) Slog.i(LOG_TAG, "finishRemoveUser " + userId);
// Let other services shutdown any activity and clean up their state before completely
// wiping the user's system directory and removing from the user list
long ident = Binder.clearCallingIdentity();
try {
Intent addedIntent = new Intent(Intent.ACTION_USER_REMOVED);
- addedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userHandle);
+ addedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
mContext.sendOrderedBroadcastAsUser(addedIntent, UserHandle.ALL,
android.Manifest.permission.MANAGE_USERS,
@@ -3097,15 +3098,15 @@ public class UserManagerService extends IUserManager.Stub {
if (DBG) {
Slog.i(LOG_TAG,
"USER_REMOVED broadcast sent, cleaning up user data "
- + userHandle);
+ + userId);
}
new Thread() {
@Override
public void run() {
// Clean up any ActivityTaskManager state
LocalServices.getService(ActivityTaskManagerInternal.class)
- .onUserStopped(userHandle);
- removeUserState(userHandle);
+ .onUserStopped(userId);
+ removeUserState(userId);
}
}.start();
}
@@ -3117,47 +3118,46 @@ public class UserManagerService extends IUserManager.Stub {
}
}
- private void removeUserState(final int userHandle) {
+ private void removeUserState(final @UserIdInt int userId) {
try {
- mContext.getSystemService(StorageManager.class).destroyUserKey(userHandle);
+ mContext.getSystemService(StorageManager.class).destroyUserKey(userId);
} catch (IllegalStateException e) {
// This may be simply because the user was partially created.
- Slog.i(LOG_TAG,
- "Destroying key for user " + userHandle + " failed, continuing anyway", e);
+ Slog.i(LOG_TAG, "Destroying key for user " + userId + " failed, continuing anyway", e);
}
// Cleanup gatekeeper secure user id
try {
final IGateKeeperService gk = GateKeeper.getService();
if (gk != null) {
- gk.clearSecureUserId(userHandle);
+ gk.clearSecureUserId(userId);
}
} catch (Exception ex) {
Slog.w(LOG_TAG, "unable to clear GK secure user id");
}
// Cleanup package manager settings
- mPm.cleanUpUser(this, userHandle);
+ mPm.cleanUpUser(this, userId);
// Clean up all data before removing metadata
- mUserDataPreparer.destroyUserData(userHandle,
+ mUserDataPreparer.destroyUserData(userId,
StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE);
// Remove this user from the list
synchronized (mUsersLock) {
- mUsers.remove(userHandle);
- mIsUserManaged.delete(userHandle);
+ mUsers.remove(userId);
+ mIsUserManaged.delete(userId);
}
synchronized (mUserStates) {
- mUserStates.delete(userHandle);
+ mUserStates.delete(userId);
}
synchronized (mRestrictionsLock) {
- mBaseUserRestrictions.remove(userHandle);
- mAppliedUserRestrictions.remove(userHandle);
- mCachedEffectiveUserRestrictions.remove(userHandle);
- mDevicePolicyLocalUserRestrictions.remove(userHandle);
- if (mDevicePolicyGlobalUserRestrictions.get(userHandle) != null) {
- mDevicePolicyGlobalUserRestrictions.remove(userHandle);
+ mBaseUserRestrictions.remove(userId);
+ mAppliedUserRestrictions.remove(userId);
+ mCachedEffectiveUserRestrictions.remove(userId);
+ mDevicePolicyLocalUserRestrictions.remove(userId);
+ if (mDevicePolicyGlobalUserRestrictions.get(userId) != null) {
+ mDevicePolicyGlobalUserRestrictions.remove(userId);
applyUserRestrictionsForAllUsersLR();
}
}
@@ -3166,12 +3166,12 @@ public class UserManagerService extends IUserManager.Stub {
writeUserListLP();
}
// Remove user file
- AtomicFile userFile = new AtomicFile(new File(mUsersDir, userHandle + XML_SUFFIX));
+ AtomicFile userFile = new AtomicFile(new File(mUsersDir, userId + XML_SUFFIX));
userFile.delete();
updateUserIds();
if (RELEASE_DELETED_USER_ID) {
synchronized (mUsers) {
- mRemovingUserIds.delete(userHandle);
+ mRemovingUserIds.delete(userId);
}
}
}
@@ -3191,7 +3191,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public Bundle getApplicationRestrictionsForUser(String packageName, int userId) {
+ public Bundle getApplicationRestrictionsForUser(String packageName, @UserIdInt int userId) {
if (UserHandle.getCallingUserId() != userId
|| !UserHandle.isSameApp(Binder.getCallingUid(), getUidForPackage(packageName))) {
checkSystemOrRoot("get application restrictions for other user/app " + packageName);
@@ -3204,7 +3204,7 @@ public class UserManagerService extends IUserManager.Stub {
@Override
public void setApplicationRestrictions(String packageName, Bundle restrictions,
- int userId) {
+ @UserIdInt int userId) {
checkSystemOrRoot("set application restrictions");
if (restrictions != null) {
restrictions.setDefusable(true);
@@ -3238,7 +3238,8 @@ public class UserManagerService extends IUserManager.Stub {
}
@GuardedBy("mAppRestrictionsLock")
- private static Bundle readApplicationRestrictionsLAr(String packageName, int userId) {
+ private static Bundle readApplicationRestrictionsLAr(String packageName,
+ @UserIdInt int userId) {
AtomicFile restrictionsFile =
new AtomicFile(new File(Environment.getUserSystemDirectory(userId),
packageToRestrictionsFileName(packageName)));
@@ -3332,7 +3333,7 @@ public class UserManagerService extends IUserManager.Stub {
@GuardedBy("mAppRestrictionsLock")
private static void writeApplicationRestrictionsLAr(String packageName,
- Bundle restrictions, int userId) {
+ Bundle restrictions, @UserIdInt int userId) {
AtomicFile restrictionsFile = new AtomicFile(
new File(Environment.getUserSystemDirectory(userId),
packageToRestrictionsFileName(packageName)));
@@ -3410,17 +3411,17 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public int getUserSerialNumber(int userHandle) {
+ public int getUserSerialNumber(@UserIdInt int userId) {
synchronized (mUsersLock) {
- final UserInfo userInfo = getUserInfoLU(userHandle);
+ final UserInfo userInfo = getUserInfoLU(userId);
return userInfo != null ? userInfo.serialNumber : -1;
}
}
@Override
- public boolean isUserNameSet(int userHandle) {
+ public boolean isUserNameSet(@UserIdInt int userId) {
synchronized (mUsersLock) {
- final UserInfo userInfo = getUserInfoLU(userHandle);
+ final UserInfo userInfo = getUserInfoLU(userId);
return userInfo != null && userInfo.name != null;
}
}
@@ -3438,21 +3439,21 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public long getUserCreationTime(int userHandle) {
+ public long getUserCreationTime(@UserIdInt int userId) {
int callingUserId = UserHandle.getCallingUserId();
UserInfo userInfo = null;
synchronized (mUsersLock) {
- if (callingUserId == userHandle) {
- userInfo = getUserInfoLU(userHandle);
+ if (callingUserId == userId) {
+ userInfo = getUserInfoLU(userId);
} else {
- UserInfo parent = getProfileParentLU(userHandle);
+ UserInfo parent = getProfileParentLU(userId);
if (parent != null && parent.id == callingUserId) {
- userInfo = getUserInfoLU(userHandle);
+ userInfo = getUserInfoLU(userId);
}
}
}
if (userInfo == null) {
- throw new SecurityException("userHandle can only be the calling user or a managed "
+ throw new SecurityException("userId can only be the calling user or a managed "
+ "profile associated with this user");
}
return userInfo.creationTime;
@@ -3485,7 +3486,7 @@ public class UserManagerService extends IUserManager.Stub {
* Called right before a user is started. This gives us a chance to prepare
* app storage and apply any user restrictions.
*/
- public void onBeforeStartUser(int userId) {
+ public void onBeforeStartUser(@UserIdInt int userId) {
UserInfo userInfo = getUserInfo(userId);
if (userInfo == null) {
return;
@@ -3600,7 +3601,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void setSeedAccountData(int userId, String accountName, String accountType,
+ public void setSeedAccountData(@UserIdInt int userId, String accountName, String accountType,
PersistableBundle accountOptions, boolean persist) {
checkManageUsersPermission("Require MANAGE_USERS permission to set user seed data");
synchronized (mPackagesLock) {
@@ -3881,20 +3882,20 @@ public class UserManagerService extends IUserManager.Stub {
* @param userId
* @return whether the user has been initialized yet
*/
- boolean isUserInitialized(int userId) {
+ boolean isUserInitialized(@UserIdInt int userId) {
return mLocalService.isUserInitialized(userId);
}
private class LocalService extends UserManagerInternal {
@Override
- public void setDevicePolicyUserRestrictions(int userId, @Nullable Bundle restrictions,
- boolean isDeviceOwner, int cameraRestrictionScope) {
+ public void setDevicePolicyUserRestrictions(@UserIdInt int userId,
+ @Nullable Bundle restrictions, boolean isDeviceOwner, int cameraRestrictionScope) {
UserManagerService.this.setDevicePolicyUserRestrictionsInner(userId, restrictions,
isDeviceOwner, cameraRestrictionScope);
}
@Override
- public Bundle getBaseUserRestrictions(int userId) {
+ public Bundle getBaseUserRestrictions(@UserIdInt int userId) {
synchronized (mRestrictionsLock) {
return mBaseUserRestrictions.get(userId);
}
@@ -3902,7 +3903,7 @@ public class UserManagerService extends IUserManager.Stub {
@Override
public void setBaseUserRestrictionsByDpmsForMigration(
- int userId, Bundle baseRestrictions) {
+ @UserIdInt int userId, Bundle baseRestrictions) {
synchronized (mRestrictionsLock) {
if (updateRestrictionsIfNeededLR(
userId, new Bundle(baseRestrictions), mBaseUserRestrictions)) {
@@ -3921,7 +3922,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean getUserRestriction(int userId, String key) {
+ public boolean getUserRestriction(@UserIdInt int userId, String key) {
return getUserRestrictions(userId).getBoolean(key);
}
@@ -3947,14 +3948,14 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void setUserManaged(int userId, boolean isManaged) {
+ public void setUserManaged(@UserIdInt int userId, boolean isManaged) {
synchronized (mUsersLock) {
mIsUserManaged.put(userId, isManaged);
}
}
@Override
- public void setUserIcon(int userId, Bitmap bitmap) {
+ public void setUserIcon(@UserIdInt int userId, Bitmap bitmap) {
long ident = Binder.clearCallingIdentity();
try {
synchronized (mPackagesLock) {
@@ -4011,7 +4012,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public void onEphemeralUserStop(int userId) {
+ public void onEphemeralUserStop(@UserIdInt int userId) {
synchronized (mUsersLock) {
UserInfo userInfo = getUserInfoLU(userId);
if (userInfo != null && userInfo.isEphemeral()) {
@@ -4040,26 +4041,26 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean removeUserEvenWhenDisallowed(int userId) {
+ public boolean removeUserEvenWhenDisallowed(@UserIdInt int userId) {
return removeUserUnchecked(userId);
}
@Override
- public boolean isUserRunning(int userId) {
+ public boolean isUserRunning(@UserIdInt int userId) {
synchronized (mUserStates) {
return mUserStates.get(userId, -1) >= 0;
}
}
@Override
- public void setUserState(int userId, int userState) {
+ public void setUserState(@UserIdInt int userId, int userState) {
synchronized (mUserStates) {
mUserStates.put(userId, userState);
}
}
@Override
- public void removeUserState(int userId) {
+ public void removeUserState(@UserIdInt int userId) {
synchronized (mUserStates) {
mUserStates.delete(userId);
}
@@ -4071,7 +4072,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean isUserUnlockingOrUnlocked(int userId) {
+ public boolean isUserUnlockingOrUnlocked(@UserIdInt int userId) {
int state;
synchronized (mUserStates) {
state = mUserStates.get(userId, -1);
@@ -4085,7 +4086,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean isUserUnlocked(int userId) {
+ public boolean isUserUnlocked(@UserIdInt int userId) {
int state;
synchronized (mUserStates) {
state = mUserStates.get(userId, -1);
@@ -4098,12 +4099,12 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean isUserInitialized(int userId) {
+ public boolean isUserInitialized(@UserIdInt int userId) {
return (getUserInfo(userId).flags & UserInfo.FLAG_INITIALIZED) != 0;
}
@Override
- public boolean exists(int userId) {
+ public boolean exists(@UserIdInt int userId) {
return getUserInfoNoChecks(userId) != null;
}
@@ -4147,7 +4148,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public int getProfileParentId(int userId) {
+ public int getProfileParentId(@UserIdInt int userId) {
synchronized (mUsersLock) {
UserInfo profileParent = getProfileParentLU(userId);
if (profileParent == null) {
@@ -4165,7 +4166,7 @@ public class UserManagerService extends IUserManager.Stub {
}
@Override
- public boolean hasUserRestriction(String restrictionKey, int userId) {
+ public boolean hasUserRestriction(String restrictionKey, @UserIdInt int userId) {
if (!UserRestrictionsUtils.isValidRestriction(restrictionKey)) {
return false;
}
@@ -4263,7 +4264,7 @@ public class UserManagerService extends IUserManager.Stub {
* @param userId The parent user
* @return
*/
- boolean hasManagedProfile(int userId) {
+ boolean hasManagedProfile(@UserIdInt int userId) {
synchronized (mUsersLock) {
UserInfo userInfo = getUserInfoLU(userId);
final int userSize = mUsers.size();