• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.Surface;
36 import android.view.SurfaceControl;
37 import android.view.SurfaceControl.Transaction;
38 import android.view.WindowRelayoutResult;
39 import android.window.ClientWindowFrames;
40 import android.window.InputTransferToken;
41 import android.window.OnBackInvokedCallbackInfo;
42 
43 import java.util.List;
44 
45 /**
46  * System private per-application interface to the window manager.
47  *
48  * {@hide}
49  */
50 interface IWindowSession {
51 
52     /**
53      * Bundle key to store the latest sync seq id for the relayout configuration.
54      * @see #relayout
55      */
56     const String KEY_RELAYOUT_BUNDLE_SEQID = "seqid";
57     /**
58      * Bundle key to store the latest ActivityWindowInfo associated with the relayout configuration.
59      * Will only be set if the relayout window is an activity window.
60      * @see #relayout
61      */
62     const String KEY_RELAYOUT_BUNDLE_ACTIVITY_WINDOW_INFO = "activity_window_info";
63 
addToDisplay(IWindow window, in WindowManager.LayoutParams attrs, in int viewVisibility, in int layerStackId, int requestedVisibleTypes, out InputChannel outInputChannel, out InsetsState insetsState, out InsetsSourceControl.Array activeControls, out Rect attachedFrame, out float[] sizeCompatScale)64     int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
65             in int viewVisibility, in int layerStackId, int requestedVisibleTypes,
66             out InputChannel outInputChannel, out InsetsState insetsState,
67             out InsetsSourceControl.Array activeControls, out Rect attachedFrame,
68             out float[] sizeCompatScale);
addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs, in int viewVisibility, in int layerStackId, in int userId, int requestedVisibleTypes, out InputChannel outInputChannel, out InsetsState insetsState, out InsetsSourceControl.Array activeControls, out Rect attachedFrame, out float[] sizeCompatScale)69     int addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs,
70             in int viewVisibility, in int layerStackId, in int userId, int requestedVisibleTypes,
71             out InputChannel outInputChannel, out InsetsState insetsState,
72             out InsetsSourceControl.Array activeControls, out Rect attachedFrame,
73             out float[] sizeCompatScale);
addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs, in int viewVisibility, in int layerStackId, out InsetsState insetsState, out Rect attachedFrame, out float[] sizeCompatScale)74     int addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
75             in int viewVisibility, in int layerStackId, out InsetsState insetsState,
76             out Rect attachedFrame, out float[] sizeCompatScale);
77 
78     /**
79      * Removes a clientToken from WMS, which includes unlinking the input channel.
80      *
81      * @param clientToken The token that should be removed. This will normally be the IWindow token
82      * for a standard window. It can also be the generic clientToken that was used when calling
83      * grantInputChannel
84      */
remove(IBinder clientToken)85     void remove(IBinder clientToken);
86 
87     /**
88      * @deprecated
89      */
relayoutLegacy(IWindow window, in WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, int flags, int seq, int lastSyncSeqId, out ClientWindowFrames outFrames, out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl, out InsetsState insetsState, out InsetsSourceControl.Array activeControls, out Bundle bundle)90     int relayoutLegacy(IWindow window, in WindowManager.LayoutParams attrs,
91             int requestedWidth, int requestedHeight, int viewVisibility,
92             int flags, int seq, int lastSyncSeqId, out ClientWindowFrames outFrames,
93             out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
94             out InsetsState insetsState, out InsetsSourceControl.Array activeControls,
95             out Bundle bundle);
96 
97     /**
98      * Change the parameters of a window.  You supply the
99      * new parameters, it returns the new frame of the window on screen (the
100      * position should be ignored) and surface of the window.  The surface
101      * will be invalid if the window is currently hidden, else you can use it
102      * to draw the window's contents.
103      *
104      * @param window The window being modified.
105      * @param attrs If non-null, new attributes to apply to the window.
106      * @param requestedWidth The width the window wants to be.
107      * @param requestedHeight The height the window wants to be.
108      * @param viewVisibility Window root view's visibility.
109      * @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING}.
110      * @param seq The calling sequence of {@link #relayout} and {@link #relayoutAsync}.
111      * @param lastSyncSeqId The last SyncSeqId that the client applied.
112      * @param outRelayoutResult Data object contains the info to be returned from server side.
113      * @return int Result flags, defined in {@link WindowManagerGlobal}.
114      */
relayout(IWindow window, in WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, int flags, int seq, int lastSyncSeqId, out @nullable WindowRelayoutResult outRelayoutResult)115     int relayout(IWindow window, in WindowManager.LayoutParams attrs, int requestedWidth,
116             int requestedHeight, int viewVisibility, int flags, int seq, int lastSyncSeqId,
117             out @nullable WindowRelayoutResult outRelayoutResult);
118 
119     /**
120      * Similar to {@link #relayout} but this is an oneway method which doesn't return anything.
121      *
122      * @param window The window being modified.
123      * @param attrs If non-null, new attributes to apply to the window.
124      * @param requestedWidth The width the window wants to be.
125      * @param requestedHeight The height the window wants to be.
126      * @param viewVisibility Window root view's visibility.
127      * @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING}.
128      * @param seq The calling sequence of {@link #relayout} and {@link #relayoutAsync}.
129      * @param lastSyncSeqId The last SyncSeqId that the client applied.
130      */
relayoutAsync(IWindow window, in WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, int flags, int seq, int lastSyncSeqId)131     oneway void relayoutAsync(IWindow window, in WindowManager.LayoutParams attrs,
132             int requestedWidth, int requestedHeight, int viewVisibility, int flags, int seq,
133             int lastSyncSeqId);
134 
135     /**
136      * Called by a client to report that it ran out of graphics memory.
137      */
outOfMemory(IWindow window)138     boolean outOfMemory(IWindow window);
139 
140     /**
141      * Tell the window manager about the content and visible insets of the
142      * given window, which can be used to adjust the <var>outContentInsets</var>
143      * and <var>outVisibleInsets</var> values returned by
144      * {@link #relayout relayout()} for windows behind this one.
145      *
146      * @param touchableInsets Controls which part of the window inside of its
147      * frame can receive pointer events, as defined by
148      * {@link android.view.ViewTreeObserver.InternalInsetsInfo}.
149      */
setInsets(IWindow window, int touchableInsets, in Rect contentInsets, in Rect visibleInsets, in Region touchableRegion)150     oneway void setInsets(IWindow window, int touchableInsets, in Rect contentInsets,
151             in Rect visibleInsets, in Region touchableRegion);
152 
153     /**
154      * Called when the client has finished drawing the surface, if needed.
155      *
156      * @param postDrawTransaction transaction filled by the client that can be
157      * used to synchronize any post draw transactions with the server. Transaction
158      * is null if there is no sync required.
159      */
160     @UnsupportedAppUsage
finishDrawing(IWindow window, in SurfaceControl.Transaction postDrawTransaction, int seqId)161     oneway void finishDrawing(IWindow window, in SurfaceControl.Transaction postDrawTransaction,
162             int seqId);
163 
164     @UnsupportedAppUsage
performHapticFeedback(int effectId, boolean always, boolean fromIme)165     boolean performHapticFeedback(int effectId, boolean always, boolean fromIme);
166 
167     /**
168      * Called by attached views to perform predefined haptic feedback without requiring VIBRATE
169      * permission.
170      */
performHapticFeedbackAsync(int effectId, boolean always, boolean fromIme)171     oneway void performHapticFeedbackAsync(int effectId, boolean always, boolean fromIme);
172 
173     /**
174      * Initiate the drag operation itself
175      *
176      * @param window Window which initiates drag operation.
177      * @param flags See {@code View#startDragAndDrop}
178      * @param surface Surface containing drag shadow image
179      * @param touchSource See {@code InputDevice#getSource()}
180      * @param touchDeviceId device ID of last touch event
181      * @param pointerId pointer ID of last touch event
182      * @param touchX X coordinate of last touch point
183      * @param touchY Y coordinate of last touch point
184      * @param thumbCenterX X coordinate for the position within the shadow image that should be
185      *         underneath the touch point during the drag and drop operation.
186      * @param thumbCenterY Y coordinate for the position within the shadow image that should be
187      *         underneath the touch point during the drag and drop operation.
188      * @param data Data transferred by drag and drop
189      * @return Token of drag operation which will be passed to cancelDragAndDrop.
190      */
performDrag(IWindow window, int flags, in SurfaceControl surface, int touchSource, int touchDeviceId, int touchPointerId, float touchX, float touchY, float thumbCenterX, float thumbCenterY, in ClipData data)191     IBinder performDrag(IWindow window, int flags, in SurfaceControl surface, int touchSource,
192             int touchDeviceId, int touchPointerId, float touchX, float touchY, float thumbCenterX,
193             float thumbCenterY, in ClipData data);
194 
195     /**
196      * Drops the content of the current drag operation for accessibility
197      */
dropForAccessibility(IWindow window, int x, int y)198     boolean dropForAccessibility(IWindow window, int x, int y);
199 
200     /**
201      * Report the result of a drop action targeted to the given window.
202      * consumed is 'true' when the drop was accepted by a valid recipient,
203      * 'false' otherwise.
204      */
reportDropResult(IWindow window, boolean consumed)205     oneway void reportDropResult(IWindow window, boolean consumed);
206 
207     /**
208      * Cancel the current drag operation.
209      * skipAnimation is 'true' when it should skip the drag cancel animation which brings the drag
210      * shadow image back to the drag start position.
211      */
cancelDragAndDrop(IBinder dragToken, boolean skipAnimation)212     oneway void cancelDragAndDrop(IBinder dragToken, boolean skipAnimation);
213 
214     /**
215      * Tell the OS that we've just dragged into a View that is willing to accept the drop
216      */
dragRecipientEntered(IWindow window)217     oneway void dragRecipientEntered(IWindow window);
218 
219     /**
220      * Tell the OS that we've just dragged *off* of a View that was willing to accept the drop
221      */
dragRecipientExited(IWindow window)222     oneway void dragRecipientExited(IWindow window);
223 
224     /**
225      * For windows with the wallpaper behind them, and the wallpaper is
226      * larger than the screen, set the offset within the screen.
227      * For multi screen launcher type applications, xstep and ystep indicate
228      * how big the increment is from one screen to another.
229      */
setWallpaperPosition(IBinder windowToken, float x, float y, float xstep, float ystep)230     oneway void setWallpaperPosition(IBinder windowToken, float x, float y, float xstep, float ystep);
231 
232     /**
233      * For wallpaper windows, sets the scale of the wallpaper based on
234      * SystemUI behavior.
235      */
setWallpaperZoomOut(IBinder windowToken, float scale)236     oneway void setWallpaperZoomOut(IBinder windowToken, float scale);
237 
238     /**
239      * For wallpaper windows, sets whether the wallpaper should actually be
240      * scaled when setWallpaperZoomOut is called. If set to false, the WallpaperService will
241      * receive the zoom out value but the surface won't be scaled.
242      */
setShouldZoomOutWallpaper(IBinder windowToken, boolean shouldZoom)243     oneway void setShouldZoomOutWallpaper(IBinder windowToken, boolean shouldZoom);
244 
245     @UnsupportedAppUsage
wallpaperOffsetsComplete(IBinder window)246     oneway void wallpaperOffsetsComplete(IBinder window);
247 
248     /**
249      * Apply a raw offset to the wallpaper service when shown behind this window.
250      */
setWallpaperDisplayOffset(IBinder windowToken, int x, int y)251     oneway void setWallpaperDisplayOffset(IBinder windowToken, int x, int y);
252 
sendWallpaperCommand(IBinder window, String action, int x, int y, int z, in Bundle extras, boolean sync)253     oneway void sendWallpaperCommand(IBinder window, String action, int x, int y,
254             int z, in Bundle extras, boolean sync);
255 
256     @UnsupportedAppUsage
wallpaperCommandComplete(IBinder window, in Bundle result)257     oneway void wallpaperCommandComplete(IBinder window, in Bundle result);
258 
259     /**
260      * Notifies that a rectangle on the screen has been requested.
261      */
onRectangleOnScreenRequested(IBinder token, in Rect rectangle)262     oneway void onRectangleOnScreenRequested(IBinder token, in Rect rectangle);
263 
getWindowId(IBinder window)264     IWindowId getWindowId(IBinder window);
265 
266     /**
267      * When the system is dozing in a low-power partially suspended state, pokes a short
268      * lived wake lock and ensures that the display is ready to accept the next frame
269      * of content drawn in the window.
270      *
271      * This mechanism is bound to the window rather than to the display manager or the
272      * power manager so that the system can ensure that the window is actually visible
273      * and prevent runaway applications from draining the battery.  This is similar to how
274      * FLAG_KEEP_SCREEN_ON works.
275      *
276      * This method is synchronous because it may need to acquire a wake lock before returning.
277      * The assumption is that this method will be called rather infrequently.
278      */
pokeDrawLock(IBinder window)279     void pokeDrawLock(IBinder window);
280 
281     /**
282      * Starts a task window move with {startX, startY} as starting point. The amount of move
283      * will be the offset between {startX, startY} and the new cursor position.
284      *
285      * Returns true if the move started successfully; false otherwise.
286      */
startMovingTask(IWindow window, float startX, float startY)287     boolean startMovingTask(IWindow window, float startX, float startY);
288 
finishMovingTask(IWindow window)289     oneway void finishMovingTask(IWindow window);
290 
291     /**
292      * Update a tap exclude region identified by provided id in the window. Touches on this region
293      * will neither be dispatched to this window nor change the focus to this window. Passing an
294      * invalid region will remove the area from the exclude region of this window.
295      */
updateTapExcludeRegion(IWindow window, in Region region)296     oneway void updateTapExcludeRegion(IWindow window, in Region region);
297 
298     /**
299      * Updates the requested visible types of insets.
300      */
updateRequestedVisibleTypes(IWindow window, int requestedVisibleTypes)301     oneway void updateRequestedVisibleTypes(IWindow window, int requestedVisibleTypes);
302 
303     /**
304      * Called when the system gesture exclusion has changed.
305      */
reportSystemGestureExclusionChanged(IWindow window, in List<Rect> exclusionRects)306     oneway void reportSystemGestureExclusionChanged(IWindow window, in List<Rect> exclusionRects);
307 
308     /**
309      * Called when the DecorView gesture interception state has changed.
310      */
reportDecorViewGestureInterceptionChanged(IWindow window, in boolean intercepted)311     oneway void reportDecorViewGestureInterceptionChanged(IWindow window, in boolean intercepted);
312 
313     /**
314      * Called when the keep-clear areas for this window have changed.
315      */
reportKeepClearAreasChanged(IWindow window, in List<Rect> restricted, in List<Rect> unrestricted)316     oneway void reportKeepClearAreasChanged(IWindow window, in List<Rect> restricted,
317            in List<Rect> unrestricted);
318 
319     /**
320     * Request the server to call setInputWindowInfo on a given Surface, and return
321     * an input channel where the client can receive input. For windows, the clientToken should be
322     * the IWindow binder object. For other requests, the token can be any unique IBinder token to
323     * be used as unique identifier.
324     */
grantInputChannel(int displayId, in SurfaceControl surface, in IBinder clientToken, in @nullable InputTransferToken hostInputTransferToken, int flags, int privateFlags, int inputFeatures, int type, in IBinder windowToken, in InputTransferToken embeddedInputTransferToken, String inputHandleName, out InputChannel outInputChannel)325     void grantInputChannel(int displayId, in SurfaceControl surface, in IBinder clientToken,
326             in @nullable InputTransferToken hostInputTransferToken, int flags, int privateFlags,
327             int inputFeatures, int type, in IBinder windowToken,
328             in InputTransferToken embeddedInputTransferToken, String inputHandleName,
329             out InputChannel outInputChannel);
330 
331     /**
332      * Update the flags on an input channel associated with a particular surface.
333      */
updateInputChannel(in IBinder channelToken, int displayId, in SurfaceControl surface, int flags, int privateFlags, int inputFeatures, in Region region)334     oneway void updateInputChannel(in IBinder channelToken, int displayId,
335             in SurfaceControl surface, int flags, int privateFlags, int inputFeatures,
336             in Region region);
337 
338     /**
339      * Transfer window focus to an embedded window if the calling window has focus.
340      *
341      * @param window - calling window owned by the caller. Window can be null if there
342      *                 is no host window but the caller must have permissions to create an embedded
343      *                 window without a host window.
344      * @param inputToken - token identifying the embedded window that should gain focus.
345      * @param grantFocus - true if focus should be granted to the embedded window, false if focus
346      *                     should be transferred back to the host window. If there is no host
347      *                     window, the system will try to find a new focus target.
348      */
grantEmbeddedWindowFocus(IWindow window, in InputTransferToken inputToken, boolean grantFocus)349     void grantEmbeddedWindowFocus(IWindow window, in InputTransferToken inputToken,
350             boolean grantFocus);
351 
352     /**
353      * Generates an DisplayHash that can be used to validate whether specific content was on
354      * screen.
355      *
356      * @param window The token for the window to generate the hash of.
357      * @param boundsInWindow The size and position in the window of where to generate the hash.
358      * @param hashAlgorithm The String for the hash algorithm to use based on values returned
359      *                      from {@link IWindowManager#getSupportedDisplayHashAlgorithms()}
360      * @param callback The callback invoked to get the results of generateDisplayHash
361      */
generateDisplayHash(IWindow window, in Rect boundsInWindow, in String hashAlgorithm, in RemoteCallback callback)362     oneway void generateDisplayHash(IWindow window, in Rect boundsInWindow,
363             in String hashAlgorithm, in RemoteCallback callback);
364 
365     /**
366      * Sets the {@link OnBackInvokedCallbackInfo} containing the callback to be invoked for
367      * a window when back is triggered.
368      *
369      * @param window The token for the window to set the callback to.
370      * @param callbackInfo The {@link OnBackInvokedCallbackInfo} to set.
371      */
setOnBackInvokedCallbackInfo( IWindow window, in OnBackInvokedCallbackInfo callbackInfo)372     oneway void setOnBackInvokedCallbackInfo(
373             IWindow window, in OnBackInvokedCallbackInfo callbackInfo);
374 
375     /**
376      * Clears a touchable region set by {@link #setInsets}.
377      */
clearTouchableRegion(IWindow window)378     void clearTouchableRegion(IWindow window);
379 
380     /**
381      * Returns whether this window needs to cancel draw and retry later.
382      */
cancelDraw(IWindow window)383     boolean cancelDraw(IWindow window);
384 
385     /**
386      * Moves the focus to the adjacent window if there is one in the given direction. This can only
387      * move the focus to the window in the same leaf task.
388      *
389      * @param fromWindow The calling window that the focus is moved from.
390      * @param direction The {@link android.view.View.FocusDirection} that the new focus should go.
391      * @return {@code true} if the focus changes. Otherwise, {@code false}.
392      */
moveFocusToAdjacentWindow(IWindow fromWindow, int direction)393     boolean moveFocusToAdjacentWindow(IWindow fromWindow, int direction);
394 }
395