blob: 6686b80d1e18940ebd45ff7d025ed99919c3143f [file] [log] [blame]
Jeff Brown4ccb8232014-01-16 22:16:42 -08001/*
Adrian Roose99bc052017-11-20 17:55:31 +01002 * Copyright (C) 2017 The Android Open Source Project
Jeff Brown4ccb8232014-01-16 22:16:42 -08003 *
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
Adrian Roose99bc052017-11-20 17:55:31 +010017package com.android.server.wm;
Jeff Brown4ccb8232014-01-16 22:16:42 -080018
Alan Viverette59e53a12016-03-28 13:41:32 -040019import android.annotation.NonNull;
Alan Viverette214fb682015-11-17 09:47:11 -050020import android.annotation.Nullable;
Daichi Hirono3c6c95e2017-09-13 12:23:57 +090021import android.content.ClipData;
Svetoslav8e3feb12014-02-24 13:46:47 -080022import android.graphics.Rect;
23import android.graphics.Region;
Jeff Brown4ccb8232014-01-16 22:16:42 -080024import android.hardware.display.DisplayManagerInternal;
Svetoslav8e3feb12014-02-24 13:46:47 -080025import android.os.IBinder;
Daichi Hirono4a545172018-02-01 10:59:48 +090026import android.view.Display;
Adrian Roose99bc052017-11-20 17:55:31 +010027import android.view.IInputFilter;
28import android.view.IWindow;
Daichi Hirono4a545172018-02-01 10:59:48 +090029import android.view.InputChannel;
Adrian Roose99bc052017-11-20 17:55:31 +010030import android.view.MagnificationSpec;
31import android.view.WindowInfo;
Svetoslav8e3feb12014-02-24 13:46:47 -080032
Daichi Hirono4a545172018-02-01 10:59:48 +090033import com.android.server.input.InputManagerService;
Adrian Roose99bc052017-11-20 17:55:31 +010034import com.android.server.policy.WindowManagerPolicy;
35
Svetoslav8e3feb12014-02-24 13:46:47 -080036import java.util.List;
Jeff Brown4ccb8232014-01-16 22:16:42 -080037
38/**
39 * Window manager local system service interface.
40 *
41 * @hide Only for use within the system server.
42 */
43public abstract class WindowManagerInternal {
Svetoslav8e3feb12014-02-24 13:46:47 -080044
45 /**
46 * Interface to receive a callback when the windows reported for
47 * accessibility changed.
48 */
49 public interface WindowsForAccessibilityCallback {
50
51 /**
52 * Called when the windows for accessibility changed.
53 *
54 * @param windows The windows for accessibility.
55 */
56 public void onWindowsForAccessibilityChanged(List<WindowInfo> windows);
57 }
58
59 /**
60 * Callbacks for contextual changes that affect the screen magnification
61 * feature.
62 */
63 public interface MagnificationCallbacks {
64
65 /**
Phil Weaver70439242016-03-10 15:15:49 -080066 * Called when the region where magnification operates changes. Note that this isn't the
67 * entire screen. For example, IMEs are not magnified.
Svetoslav8e3feb12014-02-24 13:46:47 -080068 *
Phil Weaver70439242016-03-10 15:15:49 -080069 * @param magnificationRegion the current magnification region
Svetoslav8e3feb12014-02-24 13:46:47 -080070 */
Phil Weaver70439242016-03-10 15:15:49 -080071 public void onMagnificationRegionChanged(Region magnificationRegion);
Svetoslav8e3feb12014-02-24 13:46:47 -080072
73 /**
74 * Called when an application requests a rectangle on the screen to allow
75 * the client to apply the appropriate pan and scale.
76 *
77 * @param left The rectangle left.
78 * @param top The rectangle top.
79 * @param right The rectangle right.
80 * @param bottom The rectangle bottom.
81 */
82 public void onRectangleOnScreenRequested(int left, int top, int right, int bottom);
83
84 /**
85 * Notifies that the rotation changed.
86 *
87 * @param rotation The current rotation.
88 */
89 public void onRotationChanged(int rotation);
90
91 /**
92 * Notifies that the context of the user changed. For example, an application
93 * was started.
94 */
95 public void onUserContextChanged();
96 }
97
Jeff Brown4ccb8232014-01-16 22:16:42 -080098 /**
Jorim Jaggi77ba4802015-02-18 13:57:50 +010099 * Abstract class to be notified about {@link com.android.server.wm.AppTransition} events. Held
100 * as an abstract class so a listener only needs to implement the methods of its interest.
101 */
102 public static abstract class AppTransitionListener {
103
104 /**
105 * Called when an app transition is being setup and about to be executed.
106 */
107 public void onAppTransitionPendingLocked() {}
108
109 /**
110 * Called when a pending app transition gets cancelled.
Jorim Jaggife762342016-10-13 14:33:27 +0200111 *
112 * @param transit transition type indicating what kind of transition got cancelled
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100113 */
Jorim Jaggife762342016-10-13 14:33:27 +0200114 public void onAppTransitionCancelledLocked(int transit) {}
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100115
116 /**
117 * Called when an app transition gets started
118 *
Jorim Jaggife762342016-10-13 14:33:27 +0200119 * @param transit transition type indicating what kind of transition gets run, must be one
120 * of AppTransition.TRANSIT_* values
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100121 * @param openToken the token for the opening app
122 * @param closeToken the token for the closing app
Jorim Jaggif5f9e122017-10-24 18:21:09 +0200123 * @param duration the total duration of the transition
124 * @param statusBarAnimationStartTime the desired start time for all visual animations in
125 * the status bar caused by this app transition in uptime millis
126 * @param statusBarAnimationDuration the duration for all visual animations in the status
127 * bar caused by this app transition in millis
Jorim Jaggife762342016-10-13 14:33:27 +0200128 *
129 * @return Return any bit set of {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_LAYOUT},
130 * {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_CONFIG},
131 * {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_WALLPAPER},
132 * or {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_ANIM}.
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100133 */
Jorim Jaggife762342016-10-13 14:33:27 +0200134 public int onAppTransitionStartingLocked(int transit, IBinder openToken, IBinder closeToken,
Jorim Jaggif5f9e122017-10-24 18:21:09 +0200135 long duration, long statusBarAnimationStartTime, long statusBarAnimationDuration) {
Jorim Jaggife762342016-10-13 14:33:27 +0200136 return 0;
137 }
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100138
139 /**
140 * Called when an app transition is finished running.
141 *
142 * @param token the token for app whose transition has finished
143 */
144 public void onAppTransitionFinishedLocked(IBinder token) {}
145 }
146
147 /**
Seigo Nonaka7309b122015-08-17 18:34:13 -0700148 * An interface to be notified about hardware keyboard status.
149 */
150 public interface OnHardKeyboardStatusChangeListener {
151 public void onHardKeyboardStatusChange(boolean available);
152 }
153
154 /**
Daichi Hirono3c6c95e2017-09-13 12:23:57 +0900155 * An interface to customize drag and drop behaviors.
156 */
157 public interface IDragDropCallback {
Daichi Hirono4a545172018-02-01 10:59:48 +0900158 default boolean registerInputChannel(
159 DragState state, Display display, InputManagerService service,
160 InputChannel source) {
161 state.register(display);
162 return service.transferTouchFocus(source, state.getInputChannel());
163 }
164
Daichi Hirono3c6c95e2017-09-13 12:23:57 +0900165 /**
Daichi Hironobb28efb2017-11-21 15:11:01 +0900166 * Called when drag operation is starting.
Daichi Hirono3c6c95e2017-09-13 12:23:57 +0900167 */
Daichi Hironobb28efb2017-11-21 15:11:01 +0900168 default boolean prePerformDrag(IWindow window, IBinder dragToken,
Daichi Hirono3c6c95e2017-09-13 12:23:57 +0900169 int touchSource, float touchX, float touchY, float thumbCenterX, float thumbCenterY,
170 ClipData data) {
171 return true;
172 }
173
174 /**
Daichi Hironobb28efb2017-11-21 15:11:01 +0900175 * Called when drag operation is started.
Daichi Hirono3c6c95e2017-09-13 12:23:57 +0900176 */
Daichi Hironobb28efb2017-11-21 15:11:01 +0900177 default void postPerformDrag() {}
Daichi Hirono3c6c95e2017-09-13 12:23:57 +0900178
179 /**
Daichi Hironobb28efb2017-11-21 15:11:01 +0900180 * Called when drop result is being reported.
Daichi Hirono3c6c95e2017-09-13 12:23:57 +0900181 */
Daichi Hironobb28efb2017-11-21 15:11:01 +0900182 default void preReportDropResult(IWindow window, boolean consumed) {}
183
184 /**
185 * Called when drop result was reported.
186 */
187 default void postReportDropResult() {}
188
189 /**
190 * Called when drag operation is being cancelled.
191 */
192 default void preCancelDragAndDrop(IBinder dragToken) {}
193
194 /**
195 * Called when drag operation was cancelled.
196 */
197 default void postCancelDragAndDrop() {}
Daichi Hirono3c6c95e2017-09-13 12:23:57 +0900198 }
199
200 /**
Jeff Brown4ccb8232014-01-16 22:16:42 -0800201 * Request that the window manager call
202 * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager}
203 * within a surface transaction at a later time.
204 */
205 public abstract void requestTraversalFromDisplayManager();
Svetoslav8e3feb12014-02-24 13:46:47 -0800206
207 /**
208 * Set by the accessibility layer to observe changes in the magnified region,
209 * rotation, and other window transformations related to display magnification
210 * as the window manager is responsible for doing the actual magnification
211 * and has access to the raw window data while the accessibility layer serves
212 * as a controller.
213 *
214 * @param callbacks The callbacks to invoke.
215 */
Alan Viverette214fb682015-11-17 09:47:11 -0500216 public abstract void setMagnificationCallbacks(@Nullable MagnificationCallbacks callbacks);
Svetoslav8e3feb12014-02-24 13:46:47 -0800217
218 /**
219 * Set by the accessibility layer to specify the magnification and panning to
220 * be applied to all windows that should be magnified.
221 *
Craig Mautner8a0da012014-05-31 15:13:37 -0700222 * @param spec The MagnficationSpec to set.
Svetoslav8e3feb12014-02-24 13:46:47 -0800223 *
224 * @see #setMagnificationCallbacks(MagnificationCallbacks)
225 */
226 public abstract void setMagnificationSpec(MagnificationSpec spec);
227
228 /**
Casey Burkhardt74922c62017-02-13 12:43:16 -0800229 * Set by the accessibility framework to indicate whether the magnifiable regions of the display
230 * should be shown.
231 *
232 * @param show {@code true} to show magnifiable region bounds, {@code false} to hide
233 */
234 public abstract void setForceShowMagnifiableBounds(boolean show);
235
236 /**
Phil Weaver70439242016-03-10 15:15:49 -0800237 * Obtains the magnification regions.
Alan Viverette59e53a12016-03-28 13:41:32 -0400238 *
Phil Weaver70439242016-03-10 15:15:49 -0800239 * @param magnificationRegion the current magnification region
Alan Viverette59e53a12016-03-28 13:41:32 -0400240 */
Phil Weaver70439242016-03-10 15:15:49 -0800241 public abstract void getMagnificationRegion(@NonNull Region magnificationRegion);
Alan Viverette59e53a12016-03-28 13:41:32 -0400242
243 /**
Svetoslav8e3feb12014-02-24 13:46:47 -0800244 * Gets the magnification and translation applied to a window given its token.
245 * Not all windows are magnified and the window manager policy determines which
246 * windows are magnified. The returned result also takes into account the compat
247 * scale if necessary.
248 *
249 * @param windowToken The window's token.
250 *
251 * @return The magnification spec for the window.
252 *
253 * @see #setMagnificationCallbacks(MagnificationCallbacks)
254 */
255 public abstract MagnificationSpec getCompatibleMagnificationSpecForWindow(
256 IBinder windowToken);
257
258 /**
259 * Sets a callback for observing which windows are touchable for the purposes
260 * of accessibility.
261 *
262 * @param callback The callback.
263 */
264 public abstract void setWindowsForAccessibilityCallback(
265 WindowsForAccessibilityCallback callback);
266
267 /**
268 * Sets a filter for manipulating the input event stream.
269 *
270 * @param filter The filter implementation.
271 */
272 public abstract void setInputFilter(IInputFilter filter);
273
274 /**
275 * Gets the token of the window that has input focus.
276 *
277 * @return The token.
278 */
279 public abstract IBinder getFocusedWindowToken();
280
281 /**
282 * @return Whether the keyguard is engaged.
283 */
284 public abstract boolean isKeyguardLocked();
285
286 /**
Jonathan Solnit6e8d7092017-06-15 15:17:20 -0700287 * @return Whether the keyguard is showing and not occluded.
288 */
289 public abstract boolean isKeyguardShowingAndNotOccluded();
290
291 /**
Svetoslav8e3feb12014-02-24 13:46:47 -0800292 * Gets the frame of a window given its token.
293 *
294 * @param token The token.
295 * @param outBounds The frame to populate.
296 */
297 public abstract void getWindowFrame(IBinder token, Rect outBounds);
Craig Mautner8a0da012014-05-31 15:13:37 -0700298
299 /**
Alan Viverettee34560b22014-07-10 14:50:06 -0700300 * Opens the global actions dialog.
301 */
302 public abstract void showGlobalActions();
303
304 /**
Craig Mautner8a0da012014-05-31 15:13:37 -0700305 * Invalidate all visible windows. Then report back on the callback once all windows have
306 * redrawn.
307 */
Craig Mautner13f6ea72014-06-23 14:57:02 -0700308 public abstract void waitForAllWindowsDrawn(Runnable callback, long timeout);
Svetoslav3a5c7212014-10-14 09:54:26 -0700309
310 /**
311 * Adds a window token for a given window type.
312 *
313 * @param token The token to add.
314 * @param type The window type.
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700315 * @param displayId The display to add the token to.
Svetoslav3a5c7212014-10-14 09:54:26 -0700316 */
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700317 public abstract void addWindowToken(android.os.IBinder token, int type, int displayId);
Svetoslav3a5c7212014-10-14 09:54:26 -0700318
319 /**
320 * Removes a window token.
321 *
322 * @param token The toke to remove.
323 * @param removeWindows Whether to also remove the windows associated with the token.
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700324 * @param displayId The display to remove the token from.
Svetoslav3a5c7212014-10-14 09:54:26 -0700325 */
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700326 public abstract void removeWindowToken(android.os.IBinder token, boolean removeWindows,
327 int displayId);
Jorim Jaggi24bec7c2015-02-04 12:40:14 +0100328
329 /**
330 * Registers a listener to be notified about app transition events.
331 *
332 * @param listener The listener to register.
333 */
334 public abstract void registerAppTransitionListener(AppTransitionListener listener);
Seigo Nonaka7309b122015-08-17 18:34:13 -0700335
336 /**
337 * Retrieves a height of input method window.
338 */
339 public abstract int getInputMethodWindowVisibleHeight();
340
341 /**
342 * Saves last input method window for transition.
343 *
344 * Note that it is assumed that this method is called only by InputMethodManagerService.
345 */
346 public abstract void saveLastInputMethodWindowForTransition();
347
348 /**
Yohei Yukawa833bdce2016-05-15 20:05:56 -0700349 * Clears last input method window for transition.
350 *
351 * Note that it is assumed that this method is called only by InputMethodManagerService.
352 */
353 public abstract void clearLastInputMethodWindowForTransition();
354
355 /**
Yohei Yukawa69e68022017-02-13 12:04:50 -0800356 * Notifies WindowManagerService that the current IME window status is being changed.
357 *
358 * <p>Only {@link com.android.server.InputMethodManagerService} is the expected and tested
359 * caller of this method.</p>
360 *
361 * @param imeToken token to track the active input method. Corresponding IME windows can be
362 * identified by checking {@link android.view.WindowManager.LayoutParams#token}.
363 * Note that there is no guarantee that the corresponding window is already
364 * created
365 * @param imeWindowVisible whether the active IME thinks that its window should be visible or
366 * hidden, no matter how WindowManagerService will react / has reacted
367 * to corresponding API calls. Note that this state is not guaranteed
368 * to be synchronized with state in WindowManagerService.
Yohei Yukawad6475a62017-04-17 10:35:27 -0700369 * @param dismissImeOnBackKeyPressed {@code true} if the software keyboard is shown and the back
370 * key is expected to dismiss the software keyboard.
Yohei Yukawa69e68022017-02-13 12:04:50 -0800371 * @param targetWindowToken token to identify the target window that the IME is associated with.
Yohei Yukawaee2a7ed2017-02-15 21:38:57 -0800372 * {@code null} when application, system, or the IME itself decided to
373 * change its window visibility before being associated with any target
374 * window.
Yohei Yukawa69e68022017-02-13 12:04:50 -0800375 */
Yohei Yukawaee2a7ed2017-02-15 21:38:57 -0800376 public abstract void updateInputMethodWindowStatus(@NonNull IBinder imeToken,
Yohei Yukawad6475a62017-04-17 10:35:27 -0700377 boolean imeWindowVisible, boolean dismissImeOnBackKeyPressed,
378 @Nullable IBinder targetWindowToken);
Yohei Yukawa69e68022017-02-13 12:04:50 -0800379
380 /**
Seigo Nonaka7309b122015-08-17 18:34:13 -0700381 * Returns true when the hardware keyboard is available.
382 */
383 public abstract boolean isHardKeyboardAvailable();
384
385 /**
386 * Sets the callback listener for hardware keyboard status changes.
387 *
388 * @param listener The listener to set.
389 */
390 public abstract void setOnHardKeyboardStatusChangeListener(
391 OnHardKeyboardStatusChangeListener listener);
Wale Ogunwale6e94a9e2015-10-07 15:35:49 -0700392
Wale Ogunwale44f036f2017-09-29 05:09:09 -0700393 /** Returns true if a stack in the windowing mode is currently visible. */
394 public abstract boolean isStackVisible(int windowingMode);
Jorim Jaggi9511b0f2016-01-29 19:12:44 -0800395
396 /**
397 * @return True if and only if the docked divider is currently in resize mode.
398 */
399 public abstract boolean isDockedDividerResizing();
Svetoslav Ganovfd138892016-07-13 18:20:42 -0700400
401 /**
402 * Requests the window manager to recompute the windows for accessibility.
403 */
404 public abstract void computeWindowsForAccessibility();
Tarandeep Singhe1cfcf42017-07-10 18:50:00 -0700405
406 /**
407 * Called after virtual display Id is updated by
408 * {@link com.android.server.vr.Vr2dDisplay} with a specific
409 * {@param vr2dDisplayId}.
410 */
411 public abstract void setVr2dDisplayId(int vr2dDisplayId);
Daichi Hirono3c6c95e2017-09-13 12:23:57 +0900412
413 /**
414 * Sets callback to DragDropController.
415 */
416 public abstract void registerDragDropControllerCallback(IDragDropCallback callback);
Eugene Suslaf9a651d2017-10-11 12:06:27 -0700417
418 /**
419 * @see android.view.IWindowManager#lockNow
420 */
421 public abstract void lockNow();
Tony Mak6f2e97e2018-03-26 20:43:06 +0100422
423 /**
424 * Return the user that owns the given window, {@link android.os.UserHandle#USER_NULL} if
425 * the window token is not found.
426 */
427 public abstract int getWindowOwnerUserId(IBinder windowToken);
Svetoslav8e3feb12014-02-24 13:46:47 -0800428}