Merge "Change the method to get foreground time." into oc-dr1-dev am: 9463219048

am: 3829eca2d8

Change-Id: I3b6b2a38534feb99b6c795c660734093cb7bbb2e
This commit is contained in:
jackqdyulei
2017-06-23 21:44:35 +00:00
committed by android-build-merger
2 changed files with 22 additions and 13 deletions

View File

@@ -45,6 +45,7 @@ import java.util.List;
*/
public class BatteryUtils {
public static final int UID_NULL = -1;
@Retention(RetentionPolicy.SOURCE)
@IntDef({StatusType.FOREGROUND,
StatusType.BACKGROUND,
@@ -171,7 +172,9 @@ public class BatteryUtils {
for (int i = 0, size = sippers.size(); i < size; i++) {
final BatteryStats.Uid uid = sippers.get(i).uidObj;
if (uid != null) {
final long timeMs = getForegroundActivityTotalTimeMs(uid, rawRealtimeMs);
final long timeMs = Math.min(getForegroundActivityTotalTimeMs(uid, rawRealtimeMs),
getProcessTimeMs(StatusType.FOREGROUND, uid,
BatteryStats.STATS_SINCE_CHARGED));
activityTimeArray.put(uid.getUid(), timeMs);
totalActivityTimeMs += timeMs;
}
@@ -248,7 +251,6 @@ public class BatteryUtils {
* @return the package name. If there are multiple packages related to
* given id, return the first one. Or return null if there are no known
* packages with the given id
*
* @see PackageManager#getPackagesForUid(int)
*/
public String getPackageName(int uid) {