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