WindowManager.java revision 8eb2e244f9b14d946ee587d0b673b866865026c0
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 17package android.view; 18 19import android.content.pm.ActivityInfo; 20import android.graphics.PixelFormat; 21import android.os.IBinder; 22import android.os.Parcel; 23import android.os.Parcelable; 24import android.text.TextUtils; 25import android.util.Log; 26 27 28/** 29 * The interface that apps use to talk to the window manager. 30 * <p> 31 * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these. 32 * 33 * @see android.content.Context#getSystemService 34 * @see android.content.Context#WINDOW_SERVICE 35 */ 36public interface WindowManager extends ViewManager { 37 /** 38 * Exception that is thrown when trying to add view whose 39 * {@link WindowManager.LayoutParams} {@link WindowManager.LayoutParams#token} 40 * is invalid. 41 */ 42 public static class BadTokenException extends RuntimeException { 43 public BadTokenException() { 44 } 45 46 public BadTokenException(String name) { 47 super(name); 48 } 49 } 50 51 /** 52 * Use this method to get the default Display object. 53 * 54 * @return default Display object 55 */ 56 public Display getDefaultDisplay(); 57 58 /** 59 * Special variation of {@link #removeView} that immediately invokes 60 * the given view hierarchy's {@link View#onDetachedFromWindow() 61 * View.onDetachedFromWindow()} methods before returning. This is not 62 * for normal applications; using it correctly requires great care. 63 * 64 * @param view The view to be removed. 65 */ 66 public void removeViewImmediate(View view); 67 68 public static class LayoutParams extends ViewGroup.LayoutParams 69 implements Parcelable { 70 /** 71 * X position for this window. With the default gravity it is ignored. 72 * When using {@link Gravity#LEFT} or {@link Gravity#RIGHT} it provides 73 * an offset from the given edge. 74 */ 75 @ViewDebug.ExportedProperty 76 public int x; 77 78 /** 79 * Y position for this window. With the default gravity it is ignored. 80 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides 81 * an offset from the given edge. 82 */ 83 @ViewDebug.ExportedProperty 84 public int y; 85 86 /** 87 * Indicates how much of the extra space will be allocated horizontally 88 * to the view associated with these LayoutParams. Specify 0 if the view 89 * should not be stretched. Otherwise the extra pixels will be pro-rated 90 * among all views whose weight is greater than 0. 91 */ 92 @ViewDebug.ExportedProperty 93 public float horizontalWeight; 94 95 /** 96 * Indicates how much of the extra space will be allocated vertically 97 * to the view associated with these LayoutParams. Specify 0 if the view 98 * should not be stretched. Otherwise the extra pixels will be pro-rated 99 * among all views whose weight is greater than 0. 100 */ 101 @ViewDebug.ExportedProperty 102 public float verticalWeight; 103 104 /** 105 * The general type of window. There are three main classes of 106 * window types: 107 * <ul> 108 * <li> <strong>Application windows</strong> (ranging from 109 * {@link #FIRST_APPLICATION_WINDOW} to 110 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application 111 * windows. For these types of windows, the {@link #token} must be 112 * set to the token of the activity they are a part of (this will 113 * normally be done for you if {@link #token} is null). 114 * <li> <strong>Sub-windows</strong> (ranging from 115 * {@link #FIRST_SUB_WINDOW} to 116 * {@link #LAST_SUB_WINDOW}) are associated with another top-level 117 * window. For these types of windows, the {@link #token} must be 118 * the token of the window it is attached to. 119 * <li> <strong>System windows</strong> (ranging from 120 * {@link #FIRST_SYSTEM_WINDOW} to 121 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for 122 * use by the system for specific purposes. They should not normally 123 * be used by applications, and a special permission is required 124 * to use them. 125 * </ul> 126 * 127 * @see #TYPE_BASE_APPLICATION 128 * @see #TYPE_APPLICATION 129 * @see #TYPE_APPLICATION_STARTING 130 * @see #TYPE_APPLICATION_PANEL 131 * @see #TYPE_APPLICATION_MEDIA 132 * @see #TYPE_APPLICATION_SUB_PANEL 133 * @see #TYPE_APPLICATION_ATTACHED_DIALOG 134 * @see #TYPE_STATUS_BAR 135 * @see #TYPE_SEARCH_BAR 136 * @see #TYPE_PHONE 137 * @see #TYPE_SYSTEM_ALERT 138 * @see #TYPE_KEYGUARD 139 * @see #TYPE_TOAST 140 * @see #TYPE_SYSTEM_OVERLAY 141 * @see #TYPE_PRIORITY_PHONE 142 * @see #TYPE_STATUS_BAR_PANEL 143 * @see #TYPE_SYSTEM_DIALOG 144 * @see #TYPE_KEYGUARD_DIALOG 145 * @see #TYPE_SYSTEM_ERROR 146 * @see #TYPE_INPUT_METHOD 147 * @see #TYPE_INPUT_METHOD_DIALOG 148 */ 149 @ViewDebug.ExportedProperty(mapping = { 150 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"), 151 @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"), 152 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"), 153 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"), 154 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"), 155 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"), 156 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"), 157 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"), 158 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"), 159 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"), 160 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"), 161 @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"), 162 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"), 163 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"), 164 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"), 165 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"), 166 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"), 167 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"), 168 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"), 169 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"), 170 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"), 171 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY") 172 }) 173 public int type; 174 175 /** 176 * Start of window types that represent normal application windows. 177 */ 178 public static final int FIRST_APPLICATION_WINDOW = 1; 179 180 /** 181 * Window type: an application window that serves as the "base" window 182 * of the overall application; all other application windows will 183 * appear on top of it. 184 */ 185 public static final int TYPE_BASE_APPLICATION = 1; 186 187 /** 188 * Window type: a normal application window. The {@link #token} must be 189 * an Activity token identifying who the window belongs to. 190 */ 191 public static final int TYPE_APPLICATION = 2; 192 193 /** 194 * Window type: special application window that is displayed while the 195 * application is starting. Not for use by applications themselves; 196 * this is used by the system to display something until the 197 * application can show its own windows. 198 */ 199 public static final int TYPE_APPLICATION_STARTING = 3; 200 201 /** 202 * End of types of application windows. 203 */ 204 public static final int LAST_APPLICATION_WINDOW = 99; 205 206 /** 207 * Start of types of sub-windows. The {@link #token} of these windows 208 * must be set to the window they are attached to. These types of 209 * windows are kept next to their attached window in Z-order, and their 210 * coordinate space is relative to their attached window. 211 */ 212 public static final int FIRST_SUB_WINDOW = 1000; 213 214 /** 215 * Window type: a panel on top of an application window. These windows 216 * appear on top of their attached window. 217 */ 218 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW; 219 220 /** 221 * Window type: window for showing media (e.g. video). These windows 222 * are displayed behind their attached window. 223 */ 224 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1; 225 226 /** 227 * Window type: a sub-panel on top of an application window. These 228 * windows are displayed on top their attached window and any 229 * {@link #TYPE_APPLICATION_PANEL} panels. 230 */ 231 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2; 232 233 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout 234 * of the window happens as that of a top-level window, <em>not</em> 235 * as a child of its container. 236 */ 237 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3; 238 239 /** 240 * Window type: window for showing overlays on top of media windows. 241 * These windows are displayed between TYPE_APPLICATION_MEDIA and the 242 * application window. They should be translucent to be useful. This 243 * is a big ugly hack so: 244 * @hide 245 */ 246 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4; 247 248 /** 249 * End of types of sub-windows. 250 */ 251 public static final int LAST_SUB_WINDOW = 1999; 252 253 /** 254 * Start of system-specific window types. These are not normally 255 * created by applications. 256 */ 257 public static final int FIRST_SYSTEM_WINDOW = 2000; 258 259 /** 260 * Window type: the status bar. There can be only one status bar 261 * window; it is placed at the top of the screen, and all other 262 * windows are shifted down so they are below it. 263 */ 264 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; 265 266 /** 267 * Window type: the search bar. There can be only one search bar 268 * window; it is placed at the top of the screen. 269 */ 270 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; 271 272 /** 273 * Window type: phone. These are non-application windows providing 274 * user interaction with the phone (in particular incoming calls). 275 * These windows are normally placed above all applications, but behind 276 * the status bar. 277 */ 278 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; 279 280 /** 281 * Window type: system window, such as low power alert. These windows 282 * are always on top of application windows. 283 */ 284 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; 285 286 /** 287 * Window type: keyguard window. 288 */ 289 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; 290 291 /** 292 * Window type: transient notifications. 293 */ 294 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; 295 296 /** 297 * Window type: system overlay windows, which need to be displayed 298 * on top of everything else. These windows must not take input 299 * focus, or they will interfere with the keyguard. 300 */ 301 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; 302 303 /** 304 * Window type: priority phone UI, which needs to be displayed even if 305 * the keyguard is active. These windows must not take input 306 * focus, or they will interfere with the keyguard. 307 */ 308 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; 309 310 /** 311 * Window type: panel that slides out from the status bar 312 */ 313 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; 314 315 /** 316 * Window type: dialogs that the keyguard shows 317 */ 318 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; 319 320 /** 321 * Window type: internal system error windows, appear on top of 322 * everything they can. 323 */ 324 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; 325 326 /** 327 * Window type: internal input methods windows, which appear above 328 * the normal UI. Application windows may be resized or panned to keep 329 * the input focus visible while this window is displayed. 330 */ 331 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; 332 333 /** 334 * Window type: internal input methods dialog windows, which appear above 335 * the current input method window. 336 */ 337 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12; 338 339 /** 340 * Window type: wallpaper window, placed behind any window that wants 341 * to sit on top of the wallpaper. 342 */ 343 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13; 344 345 /** 346 * Window type: panel that slides out from the status bar 347 */ 348 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14; 349 350 /** 351 * Window type: secure system overlay windows, which need to be displayed 352 * on top of everything else. These windows must not take input 353 * focus, or they will interfere with the keyguard. 354 * 355 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the 356 * system itself is allowed to create these overlays. Applications cannot 357 * obtain permission to create secure system overlays. 358 * @hide 359 */ 360 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15; 361 362 /** 363 * Window type: the drag-and-drop pseudowindow. There is only one 364 * drag layer (at most), and it is placed on top of all other windows. 365 * @hide 366 */ 367 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16; 368 369 /** 370 * End of types of system windows. 371 */ 372 public static final int LAST_SYSTEM_WINDOW = 2999; 373 374 /** 375 * Specifies what type of memory buffers should be used by this window. 376 * Default is normal. 377 * 378 * @see #MEMORY_TYPE_NORMAL 379 * @see #MEMORY_TYPE_PUSH_BUFFERS 380 */ 381 public int memoryType; 382 383 /** Memory type: The window's surface is allocated in main memory. */ 384 public static final int MEMORY_TYPE_NORMAL = 0; 385 /** Memory type: The window's surface is configured to be accessible 386 * by DMA engines and hardware accelerators. 387 * @deprecated this is ignored, this value is set automatically when needed. 388 */ 389 @Deprecated 390 public static final int MEMORY_TYPE_HARDWARE = 1; 391 /** Memory type: The window's surface is configured to be accessible 392 * by graphics accelerators. 393 * @deprecated this is ignored, this value is set automatically when needed. 394 */ 395 @Deprecated 396 public static final int MEMORY_TYPE_GPU = 2; 397 /** Memory type: The window's surface doesn't own its buffers and 398 * therefore cannot be locked. Instead the buffers are pushed to 399 * it through native binder calls. */ 400 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; 401 402 /** 403 * Various behavioral options/flags. Default is none. 404 * 405 * @see #FLAG_BLUR_BEHIND 406 * @see #FLAG_DIM_BEHIND 407 * @see #FLAG_NOT_FOCUSABLE 408 * @see #FLAG_NOT_TOUCHABLE 409 * @see #FLAG_NOT_TOUCH_MODAL 410 * @see #FLAG_LAYOUT_IN_SCREEN 411 * @see #FLAG_DITHER 412 * @see #FLAG_KEEP_SCREEN_ON 413 * @see #FLAG_FULLSCREEN 414 * @see #FLAG_FORCE_NOT_FULLSCREEN 415 * @see #FLAG_IGNORE_CHEEK_PRESSES 416 * @see #FLAG_HARDWARE_ACCELERATED 417 */ 418 @ViewDebug.ExportedProperty(flagMapping = { 419 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND, 420 name = "FLAG_BLUR_BEHIND"), 421 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND, 422 name = "FLAG_DIM_BEHIND"), 423 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE, 424 name = "FLAG_NOT_FOCUSABLE"), 425 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE, 426 name = "FLAG_NOT_TOUCHABLE"), 427 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL, 428 name = "FLAG_NOT_TOUCH_MODAL"), 429 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN, 430 name = "FLAG_LAYOUT_IN_SCREEN"), 431 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER, 432 name = "FLAG_DITHER"), 433 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON, 434 name = "FLAG_TURN_SCREEN_ON"), 435 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON, 436 name = "FLAG_KEEP_SCREEN_ON"), 437 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED, 438 name = "FLAG_SHOW_WHEN_LOCKED"), 439 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, 440 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"), 441 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD, 442 name = "FLAG_DISMISS_KEYGUARD"), 443 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN, 444 name = "FLAG_FULLSCREEN"), 445 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, 446 equals = FLAG_FORCE_NOT_FULLSCREEN, name = "FLAG_FORCE_NOT_FULLSCREEN"), 447 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, 448 equals = FLAG_IGNORE_CHEEK_PRESSES, name = "FLAG_IGNORE_CHEEK_PRESSES"), 449 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, 450 equals = FLAG_HARDWARE_ACCELERATED, name = "FLAG_HARDWARE_ACCELERATED") 451 }) 452 public int flags; 453 454 /** Window flag: as long as this window is visible to the user, allow 455 * the lock screen to activate while the screen is on. 456 * This can be used independently, or in combination with 457 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */ 458 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; 459 460 /** Window flag: everything behind this window will be dimmed. 461 * Use {@link #dimAmount} to control the amount of dim. */ 462 public static final int FLAG_DIM_BEHIND = 0x00000002; 463 464 /** Window flag: blur everything behind this window. */ 465 public static final int FLAG_BLUR_BEHIND = 0x00000004; 466 467 /** Window flag: this window won't ever get key input focus, so the 468 * user can not send key or other button events to it. Those will 469 * instead go to whatever focusable window is behind it. This flag 470 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that 471 * is explicitly set. 472 * 473 * <p>Setting this flag also implies that the window will not need to 474 * interact with 475 * a soft input method, so it will be Z-ordered and positioned 476 * independently of any active input method (typically this means it 477 * gets Z-ordered on top of the input method, so it can use the full 478 * screen for its content and cover the input method if needed. You 479 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ 480 public static final int FLAG_NOT_FOCUSABLE = 0x00000008; 481 482 /** Window flag: this window can never receive touch events. */ 483 public static final int FLAG_NOT_TOUCHABLE = 0x00000010; 484 485 /** Window flag: Even when this window is focusable (its 486 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events 487 * outside of the window to be sent to the windows behind it. Otherwise 488 * it will consume all pointer events itself, regardless of whether they 489 * are inside of the window. */ 490 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; 491 492 /** Window flag: When set, if the device is asleep when the touch 493 * screen is pressed, you will receive this first touch event. Usually 494 * the first touch event is consumed by the system since the user can 495 * not see what they are pressing on. 496 */ 497 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; 498 499 /** Window flag: as long as this window is visible to the user, keep 500 * the device's screen turned on and bright. */ 501 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; 502 503 /** Window flag: place the window within the entire screen, ignoring 504 * decorations around the border (a.k.a. the status bar). The 505 * window must correctly position its contents to take the screen 506 * decoration into account. This flag is normally set for you 507 * by Window as described in {@link Window#setFlags}. */ 508 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; 509 510 /** Window flag: allow window to extend outside of the screen. */ 511 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; 512 513 /** Window flag: Hide all screen decorations (e.g. status bar) while 514 * this window is displayed. This allows the window to use the entire 515 * display space for itself -- the status bar will be hidden when 516 * an app window with this flag set is on the top layer. */ 517 public static final int FLAG_FULLSCREEN = 0x00000400; 518 519 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the 520 * screen decorations (such as status bar) to be shown. */ 521 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; 522 523 /** Window flag: turn on dithering when compositing this window to 524 * the screen. */ 525 public static final int FLAG_DITHER = 0x00001000; 526 527 /** Window flag: don't allow screen shots while this window is 528 * displayed. */ 529 public static final int FLAG_SECURE = 0x00002000; 530 531 /** Window flag: a special mode where the layout parameters are used 532 * to perform scaling of the surface when it is composited to the 533 * screen. */ 534 public static final int FLAG_SCALED = 0x00004000; 535 536 /** Window flag: intended for windows that will often be used when the user is 537 * holding the screen against their face, it will aggressively filter the event 538 * stream to prevent unintended presses in this situation that may not be 539 * desired for a particular window, when such an event stream is detected, the 540 * application will receive a CANCEL motion event to indicate this so applications 541 * can handle this accordingly by taking no action on the event 542 * until the finger is released. */ 543 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; 544 545 /** Window flag: a special option only for use in combination with 546 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the 547 * screen your window may appear on top of or behind screen decorations 548 * such as the status bar. By also including this flag, the window 549 * manager will report the inset rectangle needed to ensure your 550 * content is not covered by screen decorations. This flag is normally 551 * set for you by Window as described in {@link Window#setFlags}.*/ 552 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; 553 554 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with 555 * respect to how this window interacts with the current method. That 556 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the 557 * window will behave as if it needs to interact with the input method 558 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is 559 * not set and this flag is set, then the window will behave as if it 560 * doesn't need to interact with the input method and can be placed 561 * to use more space and cover the input method. 562 */ 563 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; 564 565 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you 566 * can set this flag to receive a single special MotionEvent with 567 * the action 568 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for 569 * touches that occur outside of your window. Note that you will not 570 * receive the full down/move/up gesture, only the location of the 571 * first down as an ACTION_OUTSIDE. 572 */ 573 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; 574 575 /** Window flag: special flag to let windows be shown when the screen 576 * is locked. This will let application windows take precedence over 577 * key guard or any other lock screens. Can be used with 578 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows 579 * directly before showing the key guard window. Can be used with 580 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss 581 * non-secure keyguards. This flag only applies to the top-most 582 * full-screen window. 583 */ 584 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; 585 586 /** Window flag: ask that the system wallpaper be shown behind 587 * your window. The window surface must be translucent to be able 588 * to actually see the wallpaper behind it; this flag just ensures 589 * that the wallpaper surface will be there if this window actually 590 * has translucent regions. 591 */ 592 public static final int FLAG_SHOW_WALLPAPER = 0x00100000; 593 594 /** Window flag: when set as a window is being added or made 595 * visible, once the window has been shown then the system will 596 * poke the power manager's user activity (as if the user had woken 597 * up the device) to turn the screen on. */ 598 public static final int FLAG_TURN_SCREEN_ON = 0x00200000; 599 600 /** Window flag: when set the window will cause the keyguard to 601 * be dismissed, only if it is not a secure lock keyguard. Because such 602 * a keyguard is not needed for security, it will never re-appear if 603 * the user navigates to another window (in contrast to 604 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily 605 * hide both secure and non-secure keyguards but ensure they reappear 606 * when the user moves to another UI that doesn't hide them). 607 * If the keyguard is currently active and is secure (requires an 608 * unlock pattern) than the user will still need to confirm it before 609 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has 610 * also been set. 611 */ 612 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000; 613 614 /** Window flag: when set the window will accept for touch events 615 * outside of its bounds to be sent to other windows that also 616 * support split touch. When this flag is not set, the first pointer 617 * that goes down determines the window to which all subsequent touches 618 * go until all pointers go up. When this flag is set, each pointer 619 * (not necessarily the first) that goes down determines the window 620 * to which all subsequent touches of that pointer will go until that 621 * pointer goes up thereby enabling touches with multiple pointers 622 * to be split across multiple windows. 623 * 624 * {@hide} */ 625 public static final int FLAG_SPLIT_TOUCH = 0x00800000; 626 627 /** 628 * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU} 629 * and therefore needs a Menu key. For devices where Menu is a physical button this flag is 630 * ignored, but on devices where the Menu key is drawn in software it may be hidden unless 631 * this flag is set. 632 * 633 * (Note that Action Bars, when available, are the preferred way to offer additional 634 * functions otherwise accessed via an options menu.) 635 * 636 * {@hide} 637 */ 638 public static final int FLAG_NEEDS_MENU_KEY = 0x01000000; 639 640 /** Window flag: *sigh* The lock screen wants to continue running its 641 * animation while it is fading. A kind-of hack to allow this. Maybe 642 * in the future we just make this the default behavior. 643 * 644 * {@hide} */ 645 public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000; 646 647 /** Window flag: special flag to limit the size of the window to be 648 * original size ([320x480] x density). Used to create window for applications 649 * running under compatibility mode. 650 * 651 * {@hide} */ 652 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000; 653 654 /** Window flag: a special option intended for system dialogs. When 655 * this flag is set, the window will demand focus unconditionally when 656 * it is created. 657 * {@hide} */ 658 public static final int FLAG_SYSTEM_ERROR = 0x40000000; 659 660 /** 661 * Indicates whether this window should be hardware accelerated. 662 * Requesting hardware acceleration does not guarantee it will happen. 663 */ 664 public static final int FLAG_HARDWARE_ACCELERATED = 0x80000000; 665 666 /** 667 * Given a particular set of window manager flags, determine whether 668 * such a window may be a target for an input method when it has 669 * focus. In particular, this checks the 670 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} 671 * flags and returns true if the combination of the two corresponds 672 * to a window that needs to be behind the input method so that the 673 * user can type into it. 674 * 675 * @param flags The current window manager flags. 676 * 677 * @return Returns true if such a window should be behind/interact 678 * with an input method, false if not. 679 */ 680 public static boolean mayUseInputMethod(int flags) { 681 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { 682 case 0: 683 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM: 684 return true; 685 } 686 return false; 687 } 688 689 /** 690 * Mask for {@link #softInputMode} of the bits that determine the 691 * desired visibility state of the soft input area for this window. 692 */ 693 public static final int SOFT_INPUT_MASK_STATE = 0x0f; 694 695 /** 696 * Visibility state for {@link #softInputMode}: no state has been specified. 697 */ 698 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; 699 700 /** 701 * Visibility state for {@link #softInputMode}: please don't change the state of 702 * the soft input area. 703 */ 704 public static final int SOFT_INPUT_STATE_UNCHANGED = 1; 705 706 /** 707 * Visibility state for {@link #softInputMode}: please hide any soft input 708 * area when normally appropriate (when the user is navigating 709 * forward to your window). 710 */ 711 public static final int SOFT_INPUT_STATE_HIDDEN = 2; 712 713 /** 714 * Visibility state for {@link #softInputMode}: please always hide any 715 * soft input area when this window receives focus. 716 */ 717 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; 718 719 /** 720 * Visibility state for {@link #softInputMode}: please show the soft 721 * input area when normally appropriate (when the user is navigating 722 * forward to your window). 723 */ 724 public static final int SOFT_INPUT_STATE_VISIBLE = 4; 725 726 /** 727 * Visibility state for {@link #softInputMode}: please always make the 728 * soft input area visible when this window receives input focus. 729 */ 730 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; 731 732 /** 733 * Mask for {@link #softInputMode} of the bits that determine the 734 * way that the window should be adjusted to accommodate the soft 735 * input window. 736 */ 737 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; 738 739 /** Adjustment option for {@link #softInputMode}: nothing specified. 740 * The system will try to pick one or 741 * the other depending on the contents of the window. 742 */ 743 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; 744 745 /** Adjustment option for {@link #softInputMode}: set to allow the 746 * window to be resized when an input 747 * method is shown, so that its contents are not covered by the input 748 * method. This can <em>not</em> be combined with 749 * {@link #SOFT_INPUT_ADJUST_PAN}; if 750 * neither of these are set, then the system will try to pick one or 751 * the other depending on the contents of the window. 752 */ 753 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; 754 755 /** Adjustment option for {@link #softInputMode}: set to have a window 756 * pan when an input method is 757 * shown, so it doesn't need to deal with resizing but just panned 758 * by the framework to ensure the current input focus is visible. This 759 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if 760 * neither of these are set, then the system will try to pick one or 761 * the other depending on the contents of the window. 762 */ 763 public static final int SOFT_INPUT_ADJUST_PAN = 0x20; 764 765 /** Adjustment option for {@link #softInputMode}: set to have a window 766 * not adjust for a shown input method. The window will not be resized, 767 * and it will not be panned to make its focus visible. 768 */ 769 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30; 770 771 /** 772 * Bit for {@link #softInputMode}: set when the user has navigated 773 * forward to the window. This is normally set automatically for 774 * you by the system, though you may want to set it in certain cases 775 * when you are displaying a window yourself. This flag will always 776 * be cleared automatically after the window is displayed. 777 */ 778 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; 779 780 /** 781 * Desired operating mode for any soft input area. May any combination 782 * of: 783 * 784 * <ul> 785 * <li> One of the visibility states 786 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, 787 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or 788 * {@link #SOFT_INPUT_STATE_VISIBLE}. 789 * <li> One of the adjustment options 790 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, 791 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or 792 * {@link #SOFT_INPUT_ADJUST_PAN}. 793 */ 794 public int softInputMode; 795 796 /** 797 * Placement of window within the screen as per {@link Gravity}. Both 798 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 799 * android.graphics.Rect) Gravity.apply} and 800 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 801 * Gravity.applyDisplay} are used during window layout, with this value 802 * given as the desired gravity. For example you can specify 803 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and 804 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here 805 * to control the behavior of 806 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 807 * Gravity.applyDisplay}. 808 * 809 * @see Gravity 810 */ 811 public int gravity; 812 813 /** 814 * The horizontal margin, as a percentage of the container's width, 815 * between the container and the widget. See 816 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 817 * android.graphics.Rect) Gravity.apply} for how this is used. This 818 * field is added with {@link #x} to supply the <var>xAdj</var> parameter. 819 */ 820 public float horizontalMargin; 821 822 /** 823 * The vertical margin, as a percentage of the container's height, 824 * between the container and the widget. See 825 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 826 * android.graphics.Rect) Gravity.apply} for how this is used. This 827 * field is added with {@link #y} to supply the <var>yAdj</var> parameter. 828 */ 829 public float verticalMargin; 830 831 /** 832 * The desired bitmap format. May be one of the constants in 833 * {@link android.graphics.PixelFormat}. Default is OPAQUE. 834 */ 835 public int format; 836 837 /** 838 * A style resource defining the animations to use for this window. 839 * This must be a system resource; it can not be an application resource 840 * because the window manager does not have access to applications. 841 */ 842 public int windowAnimations; 843 844 /** 845 * An alpha value to apply to this entire window. 846 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent 847 */ 848 public float alpha = 1.0f; 849 850 /** 851 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming 852 * to apply. Range is from 1.0 for completely opaque to 0.0 for no 853 * dim. 854 */ 855 public float dimAmount = 1.0f; 856 857 /** 858 * Default value for {@link #screenBrightness} and {@link #buttonBrightness} 859 * indicating that the brightness value is not overridden for this window 860 * and normal brightness policy should be used. 861 */ 862 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f; 863 864 /** 865 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 866 * indicating that the screen or button backlight brightness should be set 867 * to the lowest value when this window is in front. 868 */ 869 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f; 870 871 /** 872 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 873 * indicating that the screen or button backlight brightness should be set 874 * to the hightest value when this window is in front. 875 */ 876 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f; 877 878 /** 879 * This can be used to override the user's preferred brightness of 880 * the screen. A value of less than 0, the default, means to use the 881 * preferred screen brightness. 0 to 1 adjusts the brightness from 882 * dark to full bright. 883 */ 884 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE; 885 886 /** 887 * This can be used to override the standard behavior of the button and 888 * keyboard backlights. A value of less than 0, the default, means to 889 * use the standard backlight behavior. 0 to 1 adjusts the brightness 890 * from dark to full bright. 891 */ 892 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; 893 894 /** 895 * Identifier for this window. This will usually be filled in for 896 * you. 897 */ 898 public IBinder token = null; 899 900 /** 901 * Name of the package owning this window. 902 */ 903 public String packageName = null; 904 905 /** 906 * Specific orientation value for a window. 907 * May be any of the same values allowed 908 * for {@link android.content.pm.ActivityInfo#screenOrientation}. 909 * If not set, a default value of 910 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} 911 * will be used. 912 */ 913 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; 914 915 916 public LayoutParams() { 917 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 918 type = TYPE_APPLICATION; 919 format = PixelFormat.OPAQUE; 920 } 921 922 public LayoutParams(int _type) { 923 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 924 type = _type; 925 format = PixelFormat.OPAQUE; 926 } 927 928 public LayoutParams(int _type, int _flags) { 929 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 930 type = _type; 931 flags = _flags; 932 format = PixelFormat.OPAQUE; 933 } 934 935 public LayoutParams(int _type, int _flags, int _format) { 936 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 937 type = _type; 938 flags = _flags; 939 format = _format; 940 } 941 942 public LayoutParams(int w, int h, int _type, int _flags, int _format) { 943 super(w, h); 944 type = _type; 945 flags = _flags; 946 format = _format; 947 } 948 949 public LayoutParams(int w, int h, int xpos, int ypos, int _type, 950 int _flags, int _format) { 951 super(w, h); 952 x = xpos; 953 y = ypos; 954 type = _type; 955 flags = _flags; 956 format = _format; 957 } 958 959 public final void setTitle(CharSequence title) { 960 if (null == title) 961 title = ""; 962 963 mTitle = TextUtils.stringOrSpannedString(title); 964 } 965 966 public final CharSequence getTitle() { 967 return mTitle; 968 } 969 970 public int describeContents() { 971 return 0; 972 } 973 974 public void writeToParcel(Parcel out, int parcelableFlags) { 975 out.writeInt(width); 976 out.writeInt(height); 977 out.writeInt(x); 978 out.writeInt(y); 979 out.writeInt(type); 980 out.writeInt(memoryType); 981 out.writeInt(flags); 982 out.writeInt(softInputMode); 983 out.writeInt(gravity); 984 out.writeFloat(horizontalMargin); 985 out.writeFloat(verticalMargin); 986 out.writeInt(format); 987 out.writeInt(windowAnimations); 988 out.writeFloat(alpha); 989 out.writeFloat(dimAmount); 990 out.writeFloat(screenBrightness); 991 out.writeFloat(buttonBrightness); 992 out.writeStrongBinder(token); 993 out.writeString(packageName); 994 TextUtils.writeToParcel(mTitle, out, parcelableFlags); 995 out.writeInt(screenOrientation); 996 } 997 998 public static final Parcelable.Creator<LayoutParams> CREATOR 999 = new Parcelable.Creator<LayoutParams>() { 1000 public LayoutParams createFromParcel(Parcel in) { 1001 return new LayoutParams(in); 1002 } 1003 1004 public LayoutParams[] newArray(int size) { 1005 return new LayoutParams[size]; 1006 } 1007 }; 1008 1009 1010 public LayoutParams(Parcel in) { 1011 width = in.readInt(); 1012 height = in.readInt(); 1013 x = in.readInt(); 1014 y = in.readInt(); 1015 type = in.readInt(); 1016 memoryType = in.readInt(); 1017 flags = in.readInt(); 1018 softInputMode = in.readInt(); 1019 gravity = in.readInt(); 1020 horizontalMargin = in.readFloat(); 1021 verticalMargin = in.readFloat(); 1022 format = in.readInt(); 1023 windowAnimations = in.readInt(); 1024 alpha = in.readFloat(); 1025 dimAmount = in.readFloat(); 1026 screenBrightness = in.readFloat(); 1027 buttonBrightness = in.readFloat(); 1028 token = in.readStrongBinder(); 1029 packageName = in.readString(); 1030 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); 1031 screenOrientation = in.readInt(); 1032 } 1033 1034 @SuppressWarnings({"PointlessBitwiseExpression"}) 1035 public static final int LAYOUT_CHANGED = 1<<0; 1036 public static final int TYPE_CHANGED = 1<<1; 1037 public static final int FLAGS_CHANGED = 1<<2; 1038 public static final int FORMAT_CHANGED = 1<<3; 1039 public static final int ANIMATION_CHANGED = 1<<4; 1040 public static final int DIM_AMOUNT_CHANGED = 1<<5; 1041 public static final int TITLE_CHANGED = 1<<6; 1042 public static final int ALPHA_CHANGED = 1<<7; 1043 public static final int MEMORY_TYPE_CHANGED = 1<<8; 1044 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; 1045 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; 1046 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; 1047 /** {@hide} */ 1048 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12; 1049 1050 // internal buffer to backup/restore parameters under compatibility mode. 1051 private int[] mCompatibilityParamsBackup = null; 1052 1053 public final int copyFrom(LayoutParams o) { 1054 int changes = 0; 1055 1056 if (width != o.width) { 1057 width = o.width; 1058 changes |= LAYOUT_CHANGED; 1059 } 1060 if (height != o.height) { 1061 height = o.height; 1062 changes |= LAYOUT_CHANGED; 1063 } 1064 if (x != o.x) { 1065 x = o.x; 1066 changes |= LAYOUT_CHANGED; 1067 } 1068 if (y != o.y) { 1069 y = o.y; 1070 changes |= LAYOUT_CHANGED; 1071 } 1072 if (horizontalWeight != o.horizontalWeight) { 1073 horizontalWeight = o.horizontalWeight; 1074 changes |= LAYOUT_CHANGED; 1075 } 1076 if (verticalWeight != o.verticalWeight) { 1077 verticalWeight = o.verticalWeight; 1078 changes |= LAYOUT_CHANGED; 1079 } 1080 if (horizontalMargin != o.horizontalMargin) { 1081 horizontalMargin = o.horizontalMargin; 1082 changes |= LAYOUT_CHANGED; 1083 } 1084 if (verticalMargin != o.verticalMargin) { 1085 verticalMargin = o.verticalMargin; 1086 changes |= LAYOUT_CHANGED; 1087 } 1088 if (type != o.type) { 1089 type = o.type; 1090 changes |= TYPE_CHANGED; 1091 } 1092 if (memoryType != o.memoryType) { 1093 memoryType = o.memoryType; 1094 changes |= MEMORY_TYPE_CHANGED; 1095 } 1096 if (flags != o.flags) { 1097 flags = o.flags; 1098 changes |= FLAGS_CHANGED; 1099 } 1100 if (softInputMode != o.softInputMode) { 1101 softInputMode = o.softInputMode; 1102 changes |= SOFT_INPUT_MODE_CHANGED; 1103 } 1104 if (gravity != o.gravity) { 1105 gravity = o.gravity; 1106 changes |= LAYOUT_CHANGED; 1107 } 1108 if (horizontalMargin != o.horizontalMargin) { 1109 horizontalMargin = o.horizontalMargin; 1110 changes |= LAYOUT_CHANGED; 1111 } 1112 if (verticalMargin != o.verticalMargin) { 1113 verticalMargin = o.verticalMargin; 1114 changes |= LAYOUT_CHANGED; 1115 } 1116 if (format != o.format) { 1117 format = o.format; 1118 changes |= FORMAT_CHANGED; 1119 } 1120 if (windowAnimations != o.windowAnimations) { 1121 windowAnimations = o.windowAnimations; 1122 changes |= ANIMATION_CHANGED; 1123 } 1124 if (token == null) { 1125 // NOTE: token only copied if the recipient doesn't 1126 // already have one. 1127 token = o.token; 1128 } 1129 if (packageName == null) { 1130 // NOTE: packageName only copied if the recipient doesn't 1131 // already have one. 1132 packageName = o.packageName; 1133 } 1134 if (!mTitle.equals(o.mTitle)) { 1135 mTitle = o.mTitle; 1136 changes |= TITLE_CHANGED; 1137 } 1138 if (alpha != o.alpha) { 1139 alpha = o.alpha; 1140 changes |= ALPHA_CHANGED; 1141 } 1142 if (dimAmount != o.dimAmount) { 1143 dimAmount = o.dimAmount; 1144 changes |= DIM_AMOUNT_CHANGED; 1145 } 1146 if (screenBrightness != o.screenBrightness) { 1147 screenBrightness = o.screenBrightness; 1148 changes |= SCREEN_BRIGHTNESS_CHANGED; 1149 } 1150 if (buttonBrightness != o.buttonBrightness) { 1151 buttonBrightness = o.buttonBrightness; 1152 changes |= BUTTON_BRIGHTNESS_CHANGED; 1153 } 1154 1155 if (screenOrientation != o.screenOrientation) { 1156 screenOrientation = o.screenOrientation; 1157 changes |= SCREEN_ORIENTATION_CHANGED; 1158 } 1159 1160 return changes; 1161 } 1162 1163 @Override 1164 public String debug(String output) { 1165 output += "Contents of " + this + ":"; 1166 Log.d("Debug", output); 1167 output = super.debug(""); 1168 Log.d("Debug", output); 1169 Log.d("Debug", ""); 1170 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); 1171 return ""; 1172 } 1173 1174 @Override 1175 public String toString() { 1176 StringBuilder sb = new StringBuilder(256); 1177 sb.append("WM.LayoutParams{"); 1178 sb.append("("); 1179 sb.append(x); 1180 sb.append(','); 1181 sb.append(y); 1182 sb.append(")("); 1183 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width))); 1184 sb.append('x'); 1185 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height))); 1186 sb.append(")"); 1187 if (horizontalMargin != 0) { 1188 sb.append(" hm="); 1189 sb.append(horizontalMargin); 1190 } 1191 if (verticalMargin != 0) { 1192 sb.append(" vm="); 1193 sb.append(verticalMargin); 1194 } 1195 if (gravity != 0) { 1196 sb.append(" gr=#"); 1197 sb.append(Integer.toHexString(gravity)); 1198 } 1199 if (softInputMode != 0) { 1200 sb.append(" sim=#"); 1201 sb.append(Integer.toHexString(softInputMode)); 1202 } 1203 sb.append(" ty="); 1204 sb.append(type); 1205 sb.append(" fl=#"); 1206 sb.append(Integer.toHexString(flags)); 1207 sb.append(" fmt="); 1208 sb.append(format); 1209 if (windowAnimations != 0) { 1210 sb.append(" wanim=0x"); 1211 sb.append(Integer.toHexString(windowAnimations)); 1212 } 1213 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { 1214 sb.append(" or="); 1215 sb.append(screenOrientation); 1216 } 1217 if (alpha != 1.0f) { 1218 sb.append(" alpha="); 1219 sb.append(alpha); 1220 } 1221 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) { 1222 sb.append(" sbrt="); 1223 sb.append(screenBrightness); 1224 } 1225 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) { 1226 sb.append(" bbrt="); 1227 sb.append(buttonBrightness); 1228 } 1229 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) { 1230 sb.append(" compatible=true"); 1231 } 1232 sb.append('}'); 1233 return sb.toString(); 1234 } 1235 1236 /** 1237 * Scale the layout params' coordinates and size. 1238 * @hide 1239 */ 1240 public void scale(float scale) { 1241 x = (int) (x * scale + 0.5f); 1242 y = (int) (y * scale + 0.5f); 1243 if (width > 0) { 1244 width = (int) (width * scale + 0.5f); 1245 } 1246 if (height > 0) { 1247 height = (int) (height * scale + 0.5f); 1248 } 1249 } 1250 1251 /** 1252 * Backup the layout parameters used in compatibility mode. 1253 * @see LayoutParams#restore() 1254 */ 1255 void backup() { 1256 int[] backup = mCompatibilityParamsBackup; 1257 if (backup == null) { 1258 // we backup 4 elements, x, y, width, height 1259 backup = mCompatibilityParamsBackup = new int[4]; 1260 } 1261 backup[0] = x; 1262 backup[1] = y; 1263 backup[2] = width; 1264 backup[3] = height; 1265 } 1266 1267 /** 1268 * Restore the layout params' coordinates, size and gravity 1269 * @see LayoutParams#backup() 1270 */ 1271 void restore() { 1272 int[] backup = mCompatibilityParamsBackup; 1273 if (backup != null) { 1274 x = backup[0]; 1275 y = backup[1]; 1276 width = backup[2]; 1277 height = backup[3]; 1278 } 1279 } 1280 1281 private CharSequence mTitle = ""; 1282 } 1283} 1284