Log when app move to foreground or background.
Together with screen state change, we will have appusage info. Test: manually test on device Change-Id: Ie9cfe0376cf0d6339be5e8e96f7b360c3f0771d6
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user