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.app.IAssistScreenshotReceiver; 20import com.android.internal.os.IResultReceiver; 21import com.android.internal.view.IInputContext; 22import com.android.internal.view.IInputMethodClient; 23import com.android.internal.policy.IKeyguardDismissCallback; 24import com.android.internal.policy.IShortcutService; 25 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.os.Bundle; 33import android.os.IRemoteCallback; 34import android.os.ParcelFileDescriptor; 35import android.view.IApplicationToken; 36import android.view.IAppTransitionAnimationSpecsFuture; 37import android.view.IDockedStackListener; 38import android.view.IOnKeyguardExitResult; 39import android.view.IPinnedStackListener; 40import android.view.IRotationWatcher; 41import android.view.IWindowSession; 42import android.view.IWindowSessionCallback; 43import android.view.KeyEvent; 44import android.view.InputEvent; 45import android.view.MagnificationSpec; 46import android.view.MotionEvent; 47import android.view.InputChannel; 48import android.view.InputDevice; 49import android.view.IInputFilter; 50import android.view.AppTransitionAnimationSpec; 51import android.view.WindowContentFrameStats; 52import android.view.WindowManager; 53 54/** 55 * System private interface to the window manager. 56 * 57 * {@hide} 58 */ 59interface 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 67 boolean startViewServer(int port); // Transaction #1 68 boolean stopViewServer(); // Transaction #2 69 boolean isViewServerRunning(); // Transaction #3 70 71 IWindowSession openSession(in IWindowSessionCallback callback, in IInputMethodClient client, 72 in IInputContext inputContext); 73 boolean inputMethodClientHasFocus(IInputMethodClient client); 74 75 void getInitialDisplaySize(int displayId, out Point size); 76 void getBaseDisplaySize(int displayId, out Point size); 77 void setForcedDisplaySize(int displayId, int width, int height); 78 void clearForcedDisplaySize(int displayId); 79 int getInitialDisplayDensity(int displayId); 80 int getBaseDisplayDensity(int displayId); 81 void setForcedDisplayDensityForUser(int displayId, int density, int userId); 82 void clearForcedDisplayDensityForUser(int displayId, int userId); 83 void setForcedDisplayScalingMode(int displayId, int mode); // 0 = auto, 1 = disable 84 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. 88 void setEventDispatching(boolean enabled); 89 void addWindowToken(IBinder token, int type, int displayId); 90 void removeWindowToken(IBinder token, int displayId); 91 void setFocusedApp(IBinder token, boolean moveFocusNow); 92 void prepareAppTransition(int transit, boolean alwaysKeepCurrent); 93 int getPendingAppTransition(); 94 void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim, 95 IRemoteCallback startedCallback); 96 void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, 97 int startHeight); 98 void overridePendingAppTransitionClipReveal(int startX, int startY, 99 int startWidth, int startHeight); 100 void overridePendingAppTransitionThumb(in GraphicBuffer srcThumb, int startX, int startY, 101 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 */ 113 void overridePendingAppTransitionMultiThumb(in AppTransitionAnimationSpec[] specs, 114 IRemoteCallback startedCallback, IRemoteCallback finishedCallback, boolean scaleUp); 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 */ 122 void overridePendingAppTransitionMultiThumbFuture( 123 IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback startedCallback, 124 boolean scaleUp); 125 void executeAppTransition(); 126 127 /** Used by system ui to report that recents has shown itself. */ 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. 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. 137 int[] setNewDisplayOverrideConfiguration(in Configuration overrideConfig, int displayId); 138 139 void startFreezingScreen(int exitAnim, int enterAnim); 140 void stopFreezingScreen(); 141 142 // these require DISABLE_KEYGUARD permission 143 void disableKeyguard(IBinder token, String tag); 144 void reenableKeyguard(IBinder token); 145 void exitKeyguardSecurely(IOnKeyguardExitResult callback); 146 boolean isKeyguardLocked(); 147 boolean isKeyguardSecure(); 148 boolean inKeyguardRestrictedInputMode(); 149 void dismissKeyguard(IKeyguardDismissCallback callback); 150 151 // Requires INTERACT_ACROSS_USERS_FULL permission 152 void setSwitchingUser(boolean switching); 153 154 void closeSystemDialogs(String reason); 155 156 // These can only be called with the SET_ANIMATON_SCALE permission. 157 float getAnimationScale(int which); 158 float[] getAnimationScales(); 159 void setAnimationScale(int which, float scale); 160 void setAnimationScales(in float[] scales); 161 162 float getCurrentAnimatorScale(); 163 164 // For testing 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) 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(). 178 void setStrictModeVisualIndicatorPreference(String enabled); 179 180 /** 181 * Set whether screen capture is disabled for all windows of a specific user 182 */ 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 */ 189 void enableSurfaceTrace(in ParcelFileDescriptor fd); 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 */ 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 * Used only for assist -- request a screenshot of the current application. 259 */ 260 boolean requestAssistScreenshot(IAssistScreenshotReceiver receiver); 261 262 /** 263 * Called by the status bar to notify Views of changes to System UI visiblity. 264 */ 265 oneway void statusBarVisibilityChanged(int visibility); 266 267 /** 268 * Called by System UI to notify of changes to the visibility of Recents. 269 */ 270 oneway void setRecentsVisibility(boolean visible); 271 272 /** 273 * Called by System UI to notify of changes to the visibility of PIP. 274 */ 275 oneway void setPipVisibility(boolean visible); 276 277 /** 278 * Device has a software navigation bar (separate from the status bar). 279 */ 280 boolean hasNavigationBar(); 281 282 /** 283 * Lock the device immediately with the specified options (can be null). 284 */ 285 void lockNow(in Bundle options); 286 287 /** 288 * Device is in safe mode. 289 */ 290 boolean isSafeModeEnabled(); 291 292 /** 293 * Enables the screen if all conditions are met. 294 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 335 void registerDockedStackListener(IDockedStackListener listener); 336 337 /** 338 * Registers a listener that will be called when the pinned stack state changes. 339 */ 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 */ 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 */ 356 void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId); 357 358 /** 359 * Retrieves the current stable insets from the primary display. 360 */ 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 */ 368 void registerShortcutKey(in long shortcutCode, IShortcutService keySubscriber); 369 370 /** 371 * Create an input consumer by name. 372 */ 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 */ 379 boolean destroyInputConsumer(String name); 380} 381