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.content.pm.ParceledListSlice;
24 
25 import java.util.Map;
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     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setAppInactive(String packageName, boolean inactive, int userId)46     void setAppInactive(String packageName, boolean inactive, int userId);
isAppStandbyEnabled()47     boolean isAppStandbyEnabled();
48     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
isAppInactive(String packageName, int userId, String callingPackage)49     boolean isAppInactive(String packageName, int userId, String callingPackage);
onCarrierPrivilegedAppsChanged()50     void onCarrierPrivilegedAppsChanged();
reportChooserSelection(String packageName, int userId, String contentType, in String[] annotations, String action)51     void reportChooserSelection(String packageName, int userId, String contentType,
52             in String[] annotations, String action);
getAppStandbyBucket(String packageName, String callingPackage, int userId)53     int getAppStandbyBucket(String packageName, String callingPackage, int userId);
54     @EnforcePermission("CHANGE_APP_IDLE_STATE")
setAppStandbyBucket(String packageName, int bucket, int userId)55     void setAppStandbyBucket(String packageName, int bucket, int userId);
getAppStandbyBuckets(String callingPackage, int userId)56     ParceledListSlice getAppStandbyBuckets(String callingPackage, int userId);
57     @EnforcePermission("CHANGE_APP_IDLE_STATE")
setAppStandbyBuckets(in ParceledListSlice appBuckets, int userId)58     void setAppStandbyBuckets(in ParceledListSlice appBuckets, int userId);
getAppMinStandbyBucket(String packageName, String callingPackage, int userId)59     int getAppMinStandbyBucket(String packageName, String callingPackage, int userId);
60     @EnforcePermission("CHANGE_APP_LAUNCH_TIME_ESTIMATE")
setEstimatedLaunchTime(String packageName, long estimatedLaunchTime, int userId)61     void setEstimatedLaunchTime(String packageName, long estimatedLaunchTime, int userId);
62     @EnforcePermission("CHANGE_APP_LAUNCH_TIME_ESTIMATE")
setEstimatedLaunchTimes(in ParceledListSlice appLaunchTimes, int userId)63     void setEstimatedLaunchTimes(in ParceledListSlice appLaunchTimes, int userId);
registerAppUsageObserver(int observerId, in String[] packages, long timeLimitMs, in PendingIntent callback, String callingPackage)64     void registerAppUsageObserver(int observerId, in String[] packages, long timeLimitMs,
65             in PendingIntent callback, String callingPackage);
unregisterAppUsageObserver(int observerId, String callingPackage)66     void unregisterAppUsageObserver(int observerId, String callingPackage);
registerUsageSessionObserver(int sessionObserverId, in String[] observed, long timeLimitMs, long sessionThresholdTimeMs, in PendingIntent limitReachedCallbackIntent, in PendingIntent sessionEndCallbackIntent, String callingPackage)67     void registerUsageSessionObserver(int sessionObserverId, in String[] observed, long timeLimitMs,
68             long sessionThresholdTimeMs, in PendingIntent limitReachedCallbackIntent,
69             in PendingIntent sessionEndCallbackIntent, String callingPackage);
unregisterUsageSessionObserver(int sessionObserverId, String callingPackage)70     void unregisterUsageSessionObserver(int sessionObserverId, String callingPackage);
registerAppUsageLimitObserver(int observerId, in String[] packages, long timeLimitMs, long timeUsedMs, in PendingIntent callback, String callingPackage)71     void registerAppUsageLimitObserver(int observerId, in String[] packages, long timeLimitMs,
72             long timeUsedMs, in PendingIntent callback, String callingPackage);
unregisterAppUsageLimitObserver(int observerId, String callingPackage)73     void unregisterAppUsageLimitObserver(int observerId, String callingPackage);
reportUsageStart(in IBinder activity, String token, String callingPackage)74     void reportUsageStart(in IBinder activity, String token, String callingPackage);
reportPastUsageStart(in IBinder activity, String token, long timeAgoMs, String callingPackage)75     void reportPastUsageStart(in IBinder activity, String token, long timeAgoMs,
76             String callingPackage);
reportUsageStop(in IBinder activity, String token, String callingPackage)77     void reportUsageStop(in IBinder activity, String token, String callingPackage);
reportUserInteraction(String packageName, int userId)78     void reportUserInteraction(String packageName, int userId);
getUsageSource()79     int getUsageSource();
forceUsageSourceSettingRead()80     void forceUsageSourceSettingRead();
getLastTimeAnyComponentUsed(String packageName, String callingPackage)81     long getLastTimeAnyComponentUsed(String packageName, String callingPackage);
82     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS)")
queryBroadcastResponseStats( String packageName, long id, String callingPackage, int userId)83     BroadcastResponseStatsList queryBroadcastResponseStats(
84             String packageName, long id, String callingPackage, int userId);
85     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS)")
clearBroadcastResponseStats(String packageName, long id, String callingPackage, int userId)86     void clearBroadcastResponseStats(String packageName, long id, String callingPackage,
87             int userId);
88     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS)")
clearBroadcastEvents(String callingPackage, int userId)89     void clearBroadcastEvents(String callingPackage, int userId);
90     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG)")
getAppStandbyConstant(String key)91     String getAppStandbyConstant(String key);
92 }
93