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

Commit 6f52d157 authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Pull more data from binder calls.

Exceptions counts by class name and few new fields for binder calls.

> adb shell cmd stats pull-source 10023
Pull from 10023: { 1532528725000000000 49754068496 (10023)0x10000->java.lang.SecurityException[S] 0x20000->2[I]  }
Pull from 10023: { 1532528725000000000 49754068496 (10023)0x10000->java.lang.IllegalArgumentException[S] 0x20000->16[I]  }

Test: manual
Change-Id: I4d24528a7df8edde87f629837fb3117a0504d09e
parent 4471744e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -174,10 +174,16 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
        {android::util::TEMPERATURE, {{}, {}, 1, new ResourceThermalManagerPuller()}},
        // binder_calls
        {android::util::BINDER_CALLS,
         {{4, 5, 6, 8},
          {2, 3, 7, 9, 10, 11},
         {{4, 5, 6, 8, 12},
          {2, 3, 7, 9, 10, 11, 13},
          1 * NS_PER_SEC,
          new StatsCompanionServicePuller(android::util::BINDER_CALLS)}}
          new StatsCompanionServicePuller(android::util::BINDER_CALLS)}},
        // binder_calls_exceptions
        {android::util::BINDER_CALLS_EXCEPTIONS,
         {{},
          {},
          1 * NS_PER_SEC,
          new StatsCompanionServicePuller(android::util::BINDER_CALLS_EXCEPTIONS)}}
        };

StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) {
+8 −0
Original line number Diff line number Diff line
@@ -209,6 +209,13 @@ public class BinderCallsStats implements BinderInternal.Observer {
        return resultCallStats;
    }

    /** @hide */
    public ArrayMap<String, Integer> getExportedExceptionStats() {
        synchronized (mLock) {
            return new ArrayMap(mExceptionCounts);
        }
    }

    public void dump(PrintWriter pw, Map<Integer,String> appIdToPkgNameMap, boolean verbose) {
        synchronized (mLock) {
            dumpLocked(pw, appIdToPkgNameMap, verbose);
@@ -351,6 +358,7 @@ public class BinderCallsStats implements BinderInternal.Observer {
        public int uid;
        public String className;
        public String methodName;
        public boolean screenInteractive;
        public long cpuTimeMicros;
        public long maxCpuTimeMicros;
        public long latencyMicros;
+5 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.ArrayMap;
import android.util.KeyValueListParser;
import android.util.Slog;

@@ -122,6 +123,10 @@ public class BinderCallsStatsService extends Binder {
        public ArrayList<BinderCallsStats.ExportedCallStat> getExportedCallStats() {
            return mBinderCallsStats.getExportedCallStats();
        }

        public ArrayMap<String, Integer> getExportedExceptionStats() {
            return mBinderCallsStats.getExportedExceptionStats();
        }
    }

    public static class LifeCycle extends SystemService {
+21 −1
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

@@ -900,7 +901,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
        List<ExportedCallStat> callStats = binderStats.getExportedCallStats();
        long elapsedNanos = SystemClock.elapsedRealtimeNanos();
        for (ExportedCallStat callStat : callStats) {
            StatsLogEventWrapper e = new StatsLogEventWrapper(elapsedNanos, tagId, 11 /* fields */);
            StatsLogEventWrapper e = new StatsLogEventWrapper(elapsedNanos, tagId, 13 /* fields */);
            e.writeInt(callStat.uid);
            e.writeString(callStat.className);
            e.writeString(callStat.methodName);
@@ -912,6 +913,21 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
            e.writeLong(callStat.maxCpuTimeMicros);
            e.writeLong(callStat.maxReplySizeBytes);
            e.writeLong(callStat.maxRequestSizeBytes);
            e.writeLong(callStat.recordedCallCount);
            e.writeInt(callStat.screenInteractive ? 1 : 0);
            pulledData.add(e);
        }
    }

    private void pullBinderCallsStatsExceptions(int tagId, List<StatsLogEventWrapper> pulledData) {
        BinderCallsStatsService.Internal binderStats =
                LocalServices.getService(BinderCallsStatsService.Internal.class);
        ArrayMap<String, Integer> exceptionStats = binderStats.getExportedExceptionStats();
        long elapsedNanos = SystemClock.elapsedRealtimeNanos();
        for (Entry<String, Integer> entry : exceptionStats.entrySet()) {
            StatsLogEventWrapper e = new StatsLogEventWrapper(elapsedNanos, tagId, 2 /* fields */);
            e.writeString(entry.getKey());
            e.writeInt(entry.getValue());
            pulledData.add(e);
        }
    }
@@ -1002,6 +1018,10 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                pullBinderCallsStats(tagId, ret);
                break;
            }
            case StatsLog.BINDER_CALLS_EXCEPTIONS: {
                pullBinderCallsStatsExceptions(tagId, ret);
                break;
            }
            default:
                Slog.w(TAG, "No such tagId data as " + tagId);
                return null;