Merge "Reset binder call stats along with batterystats" into pi-dev
am: 46c2b1451c
Change-Id: Icc1749b2e67a9b7015a08dd7ddfb481337531aa9
This commit is contained in:
@@ -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,7 +375,11 @@ 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) {
|
||||
|
||||
@@ -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,8 +130,7 @@ public class BinderCallsStats {
|
||||
}
|
||||
}
|
||||
if (mDetailedTracking) {
|
||||
pw.println("Binder call stats:");
|
||||
pw.println(" Raw data (uid,call_desc,time):");
|
||||
pw.println("Raw data (uid,call_desc,time):");
|
||||
entries.sort((o1, o2) -> {
|
||||
if (o1.time < o2.time) {
|
||||
return 1;
|
||||
@@ -155,12 +158,12 @@ public class BinderCallsStats {
|
||||
}
|
||||
}
|
||||
pw.println();
|
||||
pw.println(" Per UID Summary(UID: time, % of total_time, calls_count):");
|
||||
pw.println("Per UID Summary(UID: time, % of total_time, calls_count):");
|
||||
List<Map.Entry<Integer, Long>> uidTotals = new ArrayList<>(uidTimeMap.entrySet());
|
||||
uidTotals.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));
|
||||
for (Map.Entry<Integer, Long> uidTotal : uidTotals) {
|
||||
Long callCount = uidCallCountMap.get(uidTotal.getKey());
|
||||
pw.println(String.format(" %7d: %11d %3.0f%% %8d",
|
||||
pw.println(String.format(" %7d: %11d %3.0f%% %8d",
|
||||
uidTotal.getKey(), uidTotal.getValue(),
|
||||
100d * uidTotal.getValue() / totalCallsTime, callCount));
|
||||
}
|
||||
@@ -170,7 +173,7 @@ public class BinderCallsStats {
|
||||
totalCallsTime, totalCallsCount,
|
||||
(double)totalCallsTime / totalCallsCount));
|
||||
} else {
|
||||
pw.println(" Per UID Summary(UID: calls_count, % of total calls_count):");
|
||||
pw.println("Per UID Summary(UID: calls_count, % of total calls_count):");
|
||||
List<Map.Entry<Integer, Long>> uidTotals = new ArrayList<>(uidTimeMap.entrySet());
|
||||
uidTotals.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));
|
||||
for (Map.Entry<Integer, Long> uidTotal : uidTotals) {
|
||||
@@ -201,6 +204,7 @@ public class BinderCallsStats {
|
||||
public void reset() {
|
||||
synchronized (mLock) {
|
||||
mUidEntries.clear();
|
||||
mStartTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user