From 044b1790c5159cd6cc1cb9547360fd63b3a8fae7 Mon Sep 17 00:00:00 2001 From: Stanislav Zholnin Date: Wed, 3 Jun 2020 17:53:53 +0100 Subject: [PATCH] Remove package name from the attribution tag. GMSCore decided to prepend attribution tag with package name. Other developers might go the same way in the future. To save on uploading, we remove package name from attribution tag. Bug: 143519689 Test: stats_testdrive 10075 && atest UidAtomTest#testAppOps Change-Id: I2deb30fcb7615368c760655bf9dee24337a9135c --- .../server/stats/pull/StatsPullAtomService.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java index ab459fdadd21c..64d92aa236fc3 100644 --- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java @@ -3414,7 +3414,16 @@ public class StatsPullAtomService extends SystemService { private void processHistoricalOp(AppOpsManager.HistoricalOp op, List opsList, int uid, int samplingRatio, String packageName, @Nullable String attributionTag) { - AppOpEntry entry = new AppOpEntry(packageName, attributionTag, op, uid); + int firstChar = 0; + if (attributionTag != null && attributionTag.startsWith(packageName)) { + firstChar = packageName.length(); + if (firstChar < attributionTag.length() && attributionTag.charAt(firstChar) == '.') { + firstChar++; + } + } + AppOpEntry entry = new AppOpEntry(packageName, + attributionTag == null ? null : attributionTag.substring(firstChar), op, + uid); if (entry.mHash < samplingRatio) { opsList.add(entry); }