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

Commit 06659c5a authored by Lifu Tang's avatar Lifu Tang Committed by Android (Google) Code Review
Browse files

Merge "Creates Sipper even the consumption is very little" into klp-dev

parents 47aab2ee ad7bfbd3
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -320,7 +320,12 @@ public class BatteryStatsHelper {
                R.string.details_title, null, null, 0);
    }

    public void refreshStats() {
    /**
     * Refreshes the power usage list.
     * @param includeZeroConsumption whether includes those applications which have consumed very
     *                               little power up till now.
     */
    public void refreshStats(boolean includeZeroConsumption) {
        // Initialize mStats if necessary.
        getStats();

@@ -336,7 +341,7 @@ public class BatteryStatsHelper {
        mUserSippers.clear();
        mUserPower.clear();

        processAppUsage();
        processAppUsage(includeZeroConsumption);
        processMiscUsage();

        Collections.sort(mUsageList);
@@ -356,7 +361,7 @@ public class BatteryStatsHelper {
        }
    }

    private void processAppUsage() {
    private void processAppUsage(boolean includeZeroConsumption) {
        SensorManager sensorManager = (SensorManager) mActivity.getSystemService(
                Context.SENSOR_SERVICE);
        final int which = mStatsType;
@@ -522,7 +527,7 @@ public class BatteryStatsHelper {
            // Add the app to the list if it is consuming power
            boolean isOtherUser = false;
            final int userId = UserHandle.getUserId(u.getUid());
            if (power != 0 || u.getUid() == 0) {
            if (power != 0 || includeZeroConsumption || u.getUid() == 0) {
                BatterySipper app = new BatterySipper(mActivity, mRequestQueue, mHandler,
                        packageWithHighestDrain, DrainType.APP, 0, u,
                        new double[] {power});
+1 −1
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ public class PowerUsageSummary extends PreferenceFragment {
            addNotAvailableMessage();
            return;
        }
        mStatsHelper.refreshStats();
        mStatsHelper.refreshStats(false);
        List<BatterySipper> usageList = mStatsHelper.getUsageList();
        for (BatterySipper sipper : usageList) {
            if (sipper.getSortValue() < MIN_POWER_THRESHOLD) continue;
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ public class RecentLocationApps {
    public List<Preference> getAppList() {
        // Retrieve Uid-based battery blaming info and generate a package to BatterySipper HashMap
        // for later faster looking up.
        mStatsHelper.refreshStats();
        mStatsHelper.refreshStats(true);
        List<BatterySipper> usageList = mStatsHelper.getUsageList();
        // Key: package Uid. Value: BatterySipperWrapper.
        HashMap<Integer, BatterySipperWrapper> sipperMap =