Loading cmds/statsd/src/atoms.proto +21 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,7 @@ message Atom { BootSequenceReported boot_sequence_reported = 57; DaveyOccurred davey_occurred = 58; OverlayStateChanged overlay_state_changed = 59; ForegroundServiceStateChanged foreground_service_state_changed = 60; // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15. } Loading Loading @@ -998,6 +999,25 @@ message OverlayStateChanged { optional State state = 4; } /* * Logs foreground service starts and stops. * Note that this is not when a service starts or stops, but when it is * considered foreground. * Logged from * //frameworks/base/services/core/java/com/android/server/am/ActiveServices.java */ message ForegroundServiceStateChanged { optional int32 uid = 1; // package_name + "/" + class_name optional string short_name = 2; enum State { ENTER = 1; EXIT = 2; } optional State state = 3; } /** * Pulls bytes transferred via wifi (Sum of foreground and background usage). * Loading Loading @@ -1463,3 +1483,4 @@ message RemainingBatteryCapacity { message FullBatteryCapacity { optional int32 capacity_uAh = 1; } services/core/java/com/android/server/am/ActiveServices.java +8 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ import android.os.UserHandle; import android.util.EventLog; import android.util.PrintWriterPrinter; import android.util.Slog; import android.util.StatsLog; import android.util.SparseArray; import android.util.TimeUtils; import android.util.proto.ProtoOutputStream; Loading Loading @@ -1094,6 +1095,8 @@ public final class ActiveServices { active.mNumActive++; } r.isForeground = true; StatsLog.write(StatsLog.FOREGROUND_SERVICE_STATE_CHANGED, r.userId, r.shortName, StatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__ENTER); } r.postNotification(); if (r.app != null) { Loading @@ -1109,6 +1112,8 @@ public final class ActiveServices { decActiveForegroundAppLocked(smap, r); } r.isForeground = false; StatsLog.write(StatsLog.FOREGROUND_SERVICE_STATE_CHANGED, r.userId, r.shortName, StatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__EXIT); if (r.app != null) { mAm.updateLruProcessLocked(r.app, false, null); updateServiceForegroundLocked(r.app, true); Loading Loading @@ -2533,7 +2538,10 @@ public final class ActiveServices { cancelForegroundNotificationLocked(r); if (r.isForeground) { decActiveForegroundAppLocked(smap, r); StatsLog.write(StatsLog.FOREGROUND_SERVICE_STATE_CHANGED, r.userId, r.shortName, StatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__EXIT); } r.isForeground = false; r.foregroundId = 0; r.foregroundNoti = null; Loading Loading
cmds/statsd/src/atoms.proto +21 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,7 @@ message Atom { BootSequenceReported boot_sequence_reported = 57; DaveyOccurred davey_occurred = 58; OverlayStateChanged overlay_state_changed = 59; ForegroundServiceStateChanged foreground_service_state_changed = 60; // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15. } Loading Loading @@ -998,6 +999,25 @@ message OverlayStateChanged { optional State state = 4; } /* * Logs foreground service starts and stops. * Note that this is not when a service starts or stops, but when it is * considered foreground. * Logged from * //frameworks/base/services/core/java/com/android/server/am/ActiveServices.java */ message ForegroundServiceStateChanged { optional int32 uid = 1; // package_name + "/" + class_name optional string short_name = 2; enum State { ENTER = 1; EXIT = 2; } optional State state = 3; } /** * Pulls bytes transferred via wifi (Sum of foreground and background usage). * Loading Loading @@ -1463,3 +1483,4 @@ message RemainingBatteryCapacity { message FullBatteryCapacity { optional int32 capacity_uAh = 1; }
services/core/java/com/android/server/am/ActiveServices.java +8 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ import android.os.UserHandle; import android.util.EventLog; import android.util.PrintWriterPrinter; import android.util.Slog; import android.util.StatsLog; import android.util.SparseArray; import android.util.TimeUtils; import android.util.proto.ProtoOutputStream; Loading Loading @@ -1094,6 +1095,8 @@ public final class ActiveServices { active.mNumActive++; } r.isForeground = true; StatsLog.write(StatsLog.FOREGROUND_SERVICE_STATE_CHANGED, r.userId, r.shortName, StatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__ENTER); } r.postNotification(); if (r.app != null) { Loading @@ -1109,6 +1112,8 @@ public final class ActiveServices { decActiveForegroundAppLocked(smap, r); } r.isForeground = false; StatsLog.write(StatsLog.FOREGROUND_SERVICE_STATE_CHANGED, r.userId, r.shortName, StatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__EXIT); if (r.app != null) { mAm.updateLruProcessLocked(r.app, false, null); updateServiceForegroundLocked(r.app, true); Loading Loading @@ -2533,7 +2538,10 @@ public final class ActiveServices { cancelForegroundNotificationLocked(r); if (r.isForeground) { decActiveForegroundAppLocked(smap, r); StatsLog.write(StatsLog.FOREGROUND_SERVICE_STATE_CHANGED, r.userId, r.shortName, StatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__EXIT); } r.isForeground = false; r.foregroundId = 0; r.foregroundNoti = null; Loading