1 /** 2 * Copyright (c) 2014, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.app.usage; 18 19 import android.app.PendingIntent; 20 import android.app.usage.BroadcastResponseStats; 21 import android.app.usage.BroadcastResponseStatsList; 22 import android.app.usage.UsageEvents; 23 import android.app.usage.UsageEventsQuery; 24 import android.content.pm.ParceledListSlice; 25 import android.os.PersistableBundle; 26 27 /** 28 * System private API for talking with the UsageStatsManagerService. 29 * 30 * {@hide} 31 */ 32 interface IUsageStatsManager { 33 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) queryUsageStats(int bucketType, long beginTime, long endTime, String callingPackage, int userId)34 ParceledListSlice queryUsageStats(int bucketType, long beginTime, long endTime, 35 String callingPackage, int userId); 36 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) queryConfigurationStats(int bucketType, long beginTime, long endTime, String callingPackage)37 ParceledListSlice queryConfigurationStats(int bucketType, long beginTime, long endTime, 38 String callingPackage); queryEventStats(int bucketType, long beginTime, long endTime, String callingPackage)39 ParceledListSlice queryEventStats(int bucketType, long beginTime, long endTime, 40 String callingPackage); queryEvents(long beginTime, long endTime, String callingPackage)41 UsageEvents queryEvents(long beginTime, long endTime, String callingPackage); queryEventsForPackage(long beginTime, long endTime, String callingPackage)42 UsageEvents queryEventsForPackage(long beginTime, long endTime, String callingPackage); queryEventsForUser(long beginTime, long endTime, int userId, String callingPackage)43 UsageEvents queryEventsForUser(long beginTime, long endTime, int userId, String callingPackage); queryEventsForPackageForUser(long beginTime, long endTime, int userId, String pkg, String callingPackage)44 UsageEvents queryEventsForPackageForUser(long beginTime, long endTime, int userId, String pkg, String callingPackage); 45 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS)") queryEventsWithFilter(in UsageEventsQuery query, String callingPackage)46 UsageEvents queryEventsWithFilter(in UsageEventsQuery query, String callingPackage); 47 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) setAppInactive(String packageName, boolean inactive, int userId)48 void setAppInactive(String packageName, boolean inactive, int userId); isAppStandbyEnabled()49 boolean isAppStandbyEnabled(); 50 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) isAppInactive(String packageName, int userId, String callingPackage)51 boolean isAppInactive(String packageName, int userId, String callingPackage); onCarrierPrivilegedAppsChanged()52 void onCarrierPrivilegedAppsChanged(); reportChooserSelection(String packageName, int userId, String contentType, in String[] annotations, String action)53 void reportChooserSelection(String packageName, int userId, String contentType, 54 in String[] annotations, String action); getAppStandbyBucket(String packageName, String callingPackage, int userId)55 int getAppStandbyBucket(String packageName, String callingPackage, int userId); 56 @EnforcePermission("CHANGE_APP_IDLE_STATE") setAppStandbyBucket(String packageName, int bucket, int userId)57 void setAppStandbyBucket(String packageName, int bucket, int userId); getAppStandbyBuckets(String callingPackage, int userId)58 ParceledListSlice getAppStandbyBuckets(String callingPackage, int userId); 59 @EnforcePermission("CHANGE_APP_IDLE_STATE") setAppStandbyBuckets(in ParceledListSlice appBuckets, int userId)60 void setAppStandbyBuckets(in ParceledListSlice appBuckets, int userId); getAppMinStandbyBucket(String packageName, String callingPackage, int userId)61 int getAppMinStandbyBucket(String packageName, String callingPackage, int userId); 62 @EnforcePermission("CHANGE_APP_LAUNCH_TIME_ESTIMATE") setEstimatedLaunchTime(String packageName, long estimatedLaunchTime, int userId)63 void setEstimatedLaunchTime(String packageName, long estimatedLaunchTime, int userId); 64 @EnforcePermission("CHANGE_APP_LAUNCH_TIME_ESTIMATE") setEstimatedLaunchTimes(in ParceledListSlice appLaunchTimes, int userId)65 void setEstimatedLaunchTimes(in ParceledListSlice appLaunchTimes, int userId); registerAppUsageObserver(int observerId, in String[] packages, long timeLimitMs, in PendingIntent callback, String callingPackage)66 void registerAppUsageObserver(int observerId, in String[] packages, long timeLimitMs, 67 in PendingIntent callback, String callingPackage); unregisterAppUsageObserver(int observerId, String callingPackage)68 void unregisterAppUsageObserver(int observerId, String callingPackage); registerUsageSessionObserver(int sessionObserverId, in String[] observed, long timeLimitMs, long sessionThresholdTimeMs, in PendingIntent limitReachedCallbackIntent, in PendingIntent sessionEndCallbackIntent, String callingPackage)69 void registerUsageSessionObserver(int sessionObserverId, in String[] observed, long timeLimitMs, 70 long sessionThresholdTimeMs, in PendingIntent limitReachedCallbackIntent, 71 in PendingIntent sessionEndCallbackIntent, String callingPackage); unregisterUsageSessionObserver(int sessionObserverId, String callingPackage)72 void unregisterUsageSessionObserver(int sessionObserverId, String callingPackage); registerAppUsageLimitObserver(int observerId, in String[] packages, long timeLimitMs, long timeUsedMs, in PendingIntent callback, String callingPackage)73 void registerAppUsageLimitObserver(int observerId, in String[] packages, long timeLimitMs, 74 long timeUsedMs, in PendingIntent callback, String callingPackage); unregisterAppUsageLimitObserver(int observerId, String callingPackage)75 void unregisterAppUsageLimitObserver(int observerId, String callingPackage); reportUsageStart(in IBinder activity, String token, String callingPackage)76 void reportUsageStart(in IBinder activity, String token, String callingPackage); reportPastUsageStart(in IBinder activity, String token, long timeAgoMs, String callingPackage)77 void reportPastUsageStart(in IBinder activity, String token, long timeAgoMs, 78 String callingPackage); reportUsageStop(in IBinder activity, String token, String callingPackage)79 void reportUsageStop(in IBinder activity, String token, String callingPackage); reportUserInteraction(String packageName, int userId)80 void reportUserInteraction(String packageName, int userId); 81 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.REPORT_USAGE_STATS)") reportUserInteractionWithBundle(String packageName, int userId, in PersistableBundle eventExtras)82 void reportUserInteractionWithBundle(String packageName, int userId, in PersistableBundle eventExtras); getUsageSource()83 int getUsageSource(); forceUsageSourceSettingRead()84 void forceUsageSourceSettingRead(); getLastTimeAnyComponentUsed(String packageName, String callingPackage)85 long getLastTimeAnyComponentUsed(String packageName, String callingPackage); 86 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS)") queryBroadcastResponseStats( String packageName, long id, String callingPackage, int userId)87 BroadcastResponseStatsList queryBroadcastResponseStats( 88 String packageName, long id, String callingPackage, int userId); 89 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS)") clearBroadcastResponseStats(String packageName, long id, String callingPackage, int userId)90 void clearBroadcastResponseStats(String packageName, long id, String callingPackage, 91 int userId); 92 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS)") clearBroadcastEvents(String callingPackage, int userId)93 void clearBroadcastEvents(String callingPackage, int userId); 94 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)") isPackageExemptedFromBroadcastResponseStats(String packageName, int userId)95 boolean isPackageExemptedFromBroadcastResponseStats(String packageName, int userId); 96 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG)") getAppStandbyConstant(String key)97 String getAppStandbyConstant(String key); 98 } 99