Merge "Disable intent filter enforcement in startActivityFromRecents" into tm-qpr-dev am: 1cc6b20282 am: 618162505c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20613768

Change-Id: Iba2147dd927ebc2172842237899ec3b329937b00
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
John Wu
2022-12-06 16:32:45 +00:00
committed by Automerger Merge Worker
2 changed files with 13 additions and 0 deletions

View File

@@ -142,6 +142,11 @@ public class PackageManagerServiceUtils {
public static final Predicate<PackageStateInternal> REMOVE_IF_NULL_PKG =
pkgSetting -> pkgSetting.getPkg() == null;
// This is a horrible hack to workaround b/240373119, specifically for fixing the T branch.
// A proper fix should be implemented in master instead.
public static final ThreadLocal<Boolean> DISABLE_ENFORCE_INTENTS_TO_MATCH_INTENT_FILTERS =
ThreadLocal.withInitial(() -> false);
/**
* Components of apps targeting Android T and above will stop receiving intents from
* external callers that do not match its declared intent filters.
@@ -1093,6 +1098,8 @@ public class PackageManagerServiceUtils {
PlatformCompat compat, ComponentResolverApi resolver,
List<ResolveInfo> resolveInfos, boolean isReceiver,
Intent intent, String resolvedType, int filterCallingUid) {
if (DISABLE_ENFORCE_INTENTS_TO_MATCH_INTENT_FILTERS.get()) return;
final Printer logPrinter = DEBUG_INTENT_MATCHING
? new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM)
: null;

View File

@@ -145,6 +145,7 @@ import com.android.server.LocalServices;
import com.android.server.am.ActivityManagerService;
import com.android.server.am.HostingRecord;
import com.android.server.am.UserState;
import com.android.server.pm.PackageManagerServiceUtils;
import com.android.server.utils.Slogf;
import com.android.server.wm.ActivityMetricsLogger.LaunchingState;
@@ -2619,12 +2620,17 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
// ActivityStarter will acquire the lock where the places need, so execute the request
// outside of the lock.
try {
// We need to temporarily disable the explicit intent filter matching enforcement
// because Task does not store the resolved type of the intent data, causing filter
// mismatch in certain cases. (b/240373119)
PackageManagerServiceUtils.DISABLE_ENFORCE_INTENTS_TO_MATCH_INTENT_FILTERS.set(true);
return mService.getActivityStartController().startActivityInPackage(taskCallingUid,
callingPid, callingUid, callingPackage, callingFeatureId, intent, null, null,
null, 0, 0, options, userId, task, "startActivityFromRecents",
false /* validateIncomingUser */, null /* originatingPendingIntent */,
false /* allowBackgroundActivityStart */);
} finally {
PackageManagerServiceUtils.DISABLE_ENFORCE_INTENTS_TO_MATCH_INTENT_FILTERS.set(false);
synchronized (mService.mGlobalLock) {
mService.continueWindowLayout();
}