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

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

Merge "Atom and logging for foreground service state changes"

parents f3f6f000 ccfe6455
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -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.
    }

@@ -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).
 *
@@ -1463,3 +1483,4 @@ message RemainingBatteryCapacity {
message FullBatteryCapacity {
    optional int32 capacity_uAh = 1;
}
+8 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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) {
@@ -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);
@@ -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;