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

Commit 23c14fc0 authored by Adrian Roos's avatar Adrian Roos
Browse files

DozeLog: Properly initialize

Adds lazy initialization to all DozeLog traces
that are called externally. Also fixes a bug
where certain traces initialized after logging,
thus missing the first log.

Change-Id: If75d6cc048f76435856f1c570b66cd6ef96e5ee2
Fixes: 30225249
parent 88d57db0
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -57,8 +57,9 @@ public class DozeLog {
    private static SummaryStats sEmergencyCallStats;
    private static SummaryStats sEmergencyCallStats;
    private static SummaryStats[][] sProxStats; // [reason][near/far]
    private static SummaryStats[][] sProxStats; // [reason][near/far]


    public static void tracePickupPulse(boolean withinVibrationThreshold) {
    public static void tracePickupPulse(Context context, boolean withinVibrationThreshold) {
        if (!ENABLED) return;
        if (!ENABLED) return;
        init(context);
        log("pickupPulse withinVibrationThreshold=" + withinVibrationThreshold);
        log("pickupPulse withinVibrationThreshold=" + withinVibrationThreshold);
        (withinVibrationThreshold ? sPickupPulseNearVibrationStats
        (withinVibrationThreshold ? sPickupPulseNearVibrationStats
                : sPickupPulseNotNearVibrationStats).append();
                : sPickupPulseNotNearVibrationStats).append();
@@ -76,8 +77,9 @@ public class DozeLog {
        log("pulseFinish");
        log("pulseFinish");
    }
    }


    public static void traceNotificationPulse(long instance) {
    public static void traceNotificationPulse(Context context, long instance) {
        if (!ENABLED) return;
        if (!ENABLED) return;
        init(context);
        log("notificationPulse instance=" + instance);
        log("notificationPulse instance=" + instance);
        sNotificationPulseStats.append();
        sNotificationPulseStats.append();
    }
    }
@@ -153,9 +155,9 @@ public class DozeLog {
    public static void traceProximityResult(Context context, boolean near, long millis,
    public static void traceProximityResult(Context context, boolean near, long millis,
            int pulseReason) {
            int pulseReason) {
        if (!ENABLED) return;
        if (!ENABLED) return;
        init(context);
        log("proximityResult reason=" + pulseReasonToString(pulseReason) + " near=" + near
        log("proximityResult reason=" + pulseReasonToString(pulseReason) + " near=" + near
                + " millis=" + millis);
                + " millis=" + millis);
        init(context);
        sProxStats[pulseReason][near ? 0 : 1].append();
        sProxStats[pulseReason][near ? 0 : 1].append();
    }
    }


+3 −3
Original line number Original line Diff line number Diff line
@@ -373,7 +373,7 @@ public class DozeService extends DreamService {
        if (DEBUG) Log.d(mTag, "mScheduleResetsRemaining = " + mScheduleResetsRemaining);
        if (DEBUG) Log.d(mTag, "mScheduleResetsRemaining = " + mScheduleResetsRemaining);
        mNotificationPulseTime = notificationTimeMs;
        mNotificationPulseTime = notificationTimeMs;
        if (pulseImmediately) {
        if (pulseImmediately) {
            DozeLog.traceNotificationPulse(0);
            DozeLog.traceNotificationPulse(mContext, 0);
            requestPulse(DozeLog.PULSE_REASON_NOTIFICATION);
            requestPulse(DozeLog.PULSE_REASON_NOTIFICATION);
        }
        }
        // schedule the rest of the pulses
        // schedule the rest of the pulses
@@ -442,7 +442,7 @@ public class DozeService extends DreamService {
            if (NOTIFICATION_PULSE_ACTION.equals(intent.getAction())) {
            if (NOTIFICATION_PULSE_ACTION.equals(intent.getAction())) {
                final long instance = intent.getLongExtra(EXTRA_INSTANCE, -1);
                final long instance = intent.getLongExtra(EXTRA_INSTANCE, -1);
                if (DEBUG) Log.d(mTag, "Received notification pulse intent instance=" + instance);
                if (DEBUG) Log.d(mTag, "Received notification pulse intent instance=" + instance);
                DozeLog.traceNotificationPulse(instance);
                DozeLog.traceNotificationPulse(mContext, instance);
                requestPulse(DozeLog.PULSE_REASON_NOTIFICATION);
                requestPulse(DozeLog.PULSE_REASON_NOTIFICATION);
                rescheduleNotificationPulse(mNotificationLightOn);
                rescheduleNotificationPulse(mNotificationLightOn);
            }
            }
@@ -576,7 +576,7 @@ public class DozeService extends DreamService {
                    resetNotificationResets();
                    resetNotificationResets();
                }
                }
                if (mSensor.getType() == Sensor.TYPE_PICK_UP_GESTURE) {
                if (mSensor.getType() == Sensor.TYPE_PICK_UP_GESTURE) {
                    DozeLog.tracePickupPulse(withinVibrationThreshold);
                    DozeLog.tracePickupPulse(mContext, withinVibrationThreshold);
                }
                }
            } finally {
            } finally {
                mWakeLock.release();
                mWakeLock.release();