Merge changes from topic "revert-14700843-b186180067_main-GBUEFKDCBG"
* changes: Revert "Add the checking of the package installed state" Revert "Add MATCH_ANY_USER flag when get valid package uid" Revert "Use userId to query the package uid instead of 0."
This commit is contained in:
@@ -444,10 +444,8 @@ public class AccessibilitySecurityPolicy {
|
||||
private boolean isValidPackageForUid(String packageName, int uid) {
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
// Since we treat calls from a profile as if made by its parent, using
|
||||
// MATCH_ANY_USER to query the uid of the given package name.
|
||||
return uid == mPackageManager.getPackageUidAsUser(
|
||||
packageName, PackageManager.MATCH_ANY_USER, UserHandle.getUserId(uid));
|
||||
packageName, UserHandle.getUserId(uid));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
} finally {
|
||||
|
||||
@@ -4137,7 +4137,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
if (appId < 0 && packageName != null) {
|
||||
try {
|
||||
appId = UserHandle.getAppId(AppGlobals.getPackageManager()
|
||||
.getPackageUid(packageName, MATCH_DEBUG_TRIAGED_MISSING, userId));
|
||||
.getPackageUid(packageName, MATCH_DEBUG_TRIAGED_MISSING, 0));
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4215,11 +4215,11 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
// reader
|
||||
final AndroidPackage p = mPackages.get(packageName);
|
||||
if (p != null && AndroidPackageUtils.isMatchForSystemOnly(p, flags)) {
|
||||
final PackageSetting ps = getPackageSettingInternal(p.getPackageName(), callingUid);
|
||||
if (ps != null && ps.getInstalled(userId)
|
||||
&& !shouldFilterApplicationLocked(ps, callingUid, userId)) {
|
||||
return UserHandle.getUid(userId, p.getUid());
|
||||
PackageSetting ps = getPackageSettingInternal(p.getPackageName(), callingUid);
|
||||
if (shouldFilterApplicationLocked(ps, callingUid, userId)) {
|
||||
return -1;
|
||||
}
|
||||
return UserHandle.getUid(userId, p.getUid());
|
||||
}
|
||||
if ((flags & MATCH_KNOWN_PACKAGES) != 0) {
|
||||
final PackageSetting ps = mSettings.getPackageLPr(packageName);
|
||||
@@ -8579,11 +8579,13 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
synchronized (mLock) {
|
||||
final AndroidPackage p = mPackages.get(packageName);
|
||||
if (p != null && AndroidPackageUtils.isMatchForSystemOnly(p, flags)) {
|
||||
final PackageSetting ps = getPackageSetting(p.getPackageName());
|
||||
if (ps != null && ps.getInstalled(userId)
|
||||
&& !shouldFilterApplicationLocked(ps, callingUid, userId)) {
|
||||
return mPermissionManager.getGidsForUid(UserHandle.getUid(userId, ps.appId));
|
||||
PackageSetting ps = getPackageSetting(p.getPackageName());
|
||||
if (shouldFilterApplicationLocked(ps, callingUid, userId)) {
|
||||
return null;
|
||||
}
|
||||
// TODO: Shouldn't this be checking for package installed state for userId and
|
||||
// return null?
|
||||
return mPermissionManager.getGidsForUid(UserHandle.getUid(userId, ps.appId));
|
||||
}
|
||||
if ((flags & MATCH_KNOWN_PACKAGES) != 0) {
|
||||
final PackageSetting ps = mSettings.getPackageLPr(packageName);
|
||||
@@ -12206,7 +12208,6 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
}
|
||||
builder.append(" to access user ");
|
||||
builder.append(userId);
|
||||
builder.append(".");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -261,8 +261,8 @@ public class AccessibilitySecurityPolicyTest {
|
||||
@Test
|
||||
public void resolveValidReportedPackage_uidAndPkgNameMatched_returnPkgName()
|
||||
throws PackageManager.NameNotFoundException {
|
||||
when(mMockPackageManager.getPackageUidAsUser(PACKAGE_NAME,
|
||||
PackageManager.MATCH_ANY_USER, TEST_USER_ID)).thenReturn(APP_UID);
|
||||
when(mMockPackageManager.getPackageUidAsUser(PACKAGE_NAME, TEST_USER_ID))
|
||||
.thenReturn(APP_UID);
|
||||
|
||||
assertEquals(mA11ySecurityPolicy.resolveValidReportedPackageLocked(
|
||||
PACKAGE_NAME, APP_UID, TEST_USER_ID, APP_PID),
|
||||
|
||||
Reference in New Issue
Block a user