1 /* //device/java/android/android/view/IWindowSession.aidl
2 **
3 ** Copyright 2006, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 **     http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17 
18 package android.view;
19 
20 import android.content.ClipData;
21 import android.graphics.Point;
22 import android.graphics.Rect;
23 import android.graphics.Region;
24 import android.os.Bundle;
25 import android.os.RemoteCallback;
26 import android.util.MergedConfiguration;
27 import android.view.DisplayCutout;
28 import android.view.InputChannel;
29 import android.view.IWindow;
30 import android.view.IWindowId;
31 import android.view.MotionEvent;
32 import android.view.WindowManager;
33 import android.view.InsetsSourceControl;
34 import android.view.InsetsState;
35 import android.view.InsetsVisibilities;
36 import android.view.Surface;
37 import android.view.SurfaceControl;
38 import android.view.SurfaceControl.Transaction;
39 import android.window.ClientWindowFrames;
40 
41 import java.util.List;
42 
43 /**
44  * System private per-application interface to the window manager.
45  *
46  * {@hide}
47  */
48 interface IWindowSession {
addToDisplay(IWindow window, in WindowManager.LayoutParams attrs, in int viewVisibility, in int layerStackId, in InsetsVisibilities requestedVisibilities, out InputChannel outInputChannel, out InsetsState insetsState, out InsetsSourceControl[] activeControls)49     int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
50             in int viewVisibility, in int layerStackId, in InsetsVisibilities requestedVisibilities,
51             out InputChannel outInputChannel, out InsetsState insetsState,
52             out InsetsSourceControl[] activeControls);
addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs, in int viewVisibility, in int layerStackId, in int userId, in InsetsVisibilities requestedVisibilities, out InputChannel outInputChannel, out InsetsState insetsState, out InsetsSourceControl[] activeControls)53     int addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs,
54             in int viewVisibility, in int layerStackId, in int userId,
55             in InsetsVisibilities requestedVisibilities, out InputChannel outInputChannel,
56             out InsetsState insetsState, out InsetsSourceControl[] activeControls);
addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs, in int viewVisibility, in int layerStackId, out InsetsState insetsState)57     int addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
58             in int viewVisibility, in int layerStackId, out InsetsState insetsState);
59     @UnsupportedAppUsage
remove(IWindow window)60     void remove(IWindow window);
61 
62     /**
63      * Change the parameters of a window.  You supply the
64      * new parameters, it returns the new frame of the window on screen (the
65      * position should be ignored) and surface of the window.  The surface
66      * will be invalid if the window is currently hidden, else you can use it
67      * to draw the window's contents.
68      *
69      * @param window The window being modified.
70      * @param attrs If non-null, new attributes to apply to the window.
71      * @param requestedWidth The width the window wants to be.
72      * @param requestedHeight The height the window wants to be.
73      * @param viewVisibility Window root view's visibility.
74      * @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING},
75      * {@link WindowManagerGlobal#RELAYOUT_DEFER_SURFACE_DESTROY}.
76      * @param frameNumber A frame number in which changes requested in this layout will be rendered.
77      * @param outFrame Rect in which is placed the new position/size on
78      * screen.
79      * @param outContentInsets Rect in which is placed the offsets from
80      * <var>outFrame</var> in which the content of the window should be
81      * placed.  This can be used to modify the window layout to ensure its
82      * contents are visible to the user, taking into account system windows
83      * like the status bar or a soft keyboard.
84      * @param outVisibleInsets Rect in which is placed the offsets from
85      * <var>outFrame</var> in which the window is actually completely visible
86      * to the user.  This can be used to temporarily scroll the window's
87      * contents to make sure the user can see it.  This is different than
88      * <var>outContentInsets</var> in that these insets change transiently,
89      * so complex relayout of the window should not happen based on them.
90      * @param outOutsets Rect in which is placed the dead area of the screen that we would like to
91      * treat as real display. Example of such area is a chin in some models of wearable devices.
92      * @param outBackdropFrame Rect which is used draw the resizing background during a resize
93      * operation.
94      * @param outMergedConfiguration New config container that holds global, override and merged
95      * config for window, if it is now becoming visible and the merged configuration has changed
96      * since it was last displayed.
97      * @param outSurface Object in which is placed the new display surface.
98      * @param insetsState The current insets state in the system.
99      * @param outSurfaceSize The width and height of the surface control
100      *
101      * @return int Result flags: {@link WindowManagerGlobal#RELAYOUT_SHOW_FOCUS},
102      * {@link WindowManagerGlobal#RELAYOUT_FIRST_TIME}.
103      */
relayout(IWindow window, in WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, int flags, long frameNumber, out ClientWindowFrames outFrames, out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl, out InsetsState insetsState, out InsetsSourceControl[] activeControls, out Point outSurfaceSize)104     int relayout(IWindow window, in WindowManager.LayoutParams attrs,
105             int requestedWidth, int requestedHeight, int viewVisibility,
106             int flags, long frameNumber, out ClientWindowFrames outFrames,
107             out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
108             out InsetsState insetsState, out InsetsSourceControl[] activeControls,
109             out Point outSurfaceSize);
110 
111     /*
112      * Notify the window manager that an application is relaunching and
113      * windows should be prepared for replacement.
114      *
115      * @param appToken The application
116      * @param childrenOnly Whether to only prepare child windows for replacement
117      * (for example when main windows are being reused via preservation).
118      */
prepareToReplaceWindows(IBinder appToken, boolean childrenOnly)119     oneway void prepareToReplaceWindows(IBinder appToken, boolean childrenOnly);
120 
121     /**
122      * Called by a client to report that it ran out of graphics memory.
123      */
outOfMemory(IWindow window)124     boolean outOfMemory(IWindow window);
125 
126     /**
127      * Tell the window manager about the content and visible insets of the
128      * given window, which can be used to adjust the <var>outContentInsets</var>
129      * and <var>outVisibleInsets</var> values returned by
130      * {@link #relayout relayout()} for windows behind this one.
131      *
132      * @param touchableInsets Controls which part of the window inside of its
133      * frame can receive pointer events, as defined by
134      * {@link android.view.ViewTreeObserver.InternalInsetsInfo}.
135      */
setInsets(IWindow window, int touchableInsets, in Rect contentInsets, in Rect visibleInsets, in Region touchableRegion)136     oneway void setInsets(IWindow window, int touchableInsets, in Rect contentInsets,
137             in Rect visibleInsets, in Region touchableRegion);
138 
139     /**
140      * Called when the client has finished drawing the surface, if needed.
141      *
142      * @param postDrawTransaction transaction filled by the client that can be
143      * used to synchronize any post draw transactions with the server. Transaction
144      * is null if there is no sync required.
145      */
146     @UnsupportedAppUsage
finishDrawing(IWindow window, in SurfaceControl.Transaction postDrawTransaction)147     oneway void finishDrawing(IWindow window, in SurfaceControl.Transaction postDrawTransaction);
148 
149     @UnsupportedAppUsage
setInTouchMode(boolean showFocus)150     oneway void setInTouchMode(boolean showFocus);
151     @UnsupportedAppUsage
getInTouchMode()152     boolean getInTouchMode();
153 
154     @UnsupportedAppUsage
performHapticFeedback(int effectId, boolean always)155     boolean performHapticFeedback(int effectId, boolean always);
156 
157     /**
158      * Initiate the drag operation itself
159      *
160      * @param window Window which initiates drag operation.
161      * @param flags See {@code View#startDragAndDrop}
162      * @param surface Surface containing drag shadow image
163      * @param touchSource See {@code InputDevice#getSource()}
164      * @param touchX X coordinate of last touch point
165      * @param touchY Y coordinate of last touch point
166      * @param thumbCenterX X coordinate for the position within the shadow image that should be
167      *         underneath the touch point during the drag and drop operation.
168      * @param thumbCenterY Y coordinate for the position within the shadow image that should be
169      *         underneath the touch point during the drag and drop operation.
170      * @param data Data transferred by drag and drop
171      * @return Token of drag operation which will be passed to cancelDragAndDrop.
172      */
173     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
performDrag(IWindow window, int flags, in SurfaceControl surface, int touchSource, float touchX, float touchY, float thumbCenterX, float thumbCenterY, in ClipData data)174     IBinder performDrag(IWindow window, int flags, in SurfaceControl surface, int touchSource,
175             float touchX, float touchY, float thumbCenterX, float thumbCenterY, in ClipData data);
176 
177     /**
178      * Drops the content of the current drag operation for accessibility
179      */
dropForAccessibility(IWindow window, int x, int y)180     boolean dropForAccessibility(IWindow window, int x, int y);
181 
182     /**
183      * Report the result of a drop action targeted to the given window.
184      * consumed is 'true' when the drop was accepted by a valid recipient,
185      * 'false' otherwise.
186      */
reportDropResult(IWindow window, boolean consumed)187     oneway void reportDropResult(IWindow window, boolean consumed);
188 
189     /**
190      * Cancel the current drag operation.
191      * skipAnimation is 'true' when it should skip the drag cancel animation which brings the drag
192      * shadow image back to the drag start position.
193      */
cancelDragAndDrop(IBinder dragToken, boolean skipAnimation)194     oneway void cancelDragAndDrop(IBinder dragToken, boolean skipAnimation);
195 
196     /**
197      * Tell the OS that we've just dragged into a View that is willing to accept the drop
198      */
dragRecipientEntered(IWindow window)199     oneway void dragRecipientEntered(IWindow window);
200 
201     /**
202      * Tell the OS that we've just dragged *off* of a View that was willing to accept the drop
203      */
dragRecipientExited(IWindow window)204     oneway void dragRecipientExited(IWindow window);
205 
206     /**
207      * For windows with the wallpaper behind them, and the wallpaper is
208      * larger than the screen, set the offset within the screen.
209      * For multi screen launcher type applications, xstep and ystep indicate
210      * how big the increment is from one screen to another.
211      */
setWallpaperPosition(IBinder windowToken, float x, float y, float xstep, float ystep)212     oneway void setWallpaperPosition(IBinder windowToken, float x, float y, float xstep, float ystep);
213 
214     /**
215      * For wallpaper windows, sets the scale of the wallpaper based on
216      * SystemUI behavior.
217      */
setWallpaperZoomOut(IBinder windowToken, float scale)218     oneway void setWallpaperZoomOut(IBinder windowToken, float scale);
219 
220     /**
221      * For wallpaper windows, sets whether the wallpaper should actually be
222      * scaled when setWallpaperZoomOut is called. If set to false, the WallpaperService will
223      * receive the zoom out value but the surface won't be scaled.
224      */
setShouldZoomOutWallpaper(IBinder windowToken, boolean shouldZoom)225     oneway void setShouldZoomOutWallpaper(IBinder windowToken, boolean shouldZoom);
226 
227     @UnsupportedAppUsage
wallpaperOffsetsComplete(IBinder window)228     oneway void wallpaperOffsetsComplete(IBinder window);
229 
230     /**
231      * Apply a raw offset to the wallpaper service when shown behind this window.
232      */
setWallpaperDisplayOffset(IBinder windowToken, int x, int y)233     oneway void setWallpaperDisplayOffset(IBinder windowToken, int x, int y);
234 
sendWallpaperCommand(IBinder window, String action, int x, int y, int z, in Bundle extras, boolean sync)235     Bundle sendWallpaperCommand(IBinder window, String action, int x, int y,
236             int z, in Bundle extras, boolean sync);
237 
238     @UnsupportedAppUsage
wallpaperCommandComplete(IBinder window, in Bundle result)239     oneway void wallpaperCommandComplete(IBinder window, in Bundle result);
240 
241     /**
242      * Notifies that a rectangle on the screen has been requested.
243      */
onRectangleOnScreenRequested(IBinder token, in Rect rectangle)244     oneway void onRectangleOnScreenRequested(IBinder token, in Rect rectangle);
245 
getWindowId(IBinder window)246     IWindowId getWindowId(IBinder window);
247 
248     /**
249      * When the system is dozing in a low-power partially suspended state, pokes a short
250      * lived wake lock and ensures that the display is ready to accept the next frame
251      * of content drawn in the window.
252      *
253      * This mechanism is bound to the window rather than to the display manager or the
254      * power manager so that the system can ensure that the window is actually visible
255      * and prevent runaway applications from draining the battery.  This is similar to how
256      * FLAG_KEEP_SCREEN_ON works.
257      *
258      * This method is synchronous because it may need to acquire a wake lock before returning.
259      * The assumption is that this method will be called rather infrequently.
260      */
pokeDrawLock(IBinder window)261     void pokeDrawLock(IBinder window);
262 
263     /**
264      * Starts a task window move with {startX, startY} as starting point. The amount of move
265      * will be the offset between {startX, startY} and the new cursor position.
266      *
267      * Returns true if the move started successfully; false otherwise.
268      */
startMovingTask(IWindow window, float startX, float startY)269     boolean startMovingTask(IWindow window, float startX, float startY);
270 
finishMovingTask(IWindow window)271     oneway void finishMovingTask(IWindow window);
272 
updatePointerIcon(IWindow window)273     oneway void updatePointerIcon(IWindow window);
274 
275     /**
276      * Update the location of a child display in its parent window. This enables windows in the
277      * child display to compute the global transformation matrix.
278      *
279      * @param window The parent window of the display.
280      * @param x The x coordinate in the parent window.
281      * @param y The y coordinate in the parent window.
282      * @param displayId The id of the display to be notified.
283      */
updateDisplayContentLocation(IWindow window, int x, int y, int displayId)284     oneway void updateDisplayContentLocation(IWindow window, int x, int y, int displayId);
285 
286     /**
287      * Update a tap exclude region identified by provided id in the window. Touches on this region
288      * will neither be dispatched to this window nor change the focus to this window. Passing an
289      * invalid region will remove the area from the exclude region of this window.
290      */
updateTapExcludeRegion(IWindow window, in Region region)291     oneway void updateTapExcludeRegion(IWindow window, in Region region);
292 
293     /**
294      * Updates the requested visibilities of insets.
295      */
updateRequestedVisibilities(IWindow window, in InsetsVisibilities visibilities)296     oneway void updateRequestedVisibilities(IWindow window, in InsetsVisibilities visibilities);
297 
298     /**
299      * Called when the system gesture exclusion has changed.
300      */
reportSystemGestureExclusionChanged(IWindow window, in List<Rect> exclusionRects)301     oneway void reportSystemGestureExclusionChanged(IWindow window, in List<Rect> exclusionRects);
302 
303     /**
304     * Request the server to call setInputWindowInfo on a given Surface, and return
305     * an input channel where the client can receive input.
306     */
grantInputChannel(int displayId, in SurfaceControl surface, in IWindow window, in IBinder hostInputToken, int flags, int privateFlags, int type, out InputChannel outInputChannel)307     void grantInputChannel(int displayId, in SurfaceControl surface, in IWindow window,
308             in IBinder hostInputToken, int flags, int privateFlags, int type,
309             out InputChannel outInputChannel);
310 
311     /**
312      * Update the flags on an input channel associated with a particular surface.
313      */
updateInputChannel(in IBinder channelToken, int displayId, in SurfaceControl surface, int flags, int privateFlags, in Region region)314     oneway void updateInputChannel(in IBinder channelToken, int displayId,
315             in SurfaceControl surface, int flags, int privateFlags, in Region region);
316 
317     /**
318      * Transfer window focus to an embedded window if the calling window has focus.
319      *
320      * @param window - calling window owned by the caller. Window can be null if there
321      *                 is no host window but the caller must have permissions to create an embedded
322      *                 window without a host window.
323      * @param inputToken - token identifying the embedded window that should gain focus.
324      * @param grantFocus - true if focus should be granted to the embedded window, false if focus
325      *                     should be transferred back to the host window. If there is no host
326      *                     window, the system will try to find a new focus target.
327      */
grantEmbeddedWindowFocus(IWindow window, in IBinder inputToken, boolean grantFocus)328     void grantEmbeddedWindowFocus(IWindow window, in IBinder inputToken, boolean grantFocus);
329 
330     /**
331      * Generates an DisplayHash that can be used to validate whether specific content was on
332      * screen.
333      *
334      * @param window The token for the window to generate the hash of.
335      * @param boundsInWindow The size and position in the window of where to generate the hash.
336      * @param hashAlgorithm The String for the hash algorithm to use based on values returned
337      *                      from {@link IWindowManager#getSupportedDisplayHashAlgorithms()}
338      * @param callback The callback invoked to get the results of generateDisplayHash
339      */
generateDisplayHash(IWindow window, in Rect boundsInWindow, in String hashAlgorithm, in RemoteCallback callback)340     oneway void generateDisplayHash(IWindow window, in Rect boundsInWindow,
341             in String hashAlgorithm, in RemoteCallback callback);
342 }
343