2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.graphics.Rect;
22 import android.graphics.Region;
23 import android.hardware.display.DisplayManagerInternal;
24 import android.os.IBinder;
25 import android.view.animation.Animation;
27 import java.util.List;
30 * Window manager local system service interface.
32 * @hide Only for use within the system server.
34 public abstract class WindowManagerInternal {
37 * Interface to receive a callback when the windows reported for
38 * accessibility changed.
40 public interface WindowsForAccessibilityCallback {
43 * Called when the windows for accessibility changed.
45 * @param windows The windows for accessibility.
47 public void onWindowsForAccessibilityChanged(List<WindowInfo> windows);
51 * Callbacks for contextual changes that affect the screen magnification
54 public interface MagnificationCallbacks {
57 * Called when the region where magnification operates changes. Note that this isn't the
58 * entire screen. For example, IMEs are not magnified.
60 * @param magnificationRegion the current magnification region
62 public void onMagnificationRegionChanged(Region magnificationRegion);
65 * Called when an application requests a rectangle on the screen to allow
66 * the client to apply the appropriate pan and scale.
68 * @param left The rectangle left.
69 * @param top The rectangle top.
70 * @param right The rectangle right.
71 * @param bottom The rectangle bottom.
73 public void onRectangleOnScreenRequested(int left, int top, int right, int bottom);
76 * Notifies that the rotation changed.
78 * @param rotation The current rotation.
80 public void onRotationChanged(int rotation);
83 * Notifies that the context of the user changed. For example, an application
86 public void onUserContextChanged();
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.
93 public static abstract class AppTransitionListener {
96 * Called when an app transition is being setup and about to be executed.
98 public void onAppTransitionPendingLocked() {}
101 * Called when a pending app transition gets cancelled.
103 * @param transit transition type indicating what kind of transition got cancelled
105 public void onAppTransitionCancelledLocked(int transit) {}
108 * Called when an app transition gets started
110 * @param transit transition type indicating what kind of transition gets run, must be one
111 * of AppTransition.TRANSIT_* values
112 * @param openToken the token for the opening app
113 * @param closeToken the token for the closing app
114 * @param openAnimation the animation for the opening app
115 * @param closeAnimation the animation for the closing app
117 * @return Return any bit set of {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_LAYOUT},
118 * {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_CONFIG},
119 * {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_WALLPAPER},
120 * or {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_ANIM}.
122 public int onAppTransitionStartingLocked(int transit, IBinder openToken, IBinder closeToken,
123 Animation openAnimation, Animation closeAnimation) {
128 * Called when an app transition is finished running.
130 * @param token the token for app whose transition has finished
132 public void onAppTransitionFinishedLocked(IBinder token) {}
136 * An interface to be notified about hardware keyboard status.
138 public interface OnHardKeyboardStatusChangeListener {
139 public void onHardKeyboardStatusChange(boolean available);
143 * Request that the window manager call
144 * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager}
145 * within a surface transaction at a later time.
147 public abstract void requestTraversalFromDisplayManager();
150 * Set by the accessibility layer to observe changes in the magnified region,
151 * rotation, and other window transformations related to display magnification
152 * as the window manager is responsible for doing the actual magnification
153 * and has access to the raw window data while the accessibility layer serves
156 * @param callbacks The callbacks to invoke.
158 public abstract void setMagnificationCallbacks(@Nullable MagnificationCallbacks callbacks);
161 * Set by the accessibility layer to specify the magnification and panning to
162 * be applied to all windows that should be magnified.
164 * @param spec The MagnficationSpec to set.
166 * @see #setMagnificationCallbacks(MagnificationCallbacks)
168 public abstract void setMagnificationSpec(MagnificationSpec spec);
171 * Obtains the magnification regions.
173 * @param magnificationRegion the current magnification region
175 public abstract void getMagnificationRegion(@NonNull Region magnificationRegion);
178 * Gets the magnification and translation applied to a window given its token.
179 * Not all windows are magnified and the window manager policy determines which
180 * windows are magnified. The returned result also takes into account the compat
181 * scale if necessary.
183 * @param windowToken The window's token.
185 * @return The magnification spec for the window.
187 * @see #setMagnificationCallbacks(MagnificationCallbacks)
189 public abstract MagnificationSpec getCompatibleMagnificationSpecForWindow(
190 IBinder windowToken);
193 * Sets a callback for observing which windows are touchable for the purposes
196 * @param callback The callback.
198 public abstract void setWindowsForAccessibilityCallback(
199 WindowsForAccessibilityCallback callback);
202 * Sets a filter for manipulating the input event stream.
204 * @param filter The filter implementation.
206 public abstract void setInputFilter(IInputFilter filter);
209 * Gets the token of the window that has input focus.
213 public abstract IBinder getFocusedWindowToken();
216 * @return Whether the keyguard is engaged.
218 public abstract boolean isKeyguardLocked();
221 * Gets the frame of a window given its token.
223 * @param token The token.
224 * @param outBounds The frame to populate.
226 public abstract void getWindowFrame(IBinder token, Rect outBounds);
229 * Opens the global actions dialog.
231 public abstract void showGlobalActions();
234 * Invalidate all visible windows. Then report back on the callback once all windows have
237 public abstract void waitForAllWindowsDrawn(Runnable callback, long timeout);
240 * Adds a window token for a given window type.
242 * @param token The token to add.
243 * @param type The window type.
244 * @param displayId The display to add the token to.
246 public abstract void addWindowToken(android.os.IBinder token, int type, int displayId);
249 * Removes a window token.
251 * @param token The toke to remove.
252 * @param removeWindows Whether to also remove the windows associated with the token.
253 * @param displayId The display to remove the token from.
255 public abstract void removeWindowToken(android.os.IBinder token, boolean removeWindows,
259 * Registers a listener to be notified about app transition events.
261 * @param listener The listener to register.
263 public abstract void registerAppTransitionListener(AppTransitionListener listener);
266 * Retrieves a height of input method window.
268 public abstract int getInputMethodWindowVisibleHeight();
271 * Saves last input method window for transition.
273 * Note that it is assumed that this method is called only by InputMethodManagerService.
275 public abstract void saveLastInputMethodWindowForTransition();
278 * Clears last input method window for transition.
280 * Note that it is assumed that this method is called only by InputMethodManagerService.
282 public abstract void clearLastInputMethodWindowForTransition();
285 * Notifies WindowManagerService that the current IME window status is being changed.
287 * <p>Only {@link com.android.server.InputMethodManagerService} is the expected and tested
288 * caller of this method.</p>
290 * @param imeToken token to track the active input method. Corresponding IME windows can be
291 * identified by checking {@link android.view.WindowManager.LayoutParams#token}.
292 * Note that there is no guarantee that the corresponding window is already
294 * @param imeWindowVisible whether the active IME thinks that its window should be visible or
295 * hidden, no matter how WindowManagerService will react / has reacted
296 * to corresponding API calls. Note that this state is not guaranteed
297 * to be synchronized with state in WindowManagerService.
298 * @param targetWindowToken token to identify the target window that the IME is associated with.
300 public abstract void updateInputMethodWindowStatus(IBinder imeToken, boolean imeWindowVisible,
301 IBinder targetWindowToken);
304 * Returns true when the hardware keyboard is available.
306 public abstract boolean isHardKeyboardAvailable();
309 * Sets the callback listener for hardware keyboard status changes.
311 * @param listener The listener to set.
313 public abstract void setOnHardKeyboardStatusChangeListener(
314 OnHardKeyboardStatusChangeListener listener);
316 /** Returns true if the stack with the input Id is currently visible. */
317 public abstract boolean isStackVisible(int stackId);
320 * @return True if and only if the docked divider is currently in resize mode.
322 public abstract boolean isDockedDividerResizing();
325 * Requests the window manager to recompute the windows for accessibility.
327 public abstract void computeWindowsForAccessibility();