From 3e0b8ee39ab3435abd88c03069272da6e605b6a0 Mon Sep 17 00:00:00 2001 From: Patrick Baumann Date: Thu, 26 Apr 2018 12:03:15 -0700 Subject: [PATCH] Fixes non-matching instant app behavior This change ensures that a correctly formatted intent is sent to the instant app installer when no match can be found. Prior to this change, the original intent with the installer set as the component would be sent. After, we send an install intent with a sanitized intent set as an extra, as expected. Bug: 63117034 Test: manual - launch non-matching intents with flag set Change-Id: I70a3e2fab55e8f0524bbc99e88fba98dc2e28aaa --- .../java/com/android/server/pm/InstantAppResolver.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/core/java/com/android/server/pm/InstantAppResolver.java b/services/core/java/com/android/server/pm/InstantAppResolver.java index dbf0940fb4f57..d0a3757be04d7 100644 --- a/services/core/java/com/android/server/pm/InstantAppResolver.java +++ b/services/core/java/com/android/server/pm/InstantAppResolver.java @@ -16,6 +16,8 @@ package com.android.server.pm; +import static android.content.Intent.FLAG_ACTIVITY_MATCH_EXTERNAL; + import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_INSTANT_APP_RESOLUTION_PHASE_ONE; import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_INSTANT_APP_RESOLUTION_PHASE_TWO; import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_INSTANT_APP_LAUNCH_TOKEN; @@ -366,6 +368,7 @@ public abstract class InstantAppResolver { final Intent failureIntent = new Intent(origIntent); boolean requiresSecondPhase = false; failureIntent.setFlags(failureIntent.getFlags() | Intent.FLAG_IGNORE_EPHEMERAL); + failureIntent.setFlags(failureIntent.getFlags() & ~Intent.FLAG_ACTIVITY_MATCH_EXTERNAL); failureIntent.setLaunchToken(token); ArrayList filters = null; boolean isWebIntent = origIntent.isWebIntent(); @@ -408,6 +411,10 @@ public abstract class InstantAppResolver { if (filters != null && !filters.isEmpty()) { return new AuxiliaryResolveInfo(token, requiresSecondPhase, failureIntent, filters); } + // if the match external flag is set, return an empty resolve info + if ((origIntent.getFlags() & FLAG_ACTIVITY_MATCH_EXTERNAL) != 0) { + return new AuxiliaryResolveInfo(token, false, failureIntent, null /* filters */); + } // Hash or filter mis-match; no instant apps for this domain. return null; }