Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.doze; |
| 18 | |
Lucas Dupin | b7fd1eb | 2019-03-28 12:05:17 -0700 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Adrian Roos | 6023ccb | 2017-06-28 16:22:02 +0200 | [diff] [blame] | 20 | import android.app.AlarmManager; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 21 | import android.app.UiModeManager; |
| 22 | import android.content.BroadcastReceiver; |
| 23 | import android.content.Context; |
| 24 | import android.content.Intent; |
| 25 | import android.content.IntentFilter; |
| 26 | import android.content.res.Configuration; |
Issei Suzuki | ca19e6e | 2019-02-26 12:39:11 +0100 | [diff] [blame] | 27 | import android.hardware.display.AmbientDisplayConfiguration; |
Steven Wu | de35305 | 2019-03-12 13:49:23 -0400 | [diff] [blame] | 28 | import android.metrics.LogMaker; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 29 | import android.os.Handler; |
| 30 | import android.os.SystemClock; |
| 31 | import android.os.UserHandle; |
| 32 | import android.text.format.Formatter; |
| 33 | import android.util.Log; |
| 34 | |
lpeter | 8a5f470 | 2019-01-18 16:53:07 +0800 | [diff] [blame] | 35 | import com.android.internal.annotations.VisibleForTesting; |
Steven Wu | de35305 | 2019-03-12 13:49:23 -0400 | [diff] [blame] | 36 | import com.android.internal.logging.MetricsLogger; |
| 37 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Steven Wu | de35305 | 2019-03-12 13:49:23 -0400 | [diff] [blame] | 38 | import com.android.systemui.Dependency; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 39 | import com.android.systemui.broadcast.BroadcastDispatcher; |
lpeter | 8a5f470 | 2019-01-18 16:53:07 +0800 | [diff] [blame] | 40 | import com.android.systemui.dock.DockManager; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 41 | import com.android.systemui.statusbar.phone.DozeParameters; |
| 42 | import com.android.systemui.util.Assert; |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 43 | import com.android.systemui.util.sensors.AsyncSensorManager; |
| 44 | import com.android.systemui.util.sensors.ProximitySensor; |
Adrian Roos | c1b5032 | 2017-02-27 21:07:58 +0100 | [diff] [blame] | 45 | import com.android.systemui.util.wakelock.WakeLock; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 46 | |
| 47 | import java.io.PrintWriter; |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 48 | import java.util.function.Consumer; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * Handles triggers for ambient state changes. |
| 52 | */ |
| 53 | public class DozeTriggers implements DozeMachine.Part { |
| 54 | |
| 55 | private static final String TAG = "DozeTriggers"; |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 56 | private static final boolean DEBUG = DozeService.DEBUG; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 57 | |
| 58 | /** adb shell am broadcast -a com.android.systemui.doze.pulse com.android.systemui */ |
| 59 | private static final String PULSE_ACTION = "com.android.systemui.doze.pulse"; |
| 60 | |
Lucas Dupin | 1ae6cf9 | 2018-12-14 18:06:38 -0800 | [diff] [blame] | 61 | /** |
| 62 | * Last value sent by the wake-display sensor. |
| 63 | * Assuming that the screen should start on. |
| 64 | */ |
| 65 | private static boolean sWakeDisplaySensorState = true; |
| 66 | |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 67 | private static final int PROXIMITY_TIMEOUT_DELAY_MS = 500; |
| 68 | |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 69 | private final Context mContext; |
| 70 | private final DozeMachine mMachine; |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 71 | private final DozeLog mDozeLog; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 72 | private final DozeSensors mDozeSensors; |
| 73 | private final DozeHost mDozeHost; |
| 74 | private final AmbientDisplayConfiguration mConfig; |
| 75 | private final DozeParameters mDozeParameters; |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 76 | private final AsyncSensorManager mSensorManager; |
Adrian Roos | c1b5032 | 2017-02-27 21:07:58 +0100 | [diff] [blame] | 77 | private final WakeLock mWakeLock; |
Adrian Roos | f9d13f6 | 2016-11-08 15:42:20 -0800 | [diff] [blame] | 78 | private final boolean mAllowPulseTriggers; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 79 | private final UiModeManager mUiModeManager; |
| 80 | private final TriggerReceiver mBroadcastReceiver = new TriggerReceiver(); |
lpeter | 8a5f470 | 2019-01-18 16:53:07 +0800 | [diff] [blame] | 81 | private final DockEventListener mDockEventListener = new DockEventListener(); |
| 82 | private final DockManager mDockManager; |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 83 | private final ProximitySensor.ProximityCheck mProxCheck; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 84 | private final BroadcastDispatcher mBroadcastDispatcher; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 85 | |
| 86 | private long mNotificationPulseTime; |
| 87 | private boolean mPulsePending; |
| 88 | |
Steven Wu | de35305 | 2019-03-12 13:49:23 -0400 | [diff] [blame] | 89 | private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 90 | |
| 91 | public DozeTriggers(Context context, DozeMachine machine, DozeHost dozeHost, |
Adrian Roos | 6023ccb | 2017-06-28 16:22:02 +0200 | [diff] [blame] | 92 | AlarmManager alarmManager, AmbientDisplayConfiguration config, |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 93 | DozeParameters dozeParameters, AsyncSensorManager sensorManager, Handler handler, |
Dave Mankoff | bf52f4b | 2019-09-20 14:34:28 -0400 | [diff] [blame] | 94 | WakeLock wakeLock, boolean allowPulseTriggers, DockManager dockManager, |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 95 | ProximitySensor proximitySensor, |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 96 | DozeLog dozeLog, BroadcastDispatcher broadcastDispatcher) { |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 97 | mContext = context; |
| 98 | mMachine = machine; |
| 99 | mDozeHost = dozeHost; |
| 100 | mConfig = config; |
| 101 | mDozeParameters = dozeParameters; |
| 102 | mSensorManager = sensorManager; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 103 | mWakeLock = wakeLock; |
Adrian Roos | f9d13f6 | 2016-11-08 15:42:20 -0800 | [diff] [blame] | 104 | mAllowPulseTriggers = allowPulseTriggers; |
Adrian Roos | 6023ccb | 2017-06-28 16:22:02 +0200 | [diff] [blame] | 105 | mDozeSensors = new DozeSensors(context, alarmManager, mSensorManager, dozeParameters, |
Dave Mankoff | 86c7344 | 2019-12-17 12:15:16 -0500 | [diff] [blame] | 106 | config, wakeLock, this::onSensor, this::onProximityFar, dozeLog); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 107 | mUiModeManager = mContext.getSystemService(UiModeManager.class); |
lpeter | 8a5f470 | 2019-01-18 16:53:07 +0800 | [diff] [blame] | 108 | mDockManager = dockManager; |
Dave Mankoff | bf52f4b | 2019-09-20 14:34:28 -0400 | [diff] [blame] | 109 | mProxCheck = new ProximitySensor.ProximityCheck(proximitySensor, handler); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 110 | mDozeLog = dozeLog; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 111 | mBroadcastDispatcher = broadcastDispatcher; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 114 | private void onNotification(Runnable onPulseSuppressedListener) { |
Dave Mankoff | 15bbec6 | 2019-06-27 15:17:42 -0400 | [diff] [blame] | 115 | if (DozeMachine.DEBUG) { |
| 116 | Log.d(TAG, "requestNotificationPulse"); |
| 117 | } |
| 118 | if (!sWakeDisplaySensorState) { |
| 119 | Log.d(TAG, "Wake display false. Pulse denied."); |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 120 | runIfNotNull(onPulseSuppressedListener); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 121 | mDozeLog.tracePulseDropped("wakeDisplaySensor"); |
Dave Mankoff | 15bbec6 | 2019-06-27 15:17:42 -0400 | [diff] [blame] | 122 | return; |
| 123 | } |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 124 | mNotificationPulseTime = SystemClock.elapsedRealtime(); |
Dave Mankoff | 15bbec6 | 2019-06-27 15:17:42 -0400 | [diff] [blame] | 125 | if (!mConfig.pulseOnNotificationEnabled(UserHandle.USER_CURRENT)) { |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 126 | runIfNotNull(onPulseSuppressedListener); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 127 | mDozeLog.tracePulseDropped("pulseOnNotificationsDisabled"); |
Dave Mankoff | 15bbec6 | 2019-06-27 15:17:42 -0400 | [diff] [blame] | 128 | return; |
| 129 | } |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 130 | requestPulse(DozeEvent.PULSE_REASON_NOTIFICATION, false /* performedProxCheck */, |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 131 | onPulseSuppressedListener); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 132 | mDozeLog.traceNotificationPulse(); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 133 | } |
| 134 | |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 135 | private static void runIfNotNull(Runnable runnable) { |
| 136 | if (runnable != null) { |
| 137 | runnable.run(); |
| 138 | } |
| 139 | } |
| 140 | |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 141 | private void proximityCheckThenCall(Consumer<Boolean> callback, |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 142 | boolean alreadyPerformedProxCheck, |
Lucas Dupin | 323f9ff | 2018-08-27 16:55:56 -0700 | [diff] [blame] | 143 | int reason) { |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 144 | Boolean cachedProxNear = mDozeSensors.isProximityCurrentlyNear(); |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 145 | if (alreadyPerformedProxCheck) { |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 146 | callback.accept(null); |
| 147 | } else if (cachedProxNear != null) { |
| 148 | callback.accept(cachedProxNear); |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 149 | } else { |
| 150 | final long start = SystemClock.uptimeMillis(); |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 151 | mProxCheck.check(PROXIMITY_TIMEOUT_DELAY_MS, near -> { |
| 152 | final long end = SystemClock.uptimeMillis(); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 153 | mDozeLog.traceProximityResult( |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 154 | near == null ? false : near, |
| 155 | end - start, |
| 156 | reason); |
| 157 | callback.accept(near); |
| 158 | mWakeLock.release(TAG); |
| 159 | }); |
| 160 | mWakeLock.acquire(TAG); |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 161 | } |
| 162 | } |
| 163 | |
lpeter | 8a5f470 | 2019-01-18 16:53:07 +0800 | [diff] [blame] | 164 | @VisibleForTesting |
Lucas Dupin | f40bd8f | 2019-08-07 15:55:00 -0700 | [diff] [blame] | 165 | void onSensor(int pulseReason, float screenX, float screenY, float[] rawValues) { |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 166 | boolean isDoubleTap = pulseReason == DozeEvent.REASON_SENSOR_DOUBLE_TAP; |
| 167 | boolean isTap = pulseReason == DozeEvent.REASON_SENSOR_TAP; |
| 168 | boolean isPickup = pulseReason == DozeEvent.REASON_SENSOR_PICKUP; |
| 169 | boolean isLongPress = pulseReason == DozeEvent.PULSE_REASON_SENSOR_LONG_PRESS; |
| 170 | boolean isWakeDisplay = pulseReason == DozeEvent.REASON_SENSOR_WAKE_UP; |
| 171 | boolean isWakeLockScreen = pulseReason == DozeEvent.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN; |
Lucas Dupin | b2d9f48 | 2018-11-16 18:55:13 -0800 | [diff] [blame] | 172 | boolean wakeEvent = rawValues != null && rawValues.length > 0 && rawValues[0] != 0; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 173 | |
Lucas Dupin | b2d9f48 | 2018-11-16 18:55:13 -0800 | [diff] [blame] | 174 | if (isWakeDisplay) { |
Lucas Dupin | b7fd1eb | 2019-03-28 12:05:17 -0700 | [diff] [blame] | 175 | onWakeScreen(wakeEvent, mMachine.isExecutingTransition() ? null : mMachine.getState()); |
Lucas Dupin | 8a13aa7 | 2019-02-22 12:45:21 -0800 | [diff] [blame] | 176 | } else if (isLongPress) { |
Lucas Dupin | f40bd8f | 2019-08-07 15:55:00 -0700 | [diff] [blame] | 177 | requestPulse(pulseReason, true /* alreadyPerformedProxCheck */, |
| 178 | null /* onPulseSupressedListener */); |
Lucas Dupin | 8a13aa7 | 2019-02-22 12:45:21 -0800 | [diff] [blame] | 179 | } else if (isWakeLockScreen) { |
| 180 | if (wakeEvent) { |
Lucas Dupin | f40bd8f | 2019-08-07 15:55:00 -0700 | [diff] [blame] | 181 | requestPulse(pulseReason, true /* alreadyPerformedProxCheck */, |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 182 | null /* onPulseSupressedListener */); |
Lucas Dupin | 8a13aa7 | 2019-02-22 12:45:21 -0800 | [diff] [blame] | 183 | } |
Lucas Dupin | 4359b55 | 2018-08-09 15:07:54 -0700 | [diff] [blame] | 184 | } else { |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 185 | proximityCheckThenCall((result) -> { |
Dave Mankoff | bf52f4b | 2019-09-20 14:34:28 -0400 | [diff] [blame] | 186 | if (result != null && result) { |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 187 | // In pocket, drop event. |
| 188 | return; |
| 189 | } |
Lucas Dupin | d43bf70 | 2019-01-15 13:40:42 -0800 | [diff] [blame] | 190 | if (isDoubleTap || isTap) { |
| 191 | if (screenX != -1 && screenY != -1) { |
| 192 | mDozeHost.onSlpiTap(screenX, screenY); |
| 193 | } |
Lucas Dupin | ed5b7a9 | 2019-03-20 11:00:27 -0700 | [diff] [blame] | 194 | gentleWakeUp(pulseReason); |
Lucas Dupin | b2d9f48 | 2018-11-16 18:55:13 -0800 | [diff] [blame] | 195 | } else if (isPickup) { |
Lucas Dupin | ed5b7a9 | 2019-03-20 11:00:27 -0700 | [diff] [blame] | 196 | gentleWakeUp(pulseReason); |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 197 | } else { |
Lucas Dupin | 5f00fa5 | 2019-03-27 22:46:53 -0700 | [diff] [blame] | 198 | mDozeHost.extendPulse(pulseReason); |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 199 | } |
Lucas Dupin | f40bd8f | 2019-08-07 15:55:00 -0700 | [diff] [blame] | 200 | }, true /* alreadyPerformedProxCheck */, pulseReason); |
Adrian Roos | ed85e58 | 2017-04-27 15:09:28 -0700 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | if (isPickup) { |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 204 | final long timeSinceNotification = |
| 205 | SystemClock.elapsedRealtime() - mNotificationPulseTime; |
| 206 | final boolean withinVibrationThreshold = |
| 207 | timeSinceNotification < mDozeParameters.getPickupVibrationThreshold(); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 208 | mDozeLog.tracePickupWakeUp(withinVibrationThreshold); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | |
Lucas Dupin | ed5b7a9 | 2019-03-20 11:00:27 -0700 | [diff] [blame] | 212 | private void gentleWakeUp(int reason) { |
| 213 | // Log screen wake up reason (lift/pickup, tap, double-tap) |
| 214 | mMetricsLogger.write(new LogMaker(MetricsEvent.DOZING) |
| 215 | .setType(MetricsEvent.TYPE_UPDATE) |
| 216 | .setSubtype(reason)); |
| 217 | if (mDozeParameters.getDisplayNeedsBlanking()) { |
| 218 | // Let's prepare the display to wake-up by drawing black. |
| 219 | // This will cover the hardware wake-up sequence, where the display |
| 220 | // becomes black for a few frames. |
Lucas Dupin | 34306c3 | 2019-07-16 11:56:53 -0700 | [diff] [blame] | 221 | mDozeHost.setAodDimmingScrim(1f); |
Lucas Dupin | ed5b7a9 | 2019-03-20 11:00:27 -0700 | [diff] [blame] | 222 | } |
| 223 | mMachine.wakeUp(); |
| 224 | } |
| 225 | |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 226 | private void onProximityFar(boolean far) { |
Lucas Dupin | 1946b31 | 2019-03-21 14:48:23 -0700 | [diff] [blame] | 227 | // Proximity checks are asynchronous and the user might have interacted with the phone |
| 228 | // when a new event is arriving. This means that a state transition might have happened |
| 229 | // and the proximity check is now obsolete. |
| 230 | if (mMachine.isExecutingTransition()) { |
| 231 | Log.w(TAG, "onProximityFar called during transition. Ignoring sensor response."); |
| 232 | return; |
| 233 | } |
| 234 | |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 235 | final boolean near = !far; |
Adrian Roos | 6023ccb | 2017-06-28 16:22:02 +0200 | [diff] [blame] | 236 | final DozeMachine.State state = mMachine.getState(); |
Adrian Roos | c7fd696 | 2017-09-06 16:46:46 +0200 | [diff] [blame] | 237 | final boolean paused = (state == DozeMachine.State.DOZE_AOD_PAUSED); |
| 238 | final boolean pausing = (state == DozeMachine.State.DOZE_AOD_PAUSING); |
| 239 | final boolean aod = (state == DozeMachine.State.DOZE_AOD); |
Adrian Roos | 6023ccb | 2017-06-28 16:22:02 +0200 | [diff] [blame] | 240 | |
Lucas Dupin | 5f00fa5 | 2019-03-27 22:46:53 -0700 | [diff] [blame] | 241 | if (state == DozeMachine.State.DOZE_PULSING |
| 242 | || state == DozeMachine.State.DOZE_PULSING_BRIGHT) { |
Adrian Roos | a6c03f8 | 2017-07-26 16:20:30 +0200 | [diff] [blame] | 243 | boolean ignoreTouch = near; |
Dave Mankoff | 15bbec6 | 2019-06-27 15:17:42 -0400 | [diff] [blame] | 244 | if (DEBUG) { |
| 245 | Log.i(TAG, "Prox changed, ignore touch = " + ignoreTouch); |
| 246 | } |
Adrian Roos | a6c03f8 | 2017-07-26 16:20:30 +0200 | [diff] [blame] | 247 | mDozeHost.onIgnoreTouchWhilePulsing(ignoreTouch); |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 248 | } |
Lucas Dupin | 6510438 | 2018-12-04 11:53:42 -0800 | [diff] [blame] | 249 | |
Adrian Roos | c7fd696 | 2017-09-06 16:46:46 +0200 | [diff] [blame] | 250 | if (far && (paused || pausing)) { |
Dave Mankoff | 15bbec6 | 2019-06-27 15:17:42 -0400 | [diff] [blame] | 251 | if (DEBUG) { |
| 252 | Log.i(TAG, "Prox FAR, unpausing AOD"); |
| 253 | } |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 254 | mMachine.requestState(DozeMachine.State.DOZE_AOD); |
Adrian Roos | 6023ccb | 2017-06-28 16:22:02 +0200 | [diff] [blame] | 255 | } else if (near && aod) { |
Dave Mankoff | 15bbec6 | 2019-06-27 15:17:42 -0400 | [diff] [blame] | 256 | if (DEBUG) { |
| 257 | Log.i(TAG, "Prox NEAR, pausing AOD"); |
| 258 | } |
Adrian Roos | 6023ccb | 2017-06-28 16:22:02 +0200 | [diff] [blame] | 259 | mMachine.requestState(DozeMachine.State.DOZE_AOD_PAUSING); |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 260 | } |
| 261 | } |
| 262 | |
Lucas Dupin | b7fd1eb | 2019-03-28 12:05:17 -0700 | [diff] [blame] | 263 | /** |
| 264 | * When a wake screen event is received from a sensor |
| 265 | * @param wake {@code true} when it's time to wake up, {@code false} when we should sleep. |
| 266 | * @param state The current state, or null if the state could not be determined due to enqueued |
| 267 | * transitions. |
| 268 | */ |
| 269 | private void onWakeScreen(boolean wake, @Nullable DozeMachine.State state) { |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 270 | mDozeLog.traceWakeDisplay(wake); |
Lucas Dupin | 1ae6cf9 | 2018-12-14 18:06:38 -0800 | [diff] [blame] | 271 | sWakeDisplaySensorState = wake; |
Lucas Dupin | 323f9ff | 2018-08-27 16:55:56 -0700 | [diff] [blame] | 272 | |
| 273 | if (wake) { |
| 274 | proximityCheckThenCall((result) -> { |
Dave Mankoff | bf52f4b | 2019-09-20 14:34:28 -0400 | [diff] [blame] | 275 | if (result != null && result) { |
Lucas Dupin | 323f9ff | 2018-08-27 16:55:56 -0700 | [diff] [blame] | 276 | // In pocket, drop event. |
| 277 | return; |
| 278 | } |
Lucas Dupin | 5131f51 | 2019-02-01 12:57:19 -0800 | [diff] [blame] | 279 | if (state == DozeMachine.State.DOZE) { |
Lucas Dupin | 323f9ff | 2018-08-27 16:55:56 -0700 | [diff] [blame] | 280 | mMachine.requestState(DozeMachine.State.DOZE_AOD); |
Steven Wu | cef2d5d | 2019-04-23 13:27:33 -0400 | [diff] [blame] | 281 | // Logs AOD open due to sensor wake up. |
| 282 | mMetricsLogger.write(new LogMaker(MetricsEvent.DOZING) |
| 283 | .setType(MetricsEvent.TYPE_OPEN) |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 284 | .setSubtype(DozeEvent.REASON_SENSOR_WAKE_UP)); |
Lucas Dupin | 323f9ff | 2018-08-27 16:55:56 -0700 | [diff] [blame] | 285 | } |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 286 | }, true /* alreadyPerformedProxCheck */, DozeEvent.REASON_SENSOR_WAKE_UP); |
Lucas Dupin | 323f9ff | 2018-08-27 16:55:56 -0700 | [diff] [blame] | 287 | } else { |
Lucas Dupin | b7fd1eb | 2019-03-28 12:05:17 -0700 | [diff] [blame] | 288 | boolean paused = (state == DozeMachine.State.DOZE_AOD_PAUSED); |
| 289 | boolean pausing = (state == DozeMachine.State.DOZE_AOD_PAUSING); |
Lucas Dupin | 323f9ff | 2018-08-27 16:55:56 -0700 | [diff] [blame] | 290 | if (!pausing && !paused) { |
Lucas Dupin | 6510438 | 2018-12-04 11:53:42 -0800 | [diff] [blame] | 291 | mMachine.requestState(DozeMachine.State.DOZE); |
Steven Wu | cef2d5d | 2019-04-23 13:27:33 -0400 | [diff] [blame] | 292 | // Logs AOD close due to sensor wake up. |
| 293 | mMetricsLogger.write(new LogMaker(MetricsEvent.DOZING) |
| 294 | .setType(MetricsEvent.TYPE_CLOSE) |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 295 | .setSubtype(DozeEvent.REASON_SENSOR_WAKE_UP)); |
Lucas Dupin | 323f9ff | 2018-08-27 16:55:56 -0700 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 300 | @Override |
| 301 | public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) { |
| 302 | switch (newState) { |
| 303 | case INITIALIZED: |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 304 | mBroadcastReceiver.register(mBroadcastDispatcher); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 305 | mDozeHost.addCallback(mHostCallback); |
Jerry Chang | ae4dc4b | 2019-10-16 18:45:03 +0800 | [diff] [blame] | 306 | mDockManager.addListener(mDockEventListener); |
Lucas Dupin | 8a13aa7 | 2019-02-22 12:45:21 -0800 | [diff] [blame] | 307 | mDozeSensors.requestTemporaryDisable(); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 308 | checkTriggersAtInit(); |
| 309 | break; |
| 310 | case DOZE: |
| 311 | case DOZE_AOD: |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 312 | mDozeSensors.setProxListening(newState != DozeMachine.State.DOZE); |
Adrian Roos | e3ac6f8 | 2017-06-30 16:15:22 +0200 | [diff] [blame] | 313 | mDozeSensors.setListening(true); |
Lucas Dupin | fac2e8e | 2019-06-27 16:10:19 -0700 | [diff] [blame] | 314 | mDozeSensors.setPaused(false); |
Lucas Dupin | 1ae6cf9 | 2018-12-14 18:06:38 -0800 | [diff] [blame] | 315 | if (newState == DozeMachine.State.DOZE_AOD && !sWakeDisplaySensorState) { |
Lucas Dupin | 5131f51 | 2019-02-01 12:57:19 -0800 | [diff] [blame] | 316 | onWakeScreen(false, newState); |
Lucas Dupin | 1ae6cf9 | 2018-12-14 18:06:38 -0800 | [diff] [blame] | 317 | } |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 318 | break; |
Adrian Roos | 5f7bee4 | 2017-06-27 18:49:23 +0200 | [diff] [blame] | 319 | case DOZE_AOD_PAUSED: |
Adrian Roos | 6023ccb | 2017-06-28 16:22:02 +0200 | [diff] [blame] | 320 | case DOZE_AOD_PAUSING: |
Adrian Roos | 5f7bee4 | 2017-06-27 18:49:23 +0200 | [diff] [blame] | 321 | mDozeSensors.setProxListening(true); |
Lucas Dupin | fac2e8e | 2019-06-27 16:10:19 -0700 | [diff] [blame] | 322 | mDozeSensors.setPaused(true); |
Adrian Roos | 5f7bee4 | 2017-06-27 18:49:23 +0200 | [diff] [blame] | 323 | break; |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 324 | case DOZE_PULSING: |
Lucas Dupin | 5f00fa5 | 2019-03-27 22:46:53 -0700 | [diff] [blame] | 325 | case DOZE_PULSING_BRIGHT: |
Jerry Chang | ae4dc4b | 2019-10-16 18:45:03 +0800 | [diff] [blame] | 326 | case DOZE_AOD_DOCKED: |
Adrian Roos | 98d3198 | 2017-08-02 20:50:16 +0200 | [diff] [blame] | 327 | mDozeSensors.setTouchscreenSensorsListening(false); |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 328 | mDozeSensors.setProxListening(true); |
Lucas Dupin | fac2e8e | 2019-06-27 16:10:19 -0700 | [diff] [blame] | 329 | mDozeSensors.setPaused(false); |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 330 | break; |
Lucas Dupin | 8a13aa7 | 2019-02-22 12:45:21 -0800 | [diff] [blame] | 331 | case DOZE_PULSE_DONE: |
| 332 | mDozeSensors.requestTemporaryDisable(); |
Lucas Dupin | 3174c66 | 2019-07-15 15:49:54 -0700 | [diff] [blame] | 333 | // A pulse will temporarily disable sensors that require a touch screen. |
| 334 | // Let's make sure that they are re-enabled when the pulse is over. |
| 335 | mDozeSensors.updateListening(); |
Lucas Dupin | 8a13aa7 | 2019-02-22 12:45:21 -0800 | [diff] [blame] | 336 | break; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 337 | case FINISH: |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 338 | mBroadcastReceiver.unregister(mBroadcastDispatcher); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 339 | mDozeHost.removeCallback(mHostCallback); |
Jerry Chang | ae4dc4b | 2019-10-16 18:45:03 +0800 | [diff] [blame] | 340 | mDockManager.removeListener(mDockEventListener); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 341 | mDozeSensors.setListening(false); |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 342 | mDozeSensors.setProxListening(false); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 343 | break; |
| 344 | default: |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | private void checkTriggersAtInit() { |
Adrian Roos | f2d545e | 2017-07-05 16:45:42 +0200 | [diff] [blame] | 349 | if (mUiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR |
Adrian Roos | 710a0b1 | 2017-07-07 19:02:34 +0200 | [diff] [blame] | 350 | || mDozeHost.isBlockingDoze() |
Adrian Roos | f2d545e | 2017-07-05 16:45:42 +0200 | [diff] [blame] | 351 | || !mDozeHost.isProvisioned()) { |
| 352 | mMachine.requestState(DozeMachine.State.FINISH); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 353 | } |
| 354 | } |
| 355 | |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 356 | private void requestPulse(final int reason, boolean performedProxCheck, |
| 357 | Runnable onPulseSuppressedListener) { |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 358 | Assert.isMainThread(); |
Lucas Dupin | 5f00fa5 | 2019-03-27 22:46:53 -0700 | [diff] [blame] | 359 | mDozeHost.extendPulse(reason); |
| 360 | |
| 361 | // When already pulsing we're allowed to show the wallpaper directly without |
| 362 | // requesting a new pulse. |
| 363 | if (mMachine.getState() == DozeMachine.State.DOZE_PULSING |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 364 | && reason == DozeEvent.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN) { |
Lucas Dupin | 5f00fa5 | 2019-03-27 22:46:53 -0700 | [diff] [blame] | 365 | mMachine.requestState(DozeMachine.State.DOZE_PULSING_BRIGHT); |
| 366 | return; |
| 367 | } |
| 368 | |
Adrian Roos | f9d13f6 | 2016-11-08 15:42:20 -0800 | [diff] [blame] | 369 | if (mPulsePending || !mAllowPulseTriggers || !canPulse()) { |
Adrian Roos | d35d4ca | 2017-04-19 14:31:03 -0700 | [diff] [blame] | 370 | if (mAllowPulseTriggers) { |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 371 | mDozeLog.tracePulseDropped(mPulsePending, mMachine.getState(), |
Adrian Roos | d35d4ca | 2017-04-19 14:31:03 -0700 | [diff] [blame] | 372 | mDozeHost.isPulsingBlocked()); |
| 373 | } |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 374 | runIfNotNull(onPulseSuppressedListener); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 375 | return; |
| 376 | } |
| 377 | |
| 378 | mPulsePending = true; |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 379 | proximityCheckThenCall((result) -> { |
Dave Mankoff | bf52f4b | 2019-09-20 14:34:28 -0400 | [diff] [blame] | 380 | if (result != null && result) { |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 381 | // in pocket, abort pulse |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 382 | mDozeLog.tracePulseDropped("inPocket"); |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 383 | mPulsePending = false; |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 384 | runIfNotNull(onPulseSuppressedListener); |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 385 | } else { |
| 386 | // not in pocket, continue pulsing |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 387 | continuePulseRequest(reason); |
| 388 | } |
Adrian Roos | d32b366 | 2017-06-27 14:48:50 +0200 | [diff] [blame] | 389 | }, !mDozeParameters.getProxCheckBeforePulse() || performedProxCheck, reason); |
Steven Wu | de35305 | 2019-03-12 13:49:23 -0400 | [diff] [blame] | 390 | |
| 391 | // Logs request pulse reason on AOD screen. |
| 392 | mMetricsLogger.write(new LogMaker(MetricsEvent.DOZING) |
| 393 | .setType(MetricsEvent.TYPE_UPDATE).setSubtype(reason)); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | private boolean canPulse() { |
| 397 | return mMachine.getState() == DozeMachine.State.DOZE |
Jerry Chang | ae4dc4b | 2019-10-16 18:45:03 +0800 | [diff] [blame] | 398 | || mMachine.getState() == DozeMachine.State.DOZE_AOD |
| 399 | || mMachine.getState() == DozeMachine.State.DOZE_AOD_DOCKED; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | private void continuePulseRequest(int reason) { |
| 403 | mPulsePending = false; |
| 404 | if (mDozeHost.isPulsingBlocked() || !canPulse()) { |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 405 | mDozeLog.tracePulseDropped(mPulsePending, mMachine.getState(), |
Adrian Roos | d35d4ca | 2017-04-19 14:31:03 -0700 | [diff] [blame] | 406 | mDozeHost.isPulsingBlocked()); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 407 | return; |
| 408 | } |
Adrian Roos | d7b9d10 | 2017-04-28 15:42:58 -0700 | [diff] [blame] | 409 | mMachine.requestPulse(reason); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | @Override |
| 413 | public void dump(PrintWriter pw) { |
| 414 | pw.print(" notificationPulseTime="); |
| 415 | pw.println(Formatter.formatShortElapsedTime(mContext, mNotificationPulseTime)); |
| 416 | |
Dave Mankoff | 63a1282 | 2019-09-16 14:38:06 -0400 | [diff] [blame] | 417 | pw.println(" pulsePending=" + mPulsePending); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 418 | pw.println("DozeSensors:"); |
| 419 | mDozeSensors.dump(pw); |
| 420 | } |
| 421 | |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 422 | private class TriggerReceiver extends BroadcastReceiver { |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 423 | private boolean mRegistered; |
| 424 | |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 425 | @Override |
| 426 | public void onReceive(Context context, Intent intent) { |
| 427 | if (PULSE_ACTION.equals(intent.getAction())) { |
| 428 | if (DozeMachine.DEBUG) Log.d(TAG, "Received pulse intent"); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 429 | requestPulse(DozeEvent.PULSE_REASON_INTENT, false, /* performedProxCheck */ |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 430 | null /* onPulseSupressedListener */); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 431 | } |
| 432 | if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) { |
Adrian Roos | f2d545e | 2017-07-05 16:45:42 +0200 | [diff] [blame] | 433 | mMachine.requestState(DozeMachine.State.FINISH); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 434 | } |
| 435 | if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { |
| 436 | mDozeSensors.onUserSwitched(); |
| 437 | } |
| 438 | } |
| 439 | |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 440 | public void register(BroadcastDispatcher broadcastDispatcher) { |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 441 | if (mRegistered) { |
| 442 | return; |
| 443 | } |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 444 | IntentFilter filter = new IntentFilter(PULSE_ACTION); |
| 445 | filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); |
| 446 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 447 | broadcastDispatcher.registerReceiver(this, filter); |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 448 | mRegistered = true; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 449 | } |
| 450 | |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 451 | public void unregister(BroadcastDispatcher broadcastDispatcher) { |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 452 | if (!mRegistered) { |
| 453 | return; |
| 454 | } |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 455 | broadcastDispatcher.unregisterReceiver(this); |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 456 | mRegistered = false; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 457 | } |
| 458 | } |
| 459 | |
lpeter | 8a5f470 | 2019-01-18 16:53:07 +0800 | [diff] [blame] | 460 | private class DockEventListener implements DockManager.DockEventListener { |
| 461 | @Override |
| 462 | public void onEvent(int event) { |
| 463 | if (DEBUG) Log.d(TAG, "dock event = " + event); |
| 464 | switch (event) { |
| 465 | case DockManager.STATE_DOCKED: |
| 466 | case DockManager.STATE_DOCKED_HIDE: |
| 467 | mDozeSensors.ignoreTouchScreenSensorsSettingInterferingWithDocking(true); |
| 468 | break; |
| 469 | case DockManager.STATE_NONE: |
| 470 | mDozeSensors.ignoreTouchScreenSensorsSettingInterferingWithDocking(false); |
| 471 | break; |
| 472 | default: |
| 473 | // no-op |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 478 | private DozeHost.Callback mHostCallback = new DozeHost.Callback() { |
| 479 | @Override |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 480 | public void onNotificationAlerted(Runnable onPulseSuppressedListener) { |
| 481 | onNotification(onPulseSuppressedListener); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | @Override |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 485 | public void onPowerSaveChanged(boolean active) { |
Lucas Dupin | bd7366d | 2019-09-25 13:39:21 -0700 | [diff] [blame] | 486 | if (mDozeHost.isPowerSaveActive()) { |
| 487 | mMachine.requestState(DozeMachine.State.DOZE); |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 488 | } |
| 489 | } |
| 490 | }; |
| 491 | } |