Loading api/current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -6132,6 +6132,7 @@ package android.app.usage { } } public final class UsageStatsManager { public final class UsageStatsManager { method public boolean isAppIdle(java.lang.String); method public java.util.Map<java.lang.String, android.app.usage.UsageStats> queryAndAggregateUsageStats(long, long); method public java.util.Map<java.lang.String, android.app.usage.UsageStats> queryAndAggregateUsageStats(long, long); method public java.util.List<android.app.usage.ConfigurationStats> queryConfigurations(int, long, long); method public java.util.List<android.app.usage.ConfigurationStats> queryConfigurations(int, long, long); method public android.app.usage.UsageEvents queryEvents(long, long); method public android.app.usage.UsageEvents queryEvents(long, long); api/system-current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -6320,6 +6320,7 @@ package android.app.usage { } } public final class UsageStatsManager { public final class UsageStatsManager { method public boolean isAppIdle(java.lang.String); method public java.util.Map<java.lang.String, android.app.usage.UsageStats> queryAndAggregateUsageStats(long, long); method public java.util.Map<java.lang.String, android.app.usage.UsageStats> queryAndAggregateUsageStats(long, long); method public java.util.List<android.app.usage.ConfigurationStats> queryConfigurations(int, long, long); method public java.util.List<android.app.usage.ConfigurationStats> queryConfigurations(int, long, long); method public android.app.usage.UsageEvents queryEvents(long, long); method public android.app.usage.UsageEvents queryEvents(long, long); cmds/am/src/com/android/commands/am/Am.java +51 −0 Original line number Original line Diff line number Diff line Loading @@ -142,6 +142,8 @@ public class Am extends BaseCommand { " am task resizeable <TASK_ID> [true|false]\n" + " am task resizeable <TASK_ID> [true|false]\n" + " am task resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + " am task resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + " am get-config\n" + " am get-config\n" + " am set-idle [--user <USER_ID>] <PACKAGE> true|false\n" + " am get-idle [--user <USER_ID>] <PACKAGE>\n" + "\n" + "\n" + "am start: start an Activity. Options are:\n" + "am start: start an Activity. Options are:\n" + " -D: enable debugging\n" + " -D: enable debugging\n" + Loading Loading @@ -282,6 +284,11 @@ public class Am extends BaseCommand { "am get-config: retrieve the configuration and any recent configurations\n" + "am get-config: retrieve the configuration and any recent configurations\n" + " of the device\n" + " of the device\n" + "\n" + "\n" + "am set-idle: sets the idle state of an app\n" + "\n" + "am get-idle: returns the idle state of an app\n" + "\n" + "\n" + "<INTENT> specifications include these flags and arguments:\n" + "<INTENT> specifications include these flags and arguments:\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + " [-c <CATEGORY> [-c <CATEGORY>] ...]\n" + " [-c <CATEGORY> [-c <CATEGORY>] ...]\n" + Loading Loading @@ -388,6 +395,10 @@ public class Am extends BaseCommand { runTask(); runTask(); } else if (op.equals("get-config")) { } else if (op.equals("get-config")) { runGetConfig(); runGetConfig(); } else if (op.equals("set-idle")) { runSetIdle(); } else if (op.equals("get-idle")) { runGetIdle(); } else { } else { showError("Error: unknown command '" + op + "'"); showError("Error: unknown command '" + op + "'"); } } Loading Loading @@ -2019,6 +2030,46 @@ public class Am extends BaseCommand { } } } } private void runSetIdle() throws Exception { int userId = UserHandle.USER_OWNER; String opt; while ((opt=nextOption()) != null) { if (opt.equals("--user")) { userId = parseUserArg(nextArgRequired()); } else { System.err.println("Error: Unknown option: " + opt); return; } } String packageName = nextArgRequired(); String value = nextArgRequired(); IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService( Context.USAGE_STATS_SERVICE)); usm.setAppIdle(packageName, Boolean.parseBoolean(value), userId); } private void runGetIdle() throws Exception { int userId = UserHandle.USER_OWNER; String opt; while ((opt=nextOption()) != null) { if (opt.equals("--user")) { userId = parseUserArg(nextArgRequired()); } else { System.err.println("Error: Unknown option: " + opt); return; } } String packageName = nextArgRequired(); IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService( Context.USAGE_STATS_SERVICE)); boolean isIdle = usm.isAppIdle(packageName, userId); System.out.println("Idle=" + isIdle); } /** /** * Open the given file for sending into the system process. This verifies * Open the given file for sending into the system process. This verifies * with SELinux that the system will have access to the file. * with SELinux that the system will have access to the file. Loading core/java/android/app/usage/IUsageStatsManager.aidl +2 −0 Original line number Original line Diff line number Diff line Loading @@ -30,4 +30,6 @@ interface IUsageStatsManager { ParceledListSlice queryConfigurationStats(int bucketType, long beginTime, long endTime, ParceledListSlice queryConfigurationStats(int bucketType, long beginTime, long endTime, String callingPackage); String callingPackage); UsageEvents queryEvents(long beginTime, long endTime, String callingPackage); UsageEvents queryEvents(long beginTime, long endTime, String callingPackage); void setAppIdle(String packageName, boolean idle, int userId); boolean isAppIdle(String packageName, int userId); } } core/java/android/app/usage/UsageStatsManager.java +17 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.app.usage; import android.content.Context; import android.content.Context; import android.content.pm.ParceledListSlice; import android.content.pm.ParceledListSlice; import android.os.RemoteException; import android.os.RemoteException; import android.os.UserHandle; import android.util.ArrayMap; import android.util.ArrayMap; import java.util.Collections; import java.util.Collections; Loading Loading @@ -217,4 +218,20 @@ public final class UsageStatsManager { } } return aggregatedStats; return aggregatedStats; } } /** * Returns whether the specified app is currently considered idle. This will be true if the * app hasn't been used directly or indirectly for a period of time defined by the system. This * could be of the order of several hours or days. * @param packageName The package name of the app to query * @return whether the app is currently considered idle */ public boolean isAppIdle(String packageName) { try { return mService.isAppIdle(packageName, UserHandle.myUserId()); } catch (RemoteException e) { // fall through and return default } return false; } } } Loading
api/current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -6132,6 +6132,7 @@ package android.app.usage { } } public final class UsageStatsManager { public final class UsageStatsManager { method public boolean isAppIdle(java.lang.String); method public java.util.Map<java.lang.String, android.app.usage.UsageStats> queryAndAggregateUsageStats(long, long); method public java.util.Map<java.lang.String, android.app.usage.UsageStats> queryAndAggregateUsageStats(long, long); method public java.util.List<android.app.usage.ConfigurationStats> queryConfigurations(int, long, long); method public java.util.List<android.app.usage.ConfigurationStats> queryConfigurations(int, long, long); method public android.app.usage.UsageEvents queryEvents(long, long); method public android.app.usage.UsageEvents queryEvents(long, long);
api/system-current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -6320,6 +6320,7 @@ package android.app.usage { } } public final class UsageStatsManager { public final class UsageStatsManager { method public boolean isAppIdle(java.lang.String); method public java.util.Map<java.lang.String, android.app.usage.UsageStats> queryAndAggregateUsageStats(long, long); method public java.util.Map<java.lang.String, android.app.usage.UsageStats> queryAndAggregateUsageStats(long, long); method public java.util.List<android.app.usage.ConfigurationStats> queryConfigurations(int, long, long); method public java.util.List<android.app.usage.ConfigurationStats> queryConfigurations(int, long, long); method public android.app.usage.UsageEvents queryEvents(long, long); method public android.app.usage.UsageEvents queryEvents(long, long);
cmds/am/src/com/android/commands/am/Am.java +51 −0 Original line number Original line Diff line number Diff line Loading @@ -142,6 +142,8 @@ public class Am extends BaseCommand { " am task resizeable <TASK_ID> [true|false]\n" + " am task resizeable <TASK_ID> [true|false]\n" + " am task resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + " am task resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + " am get-config\n" + " am get-config\n" + " am set-idle [--user <USER_ID>] <PACKAGE> true|false\n" + " am get-idle [--user <USER_ID>] <PACKAGE>\n" + "\n" + "\n" + "am start: start an Activity. Options are:\n" + "am start: start an Activity. Options are:\n" + " -D: enable debugging\n" + " -D: enable debugging\n" + Loading Loading @@ -282,6 +284,11 @@ public class Am extends BaseCommand { "am get-config: retrieve the configuration and any recent configurations\n" + "am get-config: retrieve the configuration and any recent configurations\n" + " of the device\n" + " of the device\n" + "\n" + "\n" + "am set-idle: sets the idle state of an app\n" + "\n" + "am get-idle: returns the idle state of an app\n" + "\n" + "\n" + "<INTENT> specifications include these flags and arguments:\n" + "<INTENT> specifications include these flags and arguments:\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + " [-c <CATEGORY> [-c <CATEGORY>] ...]\n" + " [-c <CATEGORY> [-c <CATEGORY>] ...]\n" + Loading Loading @@ -388,6 +395,10 @@ public class Am extends BaseCommand { runTask(); runTask(); } else if (op.equals("get-config")) { } else if (op.equals("get-config")) { runGetConfig(); runGetConfig(); } else if (op.equals("set-idle")) { runSetIdle(); } else if (op.equals("get-idle")) { runGetIdle(); } else { } else { showError("Error: unknown command '" + op + "'"); showError("Error: unknown command '" + op + "'"); } } Loading Loading @@ -2019,6 +2030,46 @@ public class Am extends BaseCommand { } } } } private void runSetIdle() throws Exception { int userId = UserHandle.USER_OWNER; String opt; while ((opt=nextOption()) != null) { if (opt.equals("--user")) { userId = parseUserArg(nextArgRequired()); } else { System.err.println("Error: Unknown option: " + opt); return; } } String packageName = nextArgRequired(); String value = nextArgRequired(); IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService( Context.USAGE_STATS_SERVICE)); usm.setAppIdle(packageName, Boolean.parseBoolean(value), userId); } private void runGetIdle() throws Exception { int userId = UserHandle.USER_OWNER; String opt; while ((opt=nextOption()) != null) { if (opt.equals("--user")) { userId = parseUserArg(nextArgRequired()); } else { System.err.println("Error: Unknown option: " + opt); return; } } String packageName = nextArgRequired(); IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService( Context.USAGE_STATS_SERVICE)); boolean isIdle = usm.isAppIdle(packageName, userId); System.out.println("Idle=" + isIdle); } /** /** * Open the given file for sending into the system process. This verifies * Open the given file for sending into the system process. This verifies * with SELinux that the system will have access to the file. * with SELinux that the system will have access to the file. Loading
core/java/android/app/usage/IUsageStatsManager.aidl +2 −0 Original line number Original line Diff line number Diff line Loading @@ -30,4 +30,6 @@ interface IUsageStatsManager { ParceledListSlice queryConfigurationStats(int bucketType, long beginTime, long endTime, ParceledListSlice queryConfigurationStats(int bucketType, long beginTime, long endTime, String callingPackage); String callingPackage); UsageEvents queryEvents(long beginTime, long endTime, String callingPackage); UsageEvents queryEvents(long beginTime, long endTime, String callingPackage); void setAppIdle(String packageName, boolean idle, int userId); boolean isAppIdle(String packageName, int userId); } }
core/java/android/app/usage/UsageStatsManager.java +17 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.app.usage; import android.content.Context; import android.content.Context; import android.content.pm.ParceledListSlice; import android.content.pm.ParceledListSlice; import android.os.RemoteException; import android.os.RemoteException; import android.os.UserHandle; import android.util.ArrayMap; import android.util.ArrayMap; import java.util.Collections; import java.util.Collections; Loading Loading @@ -217,4 +218,20 @@ public final class UsageStatsManager { } } return aggregatedStats; return aggregatedStats; } } /** * Returns whether the specified app is currently considered idle. This will be true if the * app hasn't been used directly or indirectly for a period of time defined by the system. This * could be of the order of several hours or days. * @param packageName The package name of the app to query * @return whether the app is currently considered idle */ public boolean isAppIdle(String packageName) { try { return mService.isAppIdle(packageName, UserHandle.myUserId()); } catch (RemoteException e) { // fall through and return default } return false; } } }