From 6ebabca5471dd036914505dd0ee074c3e35f4af8 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Tue, 22 Aug 2017 10:02:12 -0700 Subject: [PATCH] Only log resolution when starting activities Change-Id: I406af40953f3d6ade39e1bab18a35c534e308f3e Fixes: 63804529 Test: Manual. Query web intent, notice no logs are emitted Test: Manual. Start activity via web intent, notice logs are emitted --- core/java/android/content/pm/InstantAppRequest.java | 6 +++++- .../java/com/android/server/pm/InstantAppResolver.java | 2 +- .../com/android/server/pm/PackageManagerService.java | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/java/android/content/pm/InstantAppRequest.java b/core/java/android/content/pm/InstantAppRequest.java index 27d28287b6ae3..38f02256ee6e0 100644 --- a/core/java/android/content/pm/InstantAppRequest.java +++ b/core/java/android/content/pm/InstantAppRequest.java @@ -38,14 +38,18 @@ public final class InstantAppRequest { * Optional extra bundle provided by the source application to the installer for additional * verification. */ public final Bundle verificationBundle; + /** Whether resolution occurs because an application is starting */ + public final boolean resolveForStart; public InstantAppRequest(AuxiliaryResolveInfo responseObj, Intent origIntent, - String resolvedType, String callingPackage, int userId, Bundle verificationBundle) { + String resolvedType, String callingPackage, int userId, Bundle verificationBundle, + boolean resolveForStart) { this.responseObj = responseObj; this.origIntent = origIntent; this.resolvedType = resolvedType; this.callingPackage = callingPackage; this.userId = userId; this.verificationBundle = verificationBundle; + this.resolveForStart = resolveForStart; } } diff --git a/services/core/java/com/android/server/pm/InstantAppResolver.java b/services/core/java/com/android/server/pm/InstantAppResolver.java index f50d0d7564a15..5f54c67a35a13 100644 --- a/services/core/java/com/android/server/pm/InstantAppResolver.java +++ b/services/core/java/com/android/server/pm/InstantAppResolver.java @@ -122,7 +122,7 @@ public abstract class InstantAppResolver { } } // Only log successful instant application resolution - if (resolutionStatus == RESOLUTION_SUCCESS) { + if (requestObj.resolveForStart && resolutionStatus == RESOLUTION_SUCCESS) { logMetrics(ACTION_INSTANT_APP_RESOLUTION_PHASE_ONE, startTime, token, resolutionStatus); } diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 99261add14081..70694ddca74d5 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -6730,7 +6730,7 @@ public class PackageManagerService extends IPackageManager.Stub Bundle verificationBundle, int userId) { final Message msg = mHandler.obtainMessage(INSTANT_APP_RESOLUTION_PHASE_TWO, new InstantAppRequest(responseObj, origIntent, resolvedType, - callingPackage, userId, verificationBundle)); + callingPackage, userId, verificationBundle, false /*resolveForStart*/)); mHandler.sendMessage(msg); } @@ -7292,7 +7292,8 @@ public class PackageManagerService extends IPackageManager.Stub } } if (addEphemeral) { - result = maybeAddInstantAppInstaller(result, intent, resolvedType, flags, userId); + result = maybeAddInstantAppInstaller( + result, intent, resolvedType, flags, userId, resolveForStart); } if (sortResult) { Collections.sort(result, mResolvePrioritySorter); @@ -7302,7 +7303,7 @@ public class PackageManagerService extends IPackageManager.Stub } private List maybeAddInstantAppInstaller(List result, Intent intent, - String resolvedType, int flags, int userId) { + String resolvedType, int flags, int userId, boolean resolveForStart) { // first, check to see if we've got an instant app already installed final boolean alreadyResolvedLocally = (flags & PackageManager.MATCH_INSTANT) != 0; ResolveInfo localInstantApp = null; @@ -7351,7 +7352,8 @@ public class PackageManagerService extends IPackageManager.Stub Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "resolveEphemeral"); final InstantAppRequest requestObject = new InstantAppRequest( null /*responseObj*/, intent /*origIntent*/, resolvedType, - null /*callingPackage*/, userId, null /*verificationBundle*/); + null /*callingPackage*/, userId, null /*verificationBundle*/, + resolveForStart); auxiliaryResponse = InstantAppResolver.doInstantAppResolutionPhaseOne( mContext, mInstantAppResolverConnection, requestObject);