Merge "Merge "Fixes shouldFilterApplication usages" into rvc-dev am: 80888dbb00 am: 8908af8914" into rvc-d1-dev-plus-aosp

This commit is contained in:
Automerger Merge Worker
2020-04-24 20:25:04 +00:00
committed by Android (Google) Code Review
2 changed files with 24 additions and 14 deletions

View File

@@ -2376,7 +2376,7 @@ public class PackageManagerService extends IPackageManager.Stub
for (String packageName : packages) {
PackageSetting setting = mSettings.mPackages.get(packageName);
if (setting != null
&& shouldFilterApplicationLocked(setting, callingUid, callingUserId)) {
&& !shouldFilterApplicationLocked(setting, callingUid, callingUserId)) {
notifyInstallObserver(packageName);
}
}
@@ -21007,11 +21007,15 @@ public class PackageManagerService extends IPackageManager.Stub
false /* requireFullPermission */, false /* checkShell */, "get enabled");
// reader
synchronized (mLock) {
if (shouldFilterApplicationLocked(
mSettings.getPackageLPr(packageName), callingUid, userId)) {
return COMPONENT_ENABLED_STATE_DISABLED;
try {
if (shouldFilterApplicationLocked(
mSettings.getPackageLPr(packageName), callingUid, userId)) {
throw new PackageManager.NameNotFoundException(packageName);
}
return mSettings.getApplicationEnabledSettingLPr(packageName, userId);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalArgumentException("Unknown package: " + packageName);
}
return mSettings.getApplicationEnabledSettingLPr(packageName, userId);
}
}
@@ -21023,12 +21027,16 @@ public class PackageManagerService extends IPackageManager.Stub
mPermissionManager.enforceCrossUserPermission(callingUid, userId,
false /*requireFullPermission*/, false /*checkShell*/, "getComponentEnabled");
synchronized (mLock) {
if (shouldFilterApplicationLocked(
mSettings.getPackageLPr(component.getPackageName()), callingUid,
component, TYPE_UNKNOWN, userId)) {
return COMPONENT_ENABLED_STATE_DISABLED;
try {
if (shouldFilterApplicationLocked(
mSettings.getPackageLPr(component.getPackageName()), callingUid,
component, TYPE_UNKNOWN, userId)) {
throw new PackageManager.NameNotFoundException(component.getPackageName());
}
return mSettings.getComponentEnabledSettingLPr(component, userId);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalArgumentException("Unknown component: " + component);
}
return mSettings.getComponentEnabledSettingLPr(component, userId);
}
}

View File

@@ -4363,19 +4363,21 @@ public final class Settings {
return pkg.installSource.isOrphaned;
}
int getApplicationEnabledSettingLPr(String packageName, int userId) {
int getApplicationEnabledSettingLPr(String packageName, int userId)
throws PackageManager.NameNotFoundException {
final PackageSetting pkg = mPackages.get(packageName);
if (pkg == null) {
throw new IllegalArgumentException("Unknown package: " + packageName);
throw new PackageManager.NameNotFoundException(packageName);
}
return pkg.getEnabled(userId);
}
int getComponentEnabledSettingLPr(ComponentName componentName, int userId) {
int getComponentEnabledSettingLPr(ComponentName componentName, int userId)
throws PackageManager.NameNotFoundException {
final String packageName = componentName.getPackageName();
final PackageSetting pkg = mPackages.get(packageName);
if (pkg == null) {
throw new IllegalArgumentException("Unknown component: " + componentName);
throw new PackageManager.NameNotFoundException(componentName.getPackageName());
}
final String classNameStr = componentName.getClassName();
return pkg.getCurrentEnabledStateLPr(classNameStr, userId);