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