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 /** 23 * UsageStatsManager local system service interface. 24 * 25 * {@hide} Only for use within the system server. 26 */ 27 public abstract class UsageStatsManagerInternal { 28 29 /** 30 * Reports an event to the UsageStatsManager. 31 * 32 * @param component The component for which this event occurred. 33 * @param userId The user id to which the component belongs to. 34 * @param eventType The event that occurred. Valid values can be found at 35 * {@link UsageEvents} 36 */ reportEvent(ComponentName component, int userId, int eventType)37 public abstract void reportEvent(ComponentName component, int userId, int eventType); 38 39 /** 40 * Reports an event to the UsageStatsManager. 41 * 42 * @param packageName The package for which this event occurred. 43 * @param userId The user id to which the component belongs to. 44 * @param eventType The event that occurred. Valid values can be found at 45 * {@link UsageEvents} 46 */ reportEvent(String packageName, int userId, int eventType)47 public abstract void reportEvent(String packageName, int userId, int eventType); 48 49 /** 50 * Reports a configuration change to the UsageStatsManager. 51 * 52 * @param config The new device configuration. 53 */ reportConfigurationChange(Configuration config, int userId)54 public abstract void reportConfigurationChange(Configuration config, int userId); 55 56 /** 57 * Reports that a content provider has been accessed by a foreground app. 58 * @param name The authority of the content provider 59 * @param pkgName The package name of the content provider 60 * @param userId The user in which the content provider was accessed. 61 */ reportContentProviderUsage(String name, String pkgName, int userId)62 public abstract void reportContentProviderUsage(String name, String pkgName, int userId); 63 64 /** 65 * Prepares the UsageStatsService for shutdown. 66 */ prepareShutdown()67 public abstract void prepareShutdown(); 68 69 /** 70 * Returns true if the app has not been used for a certain amount of time. How much time? 71 * Could be hours, could be days, who knows? 72 * 73 * @param packageName 74 * @param uidForAppId The uid of the app, which will be used for its app id 75 * @param userId 76 * @return 77 */ isAppIdle(String packageName, int uidForAppId, int userId)78 public abstract boolean isAppIdle(String packageName, int uidForAppId, int userId); 79 80 /** 81 * Returns all of the uids for a given user where all packages associating with that uid 82 * are in the app idle state -- there are no associated apps that are not idle. This means 83 * all of the returned uids can be safely considered app idle. 84 */ getIdleUidsForUser(int userId)85 public abstract int[] getIdleUidsForUser(int userId); 86 87 /** 88 * @return True if currently app idle parole mode is on. This means all idle apps are allow to 89 * run for a short period of time. 90 */ isAppIdleParoleOn()91 public abstract boolean isAppIdleParoleOn(); 92 93 /** 94 * Sets up a listener for changes to packages being accessed. 95 * @param listener A listener within the system process. 96 */ addAppIdleStateChangeListener( AppIdleStateChangeListener listener)97 public abstract void addAppIdleStateChangeListener( 98 AppIdleStateChangeListener listener); 99 100 /** 101 * Removes a listener that was previously added for package usage state changes. 102 * @param listener The listener within the system process to remove. 103 */ removeAppIdleStateChangeListener( AppIdleStateChangeListener listener)104 public abstract void removeAppIdleStateChangeListener( 105 AppIdleStateChangeListener listener); 106 107 public static abstract class AppIdleStateChangeListener { onAppIdleStateChanged(String packageName, int userId, boolean idle)108 public abstract void onAppIdleStateChanged(String packageName, int userId, boolean idle); onParoleStateChanged(boolean isParoleOn)109 public abstract void onParoleStateChanged(boolean isParoleOn); 110 } 111 112 } 113