• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  */
16 
17 package android.app.usage;
18 
19 import android.content.ComponentName;
20 import android.content.res.Configuration;
21 
22 import java.io.IOException;
23 
24 /**
25  * UsageStatsManager local system service interface.
26  *
27  * {@hide} Only for use within the system server.
28  */
29 public abstract class UsageStatsManagerInternal {
30 
31     /**
32      * Reports an event to the UsageStatsManager.
33      *
34      * @param component The component for which this event occurred.
35      * @param userId The user id to which the component belongs to.
36      * @param eventType The event that occurred. Valid values can be found at
37      * {@link UsageEvents}
38      */
reportEvent(ComponentName component, int userId, int eventType)39     public abstract void reportEvent(ComponentName component, int userId, int eventType);
40 
41     /**
42      * Reports an event to the UsageStatsManager.
43      *
44      * @param packageName The package for which this event occurred.
45      * @param userId The user id to which the component belongs to.
46      * @param eventType The event that occurred. Valid values can be found at
47      * {@link UsageEvents}
48      */
reportEvent(String packageName, int userId, int eventType)49     public abstract void reportEvent(String packageName, int userId, int eventType);
50 
51     /**
52      * Reports a configuration change to the UsageStatsManager.
53      *
54      * @param config The new device configuration.
55      */
reportConfigurationChange(Configuration config, int userId)56     public abstract void reportConfigurationChange(Configuration config, int userId);
57 
58     /**
59      * Reports that a content provider has been accessed by a foreground app.
60      * @param name The authority of the content provider
61      * @param pkgName The package name of the content provider
62      * @param userId The user in which the content provider was accessed.
63      */
reportContentProviderUsage(String name, String pkgName, int userId)64     public abstract void reportContentProviderUsage(String name, String pkgName, int userId);
65 
66     /**
67      * Prepares the UsageStatsService for shutdown.
68      */
prepareShutdown()69     public abstract void prepareShutdown();
70 
71     /**
72      * Returns true if the app has not been used for a certain amount of time. How much time?
73      * Could be hours, could be days, who knows?
74      *
75      * @param packageName
76      * @param uidForAppId The uid of the app, which will be used for its app id
77      * @param userId
78      * @return
79      */
isAppIdle(String packageName, int uidForAppId, int userId)80     public abstract boolean isAppIdle(String packageName, int uidForAppId, int userId);
81 
82     /**
83      * Returns all of the uids for a given user where all packages associating with that uid
84      * are in the app idle state -- there are no associated apps that are not idle.  This means
85      * all of the returned uids can be safely considered app idle.
86      */
getIdleUidsForUser(int userId)87     public abstract int[] getIdleUidsForUser(int userId);
88 
89     /**
90      * @return True if currently app idle parole mode is on.  This means all idle apps are allow to
91      * run for a short period of time.
92      */
isAppIdleParoleOn()93     public abstract boolean isAppIdleParoleOn();
94 
95     /**
96      * Sets up a listener for changes to packages being accessed.
97      * @param listener A listener within the system process.
98      */
addAppIdleStateChangeListener( AppIdleStateChangeListener listener)99     public abstract void addAppIdleStateChangeListener(
100             AppIdleStateChangeListener listener);
101 
102     /**
103      * Removes a listener that was previously added for package usage state changes.
104      * @param listener The listener within the system process to remove.
105      */
removeAppIdleStateChangeListener( AppIdleStateChangeListener listener)106     public abstract void removeAppIdleStateChangeListener(
107             AppIdleStateChangeListener listener);
108 
109     public static abstract class AppIdleStateChangeListener {
onAppIdleStateChanged(String packageName, int userId, boolean idle)110         public abstract void onAppIdleStateChanged(String packageName, int userId, boolean idle);
onParoleStateChanged(boolean isParoleOn)111         public abstract void onParoleStateChanged(boolean isParoleOn);
112     }
113 
114     /*  Backup/Restore API */
getBackupPayload(int user, String key)115     public abstract byte[] getBackupPayload(int user, String key);
116 
applyRestoredPayload(int user, String key, byte[] payload)117     public abstract void applyRestoredPayload(int user, String key, byte[] payload);
118 
119 }
120