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

Commit c2d02b52 authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Use the background thread instead ActivityManager to update CPU stats.

Updating the CPU stats can be quite slow and blocks the ActivityManager
handler thread.

Bug: 115506775
Change-Id: I9f67acfe2724c11d117703b2c4ccdbcc1f61c5ab
Test: manual - dumpsys batterystats | grep CPU
parent ab4bbc03
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -337,6 +337,9 @@ public class BatteryStatsImpl extends BatteryStats {
    private final PlatformIdleStateCallback mPlatformIdleStateCallback;
    /**
     * This handler is running on {@link BackgroundThread}.
     */
    final class MyHandler extends Handler {
        public MyHandler(Looper looper) {
            super(looper, null, true);
+2 −1
Original line number Diff line number Diff line
@@ -2381,7 +2381,8 @@ public class ActivityManagerService extends IActivityManager.Stub
        final File systemDir = SystemServiceManager.ensureSystemDir();
        // TODO: Move creation of battery stats service outside of activity manager service.
        mBatteryStatsService = new BatteryStatsService(systemContext, systemDir, mHandler);
        mBatteryStatsService = new BatteryStatsService(systemContext, systemDir,
                BackgroundThread.get().getHandler());
        mBatteryStatsService.getActiveStatistics().readLocked();
        mBatteryStatsService.scheduleWriteToDisk();
        mOnBattery = DEBUG_POWER ? true