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

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

Merge "Log when app move to foreground or background."

parents 57780d44 3d4f604a
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ message StatsEvent {
        PhoneSignalStrengthChanged phone_signal_strength_changed = 40;
        SettingChanged setting_changed = 41;
        KernelWakelockPulled kernel_wakelock_pulled = 42;
        ActivityForegroundStateChanged activity_foreground_state_changed = 43;
        // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
    }
}
@@ -693,3 +694,20 @@ message KernelWakelockPulled {
    optional int64 total_time = 3;
    optional string name = 4;
}

/*
 * Logs activity going to foreground or background
 *
 * Logged from:
  *   frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
 */
message ActivityForegroundStateChanged {
    enum Activity {
        MOVE_TO_BACKGROUND = 0;
        MOVE_TO_FOREGROUND = 1;
    }
    optional int32 uid = 1;
    optional string pkg_name = 2;
    optional string class_name = 3;
    optional Activity activity = 4;
}
+4 −0
Original line number Diff line number Diff line
@@ -4043,10 +4043,14 @@ public class ActivityManagerService extends IActivityManager.Stub
        if (DEBUG_SWITCH) Slog.d(TAG_SWITCH,
                "updateUsageStats: comp=" + component + "res=" + resumed);
        final BatteryStatsImpl stats = mBatteryStatsService.getActiveStatistics();
        StatsLog.write(StatsLog.ACTIVITY_FOREGROUND_STATE_CHANGED,
            component.userId, component.realActivity.getPackageName(),
            component.realActivity.getShortClassName(), resumed ? 1 : 0);
        if (resumed) {
            if (mUsageStatsService != null) {
                mUsageStatsService.reportEvent(component.realActivity, component.userId,
                        UsageEvents.Event.MOVE_TO_FOREGROUND);
            }
            synchronized (stats) {
                stats.noteActivityResumedLocked(component.app.uid);