diff options
| author | 2023-10-16 17:00:52 +0000 | |
|---|---|---|
| committer | 2023-10-16 17:00:52 +0000 | |
| commit | 170208c1f1b1039a27b107a38e0232ae23d149b5 (patch) | |
| tree | 8eb9ec7d20c459b5a473a4324c0c3ee9aaa2f765 | |
| parent | 66b4376364131ea42ab76be3f63f590397d3e9ee (diff) | |
| parent | ea10dcc58b53e9bb4e7306ec1ea91221088c735d (diff) | |
Merge "Update QAS to further restrict visibility." into main
10 files changed, 23 insertions, 46 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 884351b57045..59bb73b5916d 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -323,7 +323,7 @@ public abstract class Context { // Make sure no flag uses the sign bit (most significant bit) of the long integer, // to avoid future confusion. BIND_BYPASS_USER_NETWORK_RESTRICTIONS, - BIND_FILTER_OUT_QUARANTINED_COMPONENTS, + BIND_MATCH_QUARANTINED_COMPONENTS, }) @Retention(RetentionPolicy.SOURCE) public @interface BindServiceFlagsLongBits {} @@ -703,7 +703,7 @@ public abstract class Context { * * @hide */ - public static final long BIND_FILTER_OUT_QUARANTINED_COMPONENTS = 0x2_0000_0000L; + public static final long BIND_MATCH_QUARANTINED_COMPONENTS = 0x2_0000_0000L; /** diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 4d5d05611d7a..f98ed4b8b37a 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -838,7 +838,7 @@ public abstract class PackageManager { GET_DISABLED_COMPONENTS, GET_DISABLED_UNTIL_USED_COMPONENTS, GET_UNINSTALLED_PACKAGES, - FILTER_OUT_QUARANTINED_COMPONENTS, + MATCH_QUARANTINED_COMPONENTS, }) @Retention(RetentionPolicy.SOURCE) public @interface ComponentInfoFlagsBits {} @@ -863,7 +863,7 @@ public abstract class PackageManager { GET_DISABLED_UNTIL_USED_COMPONENTS, GET_UNINSTALLED_PACKAGES, MATCH_CLONE_PROFILE, - FILTER_OUT_QUARANTINED_COMPONENTS, + MATCH_QUARANTINED_COMPONENTS, }) @Retention(RetentionPolicy.SOURCE) public @interface ResolveInfoFlagsBits {} @@ -1257,7 +1257,7 @@ public abstract class PackageManager { /** * @hide */ - public static final long FILTER_OUT_QUARANTINED_COMPONENTS = 0x100000000L; + public static final long MATCH_QUARANTINED_COMPONENTS = 0x100000000L; /** * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java index 5fb889a23fc5..1650a96a4012 100644 --- a/services/core/java/com/android/server/accounts/AccountManagerService.java +++ b/services/core/java/com/android/server/accounts/AccountManagerService.java @@ -5309,7 +5309,7 @@ public class AccountManagerService if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "performing bindService to " + authenticatorInfo.componentName); } - long flags = Context.BIND_FILTER_OUT_QUARANTINED_COMPONENTS | Context.BIND_AUTO_CREATE; + long flags = Context.BIND_AUTO_CREATE; if (mAuthenticatorCache.getBindInstantServiceAllowed(mAccounts.userId)) { flags |= Context.BIND_ALLOW_INSTANT; } diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 0956c6ded013..5f1a7e7e8123 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -3678,8 +3678,8 @@ public final class ActiveServices { || (flags & Context.BIND_EXTERNAL_SERVICE_LONG) != 0; final boolean allowInstant = (flags & Context.BIND_ALLOW_INSTANT) != 0; final boolean inSharedIsolatedProcess = (flags & Context.BIND_SHARED_ISOLATED_PROCESS) != 0; - final boolean filterOutQuarantined = - (flags & Context.BIND_FILTER_OUT_QUARANTINED_COMPONENTS) != 0; + final boolean matchQuarantined = + (flags & Context.BIND_MATCH_QUARANTINED_COMPONENTS) != 0; ProcessRecord attributedApp = null; if (sdkSandboxClientAppUid > 0) { @@ -3689,7 +3689,7 @@ public final class ActiveServices { isSdkSandboxService, sdkSandboxClientAppUid, sdkSandboxClientAppPackage, resolvedType, callingPackage, callingPid, callingUid, userId, true, callerFg, isBindExternal, allowInstant, null /* fgsDelegateOptions */, - inSharedIsolatedProcess, filterOutQuarantined); + inSharedIsolatedProcess, matchQuarantined); if (res == null) { return 0; } @@ -4202,7 +4202,7 @@ public final class ActiveServices { sdkSandboxClientAppUid, sdkSandboxClientAppPackage, resolvedType, callingPackage, callingPid, callingUid, userId, createIfNeeded, callingFromFg, isBindExternal, allowInstant, fgsDelegateOptions, inSharedIsolatedProcess, - false /* filterOutQuarantined */); + false /* matchQuarantined */); } private ServiceLookupResult retrieveServiceLocked(Intent service, @@ -4211,7 +4211,7 @@ public final class ActiveServices { String callingPackage, int callingPid, int callingUid, int userId, boolean createIfNeeded, boolean callingFromFg, boolean isBindExternal, boolean allowInstant, ForegroundServiceDelegationOptions fgsDelegateOptions, - boolean inSharedIsolatedProcess, boolean filterOutQuarantined) { + boolean inSharedIsolatedProcess, boolean matchQuarantined) { if (isSdkSandboxService && instanceName == null) { throw new IllegalArgumentException("No instanceName provided for sdk sandbox process"); } @@ -4333,8 +4333,8 @@ public final class ActiveServices { if (allowInstant) { flags |= PackageManager.MATCH_INSTANT; } - if (filterOutQuarantined) { - flags |= PackageManager.FILTER_OUT_QUARANTINED_COMPONENTS; + if (matchQuarantined) { + flags |= PackageManager.MATCH_QUARANTINED_COMPONENTS; } // TODO: come back and remove this assumption to triage all services ResolveInfo rInfo = mAm.getPackageManagerInternal().resolveService(service, diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index b43b986064fe..31817f1c427d 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -58,7 +58,6 @@ import static android.app.ProcessMemoryState.HOSTING_COMPONENT_TYPE_INSTRUMENTAT import static android.app.ProcessMemoryState.HOSTING_COMPONENT_TYPE_PERSISTENT; import static android.app.ProcessMemoryState.HOSTING_COMPONENT_TYPE_SYSTEM; import static android.content.pm.ApplicationInfo.HIDDEN_API_ENFORCEMENT_DEFAULT; -import static android.content.pm.PackageManager.FILTER_OUT_QUARANTINED_COMPONENTS; import static android.content.pm.PackageManager.GET_SHARED_LIBRARY_FILES; import static android.content.pm.PackageManager.MATCH_ALL; import static android.content.pm.PackageManager.MATCH_ANY_USER; @@ -14295,8 +14294,7 @@ public class ActivityManagerService extends IActivityManager.Stub private List<ResolveInfo> collectReceiverComponents(Intent intent, String resolvedType, int callingUid, int[] users, int[] broadcastAllowList) { // TODO: come back and remove this assumption to triage all broadcasts - long pmFlags = STOCK_PM_FLAGS | MATCH_DEBUG_TRIAGED_MISSING - | FILTER_OUT_QUARANTINED_COMPONENTS; + long pmFlags = STOCK_PM_FLAGS | MATCH_DEBUG_TRIAGED_MISSING; List<ResolveInfo> receivers = null; HashSet<ComponentName> singleUserReceivers = null; diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java index 8736a53bb9f5..ac7d9c171247 100644 --- a/services/core/java/com/android/server/content/SyncManager.java +++ b/services/core/java/com/android/server/content/SyncManager.java @@ -221,9 +221,8 @@ public class SyncManager { /** Flags used when connecting to a sync adapter service */ private static final Context.BindServiceFlags SYNC_ADAPTER_CONNECTION_FLAGS = - Context.BindServiceFlags.of( - Context.BIND_FILTER_OUT_QUARANTINED_COMPONENTS | Context.BIND_AUTO_CREATE - | Context.BIND_NOT_FOREGROUND | Context.BIND_ALLOW_OOM_MANAGEMENT); + Context.BindServiceFlags.of(Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND + | Context.BIND_ALLOW_OOM_MANAGEMENT); /** Singleton instance. */ @GuardedBy("SyncManager.class") diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java index 7db7bf538c37..30017be96085 100644 --- a/services/core/java/com/android/server/pm/ComputerEngine.java +++ b/services/core/java/com/android/server/pm/ComputerEngine.java @@ -505,6 +505,10 @@ public class ComputerEngine implements Computer { int filterCallingUid, int userId, boolean resolveForStart, boolean allowDynamicSplits) { if (!mUserManager.exists(userId)) return Collections.emptyList(); + + // Allow to match activities of quarantined packages. + flags |= PackageManager.MATCH_QUARANTINED_COMPONENTS; + final String instantAppPkgName = getInstantAppPackageName(filterCallingUid); enforceCrossUserPermission(Binder.getCallingUid(), userId, false /* requireFullPermission */, false /* checkShell */, @@ -647,11 +651,6 @@ public class ComputerEngine implements Computer { flags = updateFlagsForResolve(flags, userId, callingUid, includeInstantApps, false /* isImplicitImageCaptureIntentAndNotSetByDpc */); - // Only if the query is coming from the system process, - // it should be allowed to match quarantined components - if (callingUid != Process.SYSTEM_UID) { - flags |= PackageManager.FILTER_OUT_QUARANTINED_COMPONENTS; - } Intent originalIntent = null; ComponentName comp = intent.getComponent(); if (comp == null) { @@ -4047,9 +4046,6 @@ public class ComputerEngine implements Computer { flags = updateFlagsForComponent(flags, userId); enforceCrossUserPermission(callingUid, userId, false /* requireFullPermission */, false /* checkShell */, "get provider info"); - if (callingUid != Process.SYSTEM_UID) { - flags |= PackageManager.FILTER_OUT_QUARANTINED_COMPONENTS; - } ParsedProvider p = mComponentResolver.getProvider(component); if (DEBUG_PACKAGE_INFO) Log.v( TAG, "getProviderInfo " + component + ": " + p); @@ -4679,9 +4675,6 @@ public class ComputerEngine implements Computer { int callingUid) { if (!mUserManager.exists(userId)) return null; flags = updateFlagsForComponent(flags, userId); - if (callingUid != Process.SYSTEM_UID) { - flags |= PackageManager.FILTER_OUT_QUARANTINED_COMPONENTS; - } final ProviderInfo providerInfo = mComponentResolver.queryProvider(this, name, flags, userId); boolean checkedGrants = false; @@ -4794,13 +4787,6 @@ public class ComputerEngine implements Computer { false /* checkShell */, "queryContentProviders"); if (!mUserManager.exists(userId)) return ParceledListSlice.emptyList(); flags = updateFlagsForComponent(flags, userId); - - // Only if the service query is coming from the system process, - // it should be allowed to match quarantined components - if (callingUid != Process.SYSTEM_UID) { - flags |= PackageManager.FILTER_OUT_QUARANTINED_COMPONENTS; - } - ArrayList<ProviderInfo> finalList = null; final List<ProviderInfo> matchList = mComponentResolver.queryProviders(this, processName, metaDataKey, uid, flags, userId); diff --git a/services/core/java/com/android/server/pm/ResolveIntentHelper.java b/services/core/java/com/android/server/pm/ResolveIntentHelper.java index da14397b9c92..203e1de61f2f 100644 --- a/services/core/java/com/android/server/pm/ResolveIntentHelper.java +++ b/services/core/java/com/android/server/pm/ResolveIntentHelper.java @@ -517,12 +517,6 @@ final class ResolveIntentHelper { if (!mUserManager.exists(userId)) return Collections.emptyList(); final int callingUid = Binder.getCallingUid(); - // Only if the service query is coming from the system process, - // it should be allowed to match quarantined components - if (callingUid != Process.SYSTEM_UID) { - flags |= PackageManager.FILTER_OUT_QUARANTINED_COMPONENTS; - } - final String instantAppPkgName = computer.getInstantAppPackageName(callingUid); flags = computer.updateFlagsForResolve(flags, userId, callingUid, false /*includeInstantApps*/, false /* isImplicitImageCaptureIntentAndNotSetByDpc */); diff --git a/services/core/java/com/android/server/pm/parsing/PackageInfoUtils.java b/services/core/java/com/android/server/pm/parsing/PackageInfoUtils.java index d804e01aa31e..61e96ca3dd59 100644 --- a/services/core/java/com/android/server/pm/parsing/PackageInfoUtils.java +++ b/services/core/java/com/android/server/pm/parsing/PackageInfoUtils.java @@ -379,7 +379,7 @@ public class PackageInfoUtils { ai.privateFlags |= flag(state.isInstantApp(), ApplicationInfo.PRIVATE_FLAG_INSTANT) | flag(state.isVirtualPreload(), ApplicationInfo.PRIVATE_FLAG_VIRTUAL_PRELOAD) | flag(state.isHidden(), ApplicationInfo.PRIVATE_FLAG_HIDDEN); - if ((flags & PackageManager.FILTER_OUT_QUARANTINED_COMPONENTS) != 0 + if ((flags & PackageManager.MATCH_QUARANTINED_COMPONENTS) == 0 && state.isQuarantined()) { ai.enabled = false; } else if (state.getEnabledState() == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { diff --git a/services/core/java/com/android/server/pm/pkg/PackageUserStateUtils.java b/services/core/java/com/android/server/pm/pkg/PackageUserStateUtils.java index 7b07e5b2bb6b..cd3583b814a4 100644 --- a/services/core/java/com/android/server/pm/pkg/PackageUserStateUtils.java +++ b/services/core/java/com/android/server/pm/pkg/PackageUserStateUtils.java @@ -16,9 +16,9 @@ package com.android.server.pm.pkg; -import static android.content.pm.PackageManager.FILTER_OUT_QUARANTINED_COMPONENTS; import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS; import static android.content.pm.PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS; +import static android.content.pm.PackageManager.MATCH_QUARANTINED_COMPONENTS; import android.annotation.NonNull; import android.content.pm.ComponentInfo; @@ -147,7 +147,7 @@ public class PackageUserStateUtils { return true; } - if ((flags & FILTER_OUT_QUARANTINED_COMPONENTS) != 0 && state.isQuarantined()) { + if ((flags & MATCH_QUARANTINED_COMPONENTS) == 0 && state.isQuarantined()) { return false; } |