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

Commit 6447ca30 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #1769910 (Track activity launch times)

The usage stats service now collects per-activity launch time stats.  There are a number of fixes and improvements to its statistics management and collection; it now operates its calendar in GMT and ensures that for checkin purposes it always reports one day and only one complete day to the checkin service.

Also change the checkin option from "-c" to "--checkin" since it is really a special thing.
parent 60a51818
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.android.internal.os.PkgUsageStats;
interface IUsageStats {
    void noteResumeComponent(in ComponentName componentName);
    void notePauseComponent(in ComponentName componentName);
    void noteLaunchTime(in ComponentName componentName, int millis);
    PkgUsageStats getPkgUsageStats(in ComponentName componentName);
    PkgUsageStats[] getAllPkgUsageStats();
}
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ class BatteryService extends Binder {
    private static final int CRITICAL_BATTERY_LEVEL = 4; 

    private static final int DUMP_MAX_LENGTH = 24 * 1024;
    private static final String[] DUMPSYS_ARGS = new String[] { "-c", "-u" };
    private static final String[] DUMPSYS_ARGS = new String[] { "--checkin", "-u" };
    private static final String BATTERY_STATS_SERVICE_NAME = "batteryinfo";
    
    private static final String DUMPSYS_DATA_PATH = "/data/system/";
+2 −2
Original line number Diff line number Diff line
@@ -1270,7 +1270,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
        mBatteryStatsService.getActiveStatistics().writeLocked();
        
        mUsageStatsService = new UsageStatsService( new File(
                systemDir, "usagestats.bin").toString());
                systemDir, "usagestats").toString());

        mConfiguration.makeDefault();
        mProcessStats.init();
@@ -8401,7 +8401,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen

    private static final void dumpApplicationMemoryUsage(FileDescriptor fd,
            PrintWriter pw, List list, String prefix, String[] args) {
        final boolean isCheckinRequest = scanArgs(args, "-c");
        final boolean isCheckinRequest = scanArgs(args, "--checkin");
        long uptime = SystemClock.uptimeMillis();
        long realtime = SystemClock.elapsedRealtime();
        
+1 −1
Original line number Diff line number Diff line
@@ -295,7 +295,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
            boolean isCheckin = false;
            if (args != null) {
                for (String arg : args) {
                    if ("-c".equals(arg)) {
                    if ("--checkin".equals(arg)) {
                        isCheckin = true;
                        break;
                    }
+11 −7
Original line number Diff line number Diff line
@@ -335,14 +335,18 @@ class HistoryRecord extends IApplicationToken.Stub {
    
    public void windowsVisible() {
        synchronized(service) {
            if (ActivityManagerService.SHOW_ACTIVITY_START_TIME
                    && startTime != 0) {
            if (startTime != 0) {
                long time = SystemClock.uptimeMillis() - startTime;
                if (ActivityManagerService.SHOW_ACTIVITY_START_TIME) {
                    EventLog.writeEvent(ActivityManagerService.LOG_ACTIVITY_LAUNCH_TIME,
                            System.identityHashCode(this), shortComponentName, time);
                    Log.i(ActivityManagerService.TAG, "Displayed activity "
                            + shortComponentName
                            + ": " + time + " ms");
                }
                if (time > 0) {
                    service.mUsageStatsService.noteLaunchTime(realActivity, (int)time);
                }
                startTime = 0;
            }
            if (ActivityManagerService.DEBUG_SWITCH) Log.v(
Loading