diff options
author | Yuliya Kamatkova <yuliyak@google.com> | 2020-02-13 01:05:09 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-02-13 01:05:09 +0000 |
commit | 4d5b0be4814cdef56872e61e7d04b8a81328ad2e (patch) | |
tree | b077cb1afda9d0ad9057e6f6b26ee8519bb907cd /services/usage | |
parent | 74a2c3932290f50192c612c2a5ca6711258e5121 (diff) | |
parent | fea62a512b58597d60b3da56fcf7273ae15aad27 (diff) |
Merge "Restrict visibility of LOCUS_ID_SET events."
Diffstat (limited to 'services/usage')
-rw-r--r-- | services/usage/java/com/android/server/usage/UsageStatsService.java | 28 | ||||
-rw-r--r-- | services/usage/java/com/android/server/usage/UserUsageStatsService.java | 8 |
2 files changed, 28 insertions, 8 deletions
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java index 1371481d097d..420695dc51e4 100644 --- a/services/usage/java/com/android/server/usage/UsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UsageStatsService.java @@ -491,6 +491,15 @@ public class UsageStatsService extends SystemService implements return true; // hide by default if we can't verify visibility } + private boolean shouldHideLocusIdEvents(int callingPid, int callingUid) { + if (callingUid == Process.SYSTEM_UID) { + return false; + } + return !(getContext().checkPermission( + android.Manifest.permission.ACCESS_LOCUS_ID_USAGE_STATS, callingPid, callingUid) + == PackageManager.PERMISSION_GRANTED); + } + private static void deleteRecursively(File f) { File[] files = f.listFiles(); if (files != null) { @@ -1030,7 +1039,8 @@ public class UsageStatsService extends SystemService implements * Called by the Binder stub. */ UsageEvents queryEvents(int userId, long beginTime, long endTime, - boolean shouldObfuscateInstantApps, boolean shouldHideShortcutInvocationEvents) { + boolean shouldObfuscateInstantApps, boolean shouldHideShortcutInvocationEvents, + boolean shouldHideLocusIdEvents) { synchronized (mLock) { if (!mUserUnlockedStates.get(userId)) { Slog.w(TAG, "Failed to query events for locked user " + userId); @@ -1042,7 +1052,7 @@ public class UsageStatsService extends SystemService implements return null; // user was stopped or removed } return service.queryEvents(beginTime, endTime, shouldObfuscateInstantApps, - shouldHideShortcutInvocationEvents); + shouldHideShortcutInvocationEvents, shouldHideLocusIdEvents); } } @@ -1465,8 +1475,10 @@ public class UsageStatsService extends SystemService implements try { final boolean hideShortcutInvocationEvents = shouldHideShortcutInvocationEvents( userId, callingPackage, callingPid, callingUid); + boolean shouldHideLocusIdEvents = shouldHideLocusIdEvents(callingPid, callingUid); return UsageStatsService.this.queryEvents(userId, beginTime, endTime, - obfuscateInstantApps, hideShortcutInvocationEvents); + obfuscateInstantApps, hideShortcutInvocationEvents, + shouldHideLocusIdEvents); } finally { Binder.restoreCallingIdentity(token); } @@ -1513,8 +1525,10 @@ public class UsageStatsService extends SystemService implements try { final boolean hideShortcutInvocationEvents = shouldHideShortcutInvocationEvents( userId, callingPackage, callingPid, callingUid); + boolean shouldHideLocusIdEvents = shouldHideLocusIdEvents(callingPid, callingUid); return UsageStatsService.this.queryEvents(userId, beginTime, endTime, - obfuscateInstantApps, hideShortcutInvocationEvents); + obfuscateInstantApps, hideShortcutInvocationEvents, + shouldHideLocusIdEvents); } finally { Binder.restoreCallingIdentity(token); } @@ -2131,9 +2145,11 @@ public class UsageStatsService extends SystemService implements @Override public UsageEvents queryEventsForUser(int userId, long beginTime, long endTime, - boolean obfuscateInstantApps, boolean hideShortcutInvocationEvents) { + boolean obfuscateInstantApps, boolean shouldHideShortcutInvocationEvents, + boolean shouldHideLocusIdEvents) { return UsageStatsService.this.queryEvents( - userId, beginTime, endTime, obfuscateInstantApps, hideShortcutInvocationEvents); + userId, beginTime, endTime, obfuscateInstantApps, + shouldHideShortcutInvocationEvents, shouldHideLocusIdEvents); } @Override diff --git a/services/usage/java/com/android/server/usage/UserUsageStatsService.java b/services/usage/java/com/android/server/usage/UserUsageStatsService.java index 4d711128da76..d9317ace6e24 100644 --- a/services/usage/java/com/android/server/usage/UserUsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UserUsageStatsService.java @@ -481,8 +481,8 @@ class UserUsageStatsService { return queryStats(bucketType, beginTime, endTime, sEventStatsCombiner); } - UsageEvents queryEvents(final long beginTime, final long endTime, - boolean obfuscateInstantApps, boolean hideShortcutInvocationEvents) { + UsageEvents queryEvents(final long beginTime, final long endTime, boolean obfuscateInstantApps, + boolean hideShortcutInvocationEvents, boolean hideLocusIdEvents) { if (!validRange(checkAndGetTimeLocked(), beginTime, endTime)) { return null; } @@ -504,6 +504,10 @@ class UserUsageStatsService { && event.mEventType == Event.SHORTCUT_INVOCATION) { continue; } + if (hideLocusIdEvents + && event.mEventType == Event.LOCUS_ID_SET) { + continue; + } if (obfuscateInstantApps) { event = event.getObfuscatedIfInstantApp(); } |