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
18package android.view;
19
20import android.content.ClipData;
21import android.graphics.Rect;
22import android.graphics.Region;
23import android.os.Bundle;
24import android.util.MergedConfiguration;
25import android.view.DisplayCutout;
26import android.view.InputChannel;
27import android.view.IWindow;
28import android.view.IWindowId;
29import android.view.MotionEvent;
30import android.view.WindowManager;
31import android.view.Surface;
32import android.view.SurfaceControl;
33
34/**
35 * System private per-application interface to the window manager.
36 *
37 * {@hide}
38 */
39interface IWindowSession {
40    int add(IWindow window, int seq, in WindowManager.LayoutParams attrs,
41            in int viewVisibility, out Rect outContentInsets, out Rect outStableInsets,
42            out InputChannel outInputChannel);
43    int addToDisplay(IWindow window, int seq, in WindowManager.LayoutParams attrs,
44            in int viewVisibility, in int layerStackId, out Rect outFrame,
45            out Rect outContentInsets, out Rect outStableInsets, out Rect outOutsets,
46            out DisplayCutout.ParcelableWrapper displayCutout, out InputChannel outInputChannel);
47    int addWithoutInputChannel(IWindow window, int seq, in WindowManager.LayoutParams attrs,
48            in int viewVisibility, out Rect outContentInsets, out Rect outStableInsets);
49    int addToDisplayWithoutInputChannel(IWindow window, int seq, in WindowManager.LayoutParams attrs,
50            in int viewVisibility, in int layerStackId, out Rect outContentInsets,
51            out Rect outStableInsets);
52    void remove(IWindow window);
53
54    /**
55     * Change the parameters of a window.  You supply the
56     * new parameters, it returns the new frame of the window on screen (the
57     * position should be ignored) and surface of the window.  The surface
58     * will be invalid if the window is currently hidden, else you can use it
59     * to draw the window's contents.
60     *
61     * @param window The window being modified.
62     * @param seq Ordering sequence number.
63     * @param attrs If non-null, new attributes to apply to the window.
64     * @param requestedWidth The width the window wants to be.
65     * @param requestedHeight The height the window wants to be.
66     * @param viewVisibility Window root view's visibility.
67     * @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING},
68     * {@link WindowManagerGlobal#RELAYOUT_DEFER_SURFACE_DESTROY}.
69     * @param frameNumber A frame number in which changes requested in this layout will be rendered.
70     * @param outFrame Rect in which is placed the new position/size on
71     * screen.
72     * @param outOverscanInsets Rect in which is placed the offsets from
73     * <var>outFrame</var> in which the content of the window are inside
74     * of the display's overlay region.
75     * @param outContentInsets Rect in which is placed the offsets from
76     * <var>outFrame</var> in which the content of the window should be
77     * placed.  This can be used to modify the window layout to ensure its
78     * contents are visible to the user, taking into account system windows
79     * like the status bar or a soft keyboard.
80     * @param outVisibleInsets Rect in which is placed the offsets from
81     * <var>outFrame</var> in which the window is actually completely visible
82     * to the user.  This can be used to temporarily scroll the window's
83     * contents to make sure the user can see it.  This is different than
84     * <var>outContentInsets</var> in that these insets change transiently,
85     * so complex relayout of the window should not happen based on them.
86     * @param outOutsets Rect in which is placed the dead area of the screen that we would like to
87     * treat as real display. Example of such area is a chin in some models of wearable devices.
88     * @param outBackdropFrame Rect which is used draw the resizing background during a resize
89     * operation.
90     * @param outMergedConfiguration New config container that holds global, override and merged
91     * config for window, if it is now becoming visible and the merged configuration has changed
92     * since it was last displayed.
93     * @param outSurface Object in which is placed the new display surface.
94     *
95     * @return int Result flags: {@link WindowManagerGlobal#RELAYOUT_SHOW_FOCUS},
96     * {@link WindowManagerGlobal#RELAYOUT_FIRST_TIME}.
97     */
98    int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
99            int requestedWidth, int requestedHeight, int viewVisibility,
100            int flags, long frameNumber, out Rect outFrame, out Rect outOverscanInsets,
101            out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets,
102            out Rect outOutsets, out Rect outBackdropFrame,
103            out DisplayCutout.ParcelableWrapper displayCutout,
104            out MergedConfiguration outMergedConfiguration, out Surface outSurface);
105
106    /*
107     * Notify the window manager that an application is relaunching and
108     * windows should be prepared for replacement.
109     *
110     * @param appToken The application
111     * @param childrenOnly Whether to only prepare child windows for replacement
112     * (for example when main windows are being reused via preservation).
113     */
114    void prepareToReplaceWindows(IBinder appToken, boolean childrenOnly);
115
116    /**
117     * Called by a client to report that it ran out of graphics memory.
118     */
119    boolean outOfMemory(IWindow window);
120
121    /**
122     * Give the window manager a hint of the part of the window that is
123     * completely transparent, allowing it to work with the surface flinger
124     * to optimize compositing of this part of the window.
125     */
126    void setTransparentRegion(IWindow window, in Region region);
127
128    /**
129     * Tell the window manager about the content and visible insets of the
130     * given window, which can be used to adjust the <var>outContentInsets</var>
131     * and <var>outVisibleInsets</var> values returned by
132     * {@link #relayout relayout()} for windows behind this one.
133     *
134     * @param touchableInsets Controls which part of the window inside of its
135     * frame can receive pointer events, as defined by
136     * {@link android.view.ViewTreeObserver.InternalInsetsInfo}.
137     */
138    void setInsets(IWindow window, int touchableInsets, in Rect contentInsets,
139            in Rect visibleInsets, in Region touchableRegion);
140
141    /**
142     * Return the current display size in which the window is being laid out,
143     * accounting for screen decorations around it.
144     */
145    void getDisplayFrame(IWindow window, out Rect outDisplayFrame);
146
147    void finishDrawing(IWindow window);
148
149    void setInTouchMode(boolean showFocus);
150    boolean getInTouchMode();
151
152    boolean performHapticFeedback(IWindow window, int effectId, boolean always);
153
154    /**
155     * Initiate the drag operation itself
156     *
157     * @param window Window which initiates drag operation.
158     * @param flags See {@code View#startDragAndDrop}
159     * @param surface Surface containing drag shadow image
160     * @param touchSource See {@code InputDevice#getSource()}
161     * @param touchX X coordinate of last touch point
162     * @param touchY Y coordinate of last touch point
163     * @param thumbCenterX X coordinate for the position within the shadow image that should be
164     *         underneath the touch point during the drag and drop operation.
165     * @param thumbCenterY Y coordinate for the position within the shadow image that should be
166     *         underneath the touch point during the drag and drop operation.
167     * @param data Data transferred by drag and drop
168     * @return Token of drag operation which will be passed to cancelDragAndDrop.
169     */
170    IBinder performDrag(IWindow window, int flags, in SurfaceControl surface, int touchSource,
171            float touchX, float touchY, float thumbCenterX, float thumbCenterY, in ClipData data);
172
173    /**
174     * Report the result of a drop action targeted to the given window.
175     * consumed is 'true' when the drop was accepted by a valid recipient,
176     * 'false' otherwise.
177     */
178    void reportDropResult(IWindow window, boolean consumed);
179
180    /**
181     * Cancel the current drag operation.
182     */
183    void cancelDragAndDrop(IBinder dragToken);
184
185    /**
186     * Tell the OS that we've just dragged into a View that is willing to accept the drop
187     */
188    void dragRecipientEntered(IWindow window);
189
190    /**
191     * Tell the OS that we've just dragged *off* of a View that was willing to accept the drop
192     */
193    void dragRecipientExited(IWindow window);
194
195    /**
196     * For windows with the wallpaper behind them, and the wallpaper is
197     * larger than the screen, set the offset within the screen.
198     * For multi screen launcher type applications, xstep and ystep indicate
199     * how big the increment is from one screen to another.
200     */
201    void setWallpaperPosition(IBinder windowToken, float x, float y, float xstep, float ystep);
202
203    void wallpaperOffsetsComplete(IBinder window);
204
205    /**
206     * Apply a raw offset to the wallpaper service when shown behind this window.
207     */
208    void setWallpaperDisplayOffset(IBinder windowToken, int x, int y);
209
210    Bundle sendWallpaperCommand(IBinder window, String action, int x, int y,
211            int z, in Bundle extras, boolean sync);
212
213    void wallpaperCommandComplete(IBinder window, in Bundle result);
214
215    /**
216     * Notifies that a rectangle on the screen has been requested.
217     */
218    void onRectangleOnScreenRequested(IBinder token, in Rect rectangle);
219
220    IWindowId getWindowId(IBinder window);
221
222    /**
223     * When the system is dozing in a low-power partially suspended state, pokes a short
224     * lived wake lock and ensures that the display is ready to accept the next frame
225     * of content drawn in the window.
226     *
227     * This mechanism is bound to the window rather than to the display manager or the
228     * power manager so that the system can ensure that the window is actually visible
229     * and prevent runaway applications from draining the battery.  This is similar to how
230     * FLAG_KEEP_SCREEN_ON works.
231     *
232     * This method is synchronous because it may need to acquire a wake lock before returning.
233     * The assumption is that this method will be called rather infrequently.
234     */
235    void pokeDrawLock(IBinder window);
236
237    /**
238     * Starts a task window move with {startX, startY} as starting point. The amount of move
239     * will be the offset between {startX, startY} and the new cursor position.
240     *
241     * Returns true if the move started successfully; false otherwise.
242     */
243    boolean startMovingTask(IWindow window, float startX, float startY);
244
245    void updatePointerIcon(IWindow window);
246
247    /**
248     * Update a tap exclude region with a rectangular area identified by provided id in the window.
249     * Touches on this region will not switch focus to this window. Passing an empty rect will
250     * remove the area from the exclude region of this window.
251     */
252    void updateTapExcludeRegion(IWindow window, int regionId, int left, int top, int width,
253            int height);
254}
255