• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 package com.android.systemui.shade
17 
18 import android.view.MotionEvent
19 import com.android.systemui.power.shared.model.WakefulnessModel
20 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
21 import com.android.systemui.statusbar.phone.HeadsUpAppearanceController
22 import com.android.systemui.statusbar.phone.KeyguardStatusBarView
23 import com.android.systemui.statusbar.phone.KeyguardStatusBarViewController
24 import java.util.function.Consumer
25 
26 /**
27  * Controller for the top level shade view.
28  *
29  * @see NotificationPanelViewController
30  */
31 interface ShadeViewController {
32     /** Returns whether the shade's top level view is enabled. */
33     @Deprecated("No longer supported. Do not add new calls to this.") val isViewEnabled: Boolean
34 
35     /** If the latency tracker is enabled, begins tracking expand latency. */
36     @Deprecated("No longer supported. Do not add new calls to this.")
startExpandLatencyTrackingnull37     fun startExpandLatencyTracking()
38 
39     /** Sets the alpha value of the shade to a value between 0 and 255. */
40     @Deprecated("No longer supported. Do not add new calls to this.")
41     fun setAlpha(alpha: Int, animate: Boolean)
42 
43     /**
44      * Sets the runnable to run after the alpha change animation completes.
45      *
46      * @see .setAlpha
47      */
48     @Deprecated("No longer supported. Do not add new calls to this.")
49     fun setAlphaChangeAnimationEndAction(r: Runnable)
50 
51     /** Sets Qs ScrimEnabled and updates QS state. */
52     @Deprecated("Does nothing when scene container is enabled.")
53     fun setQsScrimEnabled(qsScrimEnabled: Boolean)
54 
55     /** Updates notification panel-specific flags on [SysUiState]. */
56     @Deprecated("Does nothing when scene container is enabled.") fun updateSystemUiStateFlags()
57 
58     /** Ensures that the touchable region is updated. */
59     @Deprecated("No longer supported. Do not add new calls to this.") fun updateTouchableRegion()
60 
61     /**
62      * Sends an external (e.g. Status Bar) touch event to the Shade touch handler.
63      *
64      * This is different from [startInputFocusTransfer] as it doesn't rely on setting the launcher
65      * window slippery to allow the frameworks to route those events after passing the initial
66      * threshold.
67      */
68     fun handleExternalTouch(event: MotionEvent): Boolean
69 
70     /** Sends an external (e.g. Status Bar) intercept touch event to the Shade touch handler. */
71     fun handleExternalInterceptTouch(event: MotionEvent): Boolean
72 
73     /**
74      * Triggered when an input focus transfer gesture has started.
75      *
76      * Used to dispatch initial touch events before crossing the threshold to pull down the
77      * notification shade. After that, since the launcher window is set to slippery, input
78      * frameworks take care of routing the events to the notification shade.
79      */
80     @Deprecated("No longer supported. Do not add new calls to this.") fun startInputFocusTransfer()
81 
82     /** Triggered when the input focus transfer was cancelled. */
83     @Deprecated("No longer supported. Do not add new calls to this.") fun cancelInputFocusTransfer()
84 
85     /**
86      * Triggered when the input focus transfer has finished successfully.
87      *
88      * @param velocity unit is in px / millis
89      */
90     @Deprecated("No longer supported. Do not add new calls to this.")
91     fun finishInputFocusTransfer(velocity: Float)
92 
93     /** Returns the ShadeHeadsUpTracker. */
94     val shadeHeadsUpTracker: ShadeHeadsUpTracker
95 
96     @Deprecated("Temporary a11y solution until dual shade launch b/371224114")
97     /** Notifies the shade that a status bar detected a long press gesture. */
98     fun onStatusBarLongPress(event: MotionEvent)
99 
100     /** Returns the ShadeFoldAnimator. */
101     @Deprecated("This interface is deprecated in Scene Container")
102     val shadeFoldAnimator: ShadeFoldAnimator
103 
104     companion object {
105         /**
106          * Returns a multiplicative factor to use when determining the falsing threshold for touches
107          * on the shade. The factor will be larger when the device is waking up due to a touch or
108          * gesture.
109          */
110         @JvmStatic
111         fun getFalsingThresholdFactor(wakefulness: WakefulnessModel): Float {
112             return if (wakefulness.isAwakeFromTapOrGesture()) 1.5f else 1.0f
113         }
114 
115         const val WAKEUP_ANIMATION_DELAY_MS = 250
116         const val FLING_MAX_LENGTH_SECONDS = 0.6f
117         const val FLING_SPEED_UP_FACTOR = 0.6f
118         const val FLING_CLOSING_MAX_LENGTH_SECONDS = 0.6f
119         const val FLING_CLOSING_SPEED_UP_FACTOR = 0.6f
120 
121         /** Fling expanding QS. */
122         const val FLING_EXPAND = 0
123 
124         /** Fling collapsing QS, potentially stopping when QS becomes QQS. */
125         const val FLING_COLLAPSE = 1
126 
127         /** Fling until QS is completely hidden. */
128         const val FLING_HIDE = 2
129     }
130 }
131 
132 /** Manages listeners for when users begin expanding the shade from a HUN. */
133 interface ShadeHeadsUpTracker {
134     /** Add a listener for when the user starts expanding the shade from a HUN. */
addTrackingHeadsUpListenernull135     fun addTrackingHeadsUpListener(listener: Consumer<ExpandableNotificationRow>)
136 
137     /** Remove a listener for when the user starts expanding the shade from a HUN. */
138     fun removeTrackingHeadsUpListener(listener: Consumer<ExpandableNotificationRow>)
139 
140     /** Set the controller for the appearance of HUNs in the icon area and the header itself. */
141     fun setHeadsUpAppearanceController(headsUpAppearanceController: HeadsUpAppearanceController?)
142 
143     /** The notification row that was touched to initiate shade expansion. */
144     val trackedHeadsUpNotification: ExpandableNotificationRow?
145 }
146 
147 /** Handles the lifecycle of the shade's animation that happens when folding a foldable. */
148 @Deprecated("This interface should not be used in scene container. Needs flexiglass equivalent.")
149 interface ShadeFoldAnimator {
150     /** Updates the views to the initial state for the fold to AOD animation. */
151     @Deprecated("Used by the Keyguard Fold Transition. Needs flexiglass equivalent.")
152     fun prepareFoldToAodAnimation()
153 
154     /**
155      * Starts fold to AOD animation.
156      *
157      * @param startAction invoked when the animation starts.
158      * @param endAction invoked when the animation finishes, also if it was cancelled.
159      * @param cancelAction invoked when the animation is cancelled, before endAction.
160      */
161     @Deprecated("Not used when migrateClocksToBlueprint enabled.")
162     fun startFoldToAodAnimation(startAction: Runnable, endAction: Runnable, cancelAction: Runnable)
163 
164     /** Cancels fold to AOD transition and resets view state. */
165     @Deprecated("Used by the Keyguard Fold Transition. Needs flexiglass equivalent.")
166     fun cancelFoldToAodAnimation()
167 }
168 
169 /**
170  * An interface that provides the current state of the notification panel and related views, which
171  * is needed to calculate [KeyguardStatusBarView]'s state in [KeyguardStatusBarViewController].
172  */
173 @Deprecated("This interface should not be used in scene container.")
174 interface ShadeViewStateProvider {
175     /** Returns the expanded height of the panel view. */
176     @Deprecated("deprecated by SceneContainerFlag.isEnabled") val panelViewExpandedHeight: Float
177 
178     /** Returns true if heads up should be visible. */
shouldHeadsUpBeVisiblenull179     @Deprecated("deprecated by SceneContainerFlag.isEnabled.") fun shouldHeadsUpBeVisible(): Boolean
180 
181     /** Return the fraction of the shade that's expanded, when in lockscreen. */
182     @Deprecated("deprecated by SceneContainerFlag.isEnabled") val lockscreenShadeDragProgress: Float
183 }
184