diff --git a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java index 77334e520a918..a72ae56c8c419 100644 --- a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java +++ b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java @@ -142,6 +142,11 @@ public class PackageManagerServiceUtils { public static final 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. @@ -1093,6 +1098,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 3145ab37ed0db..8a247cf8b4d39 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +++ b/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java @@ -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(); }