/** @hide */ 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; } }
/** * Checks to see if both uids are referring to the same app id, ignoring the user id part of the * uids. * @param uid1 vuid to compare * @param uid2 other vuid to compare * @return whether the appId is the same for both uids * @hide */ public static final boolean isSameApp(int uid1, int uid2) { return getAppId(uid1) == getAppId(uid2); }
/** @hide */ public static final boolean isIsolated(int uid) { if (uid > 0) { final int appId = getAppId(uid); return appId >= FIRST_ISOLATED_UID && appId <= LAST_ISOLATED_UID; } else { return false; } }
public int getBaseVUid() { return VUserHandle.getAppId(vuid); }
@Override public String getNameForUid(int uid) { int appId = VUserHandle.getAppId(uid); synchronized (mPackages) { for (VPackage p : mPackages.values()) { PackageSetting ps = (PackageSetting) p.mExtras; if (ps.appId == appId) { return ps.packageName; } } return null; } }
/** * Returns the app id for a given shared app gid. * @hide */ public static int getAppIdFromSharedAppGid(int gid) { final int noUserGid = getAppId(gid); if (noUserGid < FIRST_SHARED_APPLICATION_GID || noUserGid > LAST_SHARED_APPLICATION_GID) { throw new IllegalArgumentException(Integer.toString(gid) + " is not a shared app gid"); } return (noUserGid + Process.FIRST_APPLICATION_UID) - FIRST_SHARED_APPLICATION_GID; }
public static int getBaseCallingUid() { return VUserHandle.getAppId(getCallingUid()); }
public static void formatUid(StringBuilder sb, int uid) { if (uid < Process.FIRST_APPLICATION_UID) { sb.append(uid); } else { sb.append('u'); sb.append(getUserId(uid)); final int appId = getAppId(uid); if (appId >= FIRST_ISOLATED_UID && appId <= LAST_ISOLATED_UID) { sb.append('i'); sb.append(appId - 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); } } }
/** * Generate a text representation of the vuid, breaking out its individual * components -- user, app, isolated, etc. * @hide */ public static void formatUid(PrintWriter pw, int uid) { if (uid < Process.FIRST_APPLICATION_UID) { pw.print(uid); } else { pw.print('u'); pw.print(getUserId(uid)); final int appId = getAppId(uid); if (appId >= FIRST_ISOLATED_UID && appId <= LAST_ISOLATED_UID) { pw.print('i'); pw.print(appId - 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); } } }
@Override public Object call(Object who, Method method, Object... args) throws Throwable { String pkgName = (String) args[0]; if (pkgName.equals(getHostPkg())) { return method.invoke(who, args); } int uid = VPackageManager.get().getPackageUid(pkgName, 0); return VUserHandle.getAppId(uid); }
public static int myAppId() { return getAppId(VClientImpl.get().getVUid()); }
@Override public VParceledListSlice<ProviderInfo> queryContentProviders(String processName, int vuid, int flags) { int userId = VUserHandle.getUserId(vuid); checkUserId(userId); flags = updateFlagsNought(flags); ArrayList<ProviderInfo> finalList = new ArrayList<>(3); // reader synchronized (mPackages) { for (VPackage.ProviderComponent p : mProvidersByComponent.values()) { PackageSetting ps = (PackageSetting) p.owner.mExtras; if (processName == null || ps.appId == VUserHandle.getAppId(vuid) && p.info.processName.equals(processName)) { ProviderInfo providerInfo = PackageParserEx.generateProviderInfo(p, flags, ps.readUserState(userId), userId); finalList.add(providerInfo); } } } if (!finalList.isEmpty()) { Collections.sort(finalList, sProviderInitOrderSorter); } return new VParceledListSlice<>(finalList); }
@Override public synchronized Object call(Object who, Method method, Object... args) throws Throwable { List<ActivityManager.RunningAppProcessInfo> infoList = (List<ActivityManager.RunningAppProcessInfo>) method .invoke(who, args); if (infoList != null) { for (ActivityManager.RunningAppProcessInfo info : infoList) { if (VActivityManager.get().isAppPid(info.pid)) { List<String> pkgList = VActivityManager.get().getProcessPkgList(info.pid); String processName = VActivityManager.get().getAppProcessName(info.pid); if (processName != null) { info.processName = processName; } info.pkgList = pkgList.toArray(new String[pkgList.size()]); info.uid = VUserHandle.getAppId(VActivityManager.get().getUidByPid(info.pid)); } } } return infoList; } }
public static int onGetCallingUid(int originUid) { int callingPid = Binder.getCallingPid(); if (callingPid == Process.myPid()) { return VClientImpl.get().getBaseVUid(); } if (callingPid == VirtualCore.get().getSystemPid()) { return Process.SYSTEM_UID; } int vuid = VActivityManager.get().getUidByPid(callingPid); if (vuid != -1) { return VUserHandle.getAppId(vuid); } VLog.w(TAG, String.format("Unknown uid: %s", callingPid)); return VClientImpl.get().getBaseVUid(); }
ps.libPath = libDir.getPath(); ps.packageName = pkg.packageName; ps.appId = VUserHandle.getAppId(mUidSystem.getOrCreateUid(pkg)); if (res.isUpdate) { ps.lastUpdateTime = installTime;
/** * Checks to see if both uids are referring to the same app id, ignoring the user id part of the * uids. * @param uid1 vuid to compare * @param uid2 other vuid to compare * @return whether the appId is the same for both uids * @hide */ public static final boolean isSameApp(int uid1, int uid2) { return getAppId(uid1) == getAppId(uid2); }
/** * Checks to see if both uids are referring to the same app id, ignoring the user id part of the * uids. * @param uid1 vuid to compare * @param uid2 other vuid to compare * @return whether the appId is the same for both uids * @hide */ public static final boolean isSameApp(int uid1, int uid2) { return getAppId(uid1) == getAppId(uid2); }
/** @hide */ public static final boolean isIsolated(int uid) { if (uid > 0) { final int appId = getAppId(uid); return appId >= FIRST_ISOLATED_UID && appId <= LAST_ISOLATED_UID; } else { return false; } }
/** * Returns the app id for a given shared app gid. * @hide */ public static int getAppIdFromSharedAppGid(int gid) { final int noUserGid = getAppId(gid); if (noUserGid < FIRST_SHARED_APPLICATION_GID || noUserGid > LAST_SHARED_APPLICATION_GID) { throw new IllegalArgumentException(Integer.toString(gid) + " is not a shared app gid"); } return (noUserGid + Process.FIRST_APPLICATION_UID) - FIRST_SHARED_APPLICATION_GID; }
@Override public Object call(Object who, Method method, Object... args) throws Throwable { String pkgName = (String) args[0]; if (pkgName.equals(getHostPkg())) { return method.invoke(who, args); } int uid = VPackageManager.get().getPackageUid(pkgName, 0); return VUserHandle.getAppId(uid); }