Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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.statusbar.phone; |
| 18 | |
| 19 | import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE; |
| 20 | import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING; |
| 21 | |
| 22 | import android.annotation.NonNull; |
| 23 | import android.os.Bundle; |
| 24 | import android.os.PowerManager; |
| 25 | import android.os.SystemClock; |
| 26 | import android.os.SystemProperties; |
| 27 | import android.util.Log; |
| 28 | import android.view.MotionEvent; |
| 29 | import android.view.View; |
| 30 | |
| 31 | import com.android.internal.annotations.VisibleForTesting; |
| 32 | import com.android.keyguard.KeyguardUpdateMonitor; |
| 33 | import com.android.systemui.assist.AssistManager; |
| 34 | import com.android.systemui.doze.DozeEvent; |
| 35 | import com.android.systemui.doze.DozeHost; |
| 36 | import com.android.systemui.doze.DozeLog; |
| 37 | import com.android.systemui.doze.DozeReceiver; |
| 38 | import com.android.systemui.keyguard.KeyguardViewMediator; |
| 39 | import com.android.systemui.keyguard.WakefulnessLifecycle; |
| 40 | import com.android.systemui.statusbar.PulseExpansionHandler; |
| 41 | import com.android.systemui.statusbar.StatusBarState; |
| 42 | import com.android.systemui.statusbar.SysuiStatusBarStateController; |
| 43 | import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; |
| 44 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
| 45 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
| 46 | import com.android.systemui.statusbar.policy.BatteryController; |
| 47 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
| 48 | |
| 49 | import java.util.ArrayList; |
| 50 | |
| 51 | import javax.inject.Inject; |
| 52 | import javax.inject.Singleton; |
| 53 | |
| 54 | import dagger.Lazy; |
| 55 | |
| 56 | /** |
| 57 | * Implementation of DozeHost for SystemUI. |
| 58 | */ |
| 59 | @Singleton |
| 60 | public final class DozeServiceHost implements DozeHost { |
| 61 | private static final String TAG = "DozeServiceHost"; |
| 62 | private final ArrayList<Callback> mCallbacks = new ArrayList<>(); |
| 63 | private final DozeLog mDozeLog; |
| 64 | private final PowerManager mPowerManager; |
| 65 | private boolean mAnimateWakeup; |
| 66 | private boolean mAnimateScreenOff; |
| 67 | private boolean mIgnoreTouchWhilePulsing; |
| 68 | private Runnable mPendingScreenOffCallback; |
| 69 | @VisibleForTesting |
| 70 | boolean mWakeLockScreenPerformsAuth = SystemProperties.getBoolean( |
| 71 | "persist.sysui.wake_performs_auth", true); |
| 72 | private boolean mDozingRequested; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 73 | private boolean mPulsing; |
| 74 | private WakefulnessLifecycle mWakefulnessLifecycle; |
| 75 | private final SysuiStatusBarStateController mStatusBarStateController; |
| 76 | private final DeviceProvisionedController mDeviceProvisionedController; |
| 77 | private final HeadsUpManagerPhone mHeadsUpManagerPhone; |
| 78 | private final BatteryController mBatteryController; |
| 79 | private final ScrimController mScrimController; |
| 80 | private final Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy; |
| 81 | private BiometricUnlockController mBiometricUnlockController; |
| 82 | private final KeyguardViewMediator mKeyguardViewMediator; |
Dave Mankoff | 4dd47fa | 2019-11-07 10:44:48 -0500 | [diff] [blame] | 83 | private final Lazy<AssistManager> mAssistManagerLazy; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 84 | private final DozeScrimController mDozeScrimController; |
| 85 | private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; |
| 86 | private final VisualStabilityManager mVisualStabilityManager; |
| 87 | private final PulseExpansionHandler mPulseExpansionHandler; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 88 | private final NotificationShadeWindowController mNotificationShadeWindowController; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 89 | private final NotificationWakeUpCoordinator mNotificationWakeUpCoordinator; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 90 | private NotificationShadeWindowViewController mNotificationShadeWindowViewController; |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 91 | private final LockscreenLockIconController mLockscreenLockIconController; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 92 | private NotificationIconAreaController mNotificationIconAreaController; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 93 | private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; |
Dave Mankoff | af8163f | 2020-01-08 14:24:35 -0500 | [diff] [blame] | 94 | private NotificationPanelViewController mNotificationPanel; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 95 | private View mAmbientIndicationContainer; |
| 96 | private StatusBar mStatusBar; |
| 97 | |
| 98 | @Inject |
| 99 | public DozeServiceHost(DozeLog dozeLog, PowerManager powerManager, |
| 100 | WakefulnessLifecycle wakefulnessLifecycle, |
| 101 | SysuiStatusBarStateController statusBarStateController, |
| 102 | DeviceProvisionedController deviceProvisionedController, |
| 103 | HeadsUpManagerPhone headsUpManagerPhone, BatteryController batteryController, |
| 104 | ScrimController scrimController, |
| 105 | Lazy<BiometricUnlockController> biometricUnlockControllerLazy, |
| 106 | KeyguardViewMediator keyguardViewMediator, |
Dave Mankoff | 4dd47fa | 2019-11-07 10:44:48 -0500 | [diff] [blame] | 107 | Lazy<AssistManager> assistManagerLazy, |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 108 | DozeScrimController dozeScrimController, KeyguardUpdateMonitor keyguardUpdateMonitor, |
| 109 | VisualStabilityManager visualStabilityManager, |
| 110 | PulseExpansionHandler pulseExpansionHandler, |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 111 | NotificationShadeWindowController notificationShadeWindowController, |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 112 | NotificationWakeUpCoordinator notificationWakeUpCoordinator, |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 113 | LockscreenLockIconController lockscreenLockIconController) { |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 114 | super(); |
| 115 | mDozeLog = dozeLog; |
| 116 | mPowerManager = powerManager; |
| 117 | mWakefulnessLifecycle = wakefulnessLifecycle; |
| 118 | mStatusBarStateController = statusBarStateController; |
| 119 | mDeviceProvisionedController = deviceProvisionedController; |
| 120 | mHeadsUpManagerPhone = headsUpManagerPhone; |
| 121 | mBatteryController = batteryController; |
| 122 | mScrimController = scrimController; |
| 123 | mBiometricUnlockControllerLazy = biometricUnlockControllerLazy; |
| 124 | mKeyguardViewMediator = keyguardViewMediator; |
Dave Mankoff | 4dd47fa | 2019-11-07 10:44:48 -0500 | [diff] [blame] | 125 | mAssistManagerLazy = assistManagerLazy; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 126 | mDozeScrimController = dozeScrimController; |
| 127 | mKeyguardUpdateMonitor = keyguardUpdateMonitor; |
| 128 | mVisualStabilityManager = visualStabilityManager; |
| 129 | mPulseExpansionHandler = pulseExpansionHandler; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 130 | mNotificationShadeWindowController = notificationShadeWindowController; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 131 | mNotificationWakeUpCoordinator = notificationWakeUpCoordinator; |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 132 | mLockscreenLockIconController = lockscreenLockIconController; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | // TODO: we should try to not pass status bar in here if we can avoid it. |
| 136 | |
| 137 | /** |
| 138 | * Initialize instance with objects only available later during execution. |
| 139 | */ |
| 140 | public void initialize(StatusBar statusBar, |
| 141 | NotificationIconAreaController notificationIconAreaController, |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 142 | StatusBarKeyguardViewManager statusBarKeyguardViewManager, |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 143 | NotificationShadeWindowViewController notificationShadeWindowViewController, |
Dave Mankoff | af8163f | 2020-01-08 14:24:35 -0500 | [diff] [blame] | 144 | NotificationPanelViewController notificationPanel, View ambientIndicationContainer) { |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 145 | mStatusBar = statusBar; |
| 146 | mNotificationIconAreaController = notificationIconAreaController; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 147 | mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; |
| 148 | mNotificationPanel = notificationPanel; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 149 | mNotificationShadeWindowViewController = notificationShadeWindowViewController; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 150 | mAmbientIndicationContainer = ambientIndicationContainer; |
| 151 | mBiometricUnlockController = mBiometricUnlockControllerLazy.get(); |
| 152 | } |
| 153 | |
| 154 | @Override |
| 155 | public String toString() { |
| 156 | return "PSB.DozeServiceHost[mCallbacks=" + mCallbacks.size() + "]"; |
| 157 | } |
| 158 | |
| 159 | void firePowerSaveChanged(boolean active) { |
| 160 | for (Callback callback : mCallbacks) { |
| 161 | callback.onPowerSaveChanged(active); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | void fireNotificationPulse(NotificationEntry entry) { |
| 166 | Runnable pulseSuppressedListener = () -> { |
| 167 | entry.setPulseSuppressed(true); |
| 168 | mNotificationIconAreaController.updateAodNotificationIcons(); |
| 169 | }; |
| 170 | for (Callback callback : mCallbacks) { |
| 171 | callback.onNotificationAlerted(pulseSuppressedListener); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | boolean getDozingRequested() { |
| 176 | return mDozingRequested; |
| 177 | } |
| 178 | |
| 179 | boolean isPulsing() { |
| 180 | return mPulsing; |
| 181 | } |
| 182 | |
| 183 | |
| 184 | @Override |
| 185 | public void addCallback(@NonNull Callback callback) { |
| 186 | mCallbacks.add(callback); |
| 187 | } |
| 188 | |
| 189 | @Override |
| 190 | public void removeCallback(@NonNull Callback callback) { |
| 191 | mCallbacks.remove(callback); |
| 192 | } |
| 193 | |
| 194 | @Override |
| 195 | public void startDozing() { |
| 196 | if (!mDozingRequested) { |
| 197 | mDozingRequested = true; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 198 | updateDozing(); |
Lucas Dupin | bcc606e | 2020-01-06 09:27:48 -0800 | [diff] [blame] | 199 | mDozeLog.traceDozing(mStatusBarStateController.isDozing()); |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 200 | mStatusBar.updateIsKeyguard(); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | void updateDozing() { |
| 205 | // When in wake-and-unlock while pulsing, keep dozing state until fully unlocked. |
| 206 | boolean |
| 207 | dozing = |
| 208 | mDozingRequested && mStatusBarStateController.getState() == StatusBarState.KEYGUARD |
| 209 | || mBiometricUnlockController.getMode() |
| 210 | == BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING; |
| 211 | // When in wake-and-unlock we may not have received a change to StatusBarState |
| 212 | // but we still should not be dozing, manually set to false. |
| 213 | if (mBiometricUnlockController.getMode() |
| 214 | == BiometricUnlockController.MODE_WAKE_AND_UNLOCK) { |
| 215 | dozing = false; |
| 216 | } |
| 217 | |
| 218 | |
| 219 | mStatusBarStateController.setIsDozing(dozing); |
| 220 | } |
| 221 | |
| 222 | @Override |
| 223 | public void pulseWhileDozing(@NonNull PulseCallback callback, int reason) { |
| 224 | if (reason == DozeEvent.PULSE_REASON_SENSOR_LONG_PRESS) { |
| 225 | mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE, |
| 226 | "com.android.systemui:LONG_PRESS"); |
Dave Mankoff | 4dd47fa | 2019-11-07 10:44:48 -0500 | [diff] [blame] | 227 | mAssistManagerLazy.get().startAssist(new Bundle()); |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 228 | return; |
| 229 | } |
| 230 | |
| 231 | if (reason == DozeEvent.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN) { |
| 232 | mScrimController.setWakeLockScreenSensorActive(true); |
| 233 | } |
| 234 | |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 235 | boolean passiveAuthInterrupt = reason == DozeEvent.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN |
| 236 | && mWakeLockScreenPerformsAuth; |
| 237 | // Set the state to pulsing, so ScrimController will know what to do once we ask it to |
| 238 | // execute the transition. The pulse callback will then be invoked when the scrims |
| 239 | // are black, indicating that StatusBar is ready to present the rest of the UI. |
| 240 | mPulsing = true; |
| 241 | mDozeScrimController.pulse(new PulseCallback() { |
| 242 | @Override |
| 243 | public void onPulseStarted() { |
| 244 | callback.onPulseStarted(); |
| 245 | mStatusBar.updateNotificationPanelTouchState(); |
| 246 | setPulsing(true); |
| 247 | } |
| 248 | |
| 249 | @Override |
| 250 | public void onPulseFinished() { |
| 251 | mPulsing = false; |
| 252 | callback.onPulseFinished(); |
| 253 | mStatusBar.updateNotificationPanelTouchState(); |
| 254 | mScrimController.setWakeLockScreenSensorActive(false); |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 255 | setPulsing(false); |
| 256 | } |
| 257 | |
| 258 | private void setPulsing(boolean pulsing) { |
| 259 | mStatusBarStateController.setPulsing(pulsing); |
| 260 | mStatusBarKeyguardViewManager.setPulsing(pulsing); |
| 261 | mKeyguardViewMediator.setPulsing(pulsing); |
| 262 | mNotificationPanel.setPulsing(pulsing); |
| 263 | mVisualStabilityManager.setPulsing(pulsing); |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 264 | mLockscreenLockIconController.setPulsing(pulsing); |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 265 | mIgnoreTouchWhilePulsing = false; |
| 266 | if (mKeyguardUpdateMonitor != null && passiveAuthInterrupt) { |
| 267 | mKeyguardUpdateMonitor.onAuthInterruptDetected(pulsing /* active */); |
| 268 | } |
| 269 | mStatusBar.updateScrimController(); |
| 270 | mPulseExpansionHandler.setPulsing(pulsing); |
| 271 | mNotificationWakeUpCoordinator.setPulsing(pulsing); |
| 272 | } |
| 273 | }, reason); |
| 274 | // DozeScrimController is in pulse state, now let's ask ScrimController to start |
| 275 | // pulsing and draw the black frame, if necessary. |
| 276 | mStatusBar.updateScrimController(); |
| 277 | } |
| 278 | |
| 279 | @Override |
| 280 | public void stopDozing() { |
| 281 | if (mDozingRequested) { |
| 282 | mDozingRequested = false; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 283 | updateDozing(); |
Lucas Dupin | bcc606e | 2020-01-06 09:27:48 -0800 | [diff] [blame] | 284 | mDozeLog.traceDozing(mStatusBarStateController.isDozing()); |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 285 | } |
| 286 | } |
| 287 | |
| 288 | @Override |
| 289 | public void onIgnoreTouchWhilePulsing(boolean ignore) { |
| 290 | if (ignore != mIgnoreTouchWhilePulsing) { |
| 291 | mDozeLog.tracePulseTouchDisabledByProx(ignore); |
| 292 | } |
| 293 | mIgnoreTouchWhilePulsing = ignore; |
Lucas Dupin | bcc606e | 2020-01-06 09:27:48 -0800 | [diff] [blame] | 294 | if (mStatusBarStateController.isDozing() && ignore) { |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 295 | mNotificationShadeWindowViewController.cancelCurrentTouch(); |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public void dozeTimeTick() { |
| 301 | mNotificationPanel.dozeTimeTick(); |
| 302 | if (mAmbientIndicationContainer instanceof DozeReceiver) { |
| 303 | ((DozeReceiver) mAmbientIndicationContainer).dozeTimeTick(); |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | @Override |
| 308 | public boolean isPowerSaveActive() { |
| 309 | return mBatteryController.isAodPowerSave(); |
| 310 | } |
| 311 | |
| 312 | @Override |
| 313 | public boolean isPulsingBlocked() { |
| 314 | return mBiometricUnlockController.getMode() |
| 315 | == BiometricUnlockController.MODE_WAKE_AND_UNLOCK; |
| 316 | } |
| 317 | |
| 318 | @Override |
| 319 | public boolean isProvisioned() { |
| 320 | return mDeviceProvisionedController.isDeviceProvisioned() |
| 321 | && mDeviceProvisionedController.isCurrentUserSetup(); |
| 322 | } |
| 323 | |
| 324 | @Override |
| 325 | public boolean isBlockingDoze() { |
| 326 | if (mBiometricUnlockController.hasPendingAuthentication()) { |
| 327 | Log.i(StatusBar.TAG, "Blocking AOD because fingerprint has authenticated"); |
| 328 | return true; |
| 329 | } |
| 330 | return false; |
| 331 | } |
| 332 | |
| 333 | @Override |
| 334 | public void extendPulse(int reason) { |
| 335 | if (reason == DozeEvent.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN) { |
| 336 | mScrimController.setWakeLockScreenSensorActive(true); |
| 337 | } |
| 338 | if (mDozeScrimController.isPulsing() && mHeadsUpManagerPhone.hasNotifications()) { |
| 339 | mHeadsUpManagerPhone.extendHeadsUp(); |
| 340 | } else { |
| 341 | mDozeScrimController.extendPulse(); |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | @Override |
| 346 | public void stopPulsing() { |
| 347 | if (mDozeScrimController.isPulsing()) { |
| 348 | mDozeScrimController.pulseOutNow(); |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | @Override |
| 353 | public void setAnimateWakeup(boolean animateWakeup) { |
| 354 | if (mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_AWAKE |
| 355 | || mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_WAKING) { |
| 356 | // Too late to change the wakeup animation. |
| 357 | return; |
| 358 | } |
| 359 | mAnimateWakeup = animateWakeup; |
| 360 | } |
| 361 | |
| 362 | @Override |
| 363 | public void setAnimateScreenOff(boolean animateScreenOff) { |
| 364 | mAnimateScreenOff = animateScreenOff; |
| 365 | } |
| 366 | |
| 367 | @Override |
| 368 | public void onSlpiTap(float screenX, float screenY) { |
| 369 | if (screenX > 0 && screenY > 0 && mAmbientIndicationContainer != null |
| 370 | && mAmbientIndicationContainer.getVisibility() == View.VISIBLE) { |
| 371 | int[] locationOnScreen = new int[2]; |
| 372 | mAmbientIndicationContainer.getLocationOnScreen(locationOnScreen); |
| 373 | float viewX = screenX - locationOnScreen[0]; |
| 374 | float viewY = screenY - locationOnScreen[1]; |
| 375 | if (0 <= viewX && viewX <= mAmbientIndicationContainer.getWidth() |
| 376 | && 0 <= viewY && viewY <= mAmbientIndicationContainer.getHeight()) { |
| 377 | |
| 378 | // Dispatch a tap |
| 379 | long now = SystemClock.elapsedRealtime(); |
| 380 | MotionEvent ev = MotionEvent.obtain( |
| 381 | now, now, MotionEvent.ACTION_DOWN, screenX, screenY, 0); |
| 382 | mAmbientIndicationContainer.dispatchTouchEvent(ev); |
| 383 | ev.recycle(); |
| 384 | ev = MotionEvent.obtain( |
| 385 | now, now, MotionEvent.ACTION_UP, screenX, screenY, 0); |
| 386 | mAmbientIndicationContainer.dispatchTouchEvent(ev); |
| 387 | ev.recycle(); |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | @Override |
| 393 | public void setDozeScreenBrightness(int value) { |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 394 | mNotificationShadeWindowController.setDozeScreenBrightness(value); |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | @Override |
| 398 | public void setAodDimmingScrim(float scrimOpacity) { |
| 399 | mScrimController.setAodFrontScrimAlpha(scrimOpacity); |
| 400 | } |
| 401 | |
| 402 | |
| 403 | |
| 404 | @Override |
| 405 | public void prepareForGentleSleep(Runnable onDisplayOffCallback) { |
| 406 | if (mPendingScreenOffCallback != null) { |
| 407 | Log.w(TAG, "Overlapping onDisplayOffCallback. Ignoring previous one."); |
| 408 | } |
| 409 | mPendingScreenOffCallback = onDisplayOffCallback; |
| 410 | mStatusBar.updateScrimController(); |
| 411 | } |
| 412 | |
| 413 | @Override |
| 414 | public void cancelGentleSleep() { |
| 415 | mPendingScreenOffCallback = null; |
| 416 | if (mScrimController.getState() == ScrimState.OFF) { |
| 417 | mStatusBar.updateScrimController(); |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | /** |
| 422 | * When the dozing host is waiting for scrims to fade out to change the display state. |
| 423 | */ |
| 424 | boolean hasPendingScreenOffCallback() { |
| 425 | return mPendingScreenOffCallback != null; |
| 426 | } |
| 427 | |
| 428 | /** |
| 429 | * Executes an nullifies the pending display state callback. |
| 430 | * |
| 431 | * @see #hasPendingScreenOffCallback() |
| 432 | * @see #prepareForGentleSleep(Runnable) |
| 433 | */ |
| 434 | void executePendingScreenOffCallback() { |
| 435 | if (mPendingScreenOffCallback == null) { |
| 436 | return; |
| 437 | } |
| 438 | mPendingScreenOffCallback.run(); |
| 439 | mPendingScreenOffCallback = null; |
| 440 | } |
| 441 | |
| 442 | boolean shouldAnimateWakeup() { |
| 443 | return mAnimateWakeup; |
| 444 | } |
| 445 | |
| 446 | boolean shouldAnimateScreenOff() { |
| 447 | return mAnimateScreenOff; |
| 448 | } |
| 449 | |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 450 | boolean getIgnoreTouchWhilePulsing() { |
| 451 | return mIgnoreTouchWhilePulsing; |
| 452 | } |
| 453 | } |