1 /* 2 * Copyright (C) 2020 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 android.view.ViewGroup; 20 21 import androidx.annotation.Nullable; 22 23 import com.android.systemui.statusbar.phone.StatusBarWindowCallback; 24 25 import java.util.function.Consumer; 26 27 /** 28 * Interface to control the state of the notification shade window. Not all methods of this 29 * interface will be used by each implementation of {@link NotificationShadeWindowController}. 30 */ 31 public interface NotificationShadeWindowController extends RemoteInputController.Callback { 32 33 /** 34 * Registers a {@link StatusBarWindowCallback} to receive notifications about status bar 35 * window state changes. 36 */ registerCallback(StatusBarWindowCallback callback)37 default void registerCallback(StatusBarWindowCallback callback) {} 38 39 /** 40 * Unregisters a {@link StatusBarWindowCallback previous registered with 41 * {@link #registerCallback(StatusBarWindowCallback)}} 42 */ unregisterCallback(StatusBarWindowCallback callback)43 default void unregisterCallback(StatusBarWindowCallback callback) {} 44 45 /** Notifies the registered {@link StatusBarWindowCallback} instances. */ notifyStateChangedCallbacks()46 default void notifyStateChangedCallbacks() {} 47 48 /** 49 * Registers a listener to monitor scrims visibility. 50 * 51 * @param listener A listener to monitor scrims visibility 52 */ setScrimsVisibilityListener(Consumer<Integer> listener)53 default void setScrimsVisibilityListener(Consumer<Integer> listener) {} 54 55 /** 56 * Adds the notification shade view to the window manager. 57 */ attach()58 default void attach() {} 59 60 /** Sets the notification shade view. */ setNotificationShadeView(ViewGroup view)61 default void setNotificationShadeView(ViewGroup view) {} 62 63 /** Gets the notification shade view. */ 64 @Nullable getNotificationShadeView()65 default ViewGroup getNotificationShadeView() { 66 return null; 67 } 68 69 /** Sets the state of whether the keyguard is currently showing or not. */ setKeyguardShowing(boolean showing)70 default void setKeyguardShowing(boolean showing) {} 71 72 /** Sets the state of whether the keyguard is currently occluded or not. */ setKeyguardOccluded(boolean occluded)73 default void setKeyguardOccluded(boolean occluded) {} 74 75 /** Sets the state of whether the keyguard is currently needs input or not. */ setKeyguardNeedsInput(boolean needsInput)76 default void setKeyguardNeedsInput(boolean needsInput) {} 77 78 /** Sets the state of whether the notification shade panel is currently visible or not. */ setPanelVisible(boolean visible)79 default void setPanelVisible(boolean visible) {} 80 81 /** Sets the state of whether the notification shade is focusable or not. */ setNotificationShadeFocusable(boolean focusable)82 default void setNotificationShadeFocusable(boolean focusable) {} 83 84 /** Sets the state of whether the bouncer is showing or not. */ setBouncerShowing(boolean showing)85 default void setBouncerShowing(boolean showing) {} 86 87 /** Sets the state of whether the backdrop is showing or not. */ setBackdropShowing(boolean showing)88 default void setBackdropShowing(boolean showing) {} 89 90 /** Sets the state of whether the keyguard is fading away or not. */ setKeyguardFadingAway(boolean keyguardFadingAway)91 default void setKeyguardFadingAway(boolean keyguardFadingAway) {} 92 93 /** Sets the state of whether the quick settings is expanded or not. */ setQsExpanded(boolean expanded)94 default void setQsExpanded(boolean expanded) {} 95 96 /** Sets the state of whether the user activities are forced or not. */ setForceUserActivity(boolean forceUserActivity)97 default void setForceUserActivity(boolean forceUserActivity) {} 98 99 /** Sets the state of whether an activity is launching or not. */ setLaunchingActivity(boolean launching)100 default void setLaunchingActivity(boolean launching) {} 101 102 /** Get whether an activity is launching or not. */ isLaunchingActivity()103 default boolean isLaunchingActivity() { 104 return false; 105 } 106 107 /** Sets the state of whether the scrim is visible or not. */ setScrimsVisibility(int scrimsVisibility)108 default void setScrimsVisibility(int scrimsVisibility) {} 109 110 /** Sets the background blur radius of the notification shade window. */ setBackgroundBlurRadius(int backgroundBlurRadius)111 default void setBackgroundBlurRadius(int backgroundBlurRadius) {} 112 113 /** Sets the state of whether heads up is showing or not. */ setHeadsUpShowing(boolean showing)114 default void setHeadsUpShowing(boolean showing) {} 115 116 /** Sets whether the wallpaper supports ambient mode or not. */ setWallpaperSupportsAmbientMode(boolean supportsAmbientMode)117 default void setWallpaperSupportsAmbientMode(boolean supportsAmbientMode) {} 118 119 /** Gets whether the wallpaper is showing or not. */ isShowingWallpaper()120 default boolean isShowingWallpaper() { 121 return false; 122 } 123 124 /** Sets whether the window was collapsed by force or not. */ setForceWindowCollapsed(boolean force)125 default void setForceWindowCollapsed(boolean force) {} 126 127 /** Sets whether panel is expanded or not. */ setPanelExpanded(boolean isExpanded)128 default void setPanelExpanded(boolean isExpanded) {} 129 130 /** Gets whether the panel is expanded or not. */ getPanelExpanded()131 default boolean getPanelExpanded() { 132 return false; 133 } 134 135 /** Sets the state of whether the remote input is active or not. */ onRemoteInputActive(boolean remoteInputActive)136 default void onRemoteInputActive(boolean remoteInputActive) {} 137 138 /** Sets the screen brightness level for when the device is dozing. */ setDozeScreenBrightness(int value)139 default void setDozeScreenBrightness(int value) {} 140 141 /** 142 * Sets whether the screen brightness is forced to the value we use for doze mode by the status 143 * bar window. No-op if the device does not support dozing. 144 */ setForceDozeBrightness(boolean forceDozeBrightness)145 default void setForceDozeBrightness(boolean forceDozeBrightness) {} 146 147 /** Sets the state of whether sysui is dozing or not. */ setDozing(boolean dozing)148 default void setDozing(boolean dozing) {} 149 150 /** Sets the state of whether plugin open is forced or not. */ setForcePluginOpen(boolean forcePluginOpen, Object token)151 default void setForcePluginOpen(boolean forcePluginOpen, Object token) {} 152 153 /** Gets whether we are forcing plugin open or not. */ getForcePluginOpen()154 default boolean getForcePluginOpen() { 155 return false; 156 } 157 158 /** Sets the state of whether the notification shade is touchable or not. */ setNotTouchable(boolean notTouchable)159 default void setNotTouchable(boolean notTouchable) {} 160 161 /** Sets a {@link OtherwisedCollapsedListener}. */ setStateListener(OtherwisedCollapsedListener listener)162 default void setStateListener(OtherwisedCollapsedListener listener) {} 163 164 /** Sets a {@link ForcePluginOpenListener}. */ setForcePluginOpenListener(ForcePluginOpenListener listener)165 default void setForcePluginOpenListener(ForcePluginOpenListener listener) {} 166 167 /** Sets whether the system is in a state where the keyguard is going away. */ setKeyguardGoingAway(boolean goingAway)168 default void setKeyguardGoingAway(boolean goingAway) {} 169 170 /** 171 * SystemUI may need top-ui to avoid jank when performing animations. After the 172 * animation is performed, the component should remove itself from the list of features that 173 * are forcing SystemUI to be top-ui. 174 */ setRequestTopUi(boolean requestTopUi, String componentTag)175 default void setRequestTopUi(boolean requestTopUi, String componentTag) {} 176 177 /** 178 * Under low light conditions, we might want to increase the display brightness on devices that 179 * don't have an IR camera. 180 * @param brightness float from 0 to 1 or {@code LayoutParams.BRIGHTNESS_OVERRIDE_NONE} 181 */ setFaceAuthDisplayBrightness(float brightness)182 default void setFaceAuthDisplayBrightness(float brightness) {} 183 184 /** 185 * If {@link LightRevealScrim} obscures the UI. 186 * @param opaque if the scrim is opaque 187 */ setLightRevealScrimOpaque(boolean opaque)188 default void setLightRevealScrimOpaque(boolean opaque) {} 189 190 /** 191 * Custom listener to pipe data back to plugins about whether or not the status bar would be 192 * collapsed if not for the plugin. 193 * TODO: Find cleaner way to do this. 194 */ 195 interface OtherwisedCollapsedListener { setWouldOtherwiseCollapse(boolean otherwiseCollapse)196 void setWouldOtherwiseCollapse(boolean otherwiseCollapse); 197 } 198 199 /** 200 * Listener to indicate forcePluginOpen has changed 201 */ 202 interface ForcePluginOpenListener { 203 /** 204 * Called when mState.forcePluginOpen is changed 205 */ onChange(boolean forceOpen)206 void onChange(boolean forceOpen); 207 } 208 } 209