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

Commit 32ddd534 authored by Adam Lesinski's avatar Adam Lesinski Committed by Android (Google) Code Review
Browse files

Merge "BatteryStats: Account for remaining OS wakelock time at the end of...

Merge "BatteryStats: Account for remaining OS wakelock time at the end of processing all apps" into mnc-dev
parents 5cd293b3 43f222f0
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line Diff line number Diff line
@@ -480,6 +480,7 @@ public final class BatteryStatsHelper {
        final boolean forAllUsers = (asUsers.get(UserHandle.USER_ALL) != null);
        final boolean forAllUsers = (asUsers.get(UserHandle.USER_ALL) != null);
        mStatsPeriod = mTypeBatteryRealtime;
        mStatsPeriod = mTypeBatteryRealtime;


        BatterySipper osSipper = null;
        final SparseArray<? extends Uid> uidStats = mStats.getUidStats();
        final SparseArray<? extends Uid> uidStats = mStats.getUidStats();
        final int NU = uidStats.size();
        final int NU = uidStats.size();
        for (int iu = 0; iu < NU; iu++) {
        for (int iu = 0; iu < NU; iu++) {
@@ -526,14 +527,18 @@ public final class BatteryStatsHelper {
                }
                }


                if (uid == 0) {
                if (uid == 0) {
                    osSipper = app;
                }
            }
        }

        if (osSipper != null) {
            // The device has probably been awake for longer than the screen on
            // The device has probably been awake for longer than the screen on
            // time and application wake lock time would account for.  Assign
            // time and application wake lock time would account for.  Assign
            // this remainder to the OS, if possible.
            // this remainder to the OS, if possible.
                    mWakelockPowerCalculator.calculateRemaining(app, mStats, mRawRealtime,
            mWakelockPowerCalculator.calculateRemaining(osSipper, mStats, mRawRealtime,
                                                        mRawUptime, mStatsType);
                                                        mRawUptime, mStatsType);
                    app.sumPower();
            osSipper.sumPower();
                }
            }
        }
        }
    }
    }