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