diff --git a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java index 3443d455ee824..e3b2d103fe19b 100644 --- a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java +++ b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java @@ -138,6 +138,11 @@ public class PackageManagerServiceUtils { public final static Predicate 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 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. @@ -1089,6 +1094,8 @@ public class PackageManagerServiceUtils { PlatformCompat compat, ComponentResolverApi resolver, List 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; diff --git a/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java b/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java index 6eaeb15e30b51..565b8f8d117c0 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +++ b/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java @@ -146,6 +146,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; @@ -2634,12 +2635,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(); }