Java Code Examples for android.app.usage.UsageStatsManager#STANDBY_BUCKET_ACTIVE

The following examples show how to use android.app.usage.UsageStatsManager#STANDBY_BUCKET_ACTIVE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlarmManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Return the minimum time that should elapse before an app in the specified bucket
 * can receive alarms again
 */
private long getMinDelayForBucketLocked(int bucket) {
    // UsageStats bucket values are treated as floors of their behavioral range.
    // In other words, a bucket value between WORKING and ACTIVE is treated as
    // WORKING, not as ACTIVE.  The ACTIVE and NEVER bucket apply only at specific
    // values.
    final int index;

    if (bucket == UsageStatsManager.STANDBY_BUCKET_NEVER) index = NEVER_INDEX;
    else if (bucket > UsageStatsManager.STANDBY_BUCKET_FREQUENT) index = RARE_INDEX;
    else if (bucket > UsageStatsManager.STANDBY_BUCKET_WORKING_SET) index = FREQUENT_INDEX;
    else if (bucket > UsageStatsManager.STANDBY_BUCKET_ACTIVE) index = WORKING_INDEX;
    else index = ACTIVE_INDEX;

    return mConstants.APP_STANDBY_MIN_DELAYS[index];
}
 
Example 2
Source File: ActivityManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private int bucketNameToBucketValue(String name) {
    String lower = name.toLowerCase();
    if (lower.startsWith("ac")) {
        return UsageStatsManager.STANDBY_BUCKET_ACTIVE;
    } else if (lower.startsWith("wo")) {
        return UsageStatsManager.STANDBY_BUCKET_WORKING_SET;
    } else if (lower.startsWith("fr")) {
        return UsageStatsManager.STANDBY_BUCKET_FREQUENT;
    } else if (lower.startsWith("ra")) {
        return UsageStatsManager.STANDBY_BUCKET_RARE;
    } else if (lower.startsWith("ne")) {
        return UsageStatsManager.STANDBY_BUCKET_NEVER;
    } else {
        try {
            int bucket = Integer.parseInt(lower);
            return bucket;
        } catch (NumberFormatException nfe) {
            getErrPrintWriter().println("Error: Unknown bucket: " + name);
        }
    }
    return -1;
}
 
Example 3
Source File: BucketInfo.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Not localized, for logs and debug only.
 */
public static String bucketToString(int bucket) {
  switch (bucket) {
    case UsageStatsManager.STANDBY_BUCKET_ACTIVE:      return "Active";
    case UsageStatsManager.STANDBY_BUCKET_FREQUENT:    return "Frequent";
    case UsageStatsManager.STANDBY_BUCKET_WORKING_SET: return "Working Set";
    case UsageStatsManager.STANDBY_BUCKET_RARE:        return "Rare";
    case                   STANDBY_BUCKET_EXEMPTED:    return "Exempted";
    default:                                           return "Unknown " + bucket;
  }
}
 
Example 4
Source File: JobSchedulerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public static int standbyBucketToBucketIndex(int bucket) {
    // Normalize AppStandby constants to indices into our bookkeeping
    if (bucket == UsageStatsManager.STANDBY_BUCKET_NEVER) return NEVER_INDEX;
    else if (bucket > UsageStatsManager.STANDBY_BUCKET_FREQUENT) return RARE_INDEX;
    else if (bucket > UsageStatsManager.STANDBY_BUCKET_WORKING_SET) return FREQUENT_INDEX;
    else if (bucket > UsageStatsManager.STANDBY_BUCKET_ACTIVE) return WORKING_INDEX;
    else return ACTIVE_INDEX;
}
 
Example 5
Source File: ApiTwentyEightPlus.java    From linphone-android with GNU General Public License v3.0 5 votes vote down vote up
public static String getAppStandbyBucketNameFromValue(int bucket) {
    switch (bucket) {
        case UsageStatsManager.STANDBY_BUCKET_ACTIVE:
            return "STANDBY_BUCKET_ACTIVE";
        case UsageStatsManager.STANDBY_BUCKET_FREQUENT:
            return "STANDBY_BUCKET_FREQUENT";
        case UsageStatsManager.STANDBY_BUCKET_RARE:
            return "STANDBY_BUCKET_RARE";
        case UsageStatsManager.STANDBY_BUCKET_WORKING_SET:
            return "STANDBY_BUCKET_WORKING_SET";
    }
    return null;
}