1 /* 2 * Copyright (C) 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 android.app.Presentation; 20 import android.content.Context; 21 import android.content.pm.ActivityInfo; 22 import android.graphics.PixelFormat; 23 import android.os.IBinder; 24 import android.os.Parcel; 25 import android.os.Parcelable; 26 import android.text.TextUtils; 27 import android.util.Log; 28 29 30 /** 31 * The interface that apps use to talk to the window manager. 32 * <p> 33 * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these. 34 * </p><p> 35 * Each window manager instance is bound to a particular {@link Display}. 36 * To obtain a {@link WindowManager} for a different display, use 37 * {@link Context#createDisplayContext} to obtain a {@link Context} for that 38 * display, then use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> 39 * to get the WindowManager. 40 * </p><p> 41 * The simplest way to show a window on another display is to create a 42 * {@link Presentation}. The presentation will automatically obtain a 43 * {@link WindowManager} and {@link Context} for that display. 44 * </p> 45 * 46 * @see android.content.Context#getSystemService 47 * @see android.content.Context#WINDOW_SERVICE 48 */ 49 public interface WindowManager extends ViewManager { 50 /** 51 * Exception that is thrown when trying to add view whose 52 * {@link WindowManager.LayoutParams} {@link WindowManager.LayoutParams#token} 53 * is invalid. 54 */ 55 public static class BadTokenException extends RuntimeException { BadTokenException()56 public BadTokenException() { 57 } 58 BadTokenException(String name)59 public BadTokenException(String name) { 60 super(name); 61 } 62 } 63 64 /** 65 * Exception that is thrown when calling {@link #addView} to a secondary display that cannot 66 * be found. See {@link android.app.Presentation} for more information on secondary displays. 67 */ 68 public static class InvalidDisplayException extends RuntimeException { InvalidDisplayException()69 public InvalidDisplayException() { 70 } 71 InvalidDisplayException(String name)72 public InvalidDisplayException(String name) { 73 super(name); 74 } 75 } 76 77 /** 78 * Returns the {@link Display} upon which this {@link WindowManager} instance 79 * will create new windows. 80 * <p> 81 * Despite the name of this method, the display that is returned is not 82 * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}). 83 * The returned display could instead be a secondary display that this 84 * window manager instance is managing. Think of it as the display that 85 * this {@link WindowManager} instance uses by default. 86 * </p><p> 87 * To create windows on a different display, you need to obtain a 88 * {@link WindowManager} for that {@link Display}. (See the {@link WindowManager} 89 * class documentation for more information.) 90 * </p> 91 * 92 * @return The display that this window manager is managing. 93 */ getDefaultDisplay()94 public Display getDefaultDisplay(); 95 96 /** 97 * Special variation of {@link #removeView} that immediately invokes 98 * the given view hierarchy's {@link View#onDetachedFromWindow() 99 * View.onDetachedFromWindow()} methods before returning. This is not 100 * for normal applications; using it correctly requires great care. 101 * 102 * @param view The view to be removed. 103 */ removeViewImmediate(View view)104 public void removeViewImmediate(View view); 105 106 public static class LayoutParams extends ViewGroup.LayoutParams 107 implements Parcelable { 108 /** 109 * X position for this window. With the default gravity it is ignored. 110 * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or 111 * {@link Gravity#END} it provides an offset from the given edge. 112 */ 113 @ViewDebug.ExportedProperty 114 public int x; 115 116 /** 117 * Y position for this window. With the default gravity it is ignored. 118 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides 119 * an offset from the given edge. 120 */ 121 @ViewDebug.ExportedProperty 122 public int y; 123 124 /** 125 * Indicates how much of the extra space will be allocated horizontally 126 * to the view associated with these LayoutParams. Specify 0 if the view 127 * should not be stretched. Otherwise the extra pixels will be pro-rated 128 * among all views whose weight is greater than 0. 129 */ 130 @ViewDebug.ExportedProperty 131 public float horizontalWeight; 132 133 /** 134 * Indicates how much of the extra space will be allocated vertically 135 * to the view associated with these LayoutParams. Specify 0 if the view 136 * should not be stretched. Otherwise the extra pixels will be pro-rated 137 * among all views whose weight is greater than 0. 138 */ 139 @ViewDebug.ExportedProperty 140 public float verticalWeight; 141 142 /** 143 * The general type of window. There are three main classes of 144 * window types: 145 * <ul> 146 * <li> <strong>Application windows</strong> (ranging from 147 * {@link #FIRST_APPLICATION_WINDOW} to 148 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application 149 * windows. For these types of windows, the {@link #token} must be 150 * set to the token of the activity they are a part of (this will 151 * normally be done for you if {@link #token} is null). 152 * <li> <strong>Sub-windows</strong> (ranging from 153 * {@link #FIRST_SUB_WINDOW} to 154 * {@link #LAST_SUB_WINDOW}) are associated with another top-level 155 * window. For these types of windows, the {@link #token} must be 156 * the token of the window it is attached to. 157 * <li> <strong>System windows</strong> (ranging from 158 * {@link #FIRST_SYSTEM_WINDOW} to 159 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for 160 * use by the system for specific purposes. They should not normally 161 * be used by applications, and a special permission is required 162 * to use them. 163 * </ul> 164 * 165 * @see #TYPE_BASE_APPLICATION 166 * @see #TYPE_APPLICATION 167 * @see #TYPE_APPLICATION_STARTING 168 * @see #TYPE_APPLICATION_PANEL 169 * @see #TYPE_APPLICATION_MEDIA 170 * @see #TYPE_APPLICATION_SUB_PANEL 171 * @see #TYPE_APPLICATION_ATTACHED_DIALOG 172 * @see #TYPE_STATUS_BAR 173 * @see #TYPE_SEARCH_BAR 174 * @see #TYPE_PHONE 175 * @see #TYPE_SYSTEM_ALERT 176 * @see #TYPE_KEYGUARD 177 * @see #TYPE_TOAST 178 * @see #TYPE_SYSTEM_OVERLAY 179 * @see #TYPE_PRIORITY_PHONE 180 * @see #TYPE_STATUS_BAR_PANEL 181 * @see #TYPE_SYSTEM_DIALOG 182 * @see #TYPE_KEYGUARD_DIALOG 183 * @see #TYPE_SYSTEM_ERROR 184 * @see #TYPE_INPUT_METHOD 185 * @see #TYPE_INPUT_METHOD_DIALOG 186 */ 187 @ViewDebug.ExportedProperty(mapping = { 188 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"), 189 @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"), 190 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"), 191 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"), 192 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"), 193 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"), 194 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"), 195 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY, to = "TYPE_APPLICATION_MEDIA_OVERLAY"), 196 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"), 197 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"), 198 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"), 199 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"), 200 @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"), 201 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"), 202 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"), 203 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"), 204 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"), 205 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"), 206 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"), 207 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"), 208 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"), 209 @ViewDebug.IntToString(from = TYPE_WALLPAPER, to = "TYPE_WALLPAPER"), 210 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"), 211 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY"), 212 @ViewDebug.IntToString(from = TYPE_DRAG, to = "TYPE_DRAG"), 213 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, to = "TYPE_STATUS_BAR_SUB_PANEL"), 214 @ViewDebug.IntToString(from = TYPE_POINTER, to = "TYPE_POINTER"), 215 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR, to = "TYPE_NAVIGATION_BAR"), 216 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY, to = "TYPE_VOLUME_OVERLAY"), 217 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, to = "TYPE_BOOT_PROGRESS"), 218 @ViewDebug.IntToString(from = TYPE_HIDDEN_NAV_CONSUMER, to = "TYPE_HIDDEN_NAV_CONSUMER"), 219 @ViewDebug.IntToString(from = TYPE_DREAM, to = "TYPE_DREAM"), 220 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL, to = "TYPE_NAVIGATION_BAR_PANEL"), 221 @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY, to = "TYPE_DISPLAY_OVERLAY"), 222 @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY, to = "TYPE_MAGNIFICATION_OVERLAY") 223 }) 224 public int type; 225 226 /** 227 * Start of window types that represent normal application windows. 228 */ 229 public static final int FIRST_APPLICATION_WINDOW = 1; 230 231 /** 232 * Window type: an application window that serves as the "base" window 233 * of the overall application; all other application windows will 234 * appear on top of it. 235 * In multiuser systems shows only on the owning user's window. 236 */ 237 public static final int TYPE_BASE_APPLICATION = 1; 238 239 /** 240 * Window type: a normal application window. The {@link #token} must be 241 * an Activity token identifying who the window belongs to. 242 * In multiuser systems shows only on the owning user's window. 243 */ 244 public static final int TYPE_APPLICATION = 2; 245 246 /** 247 * Window type: special application window that is displayed while the 248 * application is starting. Not for use by applications themselves; 249 * this is used by the system to display something until the 250 * application can show its own windows. 251 * In multiuser systems shows on all users' windows. 252 */ 253 public static final int TYPE_APPLICATION_STARTING = 3; 254 255 /** 256 * End of types of application windows. 257 */ 258 public static final int LAST_APPLICATION_WINDOW = 99; 259 260 /** 261 * Start of types of sub-windows. The {@link #token} of these windows 262 * must be set to the window they are attached to. These types of 263 * windows are kept next to their attached window in Z-order, and their 264 * coordinate space is relative to their attached window. 265 */ 266 public static final int FIRST_SUB_WINDOW = 1000; 267 268 /** 269 * Window type: a panel on top of an application window. These windows 270 * appear on top of their attached window. 271 */ 272 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW; 273 274 /** 275 * Window type: window for showing media (e.g. video). These windows 276 * are displayed behind their attached window. 277 */ 278 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1; 279 280 /** 281 * Window type: a sub-panel on top of an application window. These 282 * windows are displayed on top their attached window and any 283 * {@link #TYPE_APPLICATION_PANEL} panels. 284 */ 285 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2; 286 287 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout 288 * of the window happens as that of a top-level window, <em>not</em> 289 * as a child of its container. 290 */ 291 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3; 292 293 /** 294 * Window type: window for showing overlays on top of media windows. 295 * These windows are displayed between TYPE_APPLICATION_MEDIA and the 296 * application window. They should be translucent to be useful. This 297 * is a big ugly hack so: 298 * @hide 299 */ 300 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4; 301 302 /** 303 * End of types of sub-windows. 304 */ 305 public static final int LAST_SUB_WINDOW = 1999; 306 307 /** 308 * Start of system-specific window types. These are not normally 309 * created by applications. 310 */ 311 public static final int FIRST_SYSTEM_WINDOW = 2000; 312 313 /** 314 * Window type: the status bar. There can be only one status bar 315 * window; it is placed at the top of the screen, and all other 316 * windows are shifted down so they are below it. 317 * In multiuser systems shows on all users' windows. 318 */ 319 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; 320 321 /** 322 * Window type: the search bar. There can be only one search bar 323 * window; it is placed at the top of the screen. 324 * In multiuser systems shows on all users' windows. 325 */ 326 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; 327 328 /** 329 * Window type: phone. These are non-application windows providing 330 * user interaction with the phone (in particular incoming calls). 331 * These windows are normally placed above all applications, but behind 332 * the status bar. 333 * In multiuser systems shows on all users' windows. 334 */ 335 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; 336 337 /** 338 * Window type: system window, such as low power alert. These windows 339 * are always on top of application windows. 340 * In multiuser systems shows only on the owning user's window. 341 */ 342 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; 343 344 /** 345 * Window type: keyguard window. 346 * In multiuser systems shows on all users' windows. 347 */ 348 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; 349 350 /** 351 * Window type: transient notifications. 352 * In multiuser systems shows only on the owning user's window. 353 */ 354 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; 355 356 /** 357 * Window type: system overlay windows, which need to be displayed 358 * on top of everything else. These windows must not take input 359 * focus, or they will interfere with the keyguard. 360 * In multiuser systems shows only on the owning user's window. 361 */ 362 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; 363 364 /** 365 * Window type: priority phone UI, which needs to be displayed even if 366 * the keyguard is active. These windows must not take input 367 * focus, or they will interfere with the keyguard. 368 * In multiuser systems shows on all users' windows. 369 */ 370 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; 371 372 /** 373 * Window type: panel that slides out from the status bar 374 * In multiuser systems shows on all users' windows. 375 */ 376 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; 377 378 /** 379 * Window type: dialogs that the keyguard shows 380 * In multiuser systems shows on all users' windows. 381 */ 382 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; 383 384 /** 385 * Window type: internal system error windows, appear on top of 386 * everything they can. 387 * In multiuser systems shows only on the owning user's window. 388 */ 389 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; 390 391 /** 392 * Window type: internal input methods windows, which appear above 393 * the normal UI. Application windows may be resized or panned to keep 394 * the input focus visible while this window is displayed. 395 * In multiuser systems shows only on the owning user's window. 396 */ 397 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; 398 399 /** 400 * Window type: internal input methods dialog windows, which appear above 401 * the current input method window. 402 * In multiuser systems shows only on the owning user's window. 403 */ 404 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12; 405 406 /** 407 * Window type: wallpaper window, placed behind any window that wants 408 * to sit on top of the wallpaper. 409 * In multiuser systems shows only on the owning user's window. 410 */ 411 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13; 412 413 /** 414 * Window type: panel that slides out from over the status bar 415 * In multiuser systems shows on all users' windows. 416 */ 417 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14; 418 419 /** 420 * Window type: secure system overlay windows, which need to be displayed 421 * on top of everything else. These windows must not take input 422 * focus, or they will interfere with the keyguard. 423 * 424 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the 425 * system itself is allowed to create these overlays. Applications cannot 426 * obtain permission to create secure system overlays. 427 * 428 * In multiuser systems shows only on the owning user's window. 429 * @hide 430 */ 431 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15; 432 433 /** 434 * Window type: the drag-and-drop pseudowindow. There is only one 435 * drag layer (at most), and it is placed on top of all other windows. 436 * In multiuser systems shows only on the owning user's window. 437 * @hide 438 */ 439 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16; 440 441 /** 442 * Window type: panel that slides out from under the status bar 443 * In multiuser systems shows on all users' windows. 444 * @hide 445 */ 446 public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17; 447 448 /** 449 * Window type: (mouse) pointer 450 * In multiuser systems shows on all users' windows. 451 * @hide 452 */ 453 public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18; 454 455 /** 456 * Window type: Navigation bar (when distinct from status bar) 457 * In multiuser systems shows on all users' windows. 458 * @hide 459 */ 460 public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19; 461 462 /** 463 * Window type: The volume level overlay/dialog shown when the user 464 * changes the system volume. 465 * In multiuser systems shows on all users' windows. 466 * @hide 467 */ 468 public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20; 469 470 /** 471 * Window type: The boot progress dialog, goes on top of everything 472 * in the world. 473 * In multiuser systems shows on all users' windows. 474 * @hide 475 */ 476 public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21; 477 478 /** 479 * Window type: Fake window to consume touch events when the navigation 480 * bar is hidden. 481 * In multiuser systems shows on all users' windows. 482 * @hide 483 */ 484 public static final int TYPE_HIDDEN_NAV_CONSUMER = FIRST_SYSTEM_WINDOW+22; 485 486 /** 487 * Window type: Dreams (screen saver) window, just above keyguard. 488 * In multiuser systems shows only on the owning user's window. 489 * @hide 490 */ 491 public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23; 492 493 /** 494 * Window type: Navigation bar panel (when navigation bar is distinct from status bar) 495 * In multiuser systems shows on all users' windows. 496 * @hide 497 */ 498 public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24; 499 500 /** 501 * Window type: Behind the universe of the real windows. 502 * In multiuser systems shows on all users' windows. 503 * @hide 504 */ 505 public static final int TYPE_UNIVERSE_BACKGROUND = FIRST_SYSTEM_WINDOW+25; 506 507 /** 508 * Window type: Display overlay window. Used to simulate secondary display devices. 509 * In multiuser systems shows on all users' windows. 510 * @hide 511 */ 512 public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26; 513 514 /** 515 * Window type: Magnification overlay window. Used to highlight the magnified 516 * portion of a display when accessibility magnification is enabled. 517 * In multiuser systems shows on all users' windows. 518 * @hide 519 */ 520 public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27; 521 522 /** 523 * Window type: Recents. Same layer as {@link #TYPE_SYSTEM_DIALOG} but only appears on 524 * one user's screen. 525 * In multiuser systems shows on all users' windows. 526 * @hide 527 */ 528 public static final int TYPE_RECENTS_OVERLAY = FIRST_SYSTEM_WINDOW+28; 529 530 /** 531 * End of types of system windows. 532 */ 533 public static final int LAST_SYSTEM_WINDOW = 2999; 534 535 /** @deprecated this is ignored, this value is set automatically when needed. */ 536 @Deprecated 537 public static final int MEMORY_TYPE_NORMAL = 0; 538 /** @deprecated this is ignored, this value is set automatically when needed. */ 539 @Deprecated 540 public static final int MEMORY_TYPE_HARDWARE = 1; 541 /** @deprecated this is ignored, this value is set automatically when needed. */ 542 @Deprecated 543 public static final int MEMORY_TYPE_GPU = 2; 544 /** @deprecated this is ignored, this value is set automatically when needed. */ 545 @Deprecated 546 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; 547 548 /** 549 * @deprecated this is ignored 550 */ 551 @Deprecated 552 public int memoryType; 553 554 /** Window flag: as long as this window is visible to the user, allow 555 * the lock screen to activate while the screen is on. 556 * This can be used independently, or in combination with 557 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */ 558 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; 559 560 /** Window flag: everything behind this window will be dimmed. 561 * Use {@link #dimAmount} to control the amount of dim. */ 562 public static final int FLAG_DIM_BEHIND = 0x00000002; 563 564 /** Window flag: blur everything behind this window. 565 * @deprecated Blurring is no longer supported. */ 566 @Deprecated 567 public static final int FLAG_BLUR_BEHIND = 0x00000004; 568 569 /** Window flag: this window won't ever get key input focus, so the 570 * user can not send key or other button events to it. Those will 571 * instead go to whatever focusable window is behind it. This flag 572 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that 573 * is explicitly set. 574 * 575 * <p>Setting this flag also implies that the window will not need to 576 * interact with 577 * a soft input method, so it will be Z-ordered and positioned 578 * independently of any active input method (typically this means it 579 * gets Z-ordered on top of the input method, so it can use the full 580 * screen for its content and cover the input method if needed. You 581 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ 582 public static final int FLAG_NOT_FOCUSABLE = 0x00000008; 583 584 /** Window flag: this window can never receive touch events. */ 585 public static final int FLAG_NOT_TOUCHABLE = 0x00000010; 586 587 /** Window flag: Even when this window is focusable (its 588 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events 589 * outside of the window to be sent to the windows behind it. Otherwise 590 * it will consume all pointer events itself, regardless of whether they 591 * are inside of the window. */ 592 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; 593 594 /** Window flag: When set, if the device is asleep when the touch 595 * screen is pressed, you will receive this first touch event. Usually 596 * the first touch event is consumed by the system since the user can 597 * not see what they are pressing on. 598 */ 599 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; 600 601 /** Window flag: as long as this window is visible to the user, keep 602 * the device's screen turned on and bright. */ 603 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; 604 605 /** Window flag: place the window within the entire screen, ignoring 606 * decorations around the border (a.k.a. the status bar). The 607 * window must correctly position its contents to take the screen 608 * decoration into account. This flag is normally set for you 609 * by Window as described in {@link Window#setFlags}. */ 610 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; 611 612 /** Window flag: allow window to extend outside of the screen. */ 613 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; 614 615 /** Window flag: Hide all screen decorations (e.g. status bar) while 616 * this window is displayed. This allows the window to use the entire 617 * display space for itself -- the status bar will be hidden when 618 * an app window with this flag set is on the top layer. */ 619 public static final int FLAG_FULLSCREEN = 0x00000400; 620 621 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the 622 * screen decorations (such as status bar) to be shown. */ 623 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; 624 625 /** Window flag: turn on dithering when compositing this window to 626 * the screen. 627 * @deprecated This flag is no longer used. */ 628 @Deprecated 629 public static final int FLAG_DITHER = 0x00001000; 630 631 /** Window flag: Treat the content of the window as secure, preventing 632 * it from appearing in screenshots or from being viewed on non-secure 633 * displays. 634 * 635 * <p>See {@link android.view.Display#FLAG_SECURE} for more details about 636 * secure surfaces and secure displays. 637 */ 638 public static final int FLAG_SECURE = 0x00002000; 639 640 /** Window flag: a special mode where the layout parameters are used 641 * to perform scaling of the surface when it is composited to the 642 * screen. */ 643 public static final int FLAG_SCALED = 0x00004000; 644 645 /** Window flag: intended for windows that will often be used when the user is 646 * holding the screen against their face, it will aggressively filter the event 647 * stream to prevent unintended presses in this situation that may not be 648 * desired for a particular window, when such an event stream is detected, the 649 * application will receive a CANCEL motion event to indicate this so applications 650 * can handle this accordingly by taking no action on the event 651 * until the finger is released. */ 652 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; 653 654 /** Window flag: a special option only for use in combination with 655 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the 656 * screen your window may appear on top of or behind screen decorations 657 * such as the status bar. By also including this flag, the window 658 * manager will report the inset rectangle needed to ensure your 659 * content is not covered by screen decorations. This flag is normally 660 * set for you by Window as described in {@link Window#setFlags}.*/ 661 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; 662 663 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with 664 * respect to how this window interacts with the current method. That 665 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the 666 * window will behave as if it needs to interact with the input method 667 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is 668 * not set and this flag is set, then the window will behave as if it 669 * doesn't need to interact with the input method and can be placed 670 * to use more space and cover the input method. 671 */ 672 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; 673 674 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you 675 * can set this flag to receive a single special MotionEvent with 676 * the action 677 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for 678 * touches that occur outside of your window. Note that you will not 679 * receive the full down/move/up gesture, only the location of the 680 * first down as an ACTION_OUTSIDE. 681 */ 682 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; 683 684 /** Window flag: special flag to let windows be shown when the screen 685 * is locked. This will let application windows take precedence over 686 * key guard or any other lock screens. Can be used with 687 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows 688 * directly before showing the key guard window. Can be used with 689 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss 690 * non-secure keyguards. This flag only applies to the top-most 691 * full-screen window. 692 */ 693 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; 694 695 /** Window flag: ask that the system wallpaper be shown behind 696 * your window. The window surface must be translucent to be able 697 * to actually see the wallpaper behind it; this flag just ensures 698 * that the wallpaper surface will be there if this window actually 699 * has translucent regions. 700 */ 701 public static final int FLAG_SHOW_WALLPAPER = 0x00100000; 702 703 /** Window flag: when set as a window is being added or made 704 * visible, once the window has been shown then the system will 705 * poke the power manager's user activity (as if the user had woken 706 * up the device) to turn the screen on. */ 707 public static final int FLAG_TURN_SCREEN_ON = 0x00200000; 708 709 /** Window flag: when set the window will cause the keyguard to 710 * be dismissed, only if it is not a secure lock keyguard. Because such 711 * a keyguard is not needed for security, it will never re-appear if 712 * the user navigates to another window (in contrast to 713 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily 714 * hide both secure and non-secure keyguards but ensure they reappear 715 * when the user moves to another UI that doesn't hide them). 716 * If the keyguard is currently active and is secure (requires an 717 * unlock pattern) than the user will still need to confirm it before 718 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has 719 * also been set. 720 */ 721 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000; 722 723 /** Window flag: when set the window will accept for touch events 724 * outside of its bounds to be sent to other windows that also 725 * support split touch. When this flag is not set, the first pointer 726 * that goes down determines the window to which all subsequent touches 727 * go until all pointers go up. When this flag is set, each pointer 728 * (not necessarily the first) that goes down determines the window 729 * to which all subsequent touches of that pointer will go until that 730 * pointer goes up thereby enabling touches with multiple pointers 731 * to be split across multiple windows. 732 */ 733 public static final int FLAG_SPLIT_TOUCH = 0x00800000; 734 735 /** 736 * <p>Indicates whether this window should be hardware accelerated. 737 * Requesting hardware acceleration does not guarantee it will happen.</p> 738 * 739 * <p>This flag can be controlled programmatically <em>only</em> to enable 740 * hardware acceleration. To enable hardware acceleration for a given 741 * window programmatically, do the following:</p> 742 * 743 * <pre> 744 * Window w = activity.getWindow(); // in Activity's onCreate() for instance 745 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 746 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); 747 * </pre> 748 * 749 * <p>It is important to remember that this flag <strong>must</strong> 750 * be set before setting the content view of your activity or dialog.</p> 751 * 752 * <p>This flag cannot be used to disable hardware acceleration after it 753 * was enabled in your manifest using 754 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively 755 * and programmatically disable hardware acceleration (for automated testing 756 * for instance), make sure it is turned off in your manifest and enable it 757 * on your activity or dialog when you need it instead, using the method 758 * described above.</p> 759 * 760 * <p>This flag is automatically set by the system if the 761 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} 762 * XML attribute is set to true on an activity or on the application.</p> 763 */ 764 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000; 765 766 // ----- HIDDEN FLAGS. 767 // These start at the high bit and go down. 768 769 /** Window flag: Enable touches to slide out of a window into neighboring 770 * windows in mid-gesture instead of being captured for the duration of 771 * the gesture. 772 * 773 * This flag changes the behavior of touch focus for this window only. 774 * Touches can slide out of the window but they cannot necessarily slide 775 * back in (unless the other window with touch focus permits it). 776 * 777 * {@hide} 778 */ 779 public static final int FLAG_SLIPPERY = 0x04000000; 780 781 /** 782 * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU} 783 * and therefore needs a Menu key. For devices where Menu is a physical button this flag is 784 * ignored, but on devices where the Menu key is drawn in software it may be hidden unless 785 * this flag is set. 786 * 787 * (Note that Action Bars, when available, are the preferred way to offer additional 788 * functions otherwise accessed via an options menu.) 789 * 790 * {@hide} 791 */ 792 public static final int FLAG_NEEDS_MENU_KEY = 0x08000000; 793 794 /** Window flag: special flag to limit the size of the window to be 795 * original size ([320x480] x density). Used to create window for applications 796 * running under compatibility mode. 797 * 798 * {@hide} */ 799 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000; 800 801 /** Window flag: a special option intended for system dialogs. When 802 * this flag is set, the window will demand focus unconditionally when 803 * it is created. 804 * {@hide} */ 805 public static final int FLAG_SYSTEM_ERROR = 0x40000000; 806 807 /** 808 * Various behavioral options/flags. Default is none. 809 * 810 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON 811 * @see #FLAG_DIM_BEHIND 812 * @see #FLAG_NOT_FOCUSABLE 813 * @see #FLAG_NOT_TOUCHABLE 814 * @see #FLAG_NOT_TOUCH_MODAL 815 * @see #FLAG_TOUCHABLE_WHEN_WAKING 816 * @see #FLAG_KEEP_SCREEN_ON 817 * @see #FLAG_LAYOUT_IN_SCREEN 818 * @see #FLAG_LAYOUT_NO_LIMITS 819 * @see #FLAG_FULLSCREEN 820 * @see #FLAG_FORCE_NOT_FULLSCREEN 821 * @see #FLAG_SECURE 822 * @see #FLAG_SCALED 823 * @see #FLAG_IGNORE_CHEEK_PRESSES 824 * @see #FLAG_LAYOUT_INSET_DECOR 825 * @see #FLAG_ALT_FOCUSABLE_IM 826 * @see #FLAG_WATCH_OUTSIDE_TOUCH 827 * @see #FLAG_SHOW_WHEN_LOCKED 828 * @see #FLAG_SHOW_WALLPAPER 829 * @see #FLAG_TURN_SCREEN_ON 830 * @see #FLAG_DISMISS_KEYGUARD 831 * @see #FLAG_SPLIT_TOUCH 832 * @see #FLAG_HARDWARE_ACCELERATED 833 */ 834 @ViewDebug.ExportedProperty(flagMapping = { 835 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, 836 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"), 837 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND, 838 name = "FLAG_DIM_BEHIND"), 839 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND, 840 name = "FLAG_BLUR_BEHIND"), 841 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE, 842 name = "FLAG_NOT_FOCUSABLE"), 843 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE, 844 name = "FLAG_NOT_TOUCHABLE"), 845 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL, 846 name = "FLAG_NOT_TOUCH_MODAL"), 847 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING, 848 name = "FLAG_TOUCHABLE_WHEN_WAKING"), 849 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON, 850 name = "FLAG_KEEP_SCREEN_ON"), 851 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN, 852 name = "FLAG_LAYOUT_IN_SCREEN"), 853 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS, 854 name = "FLAG_LAYOUT_NO_LIMITS"), 855 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN, 856 name = "FLAG_FULLSCREEN"), 857 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN, 858 name = "FLAG_FORCE_NOT_FULLSCREEN"), 859 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER, 860 name = "FLAG_DITHER"), 861 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE, 862 name = "FLAG_SECURE"), 863 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED, 864 name = "FLAG_SCALED"), 865 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES, 866 name = "FLAG_IGNORE_CHEEK_PRESSES"), 867 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR, 868 name = "FLAG_LAYOUT_INSET_DECOR"), 869 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM, 870 name = "FLAG_ALT_FOCUSABLE_IM"), 871 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH, 872 name = "FLAG_WATCH_OUTSIDE_TOUCH"), 873 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED, 874 name = "FLAG_SHOW_WHEN_LOCKED"), 875 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER, 876 name = "FLAG_SHOW_WALLPAPER"), 877 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON, 878 name = "FLAG_TURN_SCREEN_ON"), 879 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD, 880 name = "FLAG_DISMISS_KEYGUARD"), 881 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH, 882 name = "FLAG_SPLIT_TOUCH"), 883 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED, 884 name = "FLAG_HARDWARE_ACCELERATED") 885 }) 886 public int flags; 887 888 /** 889 * If the window has requested hardware acceleration, but this is not 890 * allowed in the process it is in, then still render it as if it is 891 * hardware accelerated. This is used for the starting preview windows 892 * in the system process, which don't need to have the overhead of 893 * hardware acceleration (they are just a static rendering), but should 894 * be rendered as such to match the actual window of the app even if it 895 * is hardware accelerated. 896 * Even if the window isn't hardware accelerated, still do its rendering 897 * as if it was. 898 * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows 899 * that need hardware acceleration (e.g. LockScreen), where hardware acceleration 900 * is generally disabled. This flag must be specified in addition to 901 * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system 902 * windows. 903 * 904 * @hide 905 */ 906 public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001; 907 908 /** 909 * In the system process, we globally do not use hardware acceleration 910 * because there are many threads doing UI there and they conflict. 911 * If certain parts of the UI that really do want to use hardware 912 * acceleration, this flag can be set to force it. This is basically 913 * for the lock screen. Anyone else using it, you are probably wrong. 914 * 915 * @hide 916 */ 917 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002; 918 919 /** 920 * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers 921 * may elect to skip these notifications if they are not doing anything productive with 922 * them (they do not affect the wallpaper scrolling operation) by calling 923 * {@link 924 * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}. 925 * 926 * @hide 927 */ 928 public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004; 929 930 /** 931 * This is set for a window that has explicitly specified its 932 * FLAG_NEEDS_MENU_KEY, so we know the value on this window is the 933 * appropriate one to use. If this is not set, we should look at 934 * windows behind it to determine the appropriate value. 935 * 936 * @hide 937 */ 938 public static final int PRIVATE_FLAG_SET_NEEDS_MENU_KEY = 0x00000008; 939 940 /** In a multiuser system if this flag is set and the owner is a system process then this 941 * window will appear on all user screens. This overrides the default behavior of window 942 * types that normally only appear on the owning user's screen. Refer to each window type 943 * to determine its default behavior. 944 * 945 * {@hide} */ 946 public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010; 947 948 /** 949 * Special flag for the volume overlay: force the window manager out of "hide nav bar" 950 * mode while the window is on screen. 951 * 952 * {@hide} */ 953 public static final int PRIVATE_FLAG_FORCE_SHOW_NAV_BAR = 0x00000020; 954 955 /** 956 * Control flags that are private to the platform. 957 * @hide 958 */ 959 public int privateFlags; 960 961 /** 962 * Given a particular set of window manager flags, determine whether 963 * such a window may be a target for an input method when it has 964 * focus. In particular, this checks the 965 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} 966 * flags and returns true if the combination of the two corresponds 967 * to a window that needs to be behind the input method so that the 968 * user can type into it. 969 * 970 * @param flags The current window manager flags. 971 * 972 * @return Returns true if such a window should be behind/interact 973 * with an input method, false if not. 974 */ mayUseInputMethod(int flags)975 public static boolean mayUseInputMethod(int flags) { 976 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { 977 case 0: 978 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM: 979 return true; 980 } 981 return false; 982 } 983 984 /** 985 * Mask for {@link #softInputMode} of the bits that determine the 986 * desired visibility state of the soft input area for this window. 987 */ 988 public static final int SOFT_INPUT_MASK_STATE = 0x0f; 989 990 /** 991 * Visibility state for {@link #softInputMode}: no state has been specified. 992 */ 993 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; 994 995 /** 996 * Visibility state for {@link #softInputMode}: please don't change the state of 997 * the soft input area. 998 */ 999 public static final int SOFT_INPUT_STATE_UNCHANGED = 1; 1000 1001 /** 1002 * Visibility state for {@link #softInputMode}: please hide any soft input 1003 * area when normally appropriate (when the user is navigating 1004 * forward to your window). 1005 */ 1006 public static final int SOFT_INPUT_STATE_HIDDEN = 2; 1007 1008 /** 1009 * Visibility state for {@link #softInputMode}: please always hide any 1010 * soft input area when this window receives focus. 1011 */ 1012 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; 1013 1014 /** 1015 * Visibility state for {@link #softInputMode}: please show the soft 1016 * input area when normally appropriate (when the user is navigating 1017 * forward to your window). 1018 */ 1019 public static final int SOFT_INPUT_STATE_VISIBLE = 4; 1020 1021 /** 1022 * Visibility state for {@link #softInputMode}: please always make the 1023 * soft input area visible when this window receives input focus. 1024 */ 1025 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; 1026 1027 /** 1028 * Mask for {@link #softInputMode} of the bits that determine the 1029 * way that the window should be adjusted to accommodate the soft 1030 * input window. 1031 */ 1032 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; 1033 1034 /** Adjustment option for {@link #softInputMode}: nothing specified. 1035 * The system will try to pick one or 1036 * the other depending on the contents of the window. 1037 */ 1038 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; 1039 1040 /** Adjustment option for {@link #softInputMode}: set to allow the 1041 * window to be resized when an input 1042 * method is shown, so that its contents are not covered by the input 1043 * method. This can <em>not</em> be combined with 1044 * {@link #SOFT_INPUT_ADJUST_PAN}; if 1045 * neither of these are set, then the system will try to pick one or 1046 * the other depending on the contents of the window. 1047 */ 1048 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; 1049 1050 /** Adjustment option for {@link #softInputMode}: set to have a window 1051 * pan when an input method is 1052 * shown, so it doesn't need to deal with resizing but just panned 1053 * by the framework to ensure the current input focus is visible. This 1054 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if 1055 * neither of these are set, then the system will try to pick one or 1056 * the other depending on the contents of the window. 1057 */ 1058 public static final int SOFT_INPUT_ADJUST_PAN = 0x20; 1059 1060 /** Adjustment option for {@link #softInputMode}: set to have a window 1061 * not adjust for a shown input method. The window will not be resized, 1062 * and it will not be panned to make its focus visible. 1063 */ 1064 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30; 1065 1066 /** 1067 * Bit for {@link #softInputMode}: set when the user has navigated 1068 * forward to the window. This is normally set automatically for 1069 * you by the system, though you may want to set it in certain cases 1070 * when you are displaying a window yourself. This flag will always 1071 * be cleared automatically after the window is displayed. 1072 */ 1073 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; 1074 1075 /** 1076 * Desired operating mode for any soft input area. May be any combination 1077 * of: 1078 * 1079 * <ul> 1080 * <li> One of the visibility states 1081 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, 1082 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or 1083 * {@link #SOFT_INPUT_STATE_VISIBLE}. 1084 * <li> One of the adjustment options 1085 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, 1086 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or 1087 * {@link #SOFT_INPUT_ADJUST_PAN}. 1088 */ 1089 public int softInputMode; 1090 1091 /** 1092 * Placement of window within the screen as per {@link Gravity}. Both 1093 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1094 * android.graphics.Rect) Gravity.apply} and 1095 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 1096 * Gravity.applyDisplay} are used during window layout, with this value 1097 * given as the desired gravity. For example you can specify 1098 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and 1099 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here 1100 * to control the behavior of 1101 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 1102 * Gravity.applyDisplay}. 1103 * 1104 * @see Gravity 1105 */ 1106 public int gravity; 1107 1108 /** 1109 * The horizontal margin, as a percentage of the container's width, 1110 * between the container and the widget. See 1111 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1112 * android.graphics.Rect) Gravity.apply} for how this is used. This 1113 * field is added with {@link #x} to supply the <var>xAdj</var> parameter. 1114 */ 1115 public float horizontalMargin; 1116 1117 /** 1118 * The vertical margin, as a percentage of the container's height, 1119 * between the container and the widget. See 1120 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1121 * android.graphics.Rect) Gravity.apply} for how this is used. This 1122 * field is added with {@link #y} to supply the <var>yAdj</var> parameter. 1123 */ 1124 public float verticalMargin; 1125 1126 /** 1127 * The desired bitmap format. May be one of the constants in 1128 * {@link android.graphics.PixelFormat}. Default is OPAQUE. 1129 */ 1130 public int format; 1131 1132 /** 1133 * A style resource defining the animations to use for this window. 1134 * This must be a system resource; it can not be an application resource 1135 * because the window manager does not have access to applications. 1136 */ 1137 public int windowAnimations; 1138 1139 /** 1140 * An alpha value to apply to this entire window. 1141 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent 1142 */ 1143 public float alpha = 1.0f; 1144 1145 /** 1146 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming 1147 * to apply. Range is from 1.0 for completely opaque to 0.0 for no 1148 * dim. 1149 */ 1150 public float dimAmount = 1.0f; 1151 1152 /** 1153 * Default value for {@link #screenBrightness} and {@link #buttonBrightness} 1154 * indicating that the brightness value is not overridden for this window 1155 * and normal brightness policy should be used. 1156 */ 1157 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f; 1158 1159 /** 1160 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 1161 * indicating that the screen or button backlight brightness should be set 1162 * to the lowest value when this window is in front. 1163 */ 1164 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f; 1165 1166 /** 1167 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 1168 * indicating that the screen or button backlight brightness should be set 1169 * to the hightest value when this window is in front. 1170 */ 1171 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f; 1172 1173 /** 1174 * This can be used to override the user's preferred brightness of 1175 * the screen. A value of less than 0, the default, means to use the 1176 * preferred screen brightness. 0 to 1 adjusts the brightness from 1177 * dark to full bright. 1178 */ 1179 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE; 1180 1181 /** 1182 * This can be used to override the standard behavior of the button and 1183 * keyboard backlights. A value of less than 0, the default, means to 1184 * use the standard backlight behavior. 0 to 1 adjusts the brightness 1185 * from dark to full bright. 1186 */ 1187 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; 1188 1189 /** 1190 * Identifier for this window. This will usually be filled in for 1191 * you. 1192 */ 1193 public IBinder token = null; 1194 1195 /** 1196 * Name of the package owning this window. 1197 */ 1198 public String packageName = null; 1199 1200 /** 1201 * Specific orientation value for a window. 1202 * May be any of the same values allowed 1203 * for {@link android.content.pm.ActivityInfo#screenOrientation}. 1204 * If not set, a default value of 1205 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} 1206 * will be used. 1207 */ 1208 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; 1209 1210 /** 1211 * Control the visibility of the status bar. 1212 * 1213 * @see View#STATUS_BAR_VISIBLE 1214 * @see View#STATUS_BAR_HIDDEN 1215 */ 1216 public int systemUiVisibility; 1217 1218 /** 1219 * @hide 1220 * The ui visibility as requested by the views in this hierarchy. 1221 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility. 1222 */ 1223 public int subtreeSystemUiVisibility; 1224 1225 /** 1226 * Get callbacks about the system ui visibility changing. 1227 * 1228 * TODO: Maybe there should be a bitfield of optional callbacks that we need. 1229 * 1230 * @hide 1231 */ 1232 public boolean hasSystemUiListeners; 1233 1234 /** 1235 * When this window has focus, disable touch pad pointer gesture processing. 1236 * The window will receive raw position updates from the touch pad instead 1237 * of pointer movements and synthetic touch events. 1238 * 1239 * @hide 1240 */ 1241 public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001; 1242 1243 /** 1244 * Does not construct an input channel for this window. The channel will therefore 1245 * be incapable of receiving input. 1246 * 1247 * @hide 1248 */ 1249 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002; 1250 1251 /** 1252 * When this window has focus, does not call user activity for all input events so 1253 * the application will have to do it itself. Should only be used by 1254 * the keyguard and phone app. 1255 * <p> 1256 * Should only be used by the keyguard and phone app. 1257 * </p> 1258 * 1259 * @hide 1260 */ 1261 public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004; 1262 1263 /** 1264 * Control special features of the input subsystem. 1265 * 1266 * @see #INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES 1267 * @see #INPUT_FEATURE_NO_INPUT_CHANNEL 1268 * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY 1269 * @hide 1270 */ 1271 public int inputFeatures; 1272 1273 /** 1274 * Sets the number of milliseconds before the user activity timeout occurs 1275 * when this window has focus. A value of -1 uses the standard timeout. 1276 * A value of 0 uses the minimum support display timeout. 1277 * <p> 1278 * This property can only be used to reduce the user specified display timeout; 1279 * it can never make the timeout longer than it normally would be. 1280 * </p><p> 1281 * Should only be used by the keyguard and phone app. 1282 * </p> 1283 * 1284 * @hide 1285 */ 1286 public long userActivityTimeout = -1; 1287 LayoutParams()1288 public LayoutParams() { 1289 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1290 type = TYPE_APPLICATION; 1291 format = PixelFormat.OPAQUE; 1292 } 1293 LayoutParams(int _type)1294 public LayoutParams(int _type) { 1295 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1296 type = _type; 1297 format = PixelFormat.OPAQUE; 1298 } 1299 LayoutParams(int _type, int _flags)1300 public LayoutParams(int _type, int _flags) { 1301 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1302 type = _type; 1303 flags = _flags; 1304 format = PixelFormat.OPAQUE; 1305 } 1306 LayoutParams(int _type, int _flags, int _format)1307 public LayoutParams(int _type, int _flags, int _format) { 1308 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1309 type = _type; 1310 flags = _flags; 1311 format = _format; 1312 } 1313 LayoutParams(int w, int h, int _type, int _flags, int _format)1314 public LayoutParams(int w, int h, int _type, int _flags, int _format) { 1315 super(w, h); 1316 type = _type; 1317 flags = _flags; 1318 format = _format; 1319 } 1320 LayoutParams(int w, int h, int xpos, int ypos, int _type, int _flags, int _format)1321 public LayoutParams(int w, int h, int xpos, int ypos, int _type, 1322 int _flags, int _format) { 1323 super(w, h); 1324 x = xpos; 1325 y = ypos; 1326 type = _type; 1327 flags = _flags; 1328 format = _format; 1329 } 1330 setTitle(CharSequence title)1331 public final void setTitle(CharSequence title) { 1332 if (null == title) 1333 title = ""; 1334 1335 mTitle = TextUtils.stringOrSpannedString(title); 1336 } 1337 getTitle()1338 public final CharSequence getTitle() { 1339 return mTitle; 1340 } 1341 describeContents()1342 public int describeContents() { 1343 return 0; 1344 } 1345 writeToParcel(Parcel out, int parcelableFlags)1346 public void writeToParcel(Parcel out, int parcelableFlags) { 1347 out.writeInt(width); 1348 out.writeInt(height); 1349 out.writeInt(x); 1350 out.writeInt(y); 1351 out.writeInt(type); 1352 out.writeInt(flags); 1353 out.writeInt(privateFlags); 1354 out.writeInt(softInputMode); 1355 out.writeInt(gravity); 1356 out.writeFloat(horizontalMargin); 1357 out.writeFloat(verticalMargin); 1358 out.writeInt(format); 1359 out.writeInt(windowAnimations); 1360 out.writeFloat(alpha); 1361 out.writeFloat(dimAmount); 1362 out.writeFloat(screenBrightness); 1363 out.writeFloat(buttonBrightness); 1364 out.writeStrongBinder(token); 1365 out.writeString(packageName); 1366 TextUtils.writeToParcel(mTitle, out, parcelableFlags); 1367 out.writeInt(screenOrientation); 1368 out.writeInt(systemUiVisibility); 1369 out.writeInt(subtreeSystemUiVisibility); 1370 out.writeInt(hasSystemUiListeners ? 1 : 0); 1371 out.writeInt(inputFeatures); 1372 out.writeLong(userActivityTimeout); 1373 } 1374 1375 public static final Parcelable.Creator<LayoutParams> CREATOR 1376 = new Parcelable.Creator<LayoutParams>() { 1377 public LayoutParams createFromParcel(Parcel in) { 1378 return new LayoutParams(in); 1379 } 1380 1381 public LayoutParams[] newArray(int size) { 1382 return new LayoutParams[size]; 1383 } 1384 }; 1385 1386 LayoutParams(Parcel in)1387 public LayoutParams(Parcel in) { 1388 width = in.readInt(); 1389 height = in.readInt(); 1390 x = in.readInt(); 1391 y = in.readInt(); 1392 type = in.readInt(); 1393 flags = in.readInt(); 1394 privateFlags = in.readInt(); 1395 softInputMode = in.readInt(); 1396 gravity = in.readInt(); 1397 horizontalMargin = in.readFloat(); 1398 verticalMargin = in.readFloat(); 1399 format = in.readInt(); 1400 windowAnimations = in.readInt(); 1401 alpha = in.readFloat(); 1402 dimAmount = in.readFloat(); 1403 screenBrightness = in.readFloat(); 1404 buttonBrightness = in.readFloat(); 1405 token = in.readStrongBinder(); 1406 packageName = in.readString(); 1407 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); 1408 screenOrientation = in.readInt(); 1409 systemUiVisibility = in.readInt(); 1410 subtreeSystemUiVisibility = in.readInt(); 1411 hasSystemUiListeners = in.readInt() != 0; 1412 inputFeatures = in.readInt(); 1413 userActivityTimeout = in.readLong(); 1414 } 1415 1416 @SuppressWarnings({"PointlessBitwiseExpression"}) 1417 public static final int LAYOUT_CHANGED = 1<<0; 1418 public static final int TYPE_CHANGED = 1<<1; 1419 public static final int FLAGS_CHANGED = 1<<2; 1420 public static final int FORMAT_CHANGED = 1<<3; 1421 public static final int ANIMATION_CHANGED = 1<<4; 1422 public static final int DIM_AMOUNT_CHANGED = 1<<5; 1423 public static final int TITLE_CHANGED = 1<<6; 1424 public static final int ALPHA_CHANGED = 1<<7; 1425 public static final int MEMORY_TYPE_CHANGED = 1<<8; 1426 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; 1427 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; 1428 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; 1429 /** {@hide} */ 1430 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12; 1431 /** {@hide} */ 1432 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<13; 1433 /** {@hide} */ 1434 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<14; 1435 /** {@hide} */ 1436 public static final int INPUT_FEATURES_CHANGED = 1<<15; 1437 /** {@hide} */ 1438 public static final int PRIVATE_FLAGS_CHANGED = 1<<16; 1439 /** {@hide} */ 1440 public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<17; 1441 /** {@hide} */ 1442 public static final int EVERYTHING_CHANGED = 0xffffffff; 1443 1444 // internal buffer to backup/restore parameters under compatibility mode. 1445 private int[] mCompatibilityParamsBackup = null; 1446 copyFrom(LayoutParams o)1447 public final int copyFrom(LayoutParams o) { 1448 int changes = 0; 1449 1450 if (width != o.width) { 1451 width = o.width; 1452 changes |= LAYOUT_CHANGED; 1453 } 1454 if (height != o.height) { 1455 height = o.height; 1456 changes |= LAYOUT_CHANGED; 1457 } 1458 if (x != o.x) { 1459 x = o.x; 1460 changes |= LAYOUT_CHANGED; 1461 } 1462 if (y != o.y) { 1463 y = o.y; 1464 changes |= LAYOUT_CHANGED; 1465 } 1466 if (horizontalWeight != o.horizontalWeight) { 1467 horizontalWeight = o.horizontalWeight; 1468 changes |= LAYOUT_CHANGED; 1469 } 1470 if (verticalWeight != o.verticalWeight) { 1471 verticalWeight = o.verticalWeight; 1472 changes |= LAYOUT_CHANGED; 1473 } 1474 if (horizontalMargin != o.horizontalMargin) { 1475 horizontalMargin = o.horizontalMargin; 1476 changes |= LAYOUT_CHANGED; 1477 } 1478 if (verticalMargin != o.verticalMargin) { 1479 verticalMargin = o.verticalMargin; 1480 changes |= LAYOUT_CHANGED; 1481 } 1482 if (type != o.type) { 1483 type = o.type; 1484 changes |= TYPE_CHANGED; 1485 } 1486 if (flags != o.flags) { 1487 flags = o.flags; 1488 changes |= FLAGS_CHANGED; 1489 } 1490 if (privateFlags != o.privateFlags) { 1491 privateFlags = o.privateFlags; 1492 changes |= PRIVATE_FLAGS_CHANGED; 1493 } 1494 if (softInputMode != o.softInputMode) { 1495 softInputMode = o.softInputMode; 1496 changes |= SOFT_INPUT_MODE_CHANGED; 1497 } 1498 if (gravity != o.gravity) { 1499 gravity = o.gravity; 1500 changes |= LAYOUT_CHANGED; 1501 } 1502 if (format != o.format) { 1503 format = o.format; 1504 changes |= FORMAT_CHANGED; 1505 } 1506 if (windowAnimations != o.windowAnimations) { 1507 windowAnimations = o.windowAnimations; 1508 changes |= ANIMATION_CHANGED; 1509 } 1510 if (token == null) { 1511 // NOTE: token only copied if the recipient doesn't 1512 // already have one. 1513 token = o.token; 1514 } 1515 if (packageName == null) { 1516 // NOTE: packageName only copied if the recipient doesn't 1517 // already have one. 1518 packageName = o.packageName; 1519 } 1520 if (!mTitle.equals(o.mTitle)) { 1521 mTitle = o.mTitle; 1522 changes |= TITLE_CHANGED; 1523 } 1524 if (alpha != o.alpha) { 1525 alpha = o.alpha; 1526 changes |= ALPHA_CHANGED; 1527 } 1528 if (dimAmount != o.dimAmount) { 1529 dimAmount = o.dimAmount; 1530 changes |= DIM_AMOUNT_CHANGED; 1531 } 1532 if (screenBrightness != o.screenBrightness) { 1533 screenBrightness = o.screenBrightness; 1534 changes |= SCREEN_BRIGHTNESS_CHANGED; 1535 } 1536 if (buttonBrightness != o.buttonBrightness) { 1537 buttonBrightness = o.buttonBrightness; 1538 changes |= BUTTON_BRIGHTNESS_CHANGED; 1539 } 1540 1541 if (screenOrientation != o.screenOrientation) { 1542 screenOrientation = o.screenOrientation; 1543 changes |= SCREEN_ORIENTATION_CHANGED; 1544 } 1545 1546 if (systemUiVisibility != o.systemUiVisibility 1547 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) { 1548 systemUiVisibility = o.systemUiVisibility; 1549 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility; 1550 changes |= SYSTEM_UI_VISIBILITY_CHANGED; 1551 } 1552 1553 if (hasSystemUiListeners != o.hasSystemUiListeners) { 1554 hasSystemUiListeners = o.hasSystemUiListeners; 1555 changes |= SYSTEM_UI_LISTENER_CHANGED; 1556 } 1557 1558 if (inputFeatures != o.inputFeatures) { 1559 inputFeatures = o.inputFeatures; 1560 changes |= INPUT_FEATURES_CHANGED; 1561 } 1562 1563 if (userActivityTimeout != o.userActivityTimeout) { 1564 userActivityTimeout = o.userActivityTimeout; 1565 changes |= USER_ACTIVITY_TIMEOUT_CHANGED; 1566 } 1567 1568 return changes; 1569 } 1570 1571 @Override debug(String output)1572 public String debug(String output) { 1573 output += "Contents of " + this + ":"; 1574 Log.d("Debug", output); 1575 output = super.debug(""); 1576 Log.d("Debug", output); 1577 Log.d("Debug", ""); 1578 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); 1579 return ""; 1580 } 1581 1582 @Override toString()1583 public String toString() { 1584 StringBuilder sb = new StringBuilder(256); 1585 sb.append("WM.LayoutParams{"); 1586 sb.append("("); 1587 sb.append(x); 1588 sb.append(','); 1589 sb.append(y); 1590 sb.append(")("); 1591 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width))); 1592 sb.append('x'); 1593 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height))); 1594 sb.append(")"); 1595 if (horizontalMargin != 0) { 1596 sb.append(" hm="); 1597 sb.append(horizontalMargin); 1598 } 1599 if (verticalMargin != 0) { 1600 sb.append(" vm="); 1601 sb.append(verticalMargin); 1602 } 1603 if (gravity != 0) { 1604 sb.append(" gr=#"); 1605 sb.append(Integer.toHexString(gravity)); 1606 } 1607 if (softInputMode != 0) { 1608 sb.append(" sim=#"); 1609 sb.append(Integer.toHexString(softInputMode)); 1610 } 1611 sb.append(" ty="); 1612 sb.append(type); 1613 sb.append(" fl=#"); 1614 sb.append(Integer.toHexString(flags)); 1615 if (privateFlags != 0) { 1616 sb.append(" pfl=0x").append(Integer.toHexString(privateFlags)); 1617 } 1618 if (format != PixelFormat.OPAQUE) { 1619 sb.append(" fmt="); 1620 sb.append(format); 1621 } 1622 if (windowAnimations != 0) { 1623 sb.append(" wanim=0x"); 1624 sb.append(Integer.toHexString(windowAnimations)); 1625 } 1626 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { 1627 sb.append(" or="); 1628 sb.append(screenOrientation); 1629 } 1630 if (alpha != 1.0f) { 1631 sb.append(" alpha="); 1632 sb.append(alpha); 1633 } 1634 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) { 1635 sb.append(" sbrt="); 1636 sb.append(screenBrightness); 1637 } 1638 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) { 1639 sb.append(" bbrt="); 1640 sb.append(buttonBrightness); 1641 } 1642 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) { 1643 sb.append(" compatible=true"); 1644 } 1645 if (systemUiVisibility != 0) { 1646 sb.append(" sysui=0x"); 1647 sb.append(Integer.toHexString(systemUiVisibility)); 1648 } 1649 if (subtreeSystemUiVisibility != 0) { 1650 sb.append(" vsysui=0x"); 1651 sb.append(Integer.toHexString(subtreeSystemUiVisibility)); 1652 } 1653 if (hasSystemUiListeners) { 1654 sb.append(" sysuil="); 1655 sb.append(hasSystemUiListeners); 1656 } 1657 if (inputFeatures != 0) { 1658 sb.append(" if=0x").append(Integer.toHexString(inputFeatures)); 1659 } 1660 if (userActivityTimeout >= 0) { 1661 sb.append(" userActivityTimeout=").append(userActivityTimeout); 1662 } 1663 sb.append('}'); 1664 return sb.toString(); 1665 } 1666 1667 /** 1668 * Scale the layout params' coordinates and size. 1669 * @hide 1670 */ scale(float scale)1671 public void scale(float scale) { 1672 x = (int) (x * scale + 0.5f); 1673 y = (int) (y * scale + 0.5f); 1674 if (width > 0) { 1675 width = (int) (width * scale + 0.5f); 1676 } 1677 if (height > 0) { 1678 height = (int) (height * scale + 0.5f); 1679 } 1680 } 1681 1682 /** 1683 * Backup the layout parameters used in compatibility mode. 1684 * @see LayoutParams#restore() 1685 */ backup()1686 void backup() { 1687 int[] backup = mCompatibilityParamsBackup; 1688 if (backup == null) { 1689 // we backup 4 elements, x, y, width, height 1690 backup = mCompatibilityParamsBackup = new int[4]; 1691 } 1692 backup[0] = x; 1693 backup[1] = y; 1694 backup[2] = width; 1695 backup[3] = height; 1696 } 1697 1698 /** 1699 * Restore the layout params' coordinates, size and gravity 1700 * @see LayoutParams#backup() 1701 */ restore()1702 void restore() { 1703 int[] backup = mCompatibilityParamsBackup; 1704 if (backup != null) { 1705 x = backup[0]; 1706 y = backup[1]; 1707 width = backup[2]; 1708 height = backup[3]; 1709 } 1710 } 1711 1712 private CharSequence mTitle = ""; 1713 } 1714 } 1715