Merge "Rename pmInternal#getPackageUidInternal (1/4)"
This commit is contained in:
@@ -301,25 +301,12 @@ public abstract class PackageManagerInternal {
|
||||
public abstract @PackageManager.DistractionRestriction int getDistractingPackageRestrictions(
|
||||
String packageName, int userId);
|
||||
|
||||
/**
|
||||
* Do a straight uid lookup for the given package/application in the given user. This enforces
|
||||
* app visibility rules and permissions. Call {@link #getPackageUidInternal} for the internal
|
||||
* implementation.
|
||||
* @deprecated Use {@link PackageManager#getPackageUid(String, int)}
|
||||
* @return The app's uid, or < 0 if the package was not found in that user
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract int getPackageUid(String packageName,
|
||||
@PackageInfoFlags int flags, int userId);
|
||||
|
||||
/**
|
||||
* Do a straight uid lookup for the given package/application in the given user.
|
||||
* @see PackageManager#getPackageUidAsUser(String, int, int)
|
||||
* @return The app's uid, or < 0 if the package was not found in that user
|
||||
* TODO(b/148235092): rename this to getPackageUid
|
||||
*/
|
||||
public abstract int getPackageUidInternal(String packageName,
|
||||
@PackageInfoFlags int flags, int userId);
|
||||
public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags, int userId);
|
||||
|
||||
/**
|
||||
* Retrieve all of the information we know about a particular package/application.
|
||||
|
||||
@@ -2160,7 +2160,7 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
Slog.i(TAG, "Remounting storage for pid: " + pid);
|
||||
final String[] sharedPackages =
|
||||
mPmInternal.getSharedUserPackagesForPackage(packageName, userId);
|
||||
final int uid = mPmInternal.getPackageUidInternal(packageName, 0, userId);
|
||||
final int uid = mPmInternal.getPackageUid(packageName, 0 /* flags */, userId);
|
||||
final String[] packages =
|
||||
sharedPackages.length != 0 ? sharedPackages : new String[]{packageName};
|
||||
try {
|
||||
|
||||
@@ -605,7 +605,7 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
|
||||
private boolean isPlatformSignedAppWithAutomaticProfilesPermission(
|
||||
String packageName, int[] profileIds) {
|
||||
for (int userId : profileIds) {
|
||||
final int uid = mInjector.getPackageManagerInternal().getPackageUidInternal(
|
||||
final int uid = mInjector.getPackageManagerInternal().getPackageUid(
|
||||
packageName, /* flags= */ 0, userId);
|
||||
if (uid == -1) {
|
||||
continue;
|
||||
|
||||
@@ -24603,12 +24603,6 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
|
||||
@Override
|
||||
public int getPackageUid(String packageName, int flags, int userId) {
|
||||
return PackageManagerService.this
|
||||
.getPackageUid(packageName, flags, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPackageUidInternal(String packageName, int flags, int userId) {
|
||||
return PackageManagerService.this
|
||||
.getPackageUidInternal(packageName, flags, userId, Process.SYSTEM_UID);
|
||||
}
|
||||
|
||||
@@ -3301,7 +3301,7 @@ public class ShortcutService extends IShortcutService.Stub {
|
||||
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
int packageUid = mPackageManagerInternal.getPackageUidInternal(packageName,
|
||||
int packageUid = mPackageManagerInternal.getPackageUid(packageName,
|
||||
PackageManager.MATCH_DIRECT_BOOT_AUTO, userId);
|
||||
// Grant read uri permission to the caller on behalf of the shortcut owner. All
|
||||
// granted permissions are revoked when the default launcher changes, or when
|
||||
|
||||
@@ -258,7 +258,7 @@ public class UriGrantsManagerService extends IUriGrantsManager.Stub {
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
final int callingUserId = UserHandle.getUserId(callingUid);
|
||||
final PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
|
||||
final int packageUid = pm.getPackageUidInternal(packageName,
|
||||
final int packageUid = pm.getPackageUid(packageName,
|
||||
MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE, callingUserId);
|
||||
if (packageUid != callingUid) {
|
||||
throw new SecurityException(
|
||||
@@ -336,7 +336,7 @@ public class UriGrantsManagerService extends IUriGrantsManager.Stub {
|
||||
if (toPackage != null) {
|
||||
mAmInternal.enforceCallingPermission(FORCE_PERSISTABLE_URI_PERMISSIONS,
|
||||
"takePersistableUriPermission");
|
||||
uid = mPmInternal.getPackageUidInternal(toPackage, 0, userId);
|
||||
uid = mPmInternal.getPackageUid(toPackage, 0 /* flags */, userId);
|
||||
} else {
|
||||
enforceNotIsolatedCaller("takePersistableUriPermission");
|
||||
uid = Binder.getCallingUid();
|
||||
@@ -401,7 +401,7 @@ public class UriGrantsManagerService extends IUriGrantsManager.Stub {
|
||||
if (toPackage != null) {
|
||||
mAmInternal.enforceCallingPermission(FORCE_PERSISTABLE_URI_PERMISSIONS,
|
||||
"releasePersistableUriPermission");
|
||||
uid = mPmInternal.getPackageUidInternal(toPackage, 0, userId);
|
||||
uid = mPmInternal.getPackageUid(toPackage, 0 /* flags */ , userId);
|
||||
} else {
|
||||
enforceNotIsolatedCaller("releasePersistableUriPermission");
|
||||
uid = Binder.getCallingUid();
|
||||
@@ -600,7 +600,7 @@ public class UriGrantsManagerService extends IUriGrantsManager.Stub {
|
||||
if (needed != null) {
|
||||
targetUid = needed.targetUid;
|
||||
} else {
|
||||
targetUid = mPmInternal.getPackageUidInternal(targetPkg, MATCH_DEBUG_TRIAGED_MISSING,
|
||||
targetUid = mPmInternal.getPackageUid(targetPkg, MATCH_DEBUG_TRIAGED_MISSING,
|
||||
targetUserId);
|
||||
if (targetUid < 0) {
|
||||
if (DEBUG) Slog.v(TAG, "Can't grant URI permission no uid for: " + targetPkg
|
||||
@@ -690,7 +690,7 @@ public class UriGrantsManagerService extends IUriGrantsManager.Stub {
|
||||
final ProviderInfo pi = getProviderInfo(uri.getAuthority(), sourceUserId,
|
||||
MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE);
|
||||
if (pi != null && sourcePkg.equals(pi.packageName)) {
|
||||
int targetUid = mPmInternal.getPackageUidInternal(
|
||||
int targetUid = mPmInternal.getPackageUid(
|
||||
targetPkg, MATCH_UNINSTALLED_PACKAGES, targetUserId);
|
||||
if (targetUid != -1) {
|
||||
final GrantUri grantUri = new GrantUri(sourceUserId, uri,
|
||||
@@ -787,7 +787,7 @@ public class UriGrantsManagerService extends IUriGrantsManager.Stub {
|
||||
if (targetPkg == null) {
|
||||
throw new NullPointerException("targetPkg");
|
||||
}
|
||||
int targetUid = mPmInternal.getPackageUidInternal(targetPkg, MATCH_DEBUG_TRIAGED_MISSING,
|
||||
int targetUid = mPmInternal.getPackageUid(targetPkg, MATCH_DEBUG_TRIAGED_MISSING,
|
||||
targetUserId);
|
||||
|
||||
targetUid = checkGrantUriPermissionUnlocked(callingUid, targetPkg, grantUri, modeFlags,
|
||||
@@ -1108,7 +1108,7 @@ public class UriGrantsManagerService extends IUriGrantsManager.Stub {
|
||||
|
||||
int targetUid = lastTargetUid;
|
||||
if (targetUid < 0 && targetPkg != null) {
|
||||
targetUid = mPmInternal.getPackageUidInternal(targetPkg, MATCH_DEBUG_TRIAGED_MISSING,
|
||||
targetUid = mPmInternal.getPackageUid(targetPkg, MATCH_DEBUG_TRIAGED_MISSING,
|
||||
UserHandle.getUserId(callingUid));
|
||||
if (targetUid < 0) {
|
||||
if (DEBUG) Slog.v(TAG, "Can't grant URI permission no uid for: " + targetPkg);
|
||||
@@ -1462,7 +1462,8 @@ public class UriGrantsManagerService extends IUriGrantsManager.Stub {
|
||||
boolean printed = false;
|
||||
int dumpUid = -2;
|
||||
if (dumpPackage != null) {
|
||||
dumpUid = mPmInternal.getPackageUidInternal(dumpPackage, MATCH_ANY_USER, 0);
|
||||
dumpUid = mPmInternal.getPackageUid(dumpPackage,
|
||||
MATCH_ANY_USER, 0 /* userId */);
|
||||
}
|
||||
for (int i = 0; i < mGrantedUriPermissions.size(); i++) {
|
||||
int uid = mGrantedUriPermissions.keyAt(i);
|
||||
|
||||
@@ -204,10 +204,10 @@ public class CrossProfileAppsServiceImplRoboTest {
|
||||
CROSS_PROFILE_APP_PACKAGE_NAME, PERSONAL_PROFILE_UID, PERSONAL_PROFILE_USER_ID);
|
||||
ShadowApplicationPackageManager.setPackageUidAsUser(
|
||||
CROSS_PROFILE_APP_PACKAGE_NAME, WORK_PROFILE_UID, WORK_PROFILE_USER_ID);
|
||||
when(mPackageManagerInternal.getPackageUidInternal(
|
||||
when(mPackageManagerInternal.getPackageUid(
|
||||
CROSS_PROFILE_APP_PACKAGE_NAME, /* flags= */ 0, PERSONAL_PROFILE_USER_ID))
|
||||
.thenReturn(PERSONAL_PROFILE_UID);
|
||||
when(mPackageManagerInternal.getPackageUidInternal(
|
||||
when(mPackageManagerInternal.getPackageUid(
|
||||
CROSS_PROFILE_APP_PACKAGE_NAME, /* flags= */ 0, WORK_PROFILE_USER_ID))
|
||||
.thenReturn(WORK_PROFILE_UID);
|
||||
}
|
||||
|
||||
@@ -120,17 +120,17 @@ public class UriGrantsMockContext extends ContextWrapper {
|
||||
LocalServices.addService(PackageManagerInternal.class, mPmInternal);
|
||||
|
||||
for (int userId : new int[] { USER_PRIMARY, USER_SECONDARY }) {
|
||||
when(mPmInternal.getPackageUidInternal(eq(PKG_SOCIAL), anyInt(), eq(userId)))
|
||||
when(mPmInternal.getPackageUid(eq(PKG_SOCIAL), anyInt(), eq(userId)))
|
||||
.thenReturn(UserHandle.getUid(userId, UID_SOCIAL));
|
||||
when(mPmInternal.getPackageUidInternal(eq(PKG_CAMERA), anyInt(), eq(userId)))
|
||||
when(mPmInternal.getPackageUid(eq(PKG_CAMERA), anyInt(), eq(userId)))
|
||||
.thenReturn(UserHandle.getUid(userId, UID_CAMERA));
|
||||
when(mPmInternal.getPackageUidInternal(eq(PKG_PRIVATE), anyInt(), eq(userId)))
|
||||
when(mPmInternal.getPackageUid(eq(PKG_PRIVATE), anyInt(), eq(userId)))
|
||||
.thenReturn(UserHandle.getUid(userId, UID_PRIVATE));
|
||||
when(mPmInternal.getPackageUidInternal(eq(PKG_PUBLIC), anyInt(), eq(userId)))
|
||||
when(mPmInternal.getPackageUid(eq(PKG_PUBLIC), anyInt(), eq(userId)))
|
||||
.thenReturn(UserHandle.getUid(userId, UID_PUBLIC));
|
||||
when(mPmInternal.getPackageUidInternal(eq(PKG_FORCE), anyInt(), eq(userId)))
|
||||
when(mPmInternal.getPackageUid(eq(PKG_FORCE), anyInt(), eq(userId)))
|
||||
.thenReturn(UserHandle.getUid(userId, UID_FORCE));
|
||||
when(mPmInternal.getPackageUidInternal(eq(PKG_COMPLEX), anyInt(), eq(userId)))
|
||||
when(mPmInternal.getPackageUid(eq(PKG_COMPLEX), anyInt(), eq(userId)))
|
||||
.thenReturn(UserHandle.getUid(userId, UID_COMPLEX));
|
||||
|
||||
when(mPmInternal.resolveContentProvider(eq(PKG_CAMERA), anyInt(), eq(userId)))
|
||||
|
||||
Reference in New Issue
Block a user