Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -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 | |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 19 | import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; |
| 20 | |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 21 | import android.annotation.Nullable; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 22 | import android.app.StatusBarManager; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 23 | import android.graphics.RectF; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 24 | import android.hardware.display.AmbientDisplayConfiguration; |
| 25 | import android.media.AudioManager; |
| 26 | import android.media.session.MediaSessionLegacyHelper; |
| 27 | import android.os.SystemClock; |
| 28 | import android.os.UserHandle; |
| 29 | import android.provider.Settings; |
| 30 | import android.view.GestureDetector; |
| 31 | import android.view.InputDevice; |
| 32 | import android.view.KeyEvent; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 33 | import android.view.MotionEvent; |
| 34 | import android.view.View; |
| 35 | import android.view.ViewGroup; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 36 | |
| 37 | import com.android.internal.annotations.VisibleForTesting; |
| 38 | import com.android.systemui.ExpandHelper; |
| 39 | import com.android.systemui.R; |
Jerry Chang | 50c5da4 | 2019-10-16 17:21:07 +0800 | [diff] [blame] | 40 | import com.android.systemui.dock.DockManager; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 41 | import com.android.systemui.doze.DozeLog; |
| 42 | import com.android.systemui.plugins.FalsingManager; |
| 43 | import com.android.systemui.shared.plugins.PluginManager; |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 44 | import com.android.systemui.statusbar.CommandQueue; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 45 | import com.android.systemui.statusbar.DragDownHelper; |
| 46 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
Lucas Dupin | 43d0124 | 2020-02-03 11:58:33 -0800 | [diff] [blame] | 47 | import com.android.systemui.statusbar.NotificationShadeWindowBlurController; |
Beverly | f937f29 | 2020-02-20 13:45:36 -0500 | [diff] [blame] | 48 | import com.android.systemui.statusbar.PulseExpansionHandler; |
| 49 | import com.android.systemui.statusbar.SuperStatusBarViewFactory; |
Lucas Dupin | d236ee3 | 2019-10-08 15:33:59 -0700 | [diff] [blame] | 50 | import com.android.systemui.statusbar.SysuiStatusBarStateController; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 51 | import com.android.systemui.statusbar.notification.DynamicPrivacyController; |
| 52 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
| 53 | import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; |
| 54 | import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; |
Lucas Dupin | d236ee3 | 2019-10-08 15:33:59 -0700 | [diff] [blame] | 55 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 56 | import com.android.systemui.tuner.TunerService; |
| 57 | import com.android.systemui.util.InjectionInflationController; |
| 58 | |
| 59 | import java.io.FileDescriptor; |
| 60 | import java.io.PrintWriter; |
| 61 | |
| 62 | import javax.inject.Inject; |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 63 | |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 64 | /** |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 65 | * Controller for {@link NotificationShadeWindowView}. |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 66 | */ |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 67 | public class NotificationShadeWindowViewController { |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 68 | private final InjectionInflationController mInjectionInflationController; |
| 69 | private final NotificationWakeUpCoordinator mCoordinator; |
| 70 | private final PulseExpansionHandler mPulseExpansionHandler; |
| 71 | private final DynamicPrivacyController mDynamicPrivacyController; |
| 72 | private final KeyguardBypassController mBypassController; |
| 73 | private final PluginManager mPluginManager; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 74 | private final FalsingManager mFalsingManager; |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 75 | private final TunerService mTunerService; |
| 76 | private final NotificationLockscreenUserManager mNotificationLockscreenUserManager; |
| 77 | private final NotificationEntryManager mNotificationEntryManager; |
| 78 | private final KeyguardStateController mKeyguardStateController; |
| 79 | private final SysuiStatusBarStateController mStatusBarStateController; |
| 80 | private final DozeLog mDozeLog; |
| 81 | private final DozeParameters mDozeParameters; |
| 82 | private final CommandQueue mCommandQueue; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 83 | private final NotificationShadeWindowView mView; |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 84 | private final ShadeController mShadeController; |
Lucas Dupin | 43d0124 | 2020-02-03 11:58:33 -0800 | [diff] [blame] | 85 | private final NotificationShadeWindowBlurController mBlurController; |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 86 | |
| 87 | private GestureDetector mGestureDetector; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 88 | private View mBrightnessMirror; |
| 89 | private boolean mTouchActive; |
| 90 | private boolean mTouchCancelled; |
| 91 | private boolean mExpandAnimationPending; |
| 92 | private boolean mExpandAnimationRunning; |
| 93 | private NotificationStackScrollLayout mStackScrollLayout; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 94 | private PhoneStatusBarView mStatusBarView; |
Beverly | f937f29 | 2020-02-20 13:45:36 -0500 | [diff] [blame] | 95 | private PhoneStatusBarTransitions mBarTransitions; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 96 | private StatusBar mService; |
| 97 | private DragDownHelper mDragDownHelper; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 98 | private boolean mDoubleTapEnabled; |
| 99 | private boolean mSingleTapEnabled; |
| 100 | private boolean mExpandingBelowNotch; |
Jerry Chang | 50c5da4 | 2019-10-16 17:21:07 +0800 | [diff] [blame] | 101 | private final DockManager mDockManager; |
Dave Mankoff | af8163f | 2020-01-08 14:24:35 -0500 | [diff] [blame] | 102 | private final NotificationPanelViewController mNotificationPanelViewController; |
Beverly | f937f29 | 2020-02-20 13:45:36 -0500 | [diff] [blame] | 103 | private final SuperStatusBarViewFactory mStatusBarViewFactory; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 104 | |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 105 | // Used for determining view / touch intersection |
| 106 | private int[] mTempLocation = new int[2]; |
| 107 | private RectF mTempRect = new RectF(); |
| 108 | private boolean mIsTrackingBarGesture = false; |
| 109 | |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 110 | @Inject |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 111 | public NotificationShadeWindowViewController( |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 112 | InjectionInflationController injectionInflationController, |
| 113 | NotificationWakeUpCoordinator coordinator, |
| 114 | PulseExpansionHandler pulseExpansionHandler, |
| 115 | DynamicPrivacyController dynamicPrivacyController, |
| 116 | KeyguardBypassController bypassController, |
| 117 | FalsingManager falsingManager, |
| 118 | PluginManager pluginManager, |
| 119 | TunerService tunerService, |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 120 | NotificationLockscreenUserManager notificationLockscreenUserManager, |
| 121 | NotificationEntryManager notificationEntryManager, |
Lucas Dupin | d236ee3 | 2019-10-08 15:33:59 -0700 | [diff] [blame] | 122 | KeyguardStateController keyguardStateController, |
| 123 | SysuiStatusBarStateController statusBarStateController, |
Dave Mankoff | 2aff6c3 | 2019-10-14 17:40:37 -0400 | [diff] [blame] | 124 | DozeLog dozeLog, |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 125 | DozeParameters dozeParameters, |
Jerry Chang | 50c5da4 | 2019-10-16 17:21:07 +0800 | [diff] [blame] | 126 | CommandQueue commandQueue, |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 127 | ShadeController shadeController, |
Dave Mankoff | c1bbce1 | 2019-11-25 11:27:36 -0500 | [diff] [blame] | 128 | DockManager dockManager, |
Lucas Dupin | 43d0124 | 2020-02-03 11:58:33 -0800 | [diff] [blame] | 129 | @Nullable NotificationShadeWindowBlurController blurController, |
Beverly | f937f29 | 2020-02-20 13:45:36 -0500 | [diff] [blame] | 130 | NotificationShadeWindowView notificationShadeWindowView, |
| 131 | NotificationPanelViewController notificationPanelViewController, |
| 132 | SuperStatusBarViewFactory statusBarViewFactory) { |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 133 | mInjectionInflationController = injectionInflationController; |
| 134 | mCoordinator = coordinator; |
| 135 | mPulseExpansionHandler = pulseExpansionHandler; |
| 136 | mDynamicPrivacyController = dynamicPrivacyController; |
| 137 | mBypassController = bypassController; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 138 | mFalsingManager = falsingManager; |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 139 | mPluginManager = pluginManager; |
| 140 | mTunerService = tunerService; |
| 141 | mNotificationLockscreenUserManager = notificationLockscreenUserManager; |
| 142 | mNotificationEntryManager = notificationEntryManager; |
| 143 | mKeyguardStateController = keyguardStateController; |
| 144 | mStatusBarStateController = statusBarStateController; |
| 145 | mDozeLog = dozeLog; |
| 146 | mDozeParameters = dozeParameters; |
| 147 | mCommandQueue = commandQueue; |
Beverly | f937f29 | 2020-02-20 13:45:36 -0500 | [diff] [blame] | 148 | mView = notificationShadeWindowView; |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 149 | mShadeController = shadeController; |
Jerry Chang | 50c5da4 | 2019-10-16 17:21:07 +0800 | [diff] [blame] | 150 | mDockManager = dockManager; |
Dave Mankoff | af8163f | 2020-01-08 14:24:35 -0500 | [diff] [blame] | 151 | mNotificationPanelViewController = notificationPanelViewController; |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 152 | mBlurController = blurController; |
Beverly | f937f29 | 2020-02-20 13:45:36 -0500 | [diff] [blame] | 153 | mStatusBarViewFactory = statusBarViewFactory; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 154 | |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 155 | // This view is not part of the newly inflated expanded status bar. |
| 156 | mBrightnessMirror = mView.findViewById(R.id.brightness_mirror); |
| 157 | } |
| 158 | |
| 159 | /** Inflates the {@link R.layout#status_bar_expanded} layout and sets it up. */ |
| 160 | public void setupExpandedStatusBar() { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 161 | mStackScrollLayout = mView.findViewById(R.id.notification_stack_scroller); |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 162 | |
| 163 | TunerService.Tunable tunable = (key, newValue) -> { |
| 164 | AmbientDisplayConfiguration configuration = |
| 165 | new AmbientDisplayConfiguration(mView.getContext()); |
| 166 | switch (key) { |
| 167 | case Settings.Secure.DOZE_DOUBLE_TAP_GESTURE: |
| 168 | mDoubleTapEnabled = configuration.doubleTapGestureEnabled( |
| 169 | UserHandle.USER_CURRENT); |
| 170 | break; |
| 171 | case Settings.Secure.DOZE_TAP_SCREEN_GESTURE: |
| 172 | mSingleTapEnabled = configuration.tapGestureEnabled(UserHandle.USER_CURRENT); |
| 173 | } |
| 174 | }; |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 175 | mTunerService.addTunable(tunable, |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 176 | Settings.Secure.DOZE_DOUBLE_TAP_GESTURE, |
| 177 | Settings.Secure.DOZE_TAP_SCREEN_GESTURE); |
| 178 | |
| 179 | GestureDetector.SimpleOnGestureListener gestureListener = |
| 180 | new GestureDetector.SimpleOnGestureListener() { |
| 181 | @Override |
| 182 | public boolean onSingleTapConfirmed(MotionEvent e) { |
Jerry Chang | 50c5da4 | 2019-10-16 17:21:07 +0800 | [diff] [blame] | 183 | if (mSingleTapEnabled && !mDockManager.isDocked()) { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 184 | mService.wakeUpIfDozing( |
| 185 | SystemClock.uptimeMillis(), mView, "SINGLE_TAP"); |
| 186 | return true; |
| 187 | } |
| 188 | return false; |
| 189 | } |
| 190 | |
| 191 | @Override |
| 192 | public boolean onDoubleTap(MotionEvent e) { |
| 193 | if (mDoubleTapEnabled || mSingleTapEnabled) { |
| 194 | mService.wakeUpIfDozing( |
| 195 | SystemClock.uptimeMillis(), mView, "DOUBLE_TAP"); |
| 196 | return true; |
| 197 | } |
| 198 | return false; |
| 199 | } |
| 200 | }; |
| 201 | mGestureDetector = new GestureDetector(mView.getContext(), gestureListener); |
| 202 | |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 203 | mView.setInteractionEventHandler(new NotificationShadeWindowView.InteractionEventHandler() { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 204 | @Override |
| 205 | public Boolean handleDispatchTouchEvent(MotionEvent ev) { |
| 206 | boolean isDown = ev.getActionMasked() == MotionEvent.ACTION_DOWN; |
| 207 | boolean isUp = ev.getActionMasked() == MotionEvent.ACTION_UP; |
| 208 | boolean isCancel = ev.getActionMasked() == MotionEvent.ACTION_CANCEL; |
| 209 | |
Dave Mankoff | 978588f | 2019-11-15 17:24:12 -0500 | [diff] [blame] | 210 | boolean expandingBelowNotch = mExpandingBelowNotch; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 211 | if (isUp || isCancel) { |
| 212 | mExpandingBelowNotch = false; |
| 213 | } |
| 214 | |
| 215 | // Reset manual touch dispatch state here but make sure the UP/CANCEL event still |
| 216 | // gets |
| 217 | // delivered. |
| 218 | |
| 219 | if (!isCancel && mService.shouldIgnoreTouch()) { |
| 220 | return false; |
| 221 | } |
Dave Mankoff | af8163f | 2020-01-08 14:24:35 -0500 | [diff] [blame] | 222 | if (isDown && mNotificationPanelViewController.isFullyCollapsed()) { |
| 223 | mNotificationPanelViewController.startExpandLatencyTracking(); |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 224 | } |
| 225 | if (isDown) { |
| 226 | setTouchActive(true); |
| 227 | mTouchCancelled = false; |
| 228 | } else if (ev.getActionMasked() == MotionEvent.ACTION_UP |
| 229 | || ev.getActionMasked() == MotionEvent.ACTION_CANCEL) { |
| 230 | setTouchActive(false); |
| 231 | } |
| 232 | if (mTouchCancelled || mExpandAnimationRunning || mExpandAnimationPending) { |
| 233 | return false; |
| 234 | } |
| 235 | mFalsingManager.onTouchEvent(ev, mView.getWidth(), mView.getHeight()); |
| 236 | mGestureDetector.onTouchEvent(ev); |
| 237 | if (mBrightnessMirror != null |
| 238 | && mBrightnessMirror.getVisibility() == View.VISIBLE) { |
| 239 | // Disallow new pointers while the brightness mirror is visible. This is so that |
| 240 | // you can't touch anything other than the brightness slider while the mirror is |
| 241 | // showing and the rest of the panel is transparent. |
| 242 | if (ev.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) { |
| 243 | return false; |
| 244 | } |
| 245 | } |
| 246 | if (isDown) { |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 247 | mStackScrollLayout.closeControlsIfOutsideTouch(ev); |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 248 | } |
Heemin Seog | e9f4e96 | 2019-12-05 11:55:27 -0800 | [diff] [blame] | 249 | if (mStatusBarStateController.isDozing()) { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 250 | mService.mDozeScrimController.extendPulse(); |
| 251 | } |
| 252 | // In case we start outside of the view bounds (below the status bar), we need to |
| 253 | // dispatch |
| 254 | // the touch manually as the view system can't accommodate for touches outside of |
| 255 | // the |
| 256 | // regular view bounds. |
| 257 | if (isDown && ev.getY() >= mView.getBottom()) { |
| 258 | mExpandingBelowNotch = true; |
Dave Mankoff | 978588f | 2019-11-15 17:24:12 -0500 | [diff] [blame] | 259 | expandingBelowNotch = true; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 260 | } |
Dave Mankoff | 978588f | 2019-11-15 17:24:12 -0500 | [diff] [blame] | 261 | if (expandingBelowNotch) { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 262 | return mStatusBarView.dispatchTouchEvent(ev); |
| 263 | } |
| 264 | |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 265 | if (!mIsTrackingBarGesture && isDown |
| 266 | && mNotificationPanelViewController.isFullyCollapsed()) { |
| 267 | float x = ev.getRawX(); |
| 268 | float y = ev.getRawY(); |
| 269 | if (isIntersecting(mStatusBarView, x, y)) { |
| 270 | if (mService.isSameStatusBarState(WINDOW_STATE_SHOWING)) { |
| 271 | mIsTrackingBarGesture = true; |
| 272 | return mStatusBarView.dispatchTouchEvent(ev); |
| 273 | } else { // it's hidden or hiding, don't send to notification shade. |
| 274 | return true; |
| 275 | } |
| 276 | } |
| 277 | } else if (mIsTrackingBarGesture) { |
| 278 | final boolean sendToNotification = mStatusBarView.dispatchTouchEvent(ev); |
| 279 | if (isUp || isCancel) { |
| 280 | mIsTrackingBarGesture = false; |
| 281 | } |
| 282 | return sendToNotification; |
| 283 | } |
| 284 | |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 285 | return null; |
| 286 | } |
| 287 | |
| 288 | @Override |
| 289 | public boolean shouldInterceptTouchEvent(MotionEvent ev) { |
Heemin Seog | e9f4e96 | 2019-12-05 11:55:27 -0800 | [diff] [blame] | 290 | if (mStatusBarStateController.isDozing() && !mService.isPulsing() |
| 291 | && !mDockManager.isDocked()) { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 292 | // Capture all touch events in always-on. |
| 293 | return true; |
| 294 | } |
| 295 | boolean intercept = false; |
Dave Mankoff | af8163f | 2020-01-08 14:24:35 -0500 | [diff] [blame] | 296 | if (mNotificationPanelViewController.isFullyExpanded() |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 297 | && mDragDownHelper.isDragDownEnabled() |
| 298 | && !mService.isBouncerShowing() |
Heemin Seog | e9f4e96 | 2019-12-05 11:55:27 -0800 | [diff] [blame] | 299 | && !mStatusBarStateController.isDozing()) { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 300 | intercept = mDragDownHelper.onInterceptTouchEvent(ev); |
| 301 | } |
| 302 | |
| 303 | return intercept; |
| 304 | |
| 305 | } |
| 306 | |
| 307 | @Override |
| 308 | public void didIntercept(MotionEvent ev) { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 309 | MotionEvent cancellation = MotionEvent.obtain(ev); |
| 310 | cancellation.setAction(MotionEvent.ACTION_CANCEL); |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 311 | mStackScrollLayout.onInterceptTouchEvent(cancellation); |
Dave Mankoff | af8163f | 2020-01-08 14:24:35 -0500 | [diff] [blame] | 312 | mNotificationPanelViewController.getView().onInterceptTouchEvent(cancellation); |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 313 | cancellation.recycle(); |
| 314 | } |
| 315 | |
| 316 | @Override |
| 317 | public boolean handleTouchEvent(MotionEvent ev) { |
| 318 | boolean handled = false; |
Heemin Seog | e9f4e96 | 2019-12-05 11:55:27 -0800 | [diff] [blame] | 319 | if (mStatusBarStateController.isDozing()) { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 320 | handled = !mService.isPulsing(); |
| 321 | } |
| 322 | if ((mDragDownHelper.isDragDownEnabled() && !handled) |
| 323 | || mDragDownHelper.isDraggingDown()) { |
| 324 | // we still want to finish our drag down gesture when locking the screen |
| 325 | handled = mDragDownHelper.onTouchEvent(ev); |
| 326 | } |
| 327 | |
| 328 | return handled; |
| 329 | } |
| 330 | |
| 331 | @Override |
| 332 | public void didNotHandleTouchEvent(MotionEvent ev) { |
| 333 | final int action = ev.getActionMasked(); |
| 334 | if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { |
| 335 | mService.setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | @Override |
| 340 | public boolean interceptMediaKey(KeyEvent event) { |
| 341 | return mService.interceptMediaKey(event); |
| 342 | } |
| 343 | |
| 344 | @Override |
| 345 | public boolean dispatchKeyEvent(KeyEvent event) { |
| 346 | boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 347 | switch (event.getKeyCode()) { |
| 348 | case KeyEvent.KEYCODE_BACK: |
| 349 | if (!down) { |
| 350 | mService.onBackPressed(); |
| 351 | } |
| 352 | return true; |
| 353 | case KeyEvent.KEYCODE_MENU: |
| 354 | if (!down) { |
| 355 | return mService.onMenuPressed(); |
| 356 | } |
| 357 | break; |
| 358 | case KeyEvent.KEYCODE_SPACE: |
| 359 | if (!down) { |
| 360 | return mService.onSpacePressed(); |
| 361 | } |
| 362 | break; |
| 363 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 364 | case KeyEvent.KEYCODE_VOLUME_UP: |
Heemin Seog | e9f4e96 | 2019-12-05 11:55:27 -0800 | [diff] [blame] | 365 | if (mStatusBarStateController.isDozing()) { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 366 | MediaSessionLegacyHelper.getHelper(mView.getContext()) |
| 367 | .sendVolumeKeyEvent( |
| 368 | event, AudioManager.USE_DEFAULT_STREAM_TYPE, true); |
| 369 | return true; |
| 370 | } |
| 371 | break; |
| 372 | } |
| 373 | return false; |
| 374 | } |
| 375 | }); |
| 376 | |
| 377 | mView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() { |
| 378 | @Override |
| 379 | public void onChildViewAdded(View parent, View child) { |
| 380 | if (child.getId() == R.id.brightness_mirror) { |
| 381 | mBrightnessMirror = child; |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | @Override |
| 386 | public void onChildViewRemoved(View parent, View child) { |
| 387 | } |
| 388 | }); |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 389 | |
| 390 | ExpandHelper.Callback expandHelperCallback = mStackScrollLayout.getExpandHelperCallback(); |
| 391 | DragDownHelper.DragDownCallback dragDownCallback = mStackScrollLayout.getDragDownCallback(); |
| 392 | setDragDownHelper( |
| 393 | new DragDownHelper( |
| 394 | mView.getContext(), mView, expandHelperCallback, |
| 395 | dragDownCallback, mFalsingManager)); |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 396 | |
| 397 | if (mBlurController != null) { |
| 398 | mBlurController.setRoot(mView); |
| 399 | mNotificationPanelViewController.addExpansionListener(mBlurController); |
| 400 | } |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 401 | } |
| 402 | |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 403 | public NotificationShadeWindowView getView() { |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 404 | return mView; |
| 405 | } |
| 406 | |
| 407 | public void setTouchActive(boolean touchActive) { |
| 408 | mTouchActive = touchActive; |
| 409 | } |
| 410 | |
| 411 | public void cancelCurrentTouch() { |
| 412 | if (mTouchActive) { |
| 413 | final long now = SystemClock.uptimeMillis(); |
| 414 | MotionEvent event = MotionEvent.obtain(now, now, |
| 415 | MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0); |
| 416 | event.setSource(InputDevice.SOURCE_TOUCHSCREEN); |
| 417 | mView.dispatchTouchEvent(event); |
| 418 | event.recycle(); |
| 419 | mTouchCancelled = true; |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 424 | pw.print(" mExpandAnimationPending="); |
| 425 | pw.println(mExpandAnimationPending); |
| 426 | pw.print(" mExpandAnimationRunning="); |
| 427 | pw.println(mExpandAnimationRunning); |
| 428 | pw.print(" mTouchCancelled="); |
| 429 | pw.println(mTouchCancelled); |
| 430 | pw.print(" mTouchActive="); |
| 431 | pw.println(mTouchActive); |
| 432 | } |
| 433 | |
| 434 | public void setExpandAnimationPending(boolean pending) { |
| 435 | mExpandAnimationPending = pending; |
| 436 | } |
| 437 | |
| 438 | public void setExpandAnimationRunning(boolean running) { |
| 439 | mExpandAnimationRunning = running; |
| 440 | } |
| 441 | |
| 442 | public void cancelExpandHelper() { |
Heemin Seog | 82b96cd | 2019-11-12 16:40:00 -0800 | [diff] [blame] | 443 | if (mStackScrollLayout != null) { |
| 444 | mStackScrollLayout.cancelExpandHelper(); |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 445 | } |
| 446 | } |
| 447 | |
Beverly | f937f29 | 2020-02-20 13:45:36 -0500 | [diff] [blame] | 448 | public PhoneStatusBarTransitions getBarTransitions() { |
| 449 | return mBarTransitions; |
| 450 | } |
| 451 | |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 452 | public void setStatusBarView(PhoneStatusBarView statusBarView) { |
| 453 | mStatusBarView = statusBarView; |
Beverly | f937f29 | 2020-02-20 13:45:36 -0500 | [diff] [blame] | 454 | if (statusBarView != null && mStatusBarViewFactory != null) { |
| 455 | mBarTransitions = new PhoneStatusBarTransitions( |
| 456 | statusBarView, |
| 457 | mStatusBarViewFactory.getStatusBarWindowView() |
| 458 | .findViewById(R.id.status_bar_container)); |
| 459 | } |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | public void setService(StatusBar statusBar) { |
| 463 | mService = statusBar; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | @VisibleForTesting |
| 467 | void setDragDownHelper(DragDownHelper dragDownHelper) { |
| 468 | mDragDownHelper = dragDownHelper; |
| 469 | } |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 470 | |
| 471 | private boolean isIntersecting(View view, float x, float y) { |
| 472 | mTempLocation = view.getLocationOnScreen(); |
| 473 | mTempRect.set(mTempLocation[0], mTempLocation[1], mTempLocation[0] + view.getWidth(), |
| 474 | mTempLocation[1] + view.getHeight()); |
| 475 | return mTempRect.contains(x, y); |
| 476 | } |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 477 | } |