Methods Summary |
---|
public int | describeContents()
return 0;
|
public boolean | equals(java.lang.Object obj)
try {
if (obj != null) {
UserHandle other = (UserHandle)obj;
return mHandle == other.mHandle;
}
} catch (ClassCastException e) {
}
return false;
|
public static void | formatUid(java.lang.StringBuilder sb, int uid)Generate a text representation of the uid, breaking out its individual
components -- user, app, isolated, etc.
if (uid < Process.FIRST_APPLICATION_UID) {
sb.append(uid);
} else {
sb.append('u");
sb.append(getUserId(uid));
final int appId = getAppId(uid);
if (appId >= Process.FIRST_ISOLATED_UID && appId <= Process.LAST_ISOLATED_UID) {
sb.append('i");
sb.append(appId - Process.FIRST_ISOLATED_UID);
} else if (appId >= Process.FIRST_APPLICATION_UID) {
sb.append('a");
sb.append(appId - Process.FIRST_APPLICATION_UID);
} else {
sb.append('s");
sb.append(appId);
}
}
|
public static void | formatUid(java.io.PrintWriter pw, int uid)Generate a text representation of the uid, breaking out its individual
components -- user, app, isolated, etc.
if (uid < Process.FIRST_APPLICATION_UID) {
pw.print(uid);
} else {
pw.print('u");
pw.print(getUserId(uid));
final int appId = getAppId(uid);
if (appId >= Process.FIRST_ISOLATED_UID && appId <= Process.LAST_ISOLATED_UID) {
pw.print('i");
pw.print(appId - Process.FIRST_ISOLATED_UID);
} else if (appId >= Process.FIRST_APPLICATION_UID) {
pw.print('a");
pw.print(appId - Process.FIRST_APPLICATION_UID);
} else {
pw.print('s");
pw.print(appId);
}
}
|
public static final int | getAppId(int uid)Returns the app id (or base uid) for a given uid, stripping out the user id from it.
return uid % PER_USER_RANGE;
|
public static final android.os.UserHandle | getCallingUserHandle()
int userId = getUserId(Binder.getCallingUid());
UserHandle userHandle = userHandles.get(userId);
// Intentionally not synchronized to save time
if (userHandle == null) {
userHandle = new UserHandle(userId);
userHandles.put(userId, userHandle);
}
return userHandle;
|
public static final int | getCallingUserId()
return getUserId(Binder.getCallingUid());
|
public int | getIdentifier()Returns the userId stored in this UserHandle.
return mHandle;
|
public static final int | getSharedAppGid(int id)Returns the shared app gid for a given uid or appId.
return Process.FIRST_SHARED_APPLICATION_GID + (id % PER_USER_RANGE)
- Process.FIRST_APPLICATION_UID;
|
public static final int | getUid(int userId, int appId)Returns the uid that is composed from the userId and the appId.
if (MU_ENABLED) {
return userId * PER_USER_RANGE + (appId % PER_USER_RANGE);
} else {
return appId;
}
|
public static final int | getUserGid(int userId)Returns the gid shared between all apps with this userId.
return getUid(userId, Process.SHARED_USER_GID);
|
public static final int | getUserId(int uid)Returns the user id for a given uid.
if (MU_ENABLED) {
return uid / PER_USER_RANGE;
} else {
return 0;
}
|
public int | hashCode()
return mHandle;
|
public static boolean | isApp(int uid)
if (uid > 0) {
final int appId = getAppId(uid);
return appId >= Process.FIRST_APPLICATION_UID && appId <= Process.LAST_APPLICATION_UID;
} else {
return false;
}
|
public static final boolean | isIsolated(int uid)
if (uid > 0) {
final int appId = getAppId(uid);
return appId >= Process.FIRST_ISOLATED_UID && appId <= Process.LAST_ISOLATED_UID;
} else {
return false;
}
|
public final boolean | isOwner()Returns true if this UserHandle refers to the owner user; false otherwise.
return this.equals(OWNER);
|
public static final boolean | isSameApp(int uid1, int uid2)Checks to see if both uids are referring to the same app id, ignoring the user id part of the
uids.
return getAppId(uid1) == getAppId(uid2);
|
public static final boolean | isSameUser(int uid1, int uid2)Checks to see if the user id is the same for the two uids, i.e., they belong to the same
user.
return getUserId(uid1) == getUserId(uid2);
|
public static final int | myUserId()Returns the user id of the current process
return getUserId(Process.myUid());
|
public static android.os.UserHandle | readFromParcel(Parcel in)Read a UserHandle from a Parcel that was previously written
with {@link #writeToParcel(UserHandle, Parcel)}, returning either
a null or new object as appropriate.
int h = in.readInt();
return h != USER_NULL ? new UserHandle(h) : null;
|
public java.lang.String | toString()
return "UserHandle{" + mHandle + "}";
|
public void | writeToParcel(Parcel out, int flags)
out.writeInt(mHandle);
|
public static void | writeToParcel(android.os.UserHandle h, Parcel out)Write a UserHandle to a Parcel, handling null pointers. Must be
read with {@link #readFromParcel(Parcel)}.
if (h != null) {
h.writeToParcel(out, 0);
} else {
out.writeInt(USER_NULL);
}
|