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

Commit e094dce2 authored by Chandru S's avatar Chandru S Committed by Automerger Merge Worker
Browse files

Merge "Suspend and resume DozeTriggers when entering and exiting car mode."...

Merge "Suspend and resume DozeTriggers when entering and exiting car mode." into tm-qpr-dev am: 293f9890 am: c8844676

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18660994



Change-Id: Ic74afdd7d448073df24cdae03c8218df6b342029
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 395ca75d c8844676
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@ Note: The default UI used in AOD shares views with the Lock Screen and does not
### DOZE
Device is asleep and listening for enabled pulsing and wake-up gesture triggers. In this state, no UI shows.

### DOZE_SUSPEND_TRIGGERS
Device is asleep and not listening for any triggers to wake up. This state is used only when CAR_MODE is active. In this state, no UI shows.

### DOZE_AOD
Device is asleep, showing UI, and listening for enabled pulsing and wake-up triggers. In this state, screen brightness is handled by [DozeScreenBrightness][5] which uses the brightness sensor specified by `doze_brightness_sensor_type` in the [SystemUI config][6]. To save power, this should be a low-powered sensor that shouldn't trigger as often as the light sensor used for on-screen adaptive brightness.

+14 −0
Original line number Diff line number Diff line
@@ -331,6 +331,20 @@ public class DozeLog implements Dumpable {
        mLogger.logImmediatelyEndDoze(reason);
    }

    /**
     * Logs the car mode started event.
     */
    public void traceCarModeStarted() {
        mLogger.logCarModeStarted();
    }

    /**
     * Logs the car mode ended event.
     */
    public void traceCarModeEnded() {
        mLogger.logCarModeEnded();
    }

    /**
     * Appends power save changes that may cause a new doze state
     * @param powerSaveActive true if power saving is active
+15 −3
Original line number Diff line number Diff line
@@ -299,6 +299,18 @@ class DozeLogger @Inject constructor(
            "Doze aod dimming scrim opacity set, opacity=$long1"
        })
    }

    fun logCarModeEnded() {
        buffer.log(TAG, INFO, {}, {
            "Doze car mode ended"
        })
    }

    fun logCarModeStarted() {
        buffer.log(TAG, INFO, {}, {
            "Doze car mode started"
        })
    }
}

private const val TAG = "DozeLog"
+20 −12
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWA
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING;

import android.annotation.MainThread;
import android.app.UiModeManager;
import android.content.res.Configuration;
import android.hardware.display.AmbientDisplayConfiguration;
import android.os.Trace;
import android.os.UserHandle;
@@ -33,7 +35,6 @@ import com.android.systemui.doze.dagger.WrappedService;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.keyguard.WakefulnessLifecycle.Wakefulness;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.util.Assert;
import com.android.systemui.util.wakelock.WakeLock;

@@ -66,6 +67,8 @@ public class DozeMachine {
        INITIALIZED,
        /** Regular doze. Device is asleep and listening for pulse triggers. */
        DOZE,
        /** Deep doze. Device is asleep and is not listening for pulse triggers. */
        DOZE_SUSPEND_TRIGGERS,
        /** Always-on doze. Device is asleep, showing UI and listening for pulse triggers. */
        DOZE_AOD,
        /** Pulse has been requested. Device is awake and preparing UI */
@@ -125,6 +128,7 @@ public class DozeMachine {
                            : Display.STATE_ON;
                case DOZE_AOD_PAUSED:
                case DOZE:
                case DOZE_SUSPEND_TRIGGERS:
                    return Display.STATE_OFF;
                case DOZE_PULSING:
                case DOZE_PULSING_BRIGHT:
@@ -143,26 +147,27 @@ public class DozeMachine {
    private final WakeLock mWakeLock;
    private final AmbientDisplayConfiguration mConfig;
    private final WakefulnessLifecycle mWakefulnessLifecycle;
    private final BatteryController mBatteryController;
    private final DozeHost mDozeHost;
    private Part[] mParts;
    private final UiModeManager mUiModeManager;
    private final DockManager mDockManager;
    private final Part[] mParts;

    private final ArrayList<State> mQueuedRequests = new ArrayList<>();
    private State mState = State.UNINITIALIZED;
    private int mPulseReason;
    private boolean mWakeLockHeldForCurrentState = false;
    private DockManager mDockManager;

    @Inject
    public DozeMachine(@WrappedService Service service, AmbientDisplayConfiguration config,
            WakeLock wakeLock, WakefulnessLifecycle wakefulnessLifecycle,
            BatteryController batteryController, DozeLog dozeLog, DockManager dockManager,
            UiModeManager uiModeManager,
            DozeLog dozeLog, DockManager dockManager,
            DozeHost dozeHost, Part[] parts) {
        mDozeService = service;
        mConfig = config;
        mWakefulnessLifecycle = wakefulnessLifecycle;
        mWakeLock = wakeLock;
        mBatteryController = batteryController;
        mUiModeManager = uiModeManager;
        mDozeLog = dozeLog;
        mDockManager = dockManager;
        mDozeHost = dozeHost;
@@ -244,7 +249,7 @@ public class DozeMachine {
        Assert.isMainThread();
        if (isExecutingTransition()) {
            throw new IllegalStateException("Cannot get state because there were pending "
                    + "transitions: " + mQueuedRequests.toString());
                    + "transitions: " + mQueuedRequests);
        }
        return mState;
    }
@@ -313,11 +318,8 @@ public class DozeMachine {
        }
        mDozeLog.traceDozeStateSendComplete(newState);

        switch (newState) {
            case FINISH:
        if (newState == State.FINISH) {
            mDozeService.finish();
                break;
            default:
        }
    }

@@ -357,6 +359,12 @@ public class DozeMachine {
        if (mState == State.FINISH) {
            return State.FINISH;
        }
        if (mUiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR
                && (requestedState.canPulse() || requestedState.staysAwake())) {
            Log.i(TAG, "Doze is suppressed with all triggers disabled as car mode is active");
            mDozeLog.traceCarModeStarted();
            return State.DOZE_SUSPEND_TRIGGERS;
        }
        if (mDozeHost.isAlwaysOnSuppressed() && requestedState.isAlwaysOn()) {
            Log.i(TAG, "Doze is suppressed by an app. Suppressing state: " + requestedState);
            mDozeLog.traceAlwaysOnSuppressed(requestedState, "app");
+1 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
                setLightSensorEnabled(true);
                break;
            case DOZE:
            case DOZE_SUSPEND_TRIGGERS:
                setLightSensorEnabled(false);
                resetBrightnessToDefault();
                break;
Loading