blob: d07b2ac980eb5bb138f61dba4b4e737710999fd4 [file] [log] [blame]
Jeff Brown4ccb8232014-01-16 22:16:42 -08001/*
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
17package android.view;
18
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;
Jorim Jaggi77ba4802015-02-18 13:57:50 +010026import android.view.animation.Animation;
Svetoslav8e3feb12014-02-24 13:46:47 -080027
28import java.util.List;
Jeff Brown4ccb8232014-01-16 22:16:42 -080029
30/**
31 * Window manager local system service interface.
32 *
33 * @hide Only for use within the system server.
34 */
35public abstract class WindowManagerInternal {
Svetoslav8e3feb12014-02-24 13:46:47 -080036
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 Weaver70439242016-03-10 15:15:49 -080058 * Called when the region where magnification operates changes. Note that this isn't the
59 * entire screen. For example, IMEs are not magnified.
Svetoslav8e3feb12014-02-24 13:46:47 -080060 *
Phil Weaver70439242016-03-10 15:15:49 -080061 * @param magnificationRegion the current magnification region
Svetoslav8e3feb12014-02-24 13:46:47 -080062 */
Phil Weaver70439242016-03-10 15:15:49 -080063 public void onMagnificationRegionChanged(Region magnificationRegion);
Svetoslav8e3feb12014-02-24 13:46:47 -080064
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 Brown4ccb8232014-01-16 22:16:42 -080090 /**
Jorim Jaggi77ba4802015-02-18 13:57:50 +010091 * 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 Jaggife762342016-10-13 14:33:27 +0200103 *
104 * @param transit transition type indicating what kind of transition got cancelled
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100105 */
Jorim Jaggife762342016-10-13 14:33:27 +0200106 public void onAppTransitionCancelledLocked(int transit) {}
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100107
108 /**
109 * Called when an app transition gets started
110 *
Jorim Jaggife762342016-10-13 14:33:27 +0200111 * @param transit transition type indicating what kind of transition gets run, must be one
112 * of AppTransition.TRANSIT_* values
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100113 * @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 Jaggife762342016-10-13 14:33:27 +0200117 *
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 Jaggi77ba4802015-02-18 13:57:50 +0100122 */
Jorim Jaggife762342016-10-13 14:33:27 +0200123 public int onAppTransitionStartingLocked(int transit, IBinder openToken, IBinder closeToken,
124 Animation openAnimation, Animation closeAnimation) {
125 return 0;
126 }
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100127
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 Nonaka7309b122015-08-17 18:34:13 -0700137 * An interface to be notified about hardware keyboard status.
138 */
139 public interface OnHardKeyboardStatusChangeListener {
140 public void onHardKeyboardStatusChange(boolean available);
141 }
142
143 /**
Daichi Hirono3c6c95e2017-09-13 12:23:57 +0900144 * 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 Brown4ccb8232014-01-16 22:16:42 -0800168 * 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();
Svetoslav8e3feb12014-02-24 13:46:47 -0800173
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 Viverette214fb682015-11-17 09:47:11 -0500183 public abstract void setMagnificationCallbacks(@Nullable MagnificationCallbacks callbacks);
Svetoslav8e3feb12014-02-24 13:46:47 -0800184
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 Mautner8a0da012014-05-31 15:13:37 -0700189 * @param spec The MagnficationSpec to set.
Svetoslav8e3feb12014-02-24 13:46:47 -0800190 *
191 * @see #setMagnificationCallbacks(MagnificationCallbacks)
192 */
193 public abstract void setMagnificationSpec(MagnificationSpec spec);
194
195 /**
Casey Burkhardt74922c62017-02-13 12:43:16 -0800196 * 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 Weaver70439242016-03-10 15:15:49 -0800204 * Obtains the magnification regions.
Alan Viverette59e53a12016-03-28 13:41:32 -0400205 *
Phil Weaver70439242016-03-10 15:15:49 -0800206 * @param magnificationRegion the current magnification region
Alan Viverette59e53a12016-03-28 13:41:32 -0400207 */
Phil Weaver70439242016-03-10 15:15:49 -0800208 public abstract void getMagnificationRegion(@NonNull Region magnificationRegion);
Alan Viverette59e53a12016-03-28 13:41:32 -0400209
210 /**
Svetoslav8e3feb12014-02-24 13:46:47 -0800211 * 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 Solnit6e8d7092017-06-15 15:17:20 -0700254 * @return Whether the keyguard is showing and not occluded.
255 */
256 public abstract boolean isKeyguardShowingAndNotOccluded();
257
258 /**
Svetoslav8e3feb12014-02-24 13:46:47 -0800259 * 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 Mautner8a0da012014-05-31 15:13:37 -0700265
266 /**
Alan Viverettee34560b22014-07-10 14:50:06 -0700267 * Opens the global actions dialog.
268 */
269 public abstract void showGlobalActions();
270
271 /**
Craig Mautner8a0da012014-05-31 15:13:37 -0700272 * Invalidate all visible windows. Then report back on the callback once all windows have
273 * redrawn.
274 */
Craig Mautner13f6ea72014-06-23 14:57:02 -0700275 public abstract void waitForAllWindowsDrawn(Runnable callback, long timeout);
Svetoslav3a5c7212014-10-14 09:54:26 -0700276
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 Ogunwaleac2561e2016-11-01 15:43:46 -0700282 * @param displayId The display to add the token to.
Svetoslav3a5c7212014-10-14 09:54:26 -0700283 */
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700284 public abstract void addWindowToken(android.os.IBinder token, int type, int displayId);
Svetoslav3a5c7212014-10-14 09:54:26 -0700285
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 Ogunwaleac2561e2016-11-01 15:43:46 -0700291 * @param displayId The display to remove the token from.
Svetoslav3a5c7212014-10-14 09:54:26 -0700292 */
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700293 public abstract void removeWindowToken(android.os.IBinder token, boolean removeWindows,
294 int displayId);
Jorim Jaggi24bec7c2015-02-04 12:40:14 +0100295
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 Nonaka7309b122015-08-17 18:34:13 -0700302
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 Yukawa833bdce2016-05-15 20:05:56 -0700316 * 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 Yukawa69e68022017-02-13 12:04:50 -0800323 * 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 Yukawad6475a62017-04-17 10:35:27 -0700336 * @param dismissImeOnBackKeyPressed {@code true} if the software keyboard is shown and the back
337 * key is expected to dismiss the software keyboard.
Yohei Yukawa69e68022017-02-13 12:04:50 -0800338 * @param targetWindowToken token to identify the target window that the IME is associated with.
Yohei Yukawaee2a7ed2017-02-15 21:38:57 -0800339 * {@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 Yukawa69e68022017-02-13 12:04:50 -0800342 */
Yohei Yukawaee2a7ed2017-02-15 21:38:57 -0800343 public abstract void updateInputMethodWindowStatus(@NonNull IBinder imeToken,
Yohei Yukawad6475a62017-04-17 10:35:27 -0700344 boolean imeWindowVisible, boolean dismissImeOnBackKeyPressed,
345 @Nullable IBinder targetWindowToken);
Yohei Yukawa69e68022017-02-13 12:04:50 -0800346
347 /**
Seigo Nonaka7309b122015-08-17 18:34:13 -0700348 * 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 Ogunwale6e94a9e2015-10-07 15:35:49 -0700359
Wale Ogunwale44f036f2017-09-29 05:09:09 -0700360 /** Returns true if a stack in the windowing mode is currently visible. */
361 public abstract boolean isStackVisible(int windowingMode);
Jorim Jaggi9511b0f2016-01-29 19:12:44 -0800362
363 /**
364 * @return True if and only if the docked divider is currently in resize mode.
365 */
366 public abstract boolean isDockedDividerResizing();
Svetoslav Ganovfd138892016-07-13 18:20:42 -0700367
368 /**
369 * Requests the window manager to recompute the windows for accessibility.
370 */
371 public abstract void computeWindowsForAccessibility();
Tarandeep Singhe1cfcf42017-07-10 18:50:00 -0700372
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 Hirono3c6c95e2017-09-13 12:23:57 +0900379
380 /**
381 * Sets callback to DragDropController.
382 */
383 public abstract void registerDragDropControllerCallback(IDragDropCallback callback);
Eugene Suslaf9a651d2017-10-11 12:06:27 -0700384
385 /**
386 * @see android.view.IWindowManager#lockNow
387 */
388 public abstract void lockNow();
Svetoslav8e3feb12014-02-24 13:46:47 -0800389}