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.graphics.Region; 20 import android.view.ViewGroup; 21 22 import androidx.annotation.NonNull; 23 import androidx.annotation.Nullable; 24 25 import com.android.systemui.statusbar.phone.StatusBarWindowCallback; 26 27 import java.util.function.Consumer; 28 29 /** 30 * Interface to control the state of the notification shade window. Not all methods of this 31 * interface will be used by each implementation of {@link NotificationShadeWindowController}. 32 */ 33 public interface NotificationShadeWindowController extends RemoteInputController.Callback { 34 35 /** 36 * Registers a {@link StatusBarWindowCallback} to receive notifications about status bar 37 * window state changes. 38 */ registerCallback(StatusBarWindowCallback callback)39 default void registerCallback(StatusBarWindowCallback callback) {} 40 41 /** 42 * Unregisters a {@link StatusBarWindowCallback previous registered with 43 * {@link #registerCallback(StatusBarWindowCallback)}} 44 */ unregisterCallback(StatusBarWindowCallback callback)45 default void unregisterCallback(StatusBarWindowCallback callback) {} 46 47 /** Notifies the registered {@link StatusBarWindowCallback} instances. */ notifyStateChangedCallbacks()48 default void notifyStateChangedCallbacks() {} 49 50 /** 51 * Registers a listener to monitor scrims visibility. 52 * 53 * @param listener A listener to monitor scrims visibility 54 */ setScrimsVisibilityListener(Consumer<Integer> listener)55 default void setScrimsVisibilityListener(Consumer<Integer> listener) {} 56 57 /** 58 * Adds the notification shade view to the window manager. 59 */ attach()60 default void attach() {} 61 62 /** Sets the notification shade view. */ setWindowRootView(ViewGroup view)63 default void setWindowRootView(ViewGroup view) {} 64 65 /** Gets the notification shade view. */ 66 @Nullable getWindowRootView()67 default ViewGroup getWindowRootView() { 68 return null; 69 } 70 71 /** Sets the state of whether the keyguard is currently showing or not. */ setKeyguardShowing(boolean showing)72 default void setKeyguardShowing(boolean showing) {} 73 74 /** Sets the state of whether the keyguard is currently occluded or not. */ setKeyguardOccluded(boolean occluded)75 default void setKeyguardOccluded(boolean occluded) {} 76 77 /** Sets the state of whether the keyguard is currently needs input or not. */ setKeyguardNeedsInput(boolean needsInput)78 default void setKeyguardNeedsInput(boolean needsInput) {} 79 80 /** Sets the state of whether the notification shade panel is currently visible or not. */ setPanelVisible(boolean visible)81 default void setPanelVisible(boolean visible) {} 82 83 /** Sets the state of whether the notification shade is focusable or not. */ setNotificationShadeFocusable(boolean focusable)84 default void setNotificationShadeFocusable(boolean focusable) {} 85 86 /** Sets the state of whether the bouncer is showing or not. */ setBouncerShowing(boolean showing)87 default void setBouncerShowing(boolean showing) {} 88 89 /** Sets the state of whether the backdrop is showing or not. */ setBackdropShowing(boolean showing)90 default void setBackdropShowing(boolean showing) {} 91 92 /** Sets the state of whether the keyguard is fading away or not. */ setKeyguardFadingAway(boolean keyguardFadingAway)93 default void setKeyguardFadingAway(boolean keyguardFadingAway) {} 94 95 /** Sets the state of whether the user activities are forced or not. */ setForceUserActivity(boolean forceUserActivity)96 default void setForceUserActivity(boolean forceUserActivity) {} 97 98 /** Sets the state of whether an activity is launching or not. */ setLaunchingActivity(boolean launching)99 default void setLaunchingActivity(boolean launching) {} 100 101 /** Get whether an activity is launching or not. */ isLaunchingActivity()102 default boolean isLaunchingActivity() { 103 return false; 104 } 105 106 /** Sets the state of whether the scrim is visible or not. */ setScrimsVisibility(int scrimsVisibility)107 default void setScrimsVisibility(int scrimsVisibility) {} 108 109 /** Sets the background blur radius of the notification shade window. */ setBackgroundBlurRadius(int backgroundBlurRadius)110 default void setBackgroundBlurRadius(int backgroundBlurRadius) {} 111 112 /** Sets the state of whether heads up is showing or not. */ setHeadsUpShowing(boolean showing)113 default void setHeadsUpShowing(boolean showing) {} 114 115 /** Gets whether the wallpaper is showing or not. */ isShowingWallpaper()116 default boolean isShowingWallpaper() { 117 return false; 118 } 119 120 /** Sets whether the window was collapsed by force or not. */ setForceWindowCollapsed(boolean force)121 default void setForceWindowCollapsed(boolean force) {} 122 123 /** Gets whether the panel is expanded or not. */ getPanelExpanded()124 default boolean getPanelExpanded() { 125 return false; 126 } 127 128 /** Sets the state of whether the remote input is active or not. */ onRemoteInputActive(boolean remoteInputActive)129 default void onRemoteInputActive(boolean remoteInputActive) {} 130 131 /** Sets the screen brightness level for when the device is dozing. */ setDozeScreenBrightness(int value)132 default void setDozeScreenBrightness(int value) {} 133 134 /** 135 * Sets whether the screen brightness is forced to the value we use for doze mode by the status 136 * bar window. No-op if the device does not support dozing. 137 */ setForceDozeBrightness(boolean forceDozeBrightness)138 default void setForceDozeBrightness(boolean forceDozeBrightness) {} 139 140 /** Sets the state of whether sysui is dozing or not. */ setDozing(boolean dozing)141 default void setDozing(boolean dozing) {} 142 143 /** Sets the state of whether sysui is dreaming or not. */ setDreaming(boolean dreaming)144 default void setDreaming(boolean dreaming) {} 145 146 /** Sets the state of whether plugin open is forced or not. */ setForcePluginOpen(boolean forcePluginOpen, Object token)147 default void setForcePluginOpen(boolean forcePluginOpen, Object token) {} 148 149 /** Gets whether we are forcing plugin open or not. */ getForcePluginOpen()150 default boolean getForcePluginOpen() { 151 return false; 152 } 153 154 /** Sets the state of whether the notification shade is touchable or not. */ setNotTouchable(boolean notTouchable)155 default void setNotTouchable(boolean notTouchable) {} 156 157 /** Sets the region where touch is excluded from the parent window. */ setTouchExclusionRegion(Region region)158 default void setTouchExclusionRegion(Region region) {} 159 160 /** Sets a {@link OtherwisedCollapsedListener}. */ setStateListener(OtherwisedCollapsedListener listener)161 default void setStateListener(OtherwisedCollapsedListener listener) {} 162 163 /** Sets a {@link ForcePluginOpenListener}. */ setForcePluginOpenListener(ForcePluginOpenListener listener)164 default void setForcePluginOpenListener(ForcePluginOpenListener listener) {} 165 166 /** Sets whether the system is in a state where the keyguard is going away. */ setKeyguardGoingAway(boolean goingAway)167 default void setKeyguardGoingAway(boolean goingAway) {} 168 169 /** 170 * SystemUI may need top-ui to avoid jank when performing animations. After the 171 * animation is performed, the component should remove itself from the list of features that 172 * are forcing SystemUI to be top-ui. 173 */ setRequestTopUi(boolean requestTopUi, String componentTag)174 default void setRequestTopUi(boolean requestTopUi, String componentTag) {} 175 176 /** 177 * If {@link LightRevealScrim} obscures the UI. 178 * @param opaque if the scrim is opaque 179 */ setLightRevealScrimOpaque(boolean opaque)180 default void setLightRevealScrimOpaque(boolean opaque) {} 181 182 /** 183 * Defer any application of window {@link WindowManager.LayoutParams} until {@code scope} is 184 * fully applied. 185 */ batchApplyWindowLayoutParams(@onNull Runnable scope)186 default void batchApplyWindowLayoutParams(@NonNull Runnable scope) { 187 scope.run(); 188 } 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