1/*
2** Copyright 2006, 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
17package android.view;
18
19import com.android.internal.os.IResultReceiver;
20import com.android.internal.view.IInputContext;
21import com.android.internal.view.IInputMethodClient;
22import com.android.internal.policy.IKeyguardDismissCallback;
23import com.android.internal.policy.IShortcutService;
24
25import android.app.IAssistDataReceiver;
26import android.content.res.CompatibilityInfo;
27import android.content.res.Configuration;
28import android.graphics.Bitmap;
29import android.graphics.GraphicBuffer;
30import android.graphics.Point;
31import android.graphics.Rect;
32import android.graphics.Region;
33import android.os.Bundle;
34import android.os.IRemoteCallback;
35import android.os.ParcelFileDescriptor;
36import android.view.IApplicationToken;
37import android.view.IAppTransitionAnimationSpecsFuture;
38import android.view.IDockedStackListener;
39import android.view.IOnKeyguardExitResult;
40import android.view.IPinnedStackListener;
41import android.view.RemoteAnimationAdapter;
42import android.view.IRotationWatcher;
43import android.view.IWallpaperVisibilityListener;
44import android.view.IWindowSession;
45import android.view.IWindowSessionCallback;
46import android.view.KeyEvent;
47import android.view.InputEvent;
48import android.view.MagnificationSpec;
49import android.view.MotionEvent;
50import android.view.InputChannel;
51import android.view.InputDevice;
52import android.view.IInputFilter;
53import android.view.AppTransitionAnimationSpec;
54import android.view.WindowContentFrameStats;
55import android.view.WindowManager;
56
57/**
58 * System private interface to the window manager.
59 *
60 * {@hide}
61 */
62interface IWindowManager
63{
64    /**
65     * ===== NOTICE =====
66     * The first three methods must remain the first three methods. Scripts
67     * and tools rely on their transaction number to work properly.
68     */
69    // This is used for debugging
70    boolean startViewServer(int port);   // Transaction #1
71    boolean stopViewServer();            // Transaction #2
72    boolean isViewServerRunning();       // Transaction #3
73
74    IWindowSession openSession(in IWindowSessionCallback callback, in IInputMethodClient client,
75            in IInputContext inputContext);
76    boolean inputMethodClientHasFocus(IInputMethodClient client);
77
78    void getInitialDisplaySize(int displayId, out Point size);
79    void getBaseDisplaySize(int displayId, out Point size);
80    void setForcedDisplaySize(int displayId, int width, int height);
81    void clearForcedDisplaySize(int displayId);
82    int getInitialDisplayDensity(int displayId);
83    int getBaseDisplayDensity(int displayId);
84    void setForcedDisplayDensityForUser(int displayId, int density, int userId);
85    void clearForcedDisplayDensityForUser(int displayId, int userId);
86    void setForcedDisplayScalingMode(int displayId, int mode); // 0 = auto, 1 = disable
87
88    void setOverscan(int displayId, int left, int top, int right, int bottom);
89
90    // These can only be called when holding the MANAGE_APP_TOKENS permission.
91    void setEventDispatching(boolean enabled);
92    void addWindowToken(IBinder token, int type, int displayId);
93    void removeWindowToken(IBinder token, int displayId);
94    void setFocusedApp(IBinder token, boolean moveFocusNow);
95    void prepareAppTransition(int transit, boolean alwaysKeepCurrent);
96    int getPendingAppTransition();
97    void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
98            IRemoteCallback startedCallback);
99    void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
100            int startHeight);
101    void overridePendingAppTransitionClipReveal(int startX, int startY,
102            int startWidth, int startHeight);
103    void overridePendingAppTransitionThumb(in GraphicBuffer srcThumb, int startX, int startY,
104            IRemoteCallback startedCallback, boolean scaleUp);
105    void overridePendingAppTransitionAspectScaledThumb(in GraphicBuffer srcThumb, int startX,
106            int startY, int targetWidth, int targetHeight, IRemoteCallback startedCallback,
107            boolean scaleUp);
108    /**
109     * Overrides animation for app transition that exits from an application to a multi-window
110     * environment and allows specifying transition animation parameters for each window.
111     *
112     * @param specs Array of transition animation descriptions for entering windows.
113     *
114     * @hide
115     */
116    void overridePendingAppTransitionMultiThumb(in AppTransitionAnimationSpec[] specs,
117            IRemoteCallback startedCallback, IRemoteCallback finishedCallback, boolean scaleUp);
118    void overridePendingAppTransitionInPlace(String packageName, int anim);
119
120    /**
121     * Like overridePendingAppTransitionMultiThumb, but uses a future to supply the specs. This is
122     * used for recents, where generating the thumbnails of the specs takes a non-trivial amount of
123     * time, so we want to move that off the critical path for starting the new activity.
124     */
125    void overridePendingAppTransitionMultiThumbFuture(
126            IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback startedCallback,
127            boolean scaleUp);
128    void overridePendingAppTransitionRemote(in RemoteAnimationAdapter remoteAnimationAdapter);
129    void executeAppTransition();
130
131    /**
132      * Used by system ui to report that recents has shown itself.
133      * @deprecated to be removed once prebuilts are updated
134      */
135    void endProlongedAnimations();
136
137    // Re-evaluate the current orientation from the caller's state.
138    // If there is a change, the new Configuration is returned and the
139    // caller must call setNewConfiguration() sometime later.
140    Configuration updateOrientationFromAppTokens(in Configuration currentConfig,
141            IBinder freezeThisOneIfNeeded, int displayId);
142    // Notify window manager of the new display override configuration. Returns an array of stack
143    // ids that were affected by the update, ActivityManager should resize these stacks.
144    int[] setNewDisplayOverrideConfiguration(in Configuration overrideConfig, int displayId);
145
146    void startFreezingScreen(int exitAnim, int enterAnim);
147    void stopFreezingScreen();
148
149    // these require DISABLE_KEYGUARD permission
150    void disableKeyguard(IBinder token, String tag);
151    void reenableKeyguard(IBinder token);
152    void exitKeyguardSecurely(IOnKeyguardExitResult callback);
153    boolean isKeyguardLocked();
154    boolean isKeyguardSecure();
155    void dismissKeyguard(IKeyguardDismissCallback callback, CharSequence message);
156
157    // Requires INTERACT_ACROSS_USERS_FULL permission
158    void setSwitchingUser(boolean switching);
159
160    void closeSystemDialogs(String reason);
161
162    // These can only be called with the SET_ANIMATON_SCALE permission.
163    float getAnimationScale(int which);
164    float[] getAnimationScales();
165    void setAnimationScale(int which, float scale);
166    void setAnimationScales(in float[] scales);
167
168    float getCurrentAnimatorScale();
169
170    // For testing
171    void setInTouchMode(boolean showFocus);
172
173    // For StrictMode flashing a red border on violations from the UI
174    // thread.  The uid/pid is implicit from the Binder call, and the Window
175    // Manager uses that to determine whether or not the red border should
176    // actually be shown.  (it will be ignored that pid doesn't have windows
177    // on screen)
178    void showStrictModeViolation(boolean on);
179
180    // Proxy to set the system property for whether the flashing
181    // should be enabled.  The 'enabled' value is null or blank for
182    // the system default (differs per build variant) or any valid
183    // boolean string as parsed by SystemProperties.getBoolean().
184    void setStrictModeVisualIndicatorPreference(String enabled);
185
186    /**
187     * Set whether screen capture is disabled for all windows of a specific user from
188     * the device policy cache.
189     */
190    void refreshScreenCaptureDisabled(int userId);
191
192    // These can only be called with the SET_ORIENTATION permission.
193    /**
194     * Update the current screen rotation based on the current state of
195     * the world.
196     * @param alwaysSendConfiguration Flag to force a new configuration to
197     * be evaluated.  This can be used when there are other parameters in
198     * configuration that are changing.
199     * @param forceRelayout If true, the window manager will always do a relayout
200     * of its windows even if the rotation hasn't changed.
201     */
202    void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout);
203
204    /**
205     * Retrieve the current orientation of the primary screen.
206     * @return Constant as per {@link android.view.Surface.Rotation}.
207     *
208     * @see android.view.Display#DEFAULT_DISPLAY
209     */
210    int getDefaultDisplayRotation();
211
212    /**
213     * Watch the rotation of the specified screen.  Returns the current rotation,
214     * calls back when it changes.
215     */
216    int watchRotation(IRotationWatcher watcher, int displayId);
217
218    /**
219     * Remove a rotation watcher set using watchRotation.
220     * @hide
221     */
222    void removeRotationWatcher(IRotationWatcher watcher);
223
224    /**
225     * Determine the preferred edge of the screen to pin the compact options menu against.
226     * @return a Gravity value for the options menu panel
227     * @hide
228     */
229    int getPreferredOptionsPanelGravity();
230
231    /**
232     * Lock the device orientation to the specified rotation, or to the
233     * current rotation if -1.  Sensor input will be ignored until
234     * thawRotation() is called.
235     * @hide
236     */
237    void freezeRotation(int rotation);
238
239    /**
240     * Release the orientation lock imposed by freezeRotation().
241     * @hide
242     */
243    void thawRotation();
244
245    /**
246     * Gets whether the rotation is frozen.
247     *
248     * @return Whether the rotation is frozen.
249     */
250    boolean isRotationFrozen();
251
252    /**
253     * Screenshot the current wallpaper layer, including the whole screen.
254     */
255    Bitmap screenshotWallpaper();
256
257    /**
258     * Registers a wallpaper visibility listener.
259     * @return Current visibility.
260     */
261    boolean registerWallpaperVisibilityListener(IWallpaperVisibilityListener listener,
262        int displayId);
263
264    /**
265     * Remove a visibility watcher that was added using registerWallpaperVisibilityListener.
266     */
267    void unregisterWallpaperVisibilityListener(IWallpaperVisibilityListener listener,
268        int displayId);
269
270    /**
271     * Used only for assist -- request a screenshot of the current application.
272     */
273    boolean requestAssistScreenshot(IAssistDataReceiver receiver);
274
275    /**
276     * Called by the status bar to notify Views of changes to System UI visiblity.
277     */
278    oneway void statusBarVisibilityChanged(int visibility);
279
280    /**
281     * Called by System UI to notify of changes to the visibility of Recents.
282     */
283    oneway void setRecentsVisibility(boolean visible);
284
285    /**
286     * Called by System UI to notify of changes to the visibility of PIP.
287     */
288    oneway void setPipVisibility(boolean visible);
289
290    /**
291     * Called by System UI to notify of changes to the visibility and height of the shelf.
292     */
293    void setShelfHeight(boolean visible, int shelfHeight);
294
295    /**
296     * Called by System UI to enable or disable haptic feedback on the navigation bar buttons.
297     */
298    void setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled);
299
300    /**
301     * Device has a software navigation bar (separate from the status bar).
302     */
303    boolean hasNavigationBar();
304
305    /**
306     * Get the position of the nav bar
307     */
308    int getNavBarPosition();
309
310    /**
311     * Lock the device immediately with the specified options (can be null).
312     */
313    void lockNow(in Bundle options);
314
315    /**
316     * Device is in safe mode.
317     */
318    boolean isSafeModeEnabled();
319
320    /**
321     * Enables the screen if all conditions are met.
322     */
323    void enableScreenIfNeeded();
324
325    /**
326     * Clears the frame statistics for a given window.
327     *
328     * @param token The window token.
329     * @return Whether the frame statistics were cleared.
330     */
331    boolean clearWindowContentFrameStats(IBinder token);
332
333    /**
334     * Gets the content frame statistics for a given window.
335     *
336     * @param token The window token.
337     * @return The frame statistics or null if the window does not exist.
338     */
339    WindowContentFrameStats getWindowContentFrameStats(IBinder token);
340
341    /**
342     * @return the dock side the current docked stack is at; must be one of the
343     *         WindowManagerGlobal.DOCKED_* values
344     */
345    int getDockedStackSide();
346
347    /**
348     * Sets the region the user can touch the divider. This region will be excluded from the region
349     * which is used to cause a focus switch when dispatching touch.
350     */
351    void setDockedStackDividerTouchRegion(in Rect touchableRegion);
352
353    /**
354     * Registers a listener that will be called when the dock divider changes its visibility or when
355     * the docked stack gets added/removed.
356     */
357    void registerDockedStackListener(IDockedStackListener listener);
358
359    /**
360     * Registers a listener that will be called when the pinned stack state changes.
361     */
362    void registerPinnedStackListener(int displayId, IPinnedStackListener listener);
363
364    /**
365     * Updates the dim layer used while resizing.
366     *
367     * @param visible Whether the dim layer should be visible.
368     * @param targetWindowingMode The windowing mode of the stack the dim layer should be placed on.
369     * @param alpha The translucency of the dim layer, between 0 and 1.
370     */
371    void setResizeDimLayer(boolean visible, int targetWindowingMode, float alpha);
372
373    /**
374     * Requests Keyboard Shortcuts from the displayed window.
375     *
376     * @param receiver The receiver to deliver the results to.
377     */
378    void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId);
379
380    /**
381     * Retrieves the current stable insets from the primary display.
382     */
383    void getStableInsets(int displayId, out Rect outInsets);
384
385    /**
386     * Register shortcut key. Shortcut code is packed as:
387     * (MetaState << Integer.SIZE) | KeyCode
388     * @hide
389     */
390    void registerShortcutKey(in long shortcutCode, IShortcutService keySubscriber);
391
392    /**
393     * Create an input consumer by name.
394     */
395    void createInputConsumer(IBinder token, String name, out InputChannel inputChannel);
396
397    /**
398     * Destroy an input consumer by name.  This method will also dispose the input channels
399     * associated with that InputConsumer.
400     */
401    boolean destroyInputConsumer(String name);
402
403    /**
404     * Return the touch region for the current IME window, or an empty region if there is none.
405     */
406    Region getCurrentImeTouchRegion();
407
408    /**
409     * Starts a window trace.
410     */
411    void startWindowTrace();
412
413    /**
414     * Stops a window trace.
415     */
416    void stopWindowTrace();
417
418    /**
419     * Returns true if window trace is enabled.
420     */
421    boolean isWindowTraceEnabled();
422
423    /**
424     * Requests that the WindowManager sends WindowManagerPolicy#ACTION_USER_ACTIVITY_NOTIFICATION
425     * on the next user activity.
426     */
427    void requestUserActivityNotification();
428
429    /**
430     * Notify WindowManager that it should not override the info in DisplayManager for the specified
431     * display. This can disable letter- or pillar-boxing applied in DisplayManager when the metrics
432     * of the logical display reported from WindowManager do not correspond to the metrics of the
433     * physical display it is based on.
434     *
435     * @param displayId The id of the display.
436     */
437    void dontOverrideDisplayInfo(int displayId);
438}
439