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

Commit 46c2b145 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Reset binder call stats along with batterystats" into pi-dev

parents 43ca6add 8aa51245
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ public class BatteryStatsImpl extends BatteryStats {
    static final int MSG_REPORT_CPU_UPDATE_NEEDED = 1;
    static final int MSG_REPORT_POWER_CHANGE = 2;
    static final int MSG_REPORT_CHARGING = 3;
    static final int MSG_REPORT_RESET_STATS = 4;
    static final long DELAY_UPDATE_WAKELOCKS = 5*1000;
    private final KernelWakelockReader mKernelWakelockReader = new KernelWakelockReader();
@@ -319,6 +320,7 @@ public class BatteryStatsImpl extends BatteryStats {
        public void batteryNeedsCpuUpdate();
        public void batteryPowerChanged(boolean onBattery);
        public void batterySendBroadcast(Intent intent);
        public void batteryStatsReset();
    }
    public interface PlatformIdleStateCallback {
@@ -373,6 +375,10 @@ public class BatteryStatsImpl extends BatteryStats {
                        cb.batterySendBroadcast(intent);
                    }
                    break;
                case MSG_REPORT_RESET_STATS:
                    if (cb != null) {
                        cb.batteryStatsReset();
                    }
                }
        }
    }
@@ -10939,6 +10945,7 @@ public class BatteryStatsImpl extends BatteryStats {
        initDischarge();
        clearHistoryLocked();
        mHandler.sendEmptyMessage(MSG_REPORT_RESET_STATS);
    }
    private void initActiveHistoryEventsLocked(long elapsedRealtimeMs, long uptimeMs) {
+9 −5
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.internal.os;

import android.os.Binder;
import android.os.SystemClock;
import android.text.format.DateFormat;
import android.util.ArrayMap;
import android.util.SparseArray;

@@ -46,6 +47,7 @@ public class BinderCallsStats {
    private final SparseArray<UidEntry> mUidEntries = new SparseArray<>();
    private final Queue<CallSession> mCallSessionsPool = new ConcurrentLinkedQueue<>();
    private final Object mLock = new Object();
    private long mStartTime = System.currentTimeMillis();

    private BinderCallsStats() {
    }
@@ -108,6 +110,8 @@ public class BinderCallsStats {
        Map<Integer, Long> uidCallCountMap = new HashMap<>();
        long totalCallsCount = 0;
        long totalCallsTime = 0;
        pw.print("Start time: ");
        pw.println(DateFormat.format("yyyy-MM-dd HH:mm:ss", mStartTime));
        int uidEntriesSize = mUidEntries.size();
        List<UidEntry> entries = new ArrayList<>();
        synchronized (mLock) {
@@ -126,7 +130,6 @@ public class BinderCallsStats {
            }
        }
        if (mDetailedTracking) {
            pw.println("Binder call stats:");
            pw.println("Raw data (uid,call_desc,time):");
            entries.sort((o1, o2) -> {
                if (o1.time < o2.time) {
@@ -201,6 +204,7 @@ public class BinderCallsStats {
    public void reset() {
        synchronized (mLock) {
            mUidEntries.clear();
            mStartTime = System.currentTimeMillis();
        }
    }

+6 −0
Original line number Diff line number Diff line
@@ -433,6 +433,7 @@ import com.android.internal.util.Preconditions;
import com.android.server.AlarmManagerInternal;
import com.android.server.AppOpsService;
import com.android.server.AttributeCache;
import com.android.server.BinderCallsStatsService;
import com.android.server.DeviceIdleController;
import com.android.server.IntentResolver;
import com.android.server.IoThread;
@@ -3412,6 +3413,11 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    @Override
    public void batteryStatsReset() {
        BinderCallsStatsService.reset();
    }
    @Override
    public void batterySendBroadcast(Intent intent) {
        synchronized (this) {