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