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.UsageEvents;
21 import android.content.pm.ParceledListSlice;
22 
23 import java.util.Map;
24 
25 /**
26  * System private API for talking with the UsageStatsManagerService.
27  *
28  * {@hide}
29  */
30 interface IUsageStatsManager {
31     @UnsupportedAppUsage
queryUsageStats(int bucketType, long beginTime, long endTime, String callingPackage)32     ParceledListSlice queryUsageStats(int bucketType, long beginTime, long endTime,
33             String callingPackage);
34     @UnsupportedAppUsage
queryConfigurationStats(int bucketType, long beginTime, long endTime, String callingPackage)35     ParceledListSlice queryConfigurationStats(int bucketType, long beginTime, long endTime,
36             String callingPackage);
queryEventStats(int bucketType, long beginTime, long endTime, String callingPackage)37     ParceledListSlice queryEventStats(int bucketType, long beginTime, long endTime,
38             String callingPackage);
queryEvents(long beginTime, long endTime, String callingPackage)39     UsageEvents queryEvents(long beginTime, long endTime, String callingPackage);
queryEventsForPackage(long beginTime, long endTime, String callingPackage)40     UsageEvents queryEventsForPackage(long beginTime, long endTime, String callingPackage);
queryEventsForUser(long beginTime, long endTime, int userId, String callingPackage)41     UsageEvents queryEventsForUser(long beginTime, long endTime, int userId, String callingPackage);
queryEventsForPackageForUser(long beginTime, long endTime, int userId, String pkg, String callingPackage)42     UsageEvents queryEventsForPackageForUser(long beginTime, long endTime, int userId, String pkg, String callingPackage);
43     @UnsupportedAppUsage
setAppInactive(String packageName, boolean inactive, int userId)44     void setAppInactive(String packageName, boolean inactive, int userId);
45     @UnsupportedAppUsage
isAppInactive(String packageName, int userId)46     boolean isAppInactive(String packageName, int userId);
whitelistAppTemporarily(String packageName, long duration, int userId)47     void whitelistAppTemporarily(String packageName, long duration, int userId);
onCarrierPrivilegedAppsChanged()48     void onCarrierPrivilegedAppsChanged();
reportChooserSelection(String packageName, int userId, String contentType, in String[] annotations, String action)49     void reportChooserSelection(String packageName, int userId, String contentType,
50             in String[] annotations, String action);
getAppStandbyBucket(String packageName, String callingPackage, int userId)51     int getAppStandbyBucket(String packageName, String callingPackage, int userId);
setAppStandbyBucket(String packageName, int bucket, int userId)52     void setAppStandbyBucket(String packageName, int bucket, int userId);
getAppStandbyBuckets(String callingPackage, int userId)53     ParceledListSlice getAppStandbyBuckets(String callingPackage, int userId);
setAppStandbyBuckets(in ParceledListSlice appBuckets, int userId)54     void setAppStandbyBuckets(in ParceledListSlice appBuckets, int userId);
registerAppUsageObserver(int observerId, in String[] packages, long timeLimitMs, in PendingIntent callback, String callingPackage)55     void registerAppUsageObserver(int observerId, in String[] packages, long timeLimitMs,
56             in PendingIntent callback, String callingPackage);
unregisterAppUsageObserver(int observerId, String callingPackage)57     void unregisterAppUsageObserver(int observerId, String callingPackage);
registerUsageSessionObserver(int sessionObserverId, in String[] observed, long timeLimitMs, long sessionThresholdTimeMs, in PendingIntent limitReachedCallbackIntent, in PendingIntent sessionEndCallbackIntent, String callingPackage)58     void registerUsageSessionObserver(int sessionObserverId, in String[] observed, long timeLimitMs,
59             long sessionThresholdTimeMs, in PendingIntent limitReachedCallbackIntent,
60             in PendingIntent sessionEndCallbackIntent, String callingPackage);
unregisterUsageSessionObserver(int sessionObserverId, String callingPackage)61     void unregisterUsageSessionObserver(int sessionObserverId, String callingPackage);
registerAppUsageLimitObserver(int observerId, in String[] packages, long timeLimitMs, long timeUsedMs, in PendingIntent callback, String callingPackage)62     void registerAppUsageLimitObserver(int observerId, in String[] packages, long timeLimitMs,
63             long timeUsedMs, in PendingIntent callback, String callingPackage);
unregisterAppUsageLimitObserver(int observerId, String callingPackage)64     void unregisterAppUsageLimitObserver(int observerId, String callingPackage);
reportUsageStart(in IBinder activity, String token, String callingPackage)65     void reportUsageStart(in IBinder activity, String token, String callingPackage);
reportPastUsageStart(in IBinder activity, String token, long timeAgoMs, String callingPackage)66     void reportPastUsageStart(in IBinder activity, String token, long timeAgoMs,
67             String callingPackage);
reportUsageStop(in IBinder activity, String token, String callingPackage)68     void reportUsageStop(in IBinder activity, String token, String callingPackage);
getUsageSource()69     int getUsageSource();
forceUsageSourceSettingRead()70     void forceUsageSourceSettingRead();
71 }
72