summaryrefslogtreecommitdiff
path: root/services/usage/java
diff options
context:
space:
mode:
authorYuliya Kamatkova <yuliyak@google.com>2020-02-04 16:52:48 -0800
committerYuliya Kamatkova <yuliyak@google.com>2020-02-12 11:20:22 -0800
commitfea62a512b58597d60b3da56fcf7273ae15aad27 (patch)
treefe166ef54390b79a46dd7757264819b75080ca7a /services/usage/java
parente39ec317ca180d27a7bdca3b57cf6ed443aca883 (diff)
Restrict visibility of LOCUS_ID_SET events.
UsageStats will not return LOCUS_ID_SET events to callers of #queryEvents and #queryEventsForUser if they don't have visibility. Bug: 148821246 Test: manual, atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest Change-Id: Ic904a97e66775ef63bc8b84e67e8f430b2a4121b
Diffstat (limited to 'services/usage/java')
-rw-r--r--services/usage/java/com/android/server/usage/UsageStatsService.java28
-rw-r--r--services/usage/java/com/android/server/usage/UserUsageStatsService.java8
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 48b6e2aaad5c..3b3a58b21339 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);
}
}
@@ -1451,8 +1461,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);
}
@@ -1499,8 +1511,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);
}
@@ -2117,9 +2131,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();
}