• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
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;
26 
27 import java.util.List;
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 {
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          */
onWindowsForAccessibilityChanged(List<WindowInfo> windows)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         /**
57          * Called when the region where magnification operates changes. Note that this isn't the
58          * entire screen. For example, IMEs are not magnified.
59          *
60          * @param magnificationRegion the current magnification region
61          */
onMagnificationRegionChanged(Region magnificationRegion)62         public void onMagnificationRegionChanged(Region magnificationRegion);
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          */
onRectangleOnScreenRequested(int left, int top, int right, int bottom)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          */
onRotationChanged(int rotation)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          */
onUserContextChanged()86         public void onUserContextChanged();
87     }
88 
89     /**
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          */
onAppTransitionPendingLocked()98         public void onAppTransitionPendingLocked() {}
99 
100         /**
101          * Called when a pending app transition gets cancelled.
102          *
103          * @param transit transition type indicating what kind of transition got cancelled
104          */
onAppTransitionCancelledLocked(int transit)105         public void onAppTransitionCancelledLocked(int transit) {}
106 
107         /**
108          * Called when an app transition gets started
109          *
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
116          *
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}.
121          */
onAppTransitionStartingLocked(int transit, IBinder openToken, IBinder closeToken, Animation openAnimation, Animation closeAnimation)122         public int onAppTransitionStartingLocked(int transit, IBinder openToken, IBinder closeToken,
123                 Animation openAnimation, Animation closeAnimation) {
124             return 0;
125         }
126 
127         /**
128          * Called when an app transition is finished running.
129          *
130          * @param token the token for app whose transition has finished
131          */
onAppTransitionFinishedLocked(IBinder token)132         public void onAppTransitionFinishedLocked(IBinder token) {}
133     }
134 
135     /**
136       * An interface to be notified about hardware keyboard status.
137       */
138     public interface OnHardKeyboardStatusChangeListener {
onHardKeyboardStatusChange(boolean available)139         public void onHardKeyboardStatusChange(boolean available);
140     }
141 
142     /**
143      * Request that the window manager call
144      * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager}
145      * within a surface transaction at a later time.
146      */
requestTraversalFromDisplayManager()147     public abstract void requestTraversalFromDisplayManager();
148 
149     /**
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
154      * as a controller.
155      *
156      * @param callbacks The callbacks to invoke.
157      */
setMagnificationCallbacks(@ullable MagnificationCallbacks callbacks)158     public abstract void setMagnificationCallbacks(@Nullable MagnificationCallbacks callbacks);
159 
160     /**
161      * Set by the accessibility layer to specify the magnification and panning to
162      * be applied to all windows that should be magnified.
163      *
164      * @param spec The MagnficationSpec to set.
165      *
166      * @see #setMagnificationCallbacks(MagnificationCallbacks)
167      */
setMagnificationSpec(MagnificationSpec spec)168     public abstract void setMagnificationSpec(MagnificationSpec spec);
169 
170     /**
171      * Set by the accessibility framework to indicate whether the magnifiable regions of the display
172      * should be shown.
173      *
174      * @param show {@code true} to show magnifiable region bounds, {@code false} to hide
175      */
setForceShowMagnifiableBounds(boolean show)176     public abstract void setForceShowMagnifiableBounds(boolean show);
177 
178     /**
179      * Obtains the magnification regions.
180      *
181      * @param magnificationRegion the current magnification region
182      */
getMagnificationRegion(@onNull Region magnificationRegion)183     public abstract void getMagnificationRegion(@NonNull Region magnificationRegion);
184 
185     /**
186      * Gets the magnification and translation applied to a window given its token.
187      * Not all windows are magnified and the window manager policy determines which
188      * windows are magnified. The returned result also takes into account the compat
189      * scale if necessary.
190      *
191      * @param windowToken The window's token.
192      *
193      * @return The magnification spec for the window.
194      *
195      * @see #setMagnificationCallbacks(MagnificationCallbacks)
196      */
getCompatibleMagnificationSpecForWindow( IBinder windowToken)197     public abstract MagnificationSpec getCompatibleMagnificationSpecForWindow(
198             IBinder windowToken);
199 
200     /**
201      * Sets a callback for observing which windows are touchable for the purposes
202      * of accessibility.
203      *
204      * @param callback The callback.
205      */
setWindowsForAccessibilityCallback( WindowsForAccessibilityCallback callback)206     public abstract void setWindowsForAccessibilityCallback(
207             WindowsForAccessibilityCallback callback);
208 
209     /**
210      * Sets a filter for manipulating the input event stream.
211      *
212      * @param filter The filter implementation.
213      */
setInputFilter(IInputFilter filter)214     public abstract void setInputFilter(IInputFilter filter);
215 
216     /**
217      * Gets the token of the window that has input focus.
218      *
219      * @return The token.
220      */
getFocusedWindowToken()221     public abstract IBinder getFocusedWindowToken();
222 
223     /**
224      * @return Whether the keyguard is engaged.
225      */
isKeyguardLocked()226     public abstract boolean isKeyguardLocked();
227 
228     /**
229     * @return Whether the keyguard is showing and not occluded.
230     */
isKeyguardShowingAndNotOccluded()231     public abstract boolean isKeyguardShowingAndNotOccluded();
232 
233     /**
234      * Gets the frame of a window given its token.
235      *
236      * @param token The token.
237      * @param outBounds The frame to populate.
238      */
getWindowFrame(IBinder token, Rect outBounds)239     public abstract void getWindowFrame(IBinder token, Rect outBounds);
240 
241     /**
242      * Opens the global actions dialog.
243      */
showGlobalActions()244     public abstract void showGlobalActions();
245 
246     /**
247      * Invalidate all visible windows. Then report back on the callback once all windows have
248      * redrawn.
249      */
waitForAllWindowsDrawn(Runnable callback, long timeout)250     public abstract void waitForAllWindowsDrawn(Runnable callback, long timeout);
251 
252     /**
253      * Adds a window token for a given window type.
254      *
255      * @param token The token to add.
256      * @param type The window type.
257      * @param displayId The display to add the token to.
258      */
addWindowToken(android.os.IBinder token, int type, int displayId)259     public abstract void addWindowToken(android.os.IBinder token, int type, int displayId);
260 
261     /**
262      * Removes a window token.
263      *
264      * @param token The toke to remove.
265      * @param removeWindows Whether to also remove the windows associated with the token.
266      * @param displayId The display to remove the token from.
267      */
removeWindowToken(android.os.IBinder token, boolean removeWindows, int displayId)268     public abstract void removeWindowToken(android.os.IBinder token, boolean removeWindows,
269             int displayId);
270 
271     /**
272      * Registers a listener to be notified about app transition events.
273      *
274      * @param listener The listener to register.
275      */
registerAppTransitionListener(AppTransitionListener listener)276     public abstract void registerAppTransitionListener(AppTransitionListener listener);
277 
278     /**
279      * Retrieves a height of input method window.
280      */
getInputMethodWindowVisibleHeight()281     public abstract int getInputMethodWindowVisibleHeight();
282 
283     /**
284       * Saves last input method window for transition.
285       *
286       * Note that it is assumed that this method is called only by InputMethodManagerService.
287       */
saveLastInputMethodWindowForTransition()288     public abstract void saveLastInputMethodWindowForTransition();
289 
290     /**
291      * Clears last input method window for transition.
292      *
293      * Note that it is assumed that this method is called only by InputMethodManagerService.
294      */
clearLastInputMethodWindowForTransition()295     public abstract void clearLastInputMethodWindowForTransition();
296 
297     /**
298      * Notifies WindowManagerService that the current IME window status is being changed.
299      *
300      * <p>Only {@link com.android.server.InputMethodManagerService} is the expected and tested
301      * caller of this method.</p>
302      *
303      * @param imeToken token to track the active input method. Corresponding IME windows can be
304      *                 identified by checking {@link android.view.WindowManager.LayoutParams#token}.
305      *                 Note that there is no guarantee that the corresponding window is already
306      *                 created
307      * @param imeWindowVisible whether the active IME thinks that its window should be visible or
308      *                         hidden, no matter how WindowManagerService will react / has reacted
309      *                         to corresponding API calls.  Note that this state is not guaranteed
310      *                         to be synchronized with state in WindowManagerService.
311      * @param dismissImeOnBackKeyPressed {@code true} if the software keyboard is shown and the back
312      *                                   key is expected to dismiss the software keyboard.
313      * @param targetWindowToken token to identify the target window that the IME is associated with.
314      *                          {@code null} when application, system, or the IME itself decided to
315      *                          change its window visibility before being associated with any target
316      *                          window.
317      */
updateInputMethodWindowStatus(@onNull IBinder imeToken, boolean imeWindowVisible, boolean dismissImeOnBackKeyPressed, @Nullable IBinder targetWindowToken)318     public abstract void updateInputMethodWindowStatus(@NonNull IBinder imeToken,
319             boolean imeWindowVisible, boolean dismissImeOnBackKeyPressed,
320             @Nullable IBinder targetWindowToken);
321 
322     /**
323       * Returns true when the hardware keyboard is available.
324       */
isHardKeyboardAvailable()325     public abstract boolean isHardKeyboardAvailable();
326 
327     /**
328       * Sets the callback listener for hardware keyboard status changes.
329       *
330       * @param listener The listener to set.
331       */
setOnHardKeyboardStatusChangeListener( OnHardKeyboardStatusChangeListener listener)332     public abstract void setOnHardKeyboardStatusChangeListener(
333         OnHardKeyboardStatusChangeListener listener);
334 
335     /** Returns true if the stack with the input Id is currently visible. */
isStackVisible(int stackId)336     public abstract boolean isStackVisible(int stackId);
337 
338     /**
339      * @return True if and only if the docked divider is currently in resize mode.
340      */
isDockedDividerResizing()341     public abstract boolean isDockedDividerResizing();
342 
343     /**
344      * Requests the window manager to recompute the windows for accessibility.
345      */
computeWindowsForAccessibility()346     public abstract void computeWindowsForAccessibility();
347 
348     /**
349      * Called after virtual display Id is updated by
350      * {@link com.android.server.vr.Vr2dDisplay} with a specific
351      * {@param vr2dDisplayId}.
352      */
setVr2dDisplayId(int vr2dDisplayId)353     public abstract void setVr2dDisplayId(int vr2dDisplayId);
354 }
355