Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec1c9d94 authored by Kuan Wang's avatar Kuan Wang
Browse files

Remove foreground_service_usage_time_in_ms field which has been merged

into background_usage_time_in_ms in the BatteryUsageStats (b/257392992).

Test: make RunSettingsRoboTests + manual
Bug: 258124768
Bug: 253553141
Change-Id: I0967eec0cbe6d0cb7a0535d744a1046dec1d267b
parent b2cce522
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -629,7 +629,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
            PowerGaugePreference preference, BatteryDiffEntry entry) {
            PowerGaugePreference preference, BatteryDiffEntry entry) {
        final long foregroundUsageTimeInMs = entry.mForegroundUsageTimeInMs;
        final long foregroundUsageTimeInMs = entry.mForegroundUsageTimeInMs;
        final long backgroundUsageTimeInMs = entry.mBackgroundUsageTimeInMs;
        final long backgroundUsageTimeInMs = entry.mBackgroundUsageTimeInMs;
        // TODO: update this value after the new API for foreground service is completed.
        final long totalUsageTimeInMs = foregroundUsageTimeInMs + backgroundUsageTimeInMs;
        final long totalUsageTimeInMs = foregroundUsageTimeInMs + backgroundUsageTimeInMs;
        String usageTimeSummary = null;
        String usageTimeSummary = null;
        // Not shows summary for some system components without usage time.
        // Not shows summary for some system components without usage time.
+1 −10
Original line number Original line Diff line number Diff line
@@ -52,7 +52,6 @@ public class BatteryDiffEntry {
            (a, b) -> Double.compare(b.getPercentOfTotal(), a.getPercentOfTotal());
            (a, b) -> Double.compare(b.getPercentOfTotal(), a.getPercentOfTotal());


    public long mForegroundUsageTimeInMs;
    public long mForegroundUsageTimeInMs;
    public long mForegroundServiceUsageTimeInMs;
    public long mBackgroundUsageTimeInMs;
    public long mBackgroundUsageTimeInMs;
    public double mConsumePower;
    public double mConsumePower;
    public double mForegroundUsageConsumePower;
    public double mForegroundUsageConsumePower;
@@ -83,7 +82,6 @@ public class BatteryDiffEntry {
    public BatteryDiffEntry(
    public BatteryDiffEntry(
            Context context,
            Context context,
            long foregroundUsageTimeInMs,
            long foregroundUsageTimeInMs,
            long foregroundServiceUsageTimeInMs,
            long backgroundUsageTimeInMs,
            long backgroundUsageTimeInMs,
            double consumePower,
            double consumePower,
            double foregroundUsageConsumePower,
            double foregroundUsageConsumePower,
@@ -98,7 +96,6 @@ public class BatteryDiffEntry {
        mBackgroundUsageConsumePower = backgroundUsageConsumePower;
        mBackgroundUsageConsumePower = backgroundUsageConsumePower;
        mCachedUsageConsumePower = cachedUsageConsumePower;
        mCachedUsageConsumePower = cachedUsageConsumePower;
        mForegroundUsageTimeInMs = foregroundUsageTimeInMs;
        mForegroundUsageTimeInMs = foregroundUsageTimeInMs;
        mForegroundServiceUsageTimeInMs = foregroundServiceUsageTimeInMs;
        mBackgroundUsageTimeInMs = backgroundUsageTimeInMs;
        mBackgroundUsageTimeInMs = backgroundUsageTimeInMs;
        mBatteryHistEntry = batteryHistEntry;
        mBatteryHistEntry = batteryHistEntry;
        mUserManager = context.getSystemService(UserManager.class);
        mUserManager = context.getSystemService(UserManager.class);
@@ -121,7 +118,6 @@ public class BatteryDiffEntry {
        return new BatteryDiffEntry(
        return new BatteryDiffEntry(
                this.mContext,
                this.mContext,
                this.mForegroundUsageTimeInMs,
                this.mForegroundUsageTimeInMs,
                this.mForegroundServiceUsageTimeInMs,
                this.mBackgroundUsageTimeInMs,
                this.mBackgroundUsageTimeInMs,
                this.mConsumePower,
                this.mConsumePower,
                this.mForegroundUsageConsumePower,
                this.mForegroundUsageConsumePower,
@@ -385,14 +381,9 @@ public class BatteryDiffEntry {
                        mForegroundUsageConsumePower, mForegroundServiceUsageConsumePower))
                        mForegroundUsageConsumePower, mForegroundServiceUsageConsumePower))
                .append(String.format("\n\tconsume power= background:%f cached:%f",
                .append(String.format("\n\tconsume power= background:%f cached:%f",
                        mBackgroundUsageConsumePower, mCachedUsageConsumePower))
                        mBackgroundUsageConsumePower, mCachedUsageConsumePower))
                .append(String.format("\n\ttime= foreground:%s foregroundService:%s background:%s",
                .append(String.format("\n\ttime= foreground:%s background:%s",
                        StringUtil.formatElapsedTime(mContext, (double) mForegroundUsageTimeInMs,
                        StringUtil.formatElapsedTime(mContext, (double) mForegroundUsageTimeInMs,
                                /*withSeconds=*/ true, /*collapseTimeUnit=*/ false),
                                /*withSeconds=*/ true, /*collapseTimeUnit=*/ false),
                        StringUtil.formatElapsedTime(
                                mContext,
                                (double) mForegroundServiceUsageTimeInMs,
                                /*withSeconds=*/ true,
                                /*collapseTimeUnit=*/ false),
                        StringUtil.formatElapsedTime(mContext, (double) mBackgroundUsageTimeInMs,
                        StringUtil.formatElapsedTime(mContext, (double) mBackgroundUsageTimeInMs,
                                /*withSeconds=*/ true, /*collapseTimeUnit=*/ false)))
                                /*withSeconds=*/ true, /*collapseTimeUnit=*/ false)))
                .append(String.format("\n\tpackage:%s|%s uid:%d userId:%d",
                .append(String.format("\n\tpackage:%s|%s uid:%d userId:%d",
+0 −16
Original line number Original line Diff line number Diff line
@@ -112,7 +112,6 @@ public class BatteryEntry {
    private final int mPowerComponentId;
    private final int mPowerComponentId;
    private long mUsageDurationMs;
    private long mUsageDurationMs;
    private long mTimeInForegroundMs;
    private long mTimeInForegroundMs;
    private long mTimeInForegroundServiceMs;
    private long mTimeInBackgroundMs;
    private long mTimeInBackgroundMs;


    public String mName;
    public String mName;
@@ -176,9 +175,6 @@ public class BatteryEntry {
            getQuickNameIconForUid(uid, packages, loadDataInBackground);
            getQuickNameIconForUid(uid, packages, loadDataInBackground);
            mTimeInForegroundMs =
            mTimeInForegroundMs =
                    uidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_FOREGROUND);
                    uidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_FOREGROUND);
            //TODO: update this to the correct API after the new API is completed.
            mTimeInForegroundServiceMs =
                    uidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_FOREGROUND);
            mTimeInBackgroundMs =
            mTimeInBackgroundMs =
                    uidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_BACKGROUND);
                    uidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_BACKGROUND);
            mConsumedPowerInForeground = safeGetConsumedPower(
            mConsumedPowerInForeground = safeGetConsumedPower(
@@ -436,15 +432,6 @@ public class BatteryEntry {
        }
        }
    }
    }


    /** Returns foreground service time/ms that is attributed to this entry. */
    public long getTimeInForegroundServiceMs() {
        if (mBatteryConsumer instanceof UidBatteryConsumer) {
            return mTimeInForegroundServiceMs;
        } else {
            return 0;
        }
    }

    /** Returns background activity time/ms that is attributed to this entry. */
    /** Returns background activity time/ms that is attributed to this entry. */
    public long getTimeInBackgroundMs() {
    public long getTimeInBackgroundMs() {
        if (mBatteryConsumer instanceof UidBatteryConsumer) {
        if (mBatteryConsumer instanceof UidBatteryConsumer) {
@@ -518,9 +505,6 @@ public class BatteryEntry {
            UidBatteryConsumer uidBatteryConsumer = (UidBatteryConsumer) batteryConsumer;
            UidBatteryConsumer uidBatteryConsumer = (UidBatteryConsumer) batteryConsumer;
            mTimeInForegroundMs += uidBatteryConsumer.getTimeInStateMs(
            mTimeInForegroundMs += uidBatteryConsumer.getTimeInStateMs(
                    UidBatteryConsumer.STATE_FOREGROUND);
                    UidBatteryConsumer.STATE_FOREGROUND);
            //TODO: update this to the correct API after the new API is completed.
            mTimeInForegroundServiceMs += uidBatteryConsumer.getTimeInStateMs(
                    UidBatteryConsumer.STATE_FOREGROUND);
            mTimeInBackgroundMs += uidBatteryConsumer.getTimeInStateMs(
            mTimeInBackgroundMs += uidBatteryConsumer.getTimeInStateMs(
                    UidBatteryConsumer.STATE_BACKGROUND);
                    UidBatteryConsumer.STATE_BACKGROUND);
            mConsumedPowerInForeground += safeGetConsumedPower(
            mConsumedPowerInForeground += safeGetConsumedPower(
+1 −15
Original line number Original line Diff line number Diff line
@@ -56,7 +56,6 @@ public class BatteryHistEntry {
    public final double mCachedUsageConsumePower;
    public final double mCachedUsageConsumePower;
    public final double mPercentOfTotal;
    public final double mPercentOfTotal;
    public final long mForegroundUsageTimeInMs;
    public final long mForegroundUsageTimeInMs;
    public final long mForegroundServiceUsageTimeInMs;
    public final long mBackgroundUsageTimeInMs;
    public final long mBackgroundUsageTimeInMs;
    @BatteryConsumer.PowerComponent
    @BatteryConsumer.PowerComponent
    public final int mDrainType;
    public final int mDrainType;
@@ -91,7 +90,6 @@ public class BatteryHistEntry {
        mCachedUsageConsumePower = batteryInformation.getCachedUsageConsumePower();
        mCachedUsageConsumePower = batteryInformation.getCachedUsageConsumePower();
        mPercentOfTotal = batteryInformation.getPercentOfTotal();
        mPercentOfTotal = batteryInformation.getPercentOfTotal();
        mForegroundUsageTimeInMs = batteryInformation.getForegroundUsageTimeInMs();
        mForegroundUsageTimeInMs = batteryInformation.getForegroundUsageTimeInMs();
        mForegroundServiceUsageTimeInMs = batteryInformation.getForegroundServiceUsageTimeInMs();
        mBackgroundUsageTimeInMs = batteryInformation.getBackgroundUsageTimeInMs();
        mBackgroundUsageTimeInMs = batteryInformation.getBackgroundUsageTimeInMs();
        mDrainType = batteryInformation.getDrainType();
        mDrainType = batteryInformation.getDrainType();
        final DeviceBatteryState deviceBatteryState = batteryInformation.getDeviceBatteryState();
        final DeviceBatteryState deviceBatteryState = batteryInformation.getDeviceBatteryState();
@@ -121,7 +119,6 @@ public class BatteryHistEntry {
        mCachedUsageConsumePower = batteryInformation.getCachedUsageConsumePower();
        mCachedUsageConsumePower = batteryInformation.getCachedUsageConsumePower();
        mPercentOfTotal = batteryInformation.getPercentOfTotal();
        mPercentOfTotal = batteryInformation.getPercentOfTotal();
        mForegroundUsageTimeInMs = batteryInformation.getForegroundUsageTimeInMs();
        mForegroundUsageTimeInMs = batteryInformation.getForegroundUsageTimeInMs();
        mForegroundServiceUsageTimeInMs = batteryInformation.getForegroundServiceUsageTimeInMs();
        mBackgroundUsageTimeInMs = batteryInformation.getBackgroundUsageTimeInMs();
        mBackgroundUsageTimeInMs = batteryInformation.getBackgroundUsageTimeInMs();
        mDrainType = batteryInformation.getDrainType();
        mDrainType = batteryInformation.getDrainType();
        final DeviceBatteryState deviceBatteryState = batteryInformation.getDeviceBatteryState();
        final DeviceBatteryState deviceBatteryState = batteryInformation.getDeviceBatteryState();
@@ -141,7 +138,6 @@ public class BatteryHistEntry {
            double backgroundUsageConsumePower,
            double backgroundUsageConsumePower,
            double cachedUsageConsumePower,
            double cachedUsageConsumePower,
            long foregroundUsageTimeInMs,
            long foregroundUsageTimeInMs,
            long foregroundServiceUsageTimeInMs,
            long backgroundUsageTimeInMs,
            long backgroundUsageTimeInMs,
            int batteryLevel) {
            int batteryLevel) {
        mUid = fromEntry.mUid;
        mUid = fromEntry.mUid;
@@ -160,7 +156,6 @@ public class BatteryHistEntry {
        mCachedUsageConsumePower = cachedUsageConsumePower;
        mCachedUsageConsumePower = cachedUsageConsumePower;
        mPercentOfTotal = fromEntry.mPercentOfTotal;
        mPercentOfTotal = fromEntry.mPercentOfTotal;
        mForegroundUsageTimeInMs = foregroundUsageTimeInMs;
        mForegroundUsageTimeInMs = foregroundUsageTimeInMs;
        mForegroundServiceUsageTimeInMs = foregroundServiceUsageTimeInMs;
        mBackgroundUsageTimeInMs = backgroundUsageTimeInMs;
        mBackgroundUsageTimeInMs = backgroundUsageTimeInMs;
        mDrainType = fromEntry.mDrainType;
        mDrainType = fromEntry.mDrainType;
        mConsumerType = fromEntry.mConsumerType;
        mConsumerType = fromEntry.mConsumerType;
@@ -223,9 +218,8 @@ public class BatteryHistEntry {
                        mForegroundUsageConsumePower, mForegroundServiceUsageConsumePower))
                        mForegroundUsageConsumePower, mForegroundServiceUsageConsumePower))
                .append(String.format("\n\tbackground=%f|cached=%f",
                .append(String.format("\n\tbackground=%f|cached=%f",
                        mBackgroundUsageConsumePower, mCachedUsageConsumePower))
                        mBackgroundUsageConsumePower, mCachedUsageConsumePower))
                .append(String.format("\n\telapsedTime=%d|%d|%d",
                .append(String.format("\n\telapsedTime=%d|%d",
                        Duration.ofMillis(mForegroundUsageTimeInMs).getSeconds(),
                        Duration.ofMillis(mForegroundUsageTimeInMs).getSeconds(),
                        Duration.ofMillis(mForegroundServiceUsageTimeInMs).getSeconds(),
                        Duration.ofMillis(mBackgroundUsageTimeInMs).getSeconds()))
                        Duration.ofMillis(mBackgroundUsageTimeInMs).getSeconds()))
                .append(String.format("\n\tdrainType=%d|consumerType=%d",
                .append(String.format("\n\tdrainType=%d|consumerType=%d",
                        mDrainType, mConsumerType))
                        mDrainType, mConsumerType))
@@ -320,12 +314,6 @@ public class BatteryHistEntry {
                (double) (lowerHistEntry == null ? 0 : lowerHistEntry.mForegroundUsageTimeInMs),
                (double) (lowerHistEntry == null ? 0 : lowerHistEntry.mForegroundUsageTimeInMs),
                (double) upperHistEntry.mForegroundUsageTimeInMs,
                (double) upperHistEntry.mForegroundUsageTimeInMs,
                ratio);
                ratio);
        final double foregroundServiceUsageTimeInMs = interpolate(
                (double) (lowerHistEntry == null
                        ? 0
                        : lowerHistEntry.mForegroundServiceUsageTimeInMs),
                (double) upperHistEntry.mForegroundServiceUsageTimeInMs,
                ratio);
        final double backgroundUsageTimeInMs = interpolate(
        final double backgroundUsageTimeInMs = interpolate(
                (double) (lowerHistEntry == null ? 0 : lowerHistEntry.mBackgroundUsageTimeInMs),
                (double) (lowerHistEntry == null ? 0 : lowerHistEntry.mBackgroundUsageTimeInMs),
                (double) upperHistEntry.mBackgroundUsageTimeInMs,
                (double) upperHistEntry.mBackgroundUsageTimeInMs,
@@ -338,7 +326,6 @@ public class BatteryHistEntry {
                || upperHistEntry.mBackgroundUsageConsumePower < backgroundUsageConsumePower
                || upperHistEntry.mBackgroundUsageConsumePower < backgroundUsageConsumePower
                || upperHistEntry.mCachedUsageConsumePower < cachedUsageConsumePower
                || upperHistEntry.mCachedUsageConsumePower < cachedUsageConsumePower
                || upperHistEntry.mForegroundUsageTimeInMs < foregroundUsageTimeInMs
                || upperHistEntry.mForegroundUsageTimeInMs < foregroundUsageTimeInMs
                || upperHistEntry.mForegroundServiceUsageTimeInMs < foregroundServiceUsageTimeInMs
                || upperHistEntry.mBackgroundUsageTimeInMs < backgroundUsageTimeInMs) {
                || upperHistEntry.mBackgroundUsageTimeInMs < backgroundUsageTimeInMs) {
            if (DEBUG) {
            if (DEBUG) {
                Log.w(TAG, String.format(
                Log.w(TAG, String.format(
@@ -365,7 +352,6 @@ public class BatteryHistEntry {
                backgroundUsageConsumePower,
                backgroundUsageConsumePower,
                cachedUsageConsumePower,
                cachedUsageConsumePower,
                Math.round(foregroundUsageTimeInMs),
                Math.round(foregroundUsageTimeInMs),
                Math.round(foregroundServiceUsageTimeInMs),
                Math.round(backgroundUsageTimeInMs),
                Math.round(backgroundUsageTimeInMs),
                (int) Math.round(batteryLevel));
                (int) Math.round(batteryLevel));
    }
    }
+0 −1
Original line number Original line Diff line number Diff line
@@ -219,7 +219,6 @@ public final class ConvertUtils {
                    .setPercentOfTotal(entry.mPercent)
                    .setPercentOfTotal(entry.mPercent)
                    .setDrainType(entry.getPowerComponentId())
                    .setDrainType(entry.getPowerComponentId())
                    .setForegroundUsageTimeInMs(entry.getTimeInForegroundMs())
                    .setForegroundUsageTimeInMs(entry.getTimeInForegroundMs())
                    .setForegroundServiceUsageTimeInMs(entry.getTimeInForegroundServiceMs())
                    .setBackgroundUsageTimeInMs(entry.getTimeInBackgroundMs());
                    .setBackgroundUsageTimeInMs(entry.getTimeInBackgroundMs());
        }
        }


Loading