From cf463af83f3cc56b1e20950bf60f1cf54e66e271 Mon Sep 17 00:00:00 2001 From: Songchun Fan Date: Wed, 29 Apr 2020 12:43:53 -0700 Subject: [PATCH] [pm/metrics] do not log package name for adb installations Per privacy requirements, we will not log package name if the installation is initiated from adb. Test: manual with adb install Test: $ ./out/host/linux-x86/bin/statsd_testdrive 263 event_metrics { data { elapsed_timestamp_nanos: 630320497997 atom { package_installer_v2_reported { is_incremental: true package_name: "" duration_millis: 567 return_code: 1 } } } } BUG: 152913040 Change-Id: I147358e59bf6a43fc76b6721ec1a415167b305d7 --- .../android/server/pm/PackageInstallerSession.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index 6b1ef3acdf610..77afc960f897a 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -1801,11 +1801,16 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { } } - private void logDataLoaderInstallationSession(int returnCode, String extraMessage) { + private void logDataLoaderInstallationSession(int returnCode) { + // Skip logging the side-loaded app installations, as those are private and aren't reported + // anywhere; app stores already have a record of the installation and that's why reporting + // it here is fine + final String packageNameToLog = + (params.installFlags & PackageManager.INSTALL_FROM_ADB) == 0 ? mPackageName : ""; final long currentTimestamp = System.currentTimeMillis(); FrameworkStatsLog.write(FrameworkStatsLog.PACKAGE_INSTALLER_V2_REPORTED, isIncrementalInstallation(), - mPackageName, + packageNameToLog, currentTimestamp - createdMillis, returnCode); } @@ -2812,7 +2817,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { mCallback.onSessionFinished(this, success); if (isDataLoaderInstallation()) { - logDataLoaderInstallationSession(returnCode, msg); + logDataLoaderInstallationSession(returnCode); } }