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