• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
18 
19 import static java.lang.annotation.RetentionPolicy.SOURCE;
20 
21 import android.annotation.IntDef;
22 import android.view.InsetsVisibilities;
23 import android.view.View;
24 import android.view.WindowInsetsController.Appearance;
25 import android.view.WindowInsetsController.Behavior;
26 
27 import com.android.systemui.plugins.statusbar.StatusBarStateController;
28 import com.android.systemui.statusbar.phone.CentralSurfaces;
29 
30 import java.lang.annotation.Retention;
31 
32 /**
33  * Sends updates to {@link StateListener}s about changes to the status bar state and dozing state
34  */
35 public interface SysuiStatusBarStateController extends StatusBarStateController {
36 
37     // TODO: b/115739177 (remove this explicit ordering if we can)
38     @Retention(SOURCE)
39     @IntDef({RANK_STATUS_BAR, RANK_STATUS_BAR_WINDOW_CONTROLLER, RANK_STACK_SCROLLER, RANK_SHELF})
40     @interface SbStateListenerRank {}
41     // This is the set of known dependencies when updating StatusBarState
42     int RANK_STATUS_BAR = 0;
43     int RANK_STATUS_BAR_WINDOW_CONTROLLER = 1;
44     int RANK_STACK_SCROLLER = 2;
45     int RANK_SHELF = 3;
46 
47     /**
48      * Add a listener and a rank based on the priority of this message
49      * @param listener the listener
50      * @param rank the order in which you'd like to be called. Ranked listeners will be
51      * notified before unranked, and we will sort ranked listeners from low to high
52      *
53      * @deprecated This method exists only to solve latent inter-dependencies from refactoring
54      * StatusBarState out of CentralSurfaces.java. Any new listeners should be built not to need
55      * ranking (i.e., they are non-dependent on the order of operations of StatusBarState
56      * listeners).
57      */
58     @Deprecated
addCallback(StateListener listener, int rank)59     void addCallback(StateListener listener, int rank);
60 
61     /**
62      * Update the status bar state
63      * @param state see {@link StatusBarState} for valid options
64      * @return {@code true} if the state changed, else {@code false}
65      */
setState(int state)66     default boolean setState(int state) {
67         return setState(state, false /* force */);
68     }
69 
70     /**
71      * Update the status bar state
72      * @param state see {@link StatusBarState} for valid options
73      * @param force whether to set the state even if it's the same as the current state. This will
74      *              dispatch the state to all StatusBarStateListeners, ensuring that all listening
75      *              components are reset to this state.
76      * @return {@code true} if the state was changed or set forcefully
77      */
setState(int state, boolean force)78     boolean setState(int state, boolean force);
79 
80     /**
81      * Provides a hint that the status bar has started to transition to another
82      * {@link StatusBarState}. This suggests that a matching call to setState() with the same value
83      * will happen in the near future, although that may not happen if the animation is canceled,
84      * etc.
85      */
setUpcomingState(int state)86     void setUpcomingState(int state);
87 
88     /**
89      * If the status bar is in the process of transitioning to a new state, returns that state.
90      * Otherwise, returns the current state.
91      */
getCurrentOrUpcomingState()92     int getCurrentOrUpcomingState();
93 
94     /**
95      * Update the dozing state from {@link CentralSurfaces}'s perspective
96      * @param isDozing well, are we dozing?
97      * @return {@code true} if the state changed, else {@code false}
98      */
setIsDozing(boolean isDozing)99     boolean setIsDozing(boolean isDozing);
100 
101     /**
102      * Update the dreaming state from {@link CentralSurfaces}'s perspective
103      * @param isDreaming whether we are dreaming
104      * @return {@code true} if the state changed, else {@code false}
105      */
setIsDreaming(boolean isDreaming)106     boolean setIsDreaming(boolean isDreaming);
107 
108     /**
109      * Changes the current doze amount, also starts the
110      * {@link com.android.internal.jank.InteractionJankMonitor InteractionJankMonitor} as possible.
111      *
112      * @param view An attached view, which will be used by InteractionJankMonitor.
113      * @param dozeAmount New doze/dark amount.
114      * @param animated If change should be animated or not. This will cancel current animations.
115      */
setAndInstrumentDozeAmount(View view, float dozeAmount, boolean animated)116     void setAndInstrumentDozeAmount(View view, float dozeAmount, boolean animated);
117 
118     /**
119      * Sets whether to leave status bar open when hiding keyguard
120      */
setLeaveOpenOnKeyguardHide(boolean leaveOpen)121     void setLeaveOpenOnKeyguardHide(boolean leaveOpen);
122 
123     /**
124      * Whether to leave status bar open when hiding keyguard
125      */
leaveOpenOnKeyguardHide()126     boolean leaveOpenOnKeyguardHide();
127 
128     /**
129      * Interpolated doze amount
130      */
getInterpolatedDozeAmount()131     float getInterpolatedDozeAmount();
132 
133     /**
134      * Whether status bar is going to full shade
135      */
goingToFullShade()136     boolean goingToFullShade();
137 
138     /**
139      * Whether the previous state of the status bar was the shade locked
140      */
fromShadeLocked()141     boolean fromShadeLocked();
142 
143     /**
144      * Set keyguard requested
145      */
setKeyguardRequested(boolean keyguardRequested)146     void setKeyguardRequested(boolean keyguardRequested);
147 
148     /**
149      * Is keyguard requested
150      */
isKeyguardRequested()151     boolean isKeyguardRequested();
152 
153     /**
154      * Set the system bar attributes
155      */
setSystemBarAttributes(@ppearance int appearance, @Behavior int behavior, InsetsVisibilities requestedVisibilities, String packageName)156     void setSystemBarAttributes(@Appearance int appearance, @Behavior int behavior,
157             InsetsVisibilities requestedVisibilities, String packageName);
158 
159     /**
160      * Set pulsing
161      */
setPulsing(boolean visibility)162     void setPulsing(boolean visibility);
163 
164     /**
165      * Listener with rankings SbStateListenerRank that have dependencies so must be updated
166      * in a certain order
167      */
168     class RankedListener {
169         final StateListener mListener;
170         final int mRank;
171 
RankedListener(StateListener l, int r)172         RankedListener(StateListener l, int r) {
173             mListener = l;
174             mRank = r;
175         }
176     }
177 }
178