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 23 import com.android.systemui.plugins.statusbar.StatusBarStateController; 24 import com.android.systemui.statusbar.phone.StatusBar; 25 26 import java.lang.annotation.Retention; 27 28 /** 29 * Sends updates to {@link StateListener}s about changes to the status bar state and dozing state 30 */ 31 public interface SysuiStatusBarStateController extends StatusBarStateController { 32 33 // TODO: b/115739177 (remove this explicit ordering if we can) 34 @Retention(SOURCE) 35 @IntDef({RANK_STATUS_BAR, RANK_STATUS_BAR_WINDOW_CONTROLLER, RANK_STACK_SCROLLER, RANK_SHELF}) 36 @interface SbStateListenerRank {} 37 // This is the set of known dependencies when updating StatusBarState 38 int RANK_STATUS_BAR = 0; 39 int RANK_STATUS_BAR_WINDOW_CONTROLLER = 1; 40 int RANK_STACK_SCROLLER = 2; 41 int RANK_SHELF = 3; 42 43 /** 44 * Add a listener and a rank based on the priority of this message 45 * @param listener the listener 46 * @param rank the order in which you'd like to be called. Ranked listeners will be 47 * notified before unranked, and we will sort ranked listeners from low to high 48 * 49 * @deprecated This method exists only to solve latent inter-dependencies from refactoring 50 * StatusBarState out of StatusBar.java. Any new listeners should be built not to need ranking 51 * (i.e., they are non-dependent on the order of operations of StatusBarState listeners). 52 */ 53 @Deprecated addCallback(StateListener listener, int rank)54 void addCallback(StateListener listener, int rank); 55 56 /** 57 * Update the status bar state 58 * @param state see {@link StatusBarState} for valid options 59 * @return {@code true} if the state changed, else {@code false} 60 */ setState(int state)61 boolean setState(int state); 62 63 /** 64 * Update the dozing state from {@link StatusBar}'s perspective 65 * @param isDozing well, are we dozing? 66 * @return {@code true} if the state changed, else {@code false} 67 */ setIsDozing(boolean isDozing)68 boolean setIsDozing(boolean isDozing); 69 70 /** 71 * Changes the current doze amount. 72 * 73 * @param dozeAmount New doze/dark amount. 74 * @param animated If change should be animated or not. This will cancel current animations. 75 */ setDozeAmount(float dozeAmount, boolean animated)76 void setDozeAmount(float dozeAmount, boolean animated); 77 78 /** 79 * Sets whether to leave status bar open when hiding keyguard 80 */ setLeaveOpenOnKeyguardHide(boolean leaveOpen)81 void setLeaveOpenOnKeyguardHide(boolean leaveOpen); 82 83 /** 84 * Whether to leave status bar open when hiding keyguard 85 */ leaveOpenOnKeyguardHide()86 boolean leaveOpenOnKeyguardHide(); 87 88 /** 89 * Interpolated doze amount 90 */ getInterpolatedDozeAmount()91 float getInterpolatedDozeAmount(); 92 93 /** 94 * Whether status bar is going to full shade 95 */ goingToFullShade()96 boolean goingToFullShade(); 97 98 /** 99 * Whether the previous state of the status bar was the shade locked 100 */ fromShadeLocked()101 boolean fromShadeLocked(); 102 103 /** 104 * Set keyguard requested 105 */ setKeyguardRequested(boolean keyguardRequested)106 void setKeyguardRequested(boolean keyguardRequested); 107 108 /** 109 * Is keyguard requested 110 */ isKeyguardRequested()111 boolean isKeyguardRequested(); 112 113 /** 114 * Set systemui visibility 115 */ setSystemUiVisibility(int visibility)116 void setSystemUiVisibility(int visibility); 117 118 /** 119 * Set pulsing 120 */ setPulsing(boolean visibility)121 void setPulsing(boolean visibility); 122 123 /** 124 * Listener with rankings SbStateListenerRank that have dependencies so must be updated 125 * in a certain order 126 */ 127 class RankedListener { 128 final StateListener mListener; 129 final int mRank; 130 RankedListener(StateListener l, int r)131 RankedListener(StateListener l, int r) { 132 mListener = l; 133 mRank = r; 134 } 135 } 136 } 137