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

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

Merge "Improve logging for NightDisplayService/TwilightService" into nyc-mr1-dev

parents c3eedd97 ec8837ae
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -182,6 +182,8 @@ public final class NightDisplayService extends SystemService
    }

    private void setUp() {
        Slog.d(TAG, "setUp: currentUser=" + mCurrentUser);

        // Create a new controller for the current user and start listening for changes.
        mController = new NightDisplayController(getContext(), mCurrentUser);
        mController.setListener(this);
@@ -196,6 +198,8 @@ public final class NightDisplayService extends SystemService
    }

    private void tearDown() {
        Slog.d(TAG, "tearDown: currentUser=" + mCurrentUser);

        if (mController != null) {
            mController.setListener(null);
            mController = null;
@@ -273,6 +277,8 @@ public final class NightDisplayService extends SystemService

    @Override
    public void onAutoModeChanged(int autoMode) {
        Slog.d(TAG, "onAutoModeChanged: autoMode=" + autoMode);

        if (mAutoMode != null) {
            mAutoMode.onStop();
            mAutoMode = null;
@@ -291,6 +297,8 @@ public final class NightDisplayService extends SystemService

    @Override
    public void onCustomStartTimeChanged(NightDisplayController.LocalTime startTime) {
        Slog.d(TAG, "onCustomStartTimeChanged: startTime=" + startTime);

        if (mAutoMode != null) {
            mAutoMode.onCustomStartTimeChanged(startTime);
        }
@@ -298,6 +306,8 @@ public final class NightDisplayService extends SystemService

    @Override
    public void onCustomEndTimeChanged(NightDisplayController.LocalTime endTime) {
        Slog.d(TAG, "onCustomEndTimeChanged: endTime=" + endTime);

        if (mAutoMode != null) {
            mAutoMode.onCustomEndTimeChanged(endTime);
        }
@@ -419,7 +429,7 @@ public final class NightDisplayService extends SystemService

        @Override
        public void onAlarm() {
            if (DEBUG) Slog.d(TAG, "onAlarm");
            Slog.d(TAG, "onAlarm");
            updateActivated();
        }
    }
@@ -477,7 +487,8 @@ public final class NightDisplayService extends SystemService

        @Override
        public void onTwilightStateChanged(@Nullable TwilightState state) {
            if (DEBUG) Slog.d(TAG, "onTwilightStateChanged");
            Slog.d(TAG, "onTwilightStateChanged: isNight="
                    + (state == null ? null : state.isNight()));
            updateActivated(state);
        }
    }
+12 −7
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ public final class TwilightService extends SystemService
    }

    private void startListening() {
        if (DEBUG) Slog.d(TAG, "startListening");
        Slog.d(TAG, "startListening");

        // Start listening for location updates (default: low power, max 1h, min 10m).
        mLocationManager.requestLocationUpdates(
@@ -173,7 +173,7 @@ public final class TwilightService extends SystemService
            mTimeChangedReceiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    if (DEBUG) Slog.d(TAG, "onReceive: " + intent);
                    Slog.d(TAG, "onReceive: " + intent);
                    updateTwilightState();
                }
            };
@@ -188,7 +188,7 @@ public final class TwilightService extends SystemService
    }

    private void stopListening() {
        if (DEBUG) Slog.d(TAG, "stopListening");
        Slog.d(TAG, "stopListening");

        if (mTimeChangedReceiver != null) {
            getContext().unregisterReceiver(mTimeChangedReceiver);
@@ -241,16 +241,21 @@ public final class TwilightService extends SystemService

    @Override
    public void onAlarm() {
        if (DEBUG) Slog.d(TAG, "onAlarm");
        Slog.d(TAG, "onAlarm");
        updateTwilightState();
    }

    @Override
    public void onLocationChanged(Location location) {
        if (DEBUG) Slog.d(TAG, "onLocationChanged: " + location);
        if (location != null) {
            Slog.d(TAG, "onLocationChanged:"
                    + " provider=" + location.getProvider()
                    + " accuracy=" + location.getAccuracy()
                    + " time=" + location.getTime());
            mLastLocation = location;
            updateTwilightState();
        }
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {