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

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

Merge changes from topic "newnotifpipeline_logs"

* changes:
  SysUi can mock static methods + coordinator tests
  Revert "Revert "Recycle SysuiLogs + add NotifLogs""
parents 1c013ae3 9028d41a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ android_library {
        "SystemUI-proto",
        "metrics-helper-lib",
        "androidx.test.rules", "hamcrest-library",
        "mockito-target-inline-minus-junit4",
        "mockito-target-extended-minus-junit4",
        "testables",
        "truth-prebuilt",
        "dagger2-2.19",
+8 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;

import android.app.INotificationManager;
import android.content.Context;
import android.content.pm.IPackageManager;
import android.hardware.display.AmbientDisplayConfiguration;
import android.hardware.display.NightDisplayListener;
import android.os.Handler;
@@ -147,6 +148,13 @@ public class DependencyProvider {
                ServiceManager.getService(Context.NOTIFICATION_SERVICE));
    }

    /** */
    @Singleton
    @Provides
    public IPackageManager provideIPackageManager() {
        return IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
    }

    /** */
    @Singleton
    @Provides
+7 −19
Original line number Diff line number Diff line
@@ -28,10 +28,12 @@ import java.lang.annotation.RetentionPolicy;
 * and triaging purposes.
 */
public class DozeEvent extends RichEvent {
    public static final int TOTAL_EVENT_TYPES = 19;

