Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 android.view; |
| 18 | |
Alan Viverette | 59e53a1 | 2016-03-28 13:41:32 -0400 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Alan Viverette | 214fb68 | 2015-11-17 09:47:11 -0500 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 21 | import android.graphics.Rect; |
| 22 | import android.graphics.Region; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 23 | import android.hardware.display.DisplayManagerInternal; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 24 | import android.os.IBinder; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 25 | import android.view.animation.Animation; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 26 | |
| 27 | import java.util.List; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * Window manager local system service interface. |
| 31 | * |
| 32 | * @hide Only for use within the system server. |
| 33 | */ |
| 34 | public abstract class WindowManagerInternal { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Interface to receive a callback when the windows reported for |
| 38 | * accessibility changed. |
| 39 | */ |
| 40 | public interface WindowsForAccessibilityCallback { |
| 41 | |
| 42 | /** |
| 43 | * Called when the windows for accessibility changed. |
| 44 | * |
| 45 | * @param windows The windows for accessibility. |
| 46 | */ |
| 47 | public void onWindowsForAccessibilityChanged(List<WindowInfo> windows); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Callbacks for contextual changes that affect the screen magnification |
| 52 | * feature. |
| 53 | */ |
| 54 | public interface MagnificationCallbacks { |
| 55 | |
| 56 | /** |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 57 | * Called when the region where magnification operates changes. Note that this isn't the |
| 58 | * entire screen. For example, IMEs are not magnified. |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 59 | * |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 60 | * @param magnificationRegion the current magnification region |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 61 | */ |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 62 | public void onMagnificationRegionChanged(Region magnificationRegion); |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | * Called when an application requests a rectangle on the screen to allow |
| 66 | * the client to apply the appropriate pan and scale. |
| 67 | * |
| 68 | * @param left The rectangle left. |
| 69 | * @param top The rectangle top. |
| 70 | * @param right The rectangle right. |
| 71 | * @param bottom The rectangle bottom. |
| 72 | */ |
| 73 | public void onRectangleOnScreenRequested(int left, int top, int right, int bottom); |
| 74 | |
| 75 | /** |
| 76 | * Notifies that the rotation changed. |
| 77 | * |
| 78 | * @param rotation The current rotation. |
| 79 | */ |
| 80 | public void onRotationChanged(int rotation); |
| 81 | |
| 82 | /** |
| 83 | * Notifies that the context of the user changed. For example, an application |
| 84 | * was started. |
| 85 | */ |
| 86 | public void onUserContextChanged(); |
| 87 | } |
| 88 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 89 | /** |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 90 | * Abstract class to be notified about {@link com.android.server.wm.AppTransition} events. Held |
| 91 | * as an abstract class so a listener only needs to implement the methods of its interest. |
| 92 | */ |
| 93 | public static abstract class AppTransitionListener { |
| 94 | |
| 95 | /** |
| 96 | * Called when an app transition is being setup and about to be executed. |
| 97 | */ |
| 98 | public void onAppTransitionPendingLocked() {} |
| 99 | |
| 100 | /** |
| 101 | * Called when a pending app transition gets cancelled. |
| 102 | */ |
| 103 | public void onAppTransitionCancelledLocked() {} |
| 104 | |
| 105 | /** |
| 106 | * Called when an app transition gets started |
| 107 | * |
| 108 | * @param openToken the token for the opening app |
| 109 | * @param closeToken the token for the closing app |
| 110 | * @param openAnimation the animation for the opening app |
| 111 | * @param closeAnimation the animation for the closing app |
| 112 | */ |
| 113 | public void onAppTransitionStartingLocked(IBinder openToken, IBinder closeToken, |
| 114 | Animation openAnimation, Animation closeAnimation) {} |
| 115 | |
| 116 | /** |
| 117 | * Called when an app transition is finished running. |
| 118 | * |
| 119 | * @param token the token for app whose transition has finished |
| 120 | */ |
| 121 | public void onAppTransitionFinishedLocked(IBinder token) {} |
| 122 | } |
| 123 | |
| 124 | /** |
Seigo Nonaka | 7309b12 | 2015-08-17 18:34:13 -0700 | [diff] [blame] | 125 | * An interface to be notified about hardware keyboard status. |
| 126 | */ |
| 127 | public interface OnHardKeyboardStatusChangeListener { |
| 128 | public void onHardKeyboardStatusChange(boolean available); |
| 129 | } |
| 130 | |
| 131 | /** |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 132 | * Request that the window manager call |
| 133 | * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager} |
| 134 | * within a surface transaction at a later time. |
| 135 | */ |
| 136 | public abstract void requestTraversalFromDisplayManager(); |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 137 | |
| 138 | /** |
| 139 | * Set by the accessibility layer to observe changes in the magnified region, |
| 140 | * rotation, and other window transformations related to display magnification |
| 141 | * as the window manager is responsible for doing the actual magnification |
| 142 | * and has access to the raw window data while the accessibility layer serves |
| 143 | * as a controller. |
| 144 | * |
| 145 | * @param callbacks The callbacks to invoke. |
| 146 | */ |
Alan Viverette | 214fb68 | 2015-11-17 09:47:11 -0500 | [diff] [blame] | 147 | public abstract void setMagnificationCallbacks(@Nullable MagnificationCallbacks callbacks); |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 148 | |
| 149 | /** |
| 150 | * Set by the accessibility layer to specify the magnification and panning to |
| 151 | * be applied to all windows that should be magnified. |
| 152 | * |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 153 | * @param spec The MagnficationSpec to set. |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 154 | * |
| 155 | * @see #setMagnificationCallbacks(MagnificationCallbacks) |
| 156 | */ |
| 157 | public abstract void setMagnificationSpec(MagnificationSpec spec); |
| 158 | |
| 159 | /** |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 160 | * Obtains the magnification regions. |
Alan Viverette | 59e53a1 | 2016-03-28 13:41:32 -0400 | [diff] [blame] | 161 | * |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 162 | * @param magnificationRegion the current magnification region |
Alan Viverette | 59e53a1 | 2016-03-28 13:41:32 -0400 | [diff] [blame] | 163 | */ |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 164 | public abstract void getMagnificationRegion(@NonNull Region magnificationRegion); |
Alan Viverette | 59e53a1 | 2016-03-28 13:41:32 -0400 | [diff] [blame] | 165 | |
| 166 | /** |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 167 | * Gets the magnification and translation applied to a window given its token. |
| 168 | * Not all windows are magnified and the window manager policy determines which |
| 169 | * windows are magnified. The returned result also takes into account the compat |
| 170 | * scale if necessary. |
| 171 | * |
| 172 | * @param windowToken The window's token. |
| 173 | * |
| 174 | * @return The magnification spec for the window. |
| 175 | * |
| 176 | * @see #setMagnificationCallbacks(MagnificationCallbacks) |
| 177 | */ |
| 178 | public abstract MagnificationSpec getCompatibleMagnificationSpecForWindow( |
| 179 | IBinder windowToken); |
| 180 | |
| 181 | /** |
| 182 | * Sets a callback for observing which windows are touchable for the purposes |
| 183 | * of accessibility. |
| 184 | * |
| 185 | * @param callback The callback. |
| 186 | */ |
| 187 | public abstract void setWindowsForAccessibilityCallback( |
| 188 | WindowsForAccessibilityCallback callback); |
| 189 | |
| 190 | /** |
| 191 | * Sets a filter for manipulating the input event stream. |
| 192 | * |
| 193 | * @param filter The filter implementation. |
| 194 | */ |
| 195 | public abstract void setInputFilter(IInputFilter filter); |
| 196 | |
| 197 | /** |
| 198 | * Gets the token of the window that has input focus. |
| 199 | * |
| 200 | * @return The token. |
| 201 | */ |
| 202 | public abstract IBinder getFocusedWindowToken(); |
| 203 | |
| 204 | /** |
| 205 | * @return Whether the keyguard is engaged. |
| 206 | */ |
| 207 | public abstract boolean isKeyguardLocked(); |
| 208 | |
| 209 | /** |
| 210 | * Gets the frame of a window given its token. |
| 211 | * |
| 212 | * @param token The token. |
| 213 | * @param outBounds The frame to populate. |
| 214 | */ |
| 215 | public abstract void getWindowFrame(IBinder token, Rect outBounds); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 216 | |
| 217 | /** |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 218 | * Opens the global actions dialog. |
| 219 | */ |
| 220 | public abstract void showGlobalActions(); |
| 221 | |
| 222 | /** |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 223 | * Invalidate all visible windows. Then report back on the callback once all windows have |
| 224 | * redrawn. |
| 225 | */ |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 226 | public abstract void waitForAllWindowsDrawn(Runnable callback, long timeout); |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 227 | |
| 228 | /** |
| 229 | * Adds a window token for a given window type. |
| 230 | * |
| 231 | * @param token The token to add. |
| 232 | * @param type The window type. |
| 233 | */ |
| 234 | public abstract void addWindowToken(android.os.IBinder token, int type); |
| 235 | |
| 236 | /** |
| 237 | * Removes a window token. |
| 238 | * |
| 239 | * @param token The toke to remove. |
| 240 | * @param removeWindows Whether to also remove the windows associated with the token. |
| 241 | */ |
| 242 | public abstract void removeWindowToken(android.os.IBinder token, boolean removeWindows); |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 243 | |
| 244 | /** |
| 245 | * Registers a listener to be notified about app transition events. |
| 246 | * |
| 247 | * @param listener The listener to register. |
| 248 | */ |
| 249 | public abstract void registerAppTransitionListener(AppTransitionListener listener); |
Seigo Nonaka | 7309b12 | 2015-08-17 18:34:13 -0700 | [diff] [blame] | 250 | |
| 251 | /** |
| 252 | * Retrieves a height of input method window. |
| 253 | */ |
| 254 | public abstract int getInputMethodWindowVisibleHeight(); |
| 255 | |
| 256 | /** |
| 257 | * Saves last input method window for transition. |
| 258 | * |
| 259 | * Note that it is assumed that this method is called only by InputMethodManagerService. |
| 260 | */ |
| 261 | public abstract void saveLastInputMethodWindowForTransition(); |
| 262 | |
| 263 | /** |
Yohei Yukawa | 833bdce | 2016-05-15 20:05:56 -0700 | [diff] [blame] | 264 | * Clears last input method window for transition. |
| 265 | * |
| 266 | * Note that it is assumed that this method is called only by InputMethodManagerService. |
| 267 | */ |
| 268 | public abstract void clearLastInputMethodWindowForTransition(); |
| 269 | |
| 270 | /** |
Seigo Nonaka | 7309b12 | 2015-08-17 18:34:13 -0700 | [diff] [blame] | 271 | * Returns true when the hardware keyboard is available. |
| 272 | */ |
| 273 | public abstract boolean isHardKeyboardAvailable(); |
| 274 | |
| 275 | /** |
| 276 | * Sets the callback listener for hardware keyboard status changes. |
| 277 | * |
| 278 | * @param listener The listener to set. |
| 279 | */ |
| 280 | public abstract void setOnHardKeyboardStatusChangeListener( |
| 281 | OnHardKeyboardStatusChangeListener listener); |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 282 | |
| 283 | /** Returns true if the stack with the input Id is currently visible. */ |
| 284 | public abstract boolean isStackVisible(int stackId); |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 285 | |
| 286 | /** |
| 287 | * @return True if and only if the docked divider is currently in resize mode. |
| 288 | */ |
| 289 | public abstract boolean isDockedDividerResizing(); |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 290 | } |