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; |
Daichi Hirono | 3c6c95e | 2017-09-13 12:23:57 +0900 | [diff] [blame] | 21 | import android.content.ClipData; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 22 | import android.graphics.Rect; |
| 23 | import android.graphics.Region; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 24 | import android.hardware.display.DisplayManagerInternal; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 25 | import android.os.IBinder; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 26 | import android.view.animation.Animation; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 27 | |
| 28 | import java.util.List; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Window manager local system service interface. |
| 32 | * |
| 33 | * @hide Only for use within the system server. |
| 34 | */ |
| 35 | public abstract class WindowManagerInternal { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * Interface to receive a callback when the windows reported for |
| 39 | * accessibility changed. |
| 40 | */ |
| 41 | public interface WindowsForAccessibilityCallback { |
| 42 | |
| 43 | /** |
| 44 | * Called when the windows for accessibility changed. |
| 45 | * |
| 46 | * @param windows The windows for accessibility. |
| 47 | */ |
| 48 | public void onWindowsForAccessibilityChanged(List<WindowInfo> windows); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Callbacks for contextual changes that affect the screen magnification |
| 53 | * feature. |
| 54 | */ |
| 55 | public interface MagnificationCallbacks { |
| 56 | |
| 57 | /** |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 58 | * Called when the region where magnification operates changes. Note that this isn't the |
| 59 | * entire screen. For example, IMEs are not magnified. |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 60 | * |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 61 | * @param magnificationRegion the current magnification region |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 62 | */ |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 63 | public void onMagnificationRegionChanged(Region magnificationRegion); |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * Called when an application requests a rectangle on the screen to allow |
| 67 | * the client to apply the appropriate pan and scale. |
| 68 | * |
| 69 | * @param left The rectangle left. |
| 70 | * @param top The rectangle top. |
| 71 | * @param right The rectangle right. |
| 72 | * @param bottom The rectangle bottom. |
| 73 | */ |
| 74 | public void onRectangleOnScreenRequested(int left, int top, int right, int bottom); |
| 75 | |
| 76 | /** |
| 77 | * Notifies that the rotation changed. |
| 78 | * |
| 79 | * @param rotation The current rotation. |
| 80 | */ |
| 81 | public void onRotationChanged(int rotation); |
| 82 | |
| 83 | /** |
| 84 | * Notifies that the context of the user changed. For example, an application |
| 85 | * was started. |
| 86 | */ |
| 87 | public void onUserContextChanged(); |
| 88 | } |
| 89 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 90 | /** |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 91 | * Abstract class to be notified about {@link com.android.server.wm.AppTransition} events. Held |
| 92 | * as an abstract class so a listener only needs to implement the methods of its interest. |
| 93 | */ |
| 94 | public static abstract class AppTransitionListener { |
| 95 | |
| 96 | /** |
| 97 | * Called when an app transition is being setup and about to be executed. |
| 98 | */ |
| 99 | public void onAppTransitionPendingLocked() {} |
| 100 | |
| 101 | /** |
| 102 | * Called when a pending app transition gets cancelled. |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 103 | * |
| 104 | * @param transit transition type indicating what kind of transition got cancelled |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 105 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 106 | public void onAppTransitionCancelledLocked(int transit) {} |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Called when an app transition gets started |
| 110 | * |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 111 | * @param transit transition type indicating what kind of transition gets run, must be one |
| 112 | * of AppTransition.TRANSIT_* values |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 113 | * @param openToken the token for the opening app |
| 114 | * @param closeToken the token for the closing app |
| 115 | * @param openAnimation the animation for the opening app |
| 116 | * @param closeAnimation the animation for the closing app |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 117 | * |
| 118 | * @return Return any bit set of {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_LAYOUT}, |
| 119 | * {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_CONFIG}, |
| 120 | * {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_WALLPAPER}, |
| 121 | * or {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_ANIM}. |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 122 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 123 | public int onAppTransitionStartingLocked(int transit, IBinder openToken, IBinder closeToken, |
| 124 | Animation openAnimation, Animation closeAnimation) { |
| 125 | return 0; |
| 126 | } |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * Called when an app transition is finished running. |
| 130 | * |
| 131 | * @param token the token for app whose transition has finished |
| 132 | */ |
| 133 | public void onAppTransitionFinishedLocked(IBinder token) {} |
| 134 | } |
| 135 | |
| 136 | /** |
Seigo Nonaka | 7309b12 | 2015-08-17 18:34:13 -0700 | [diff] [blame] | 137 | * An interface to be notified about hardware keyboard status. |
| 138 | */ |
| 139 | public interface OnHardKeyboardStatusChangeListener { |
| 140 | public void onHardKeyboardStatusChange(boolean available); |
| 141 | } |
| 142 | |
| 143 | /** |
Daichi Hirono | 3c6c95e | 2017-09-13 12:23:57 +0900 | [diff] [blame] | 144 | * An interface to customize drag and drop behaviors. |
| 145 | */ |
| 146 | public interface IDragDropCallback { |
| 147 | /** |
| 148 | * Called when drag operation is started. |
| 149 | */ |
| 150 | default boolean performDrag(IWindow window, IBinder dragToken, |
| 151 | int touchSource, float touchX, float touchY, float thumbCenterX, float thumbCenterY, |
| 152 | ClipData data) { |
| 153 | return true; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Called when drop result is reported. |
| 158 | */ |
| 159 | default void reportDropResult(IWindow window, boolean consumed) {} |
| 160 | |
| 161 | /** |
| 162 | * Called when drag operation is cancelled. |
| 163 | */ |
| 164 | default void cancelDragAndDrop(IBinder dragToken) {} |
| 165 | } |
| 166 | |
| 167 | /** |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 168 | * Request that the window manager call |
| 169 | * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager} |
| 170 | * within a surface transaction at a later time. |
| 171 | */ |
| 172 | public abstract void requestTraversalFromDisplayManager(); |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 173 | |
| 174 | /** |
| 175 | * Set by the accessibility layer to observe changes in the magnified region, |
| 176 | * rotation, and other window transformations related to display magnification |
| 177 | * as the window manager is responsible for doing the actual magnification |
| 178 | * and has access to the raw window data while the accessibility layer serves |
| 179 | * as a controller. |
| 180 | * |
| 181 | * @param callbacks The callbacks to invoke. |
| 182 | */ |
Alan Viverette | 214fb68 | 2015-11-17 09:47:11 -0500 | [diff] [blame] | 183 | public abstract void setMagnificationCallbacks(@Nullable MagnificationCallbacks callbacks); |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 184 | |
| 185 | /** |
| 186 | * Set by the accessibility layer to specify the magnification and panning to |
| 187 | * be applied to all windows that should be magnified. |
| 188 | * |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 189 | * @param spec The MagnficationSpec to set. |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 190 | * |
| 191 | * @see #setMagnificationCallbacks(MagnificationCallbacks) |
| 192 | */ |
| 193 | public abstract void setMagnificationSpec(MagnificationSpec spec); |
| 194 | |
| 195 | /** |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 196 | * Set by the accessibility framework to indicate whether the magnifiable regions of the display |
| 197 | * should be shown. |
| 198 | * |
| 199 | * @param show {@code true} to show magnifiable region bounds, {@code false} to hide |
| 200 | */ |
| 201 | public abstract void setForceShowMagnifiableBounds(boolean show); |
| 202 | |
| 203 | /** |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 204 | * Obtains the magnification regions. |
Alan Viverette | 59e53a1 | 2016-03-28 13:41:32 -0400 | [diff] [blame] | 205 | * |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 206 | * @param magnificationRegion the current magnification region |
Alan Viverette | 59e53a1 | 2016-03-28 13:41:32 -0400 | [diff] [blame] | 207 | */ |
Phil Weaver | 7043924 | 2016-03-10 15:15:49 -0800 | [diff] [blame] | 208 | public abstract void getMagnificationRegion(@NonNull Region magnificationRegion); |
Alan Viverette | 59e53a1 | 2016-03-28 13:41:32 -0400 | [diff] [blame] | 209 | |
| 210 | /** |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 211 | * Gets the magnification and translation applied to a window given its token. |
| 212 | * Not all windows are magnified and the window manager policy determines which |
| 213 | * windows are magnified. The returned result also takes into account the compat |
| 214 | * scale if necessary. |
| 215 | * |
| 216 | * @param windowToken The window's token. |
| 217 | * |
| 218 | * @return The magnification spec for the window. |
| 219 | * |
| 220 | * @see #setMagnificationCallbacks(MagnificationCallbacks) |
| 221 | */ |
| 222 | public abstract MagnificationSpec getCompatibleMagnificationSpecForWindow( |
| 223 | IBinder windowToken); |
| 224 | |
| 225 | /** |
| 226 | * Sets a callback for observing which windows are touchable for the purposes |
| 227 | * of accessibility. |
| 228 | * |
| 229 | * @param callback The callback. |
| 230 | */ |
| 231 | public abstract void setWindowsForAccessibilityCallback( |
| 232 | WindowsForAccessibilityCallback callback); |
| 233 | |
| 234 | /** |
| 235 | * Sets a filter for manipulating the input event stream. |
| 236 | * |
| 237 | * @param filter The filter implementation. |
| 238 | */ |
| 239 | public abstract void setInputFilter(IInputFilter filter); |
| 240 | |
| 241 | /** |
| 242 | * Gets the token of the window that has input focus. |
| 243 | * |
| 244 | * @return The token. |
| 245 | */ |
| 246 | public abstract IBinder getFocusedWindowToken(); |
| 247 | |
| 248 | /** |
| 249 | * @return Whether the keyguard is engaged. |
| 250 | */ |
| 251 | public abstract boolean isKeyguardLocked(); |
| 252 | |
| 253 | /** |
Jonathan Solnit | 6e8d709 | 2017-06-15 15:17:20 -0700 | [diff] [blame] | 254 | * @return Whether the keyguard is showing and not occluded. |
| 255 | */ |
| 256 | public abstract boolean isKeyguardShowingAndNotOccluded(); |
| 257 | |
| 258 | /** |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 259 | * Gets the frame of a window given its token. |
| 260 | * |
| 261 | * @param token The token. |
| 262 | * @param outBounds The frame to populate. |
| 263 | */ |
| 264 | public abstract void getWindowFrame(IBinder token, Rect outBounds); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 265 | |
| 266 | /** |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 267 | * Opens the global actions dialog. |
| 268 | */ |
| 269 | public abstract void showGlobalActions(); |
| 270 | |
| 271 | /** |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 272 | * Invalidate all visible windows. Then report back on the callback once all windows have |
| 273 | * redrawn. |
| 274 | */ |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 275 | public abstract void waitForAllWindowsDrawn(Runnable callback, long timeout); |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 276 | |
| 277 | /** |
| 278 | * Adds a window token for a given window type. |
| 279 | * |
| 280 | * @param token The token to add. |
| 281 | * @param type The window type. |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 282 | * @param displayId The display to add the token to. |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 283 | */ |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 284 | public abstract void addWindowToken(android.os.IBinder token, int type, int displayId); |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 285 | |
| 286 | /** |
| 287 | * Removes a window token. |
| 288 | * |
| 289 | * @param token The toke to remove. |
| 290 | * @param removeWindows Whether to also remove the windows associated with the token. |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 291 | * @param displayId The display to remove the token from. |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 292 | */ |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 293 | public abstract void removeWindowToken(android.os.IBinder token, boolean removeWindows, |
| 294 | int displayId); |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 295 | |
| 296 | /** |
| 297 | * Registers a listener to be notified about app transition events. |
| 298 | * |
| 299 | * @param listener The listener to register. |
| 300 | */ |
| 301 | public abstract void registerAppTransitionListener(AppTransitionListener listener); |
Seigo Nonaka | 7309b12 | 2015-08-17 18:34:13 -0700 | [diff] [blame] | 302 | |
| 303 | /** |
| 304 | * Retrieves a height of input method window. |
| 305 | */ |
| 306 | public abstract int getInputMethodWindowVisibleHeight(); |
| 307 | |
| 308 | /** |
| 309 | * Saves last input method window for transition. |
| 310 | * |
| 311 | * Note that it is assumed that this method is called only by InputMethodManagerService. |
| 312 | */ |
| 313 | public abstract void saveLastInputMethodWindowForTransition(); |
| 314 | |
| 315 | /** |
Yohei Yukawa | 833bdce | 2016-05-15 20:05:56 -0700 | [diff] [blame] | 316 | * Clears last input method window for transition. |
| 317 | * |
| 318 | * Note that it is assumed that this method is called only by InputMethodManagerService. |
| 319 | */ |
| 320 | public abstract void clearLastInputMethodWindowForTransition(); |
| 321 | |
| 322 | /** |
Yohei Yukawa | 69e6802 | 2017-02-13 12:04:50 -0800 | [diff] [blame] | 323 | * Notifies WindowManagerService that the current IME window status is being changed. |
| 324 | * |
| 325 | * <p>Only {@link com.android.server.InputMethodManagerService} is the expected and tested |
| 326 | * caller of this method.</p> |
| 327 | * |
| 328 | * @param imeToken token to track the active input method. Corresponding IME windows can be |
| 329 | * identified by checking {@link android.view.WindowManager.LayoutParams#token}. |
| 330 | * Note that there is no guarantee that the corresponding window is already |
| 331 | * created |
| 332 | * @param imeWindowVisible whether the active IME thinks that its window should be visible or |
| 333 | * hidden, no matter how WindowManagerService will react / has reacted |
| 334 | * to corresponding API calls. Note that this state is not guaranteed |
| 335 | * to be synchronized with state in WindowManagerService. |
Yohei Yukawa | d6475a6 | 2017-04-17 10:35:27 -0700 | [diff] [blame] | 336 | * @param dismissImeOnBackKeyPressed {@code true} if the software keyboard is shown and the back |
| 337 | * key is expected to dismiss the software keyboard. |
Yohei Yukawa | 69e6802 | 2017-02-13 12:04:50 -0800 | [diff] [blame] | 338 | * @param targetWindowToken token to identify the target window that the IME is associated with. |
Yohei Yukawa | ee2a7ed | 2017-02-15 21:38:57 -0800 | [diff] [blame] | 339 | * {@code null} when application, system, or the IME itself decided to |
| 340 | * change its window visibility before being associated with any target |
| 341 | * window. |
Yohei Yukawa | 69e6802 | 2017-02-13 12:04:50 -0800 | [diff] [blame] | 342 | */ |
Yohei Yukawa | ee2a7ed | 2017-02-15 21:38:57 -0800 | [diff] [blame] | 343 | public abstract void updateInputMethodWindowStatus(@NonNull IBinder imeToken, |
Yohei Yukawa | d6475a6 | 2017-04-17 10:35:27 -0700 | [diff] [blame] | 344 | boolean imeWindowVisible, boolean dismissImeOnBackKeyPressed, |
| 345 | @Nullable IBinder targetWindowToken); |
Yohei Yukawa | 69e6802 | 2017-02-13 12:04:50 -0800 | [diff] [blame] | 346 | |
| 347 | /** |
Seigo Nonaka | 7309b12 | 2015-08-17 18:34:13 -0700 | [diff] [blame] | 348 | * Returns true when the hardware keyboard is available. |
| 349 | */ |
| 350 | public abstract boolean isHardKeyboardAvailable(); |
| 351 | |
| 352 | /** |
| 353 | * Sets the callback listener for hardware keyboard status changes. |
| 354 | * |
| 355 | * @param listener The listener to set. |
| 356 | */ |
| 357 | public abstract void setOnHardKeyboardStatusChangeListener( |
| 358 | OnHardKeyboardStatusChangeListener listener); |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 359 | |
Wale Ogunwale | 44f036f | 2017-09-29 05:09:09 -0700 | [diff] [blame] | 360 | /** Returns true if a stack in the windowing mode is currently visible. */ |
| 361 | public abstract boolean isStackVisible(int windowingMode); |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 362 | |
| 363 | /** |
| 364 | * @return True if and only if the docked divider is currently in resize mode. |
| 365 | */ |
| 366 | public abstract boolean isDockedDividerResizing(); |
Svetoslav Ganov | fd13889 | 2016-07-13 18:20:42 -0700 | [diff] [blame] | 367 | |
| 368 | /** |
| 369 | * Requests the window manager to recompute the windows for accessibility. |
| 370 | */ |
| 371 | public abstract void computeWindowsForAccessibility(); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 372 | |
| 373 | /** |
| 374 | * Called after virtual display Id is updated by |
| 375 | * {@link com.android.server.vr.Vr2dDisplay} with a specific |
| 376 | * {@param vr2dDisplayId}. |
| 377 | */ |
| 378 | public abstract void setVr2dDisplayId(int vr2dDisplayId); |
Daichi Hirono | 3c6c95e | 2017-09-13 12:23:57 +0900 | [diff] [blame] | 379 | |
| 380 | /** |
| 381 | * Sets callback to DragDropController. |
| 382 | */ |
| 383 | public abstract void registerDragDropControllerCallback(IDragDropCallback callback); |
Eugene Susla | f9a651d | 2017-10-11 12:06:27 -0700 | [diff] [blame] | 384 | |
| 385 | /** |
| 386 | * @see android.view.IWindowManager#lockNow |
| 387 | */ |
| 388 | public abstract void lockNow(); |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 389 | } |