diff options
| author | Michael Wachenschwanz <mwachens@google.com> | 2020-04-20 15:15:35 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-20 15:15:35 +0000 |
| commit | dcc388ab4461978f25cf95accf82874c2fc4decb (patch) | |
| tree | 5168846aacd7f1ec4eec5f4889026ae37bd460d4 /core/java | |
| parent | 711d0a9a76dddc197a124f3cc484eac0e9bacd8d (diff) | |
| parent | d2b132fac44c38aea685db9170f24cf93a25ca99 (diff) | |
Merge "Add permission check to UsageStatsManager#isAppInactive" into rvc-dev
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/usage/IUsageStatsManager.aidl | 2 | ||||
| -rw-r--r-- | core/java/android/app/usage/UsageStatsManager.java | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/core/java/android/app/usage/IUsageStatsManager.aidl b/core/java/android/app/usage/IUsageStatsManager.aidl index 1211c731e2e1..ed6ba0c5efa4 100644 --- a/core/java/android/app/usage/IUsageStatsManager.aidl +++ b/core/java/android/app/usage/IUsageStatsManager.aidl @@ -43,7 +43,7 @@ interface IUsageStatsManager { @UnsupportedAppUsage void setAppInactive(String packageName, boolean inactive, int userId); @UnsupportedAppUsage - boolean isAppInactive(String packageName, int userId); + boolean isAppInactive(String packageName, int userId, String callingPackage); void onCarrierPrivilegedAppsChanged(); void reportChooserSelection(String packageName, int userId, String contentType, in String[] annotations, String action); diff --git a/core/java/android/app/usage/UsageStatsManager.java b/core/java/android/app/usage/UsageStatsManager.java index 0a67802fe92b..2ce6a86753a6 100644 --- a/core/java/android/app/usage/UsageStatsManager.java +++ b/core/java/android/app/usage/UsageStatsManager.java @@ -622,12 +622,17 @@ public final class UsageStatsManager { * app hasn't been used directly or indirectly for a period of time defined by the system. This * could be of the order of several hours or days. Apps are not considered inactive when the * device is charging. + * <p> The caller must have {@link android.Manifest.permission#PACKAGE_USAGE_STATS} to query the + * inactive state of other apps</p> + * * @param packageName The package name of the app to query - * @return whether the app is currently considered inactive + * @return whether the app is currently considered inactive or false if querying another app + * without {@link android.Manifest.permission#PACKAGE_USAGE_STATS} */ public boolean isAppInactive(String packageName) { try { - return mService.isAppInactive(packageName, mContext.getUserId()); + return mService.isAppInactive(packageName, mContext.getUserId(), + mContext.getOpPackageName()); } catch (RemoteException e) { // fall through and return default } |
