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.os.IResultReceiver; 20 import com.android.internal.view.IInputContext; 21 import com.android.internal.view.IInputMethodClient; 22 import com.android.internal.policy.IKeyguardDismissCallback; 23 import com.android.internal.policy.IShortcutService; 24 25 import android.app.IAssistDataReceiver; 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.graphics.Region; 33 import android.os.Bundle; 34 import android.os.IRemoteCallback; 35 import android.os.ParcelFileDescriptor; 36 import android.view.IApplicationToken; 37 import android.view.IAppTransitionAnimationSpecsFuture; 38 import android.view.IDockedStackListener; 39 import android.view.IOnKeyguardExitResult; 40 import android.view.IPinnedStackListener; 41 import android.view.RemoteAnimationAdapter; 42 import android.view.IRotationWatcher; 43 import android.view.IWallpaperVisibilityListener; 44 import android.view.IWindowSession; 45 import android.view.IWindowSessionCallback; 46 import android.view.KeyEvent; 47 import android.view.InputEvent; 48 import android.view.MagnificationSpec; 49 import android.view.MotionEvent; 50 import android.view.InputChannel; 51 import android.view.InputDevice; 52 import android.view.IInputFilter; 53 import android.view.AppTransitionAnimationSpec; 54 import android.view.WindowContentFrameStats; 55 import android.view.WindowManager; 56 57 /** 58 * System private interface to the window manager. 59 * 60 * {@hide} 61 */ 62 interface 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 startViewServer(int port)70 boolean startViewServer(int port); // Transaction #1 stopViewServer()71 boolean stopViewServer(); // Transaction #2 isViewServerRunning()72 boolean isViewServerRunning(); // Transaction #3 73 openSession(in IWindowSessionCallback callback, in IInputMethodClient client, in IInputContext inputContext)74 IWindowSession openSession(in IWindowSessionCallback callback, in IInputMethodClient client, 75 in IInputContext inputContext); inputMethodClientHasFocus(IInputMethodClient client)76 boolean inputMethodClientHasFocus(IInputMethodClient client); 77 getInitialDisplaySize(int displayId, out Point size)78 void getInitialDisplaySize(int displayId, out Point size); getBaseDisplaySize(int displayId, out Point size)79 void getBaseDisplaySize(int displayId, out Point size); setForcedDisplaySize(int displayId, int width, int height)80 void setForcedDisplaySize(int displayId, int width, int height); clearForcedDisplaySize(int displayId)81 void clearForcedDisplaySize(int displayId); getInitialDisplayDensity(int displayId)82 int getInitialDisplayDensity(int displayId); getBaseDisplayDensity(int displayId)83 int getBaseDisplayDensity(int displayId); setForcedDisplayDensityForUser(int displayId, int density, int userId)84 void setForcedDisplayDensityForUser(int displayId, int density, int userId); clearForcedDisplayDensityForUser(int displayId, int userId)85 void clearForcedDisplayDensityForUser(int displayId, int userId); setForcedDisplayScalingMode(int displayId, int mode)86 void setForcedDisplayScalingMode(int displayId, int mode); // 0 = auto, 1 = disable 87 setOverscan(int displayId, int left, int top, int right, int bottom)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. setEventDispatching(boolean enabled)91 void setEventDispatching(boolean enabled); addWindowToken(IBinder token, int type, int displayId)92 void addWindowToken(IBinder token, int type, int displayId); removeWindowToken(IBinder token, int displayId)93 void removeWindowToken(IBinder token, int displayId); setFocusedApp(IBinder token, boolean moveFocusNow)94 void setFocusedApp(IBinder token, boolean moveFocusNow); prepareAppTransition(int transit, boolean alwaysKeepCurrent)95 void prepareAppTransition(int transit, boolean alwaysKeepCurrent); getPendingAppTransition()96 int getPendingAppTransition(); overridePendingAppTransition(String packageName, int enterAnim, int exitAnim, IRemoteCallback startedCallback)97 void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim, 98 IRemoteCallback startedCallback); overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, int startHeight)99 void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, 100 int startHeight); overridePendingAppTransitionClipReveal(int startX, int startY, int startWidth, int startHeight)101 void overridePendingAppTransitionClipReveal(int startX, int startY, 102 int startWidth, int startHeight); overridePendingAppTransitionThumb(in GraphicBuffer srcThumb, int startX, int startY, IRemoteCallback startedCallback, boolean scaleUp)103 void overridePendingAppTransitionThumb(in GraphicBuffer srcThumb, int startX, int startY, 104 IRemoteCallback startedCallback, boolean scaleUp); overridePendingAppTransitionAspectScaledThumb(in GraphicBuffer srcThumb, int startX, int startY, int targetWidth, int targetHeight, 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 */ overridePendingAppTransitionMultiThumb(in AppTransitionAnimationSpec[] specs, IRemoteCallback startedCallback, IRemoteCallback finishedCallback, boolean scaleUp)116 void overridePendingAppTransitionMultiThumb(in AppTransitionAnimationSpec[] specs, 117 IRemoteCallback startedCallback, IRemoteCallback finishedCallback, boolean scaleUp); overridePendingAppTransitionInPlace(String packageName, int anim)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 */ overridePendingAppTransitionMultiThumbFuture( IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback startedCallback, boolean scaleUp)125 void overridePendingAppTransitionMultiThumbFuture( 126 IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback startedCallback, 127 boolean scaleUp); overridePendingAppTransitionRemote(in RemoteAnimationAdapter remoteAnimationAdapter)128 void overridePendingAppTransitionRemote(in RemoteAnimationAdapter remoteAnimationAdapter); executeAppTransition()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 */ endProlongedAnimations()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. updateOrientationFromAppTokens(in Configuration currentConfig, IBinder freezeThisOneIfNeeded, int displayId)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. setNewDisplayOverrideConfiguration(in Configuration overrideConfig, int displayId)144 int[] setNewDisplayOverrideConfiguration(in Configuration overrideConfig, int displayId); 145 startFreezingScreen(int exitAnim, int enterAnim)146 void startFreezingScreen(int exitAnim, int enterAnim); stopFreezingScreen()147 void stopFreezingScreen(); 148 149 // these require DISABLE_KEYGUARD permission disableKeyguard(IBinder token, String tag)150 void disableKeyguard(IBinder token, String tag); reenableKeyguard(IBinder token)151 void reenableKeyguard(IBinder token); exitKeyguardSecurely(IOnKeyguardExitResult callback)152 void exitKeyguardSecurely(IOnKeyguardExitResult callback); isKeyguardLocked()153 boolean isKeyguardLocked(); isKeyguardSecure()154 boolean isKeyguardSecure(); dismissKeyguard(IKeyguardDismissCallback callback, CharSequence message)155 void dismissKeyguard(IKeyguardDismissCallback callback, CharSequence message); 156 157 // Requires INTERACT_ACROSS_USERS_FULL permission setSwitchingUser(boolean switching)158 void setSwitchingUser(boolean switching); 159 closeSystemDialogs(String reason)160 void closeSystemDialogs(String reason); 161 162 // These can only be called with the SET_ANIMATON_SCALE permission. getAnimationScale(int which)163 float getAnimationScale(int which); getAnimationScales()164 float[] getAnimationScales(); setAnimationScale(int which, float scale)165 void setAnimationScale(int which, float scale); setAnimationScales(in float[] scales)166 void setAnimationScales(in float[] scales); 167 getCurrentAnimatorScale()168 float getCurrentAnimatorScale(); 169 170 // For testing setInTouchMode(boolean showFocus)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) showStrictModeViolation(boolean on)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(). setStrictModeVisualIndicatorPreference(String enabled)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 */ refreshScreenCaptureDisabled(int userId)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 */ 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 * Registers a wallpaper visibility listener. 259 * @return Current visibility. 260 */ registerWallpaperVisibilityListener(IWallpaperVisibilityListener listener, int displayId)261 boolean registerWallpaperVisibilityListener(IWallpaperVisibilityListener listener, 262 int displayId); 263 264 /** 265 * Remove a visibility watcher that was added using registerWallpaperVisibilityListener. 266 */ unregisterWallpaperVisibilityListener(IWallpaperVisibilityListener listener, int displayId)267 void unregisterWallpaperVisibilityListener(IWallpaperVisibilityListener listener, 268 int displayId); 269 270 /** 271 * Used only for assist -- request a screenshot of the current application. 272 */ requestAssistScreenshot(IAssistDataReceiver receiver)273 boolean requestAssistScreenshot(IAssistDataReceiver receiver); 274 275 /** 276 * Called by the status bar to notify Views of changes to System UI visiblity. 277 */ statusBarVisibilityChanged(int visibility)278 oneway void statusBarVisibilityChanged(int visibility); 279 280 /** 281 * Called by System UI to notify of changes to the visibility of Recents. 282 */ setRecentsVisibility(boolean visible)283 oneway void setRecentsVisibility(boolean visible); 284 285 /** 286 * Called by System UI to notify of changes to the visibility of PIP. 287 */ setPipVisibility(boolean visible)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 */ setShelfHeight(boolean visible, int shelfHeight)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 */ setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled)298 void setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled); 299 300 /** 301 * Device has a software navigation bar (separate from the status bar). 302 */ hasNavigationBar()303 boolean hasNavigationBar(); 304 305 /** 306 * Get the position of the nav bar 307 */ getNavBarPosition()308 int getNavBarPosition(); 309 310 /** 311 * Lock the device immediately with the specified options (can be null). 312 */ lockNow(in Bundle options)313 void lockNow(in Bundle options); 314 315 /** 316 * Device is in safe mode. 317 */ isSafeModeEnabled()318 boolean isSafeModeEnabled(); 319 320 /** 321 * Enables the screen if all conditions are met. 322 */ enableScreenIfNeeded()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 */ clearWindowContentFrameStats(IBinder token)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 */ getWindowContentFrameStats(IBinder token)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 */ getDockedStackSide()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 */ setDockedStackDividerTouchRegion(in Rect touchableRegion)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 */ registerDockedStackListener(IDockedStackListener listener)357 void registerDockedStackListener(IDockedStackListener listener); 358 359 /** 360 * Registers a listener that will be called when the pinned stack state changes. 361 */ registerPinnedStackListener(int displayId, IPinnedStackListener listener)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 */ setResizeDimLayer(boolean visible, int targetWindowingMode, float alpha)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 */ requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId)378 void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId); 379 380 /** 381 * Retrieves the current stable insets from the primary display. 382 */ getStableInsets(int displayId, out Rect outInsets)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 */ registerShortcutKey(in long shortcutCode, IShortcutService keySubscriber)390 void registerShortcutKey(in long shortcutCode, IShortcutService keySubscriber); 391 392 /** 393 * Create an input consumer by name. 394 */ createInputConsumer(IBinder token, String name, out InputChannel inputChannel)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 */ destroyInputConsumer(String name)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 */ getCurrentImeTouchRegion()406 Region getCurrentImeTouchRegion(); 407 408 /** 409 * Starts a window trace. 410 */ startWindowTrace()411 void startWindowTrace(); 412 413 /** 414 * Stops a window trace. 415 */ stopWindowTrace()416 void stopWindowTrace(); 417 418 /** 419 * Returns true if window trace is enabled. 420 */ isWindowTraceEnabled()421 boolean isWindowTraceEnabled(); 422 423 /** 424 * Requests that the WindowManager sends WindowManagerPolicy#ACTION_USER_ACTIVITY_NOTIFICATION 425 * on the next user activity. 426 */ requestUserActivityNotification()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 */ dontOverrideDisplayInfo(int displayId)437 void dontOverrideDisplayInfo(int displayId); 438 } 439