    public DozeEvent(int logLevel, int type, String reason) {
        super(logLevel, type, reason);
    /**
     * Initializes a doze event
     */
    public DozeEvent init(@EventType int type, String reason) {
        super.init(DEBUG, type, reason);
        return this;
    }

    /**
@@ -89,21 +91,6 @@ public class DozeEvent extends RichEvent {
        }
    }

    /**
     * Builds a DozeEvent.
     */
    public static class DozeEventBuilder extends RichEvent.Builder<DozeEventBuilder> {
        @Override
        public DozeEventBuilder getBuilder() {
            return this;
        }

        @Override
        public RichEvent build() {
            return new DozeEvent(mLogLevel, mType, mReason);
        }
    }

    @IntDef({PICKUP_WAKEUP, PULSE_START, PULSE_FINISH, NOTIFICATION_PULSE, DOZING, FLING,
            EMERGENCY_CALL, KEYGUARD_BOUNCER_CHANGED, SCREEN_ON, SCREEN_OFF, MISSED_TICK,
            TIME_TICK_SCHEDULED, KEYGUARD_VISIBILITY_CHANGE, DOZE_STATE_CHANGED, WAKE_DISPLAY,
@@ -132,6 +119,7 @@ public class DozeEvent extends RichEvent {
    public static final int PULSE_DROPPED = 16;
    public static final int PULSE_DISABLED_BY_PROX = 17;
    public static final int SENSOR_TRIGGERED = 18;
    public static final int TOTAL_EVENT_TYPES = 19;

    public static final int TOTAL_REASONS = 10;
    @IntDef({PULSE_REASON_NONE, PULSE_REASON_INTENT, PULSE_REASON_NOTIFICATION,
+31 −35
Original line number Diff line number Diff line
@@ -35,9 +35,11 @@ import javax.inject.Singleton;
 *      dependency DumpController DozeLog
 */
@Singleton
public class DozeLog extends SysuiLog {
public class DozeLog extends SysuiLog<DozeEvent> {
    private static final String TAG = "DozeLog";

    private DozeEvent mRecycledEvent;

    private boolean mPulsing;
    private long mSince;
    private SummaryStats mPickupPulseNearVibrationStats;
@@ -73,8 +75,8 @@ public class DozeLog extends SysuiLog {
     * Appends pickup wakeup event to the logs
     */
    public void tracePickupWakeUp(boolean withinVibrationThreshold) {
        if (log(DozeEvent.PICKUP_WAKEUP,
                "withinVibrationThreshold=" + withinVibrationThreshold)) {
        log(DozeEvent.PICKUP_WAKEUP, "withinVibrationThreshold=" + withinVibrationThreshold);
        if (mEnabled) {
            (withinVibrationThreshold ? mPickupPulseNearVibrationStats
                    : mPickupPulseNotNearVibrationStats).append();
        }
@@ -85,27 +87,24 @@ public class DozeLog extends SysuiLog {
     * @param reason why the pulse started
     */
    public void tracePulseStart(@DozeEvent.Reason int reason) {
        if (log(DozeEvent.PULSE_START, DozeEvent.reasonToString(reason))) {
            mPulsing = true;
        }
        log(DozeEvent.PULSE_START, DozeEvent.reasonToString(reason));
        if (mEnabled) mPulsing = true;
    }

    /**
     * Appends pulse finished event to the logs
     */
    public void tracePulseFinish() {
        if (log(DozeEvent.PULSE_FINISH)) {
            mPulsing = false;
        }
        log(DozeEvent.PULSE_FINISH);
        if (mEnabled) mPulsing = false;
    }

    /**
     * Appends pulse event to the logs
     */
    public void traceNotificationPulse() {
        if (log(DozeEvent.NOTIFICATION_PULSE)) {
            mNotificationPulseStats.append();
        }
        log(DozeEvent.NOTIFICATION_PULSE);
        if (mEnabled) mNotificationPulseStats.append();
    }

    /**
@@ -113,9 +112,8 @@ public class DozeLog extends SysuiLog {
     * @param dozing true if dozing, else false
     */
    public void traceDozing(boolean dozing) {
        if (log(DozeEvent.DOZING, "dozing=" + dozing)) {
            mPulsing = false;
        }
        log(DozeEvent.DOZING, "dozing=" + dozing);
        if (mEnabled) mPulsing = false;
    }

    /**
@@ -133,9 +131,8 @@ public class DozeLog extends SysuiLog {
     * Appends emergency call event to the logs
     */
    public void traceEmergencyCall() {
        if (log(DozeEvent.EMERGENCY_CALL)) {
            mEmergencyCallStats.append();
        }
        log(DozeEvent.EMERGENCY_CALL);
        if (mEnabled) mEmergencyCallStats.append();
    }

    /**
@@ -150,7 +147,8 @@ public class DozeLog extends SysuiLog {
     * Appends screen-on event to the logs
     */
    public void traceScreenOn() {
        if (log(DozeEvent.SCREEN_ON, "pulsing=" + mPulsing)) {
        log(DozeEvent.SCREEN_ON, "pulsing=" + mPulsing);
        if (mEnabled) {
            (mPulsing ? mScreenOnPulsingStats : mScreenOnNotPulsingStats).append();
            mPulsing = false;
        }
@@ -188,10 +186,8 @@ public class DozeLog extends SysuiLog {
     * @param showing whether the keyguard is now showing
     */
    public void traceKeyguard(boolean showing) {
        if (log(DozeEvent.KEYGUARD_VISIBILITY_CHANGE, "showing=" + showing)
                && !showing) {
            mPulsing = false;
        }
        log(DozeEvent.KEYGUARD_VISIBILITY_CHANGE, "showing=" + showing);
        if (mEnabled && !showing) mPulsing = false;
    }

    /**
@@ -217,12 +213,11 @@ public class DozeLog extends SysuiLog {
     * @param reason why proximity result was triggered
     */
    public void traceProximityResult(boolean near, long millis, @DozeEvent.Reason int reason) {
        if (log(DozeEvent.PROXIMITY_RESULT,
        log(DozeEvent.PROXIMITY_RESULT,
                " reason=" + DozeEvent.reasonToString(reason)
                        + " near=" + near
                + " millis=" + millis)) {
            mProxStats[reason][near ? 0 : 1].append();
        }
                        + " millis=" + millis);
        if (mEnabled) mProxStats[reason][near ? 0 : 1].append();
    }

    /**
@@ -250,15 +245,16 @@ public class DozeLog extends SysuiLog {
        }
    }

    private boolean log(@DozeEvent.EventType int eventType) {
        return log(eventType, "");
    private void log(@DozeEvent.EventType int eventType) {
        log(eventType, "");
    }

    private boolean log(@DozeEvent.EventType int eventType, String msg) {
        return super.log(new DozeEvent.DozeEventBuilder()
                .setType(eventType)
                .setReason(msg)
                .build());
    private void log(@DozeEvent.EventType int eventType, String msg) {
        if (mRecycledEvent != null) {
            mRecycledEvent = log(mRecycledEvent.init(eventType, msg));
        } else {
            mRecycledEvent = log(new DozeEvent().init(eventType, msg));
        }
    }

    /**
+23 −6
Original line number Diff line number Diff line
@@ -37,20 +37,28 @@ public class Event {
    public static final int INFO = 4;
    public static final int WARN = 5;
    public static final int ERROR = 6;
    public static final @Level int DEFAULT_LOG_LEVEL = DEBUG;

    private long mTimestamp;
    private @Level int mLogLevel = DEBUG;
    protected String mMessage;
    private @Level int mLogLevel = DEFAULT_LOG_LEVEL;
    private String mMessage = "";

    public Event(String message) {
        mTimestamp = System.currentTimeMillis();
        mMessage = message;
    /**
     * initialize an event with a message
     */
    public Event init(String message) {
        init(DEFAULT_LOG_LEVEL, message);
        return this;
    }

    public Event(@Level int logLevel, String message) {
    /**
     * initialize an event with a logLevel and message
     */
    public Event init(@Level int logLevel, String message) {
        mTimestamp = System.currentTimeMillis();
        mLogLevel = logLevel;
        mMessage = message;
        return this;
    }

    public String getMessage() {
@@ -64,4 +72,13 @@ public class Event {
    public @Level int getLogLevel() {
        return mLogLevel;
    }

    /**
     * Recycle this event
     */
    void recycle() {
        mTimestamp = -1;
        mLogLevel = DEFAULT_LOG_LEVEL;
        mMessage = "";
    }
}
Loading