blob: 6e512704333705e1796359a208d315ba0f867095 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
Jeff Browna492c3a2012-08-23 19:48:44 -070019import android.app.Presentation;
20import android.content.Context;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.pm.ActivityInfo;
22import android.graphics.PixelFormat;
23import android.os.IBinder;
24import android.os.Parcel;
25import android.os.Parcelable;
26import android.text.TextUtils;
27import 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.
Jeff Browna492c3a2012-08-23 19:48:44 -070034 * </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>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045 *
46 * @see android.content.Context#getSystemService
47 * @see android.content.Context#WINDOW_SERVICE
48 */
49public 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 {
56 public BadTokenException() {
57 }
58
59 public BadTokenException(String name) {
60 super(name);
61 }
62 }
63
64 /**
Jeff Browna492c3a2012-08-23 19:48:44 -070065 * Returns the {@link Display} upon which this {@link WindowManager} instance
66 * will create new windows.
67 * <p>
68 * Despite the name of this method, the display that is returned is not
69 * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}).
70 * The returned display could instead be a secondary display that this
71 * window manager instance is managing. Think of it as the display that
72 * this {@link WindowManager} instance uses by default.
73 * </p><p>
74 * To create windows on a different display, you need to obtain a
75 * {@link WindowManager} for that {@link Display}. (See the {@link WindowManager}
76 * class documentation for more information.)
77 * </p>
78 *
79 * @return The display that this window manager is managing.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080 */
81 public Display getDefaultDisplay();
Jeff Browna492c3a2012-08-23 19:48:44 -070082
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083 /**
84 * Special variation of {@link #removeView} that immediately invokes
85 * the given view hierarchy's {@link View#onDetachedFromWindow()
86 * View.onDetachedFromWindow()} methods before returning. This is not
87 * for normal applications; using it correctly requires great care.
88 *
89 * @param view The view to be removed.
90 */
91 public void removeViewImmediate(View view);
Jeff Brownd32460c2012-07-20 16:15:36 -070092
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093 public static class LayoutParams extends ViewGroup.LayoutParams
94 implements Parcelable {
95 /**
96 * X position for this window. With the default gravity it is ignored.
Fabrice Di Meglio9e3b0022011-06-06 16:30:29 -070097 * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or
98 * {@link Gravity#END} it provides an offset from the given edge.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 */
Romain Guy529b60a2010-08-03 18:05:47 -0700100 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101 public int x;
102
103 /**
104 * Y position for this window. With the default gravity it is ignored.
105 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
106 * an offset from the given edge.
107 */
Romain Guy529b60a2010-08-03 18:05:47 -0700108 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109 public int y;
110
111 /**
112 * Indicates how much of the extra space will be allocated horizontally
113 * to the view associated with these LayoutParams. Specify 0 if the view
114 * should not be stretched. Otherwise the extra pixels will be pro-rated
115 * among all views whose weight is greater than 0.
116 */
Romain Guy529b60a2010-08-03 18:05:47 -0700117 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 public float horizontalWeight;
119
120 /**
121 * Indicates how much of the extra space will be allocated vertically
122 * to the view associated with these LayoutParams. Specify 0 if the view
123 * should not be stretched. Otherwise the extra pixels will be pro-rated
124 * among all views whose weight is greater than 0.
125 */
Romain Guy529b60a2010-08-03 18:05:47 -0700126 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800127 public float verticalWeight;
Romain Guy529b60a2010-08-03 18:05:47 -0700128
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800129 /**
130 * The general type of window. There are three main classes of
131 * window types:
132 * <ul>
133 * <li> <strong>Application windows</strong> (ranging from
134 * {@link #FIRST_APPLICATION_WINDOW} to
135 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application
136 * windows. For these types of windows, the {@link #token} must be
137 * set to the token of the activity they are a part of (this will
138 * normally be done for you if {@link #token} is null).
139 * <li> <strong>Sub-windows</strong> (ranging from
140 * {@link #FIRST_SUB_WINDOW} to
141 * {@link #LAST_SUB_WINDOW}) are associated with another top-level
142 * window. For these types of windows, the {@link #token} must be
143 * the token of the window it is attached to.
144 * <li> <strong>System windows</strong> (ranging from
145 * {@link #FIRST_SYSTEM_WINDOW} to
146 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for
147 * use by the system for specific purposes. They should not normally
148 * be used by applications, and a special permission is required
149 * to use them.
150 * </ul>
151 *
152 * @see #TYPE_BASE_APPLICATION
153 * @see #TYPE_APPLICATION
154 * @see #TYPE_APPLICATION_STARTING
155 * @see #TYPE_APPLICATION_PANEL
156 * @see #TYPE_APPLICATION_MEDIA
157 * @see #TYPE_APPLICATION_SUB_PANEL
158 * @see #TYPE_APPLICATION_ATTACHED_DIALOG
159 * @see #TYPE_STATUS_BAR
160 * @see #TYPE_SEARCH_BAR
161 * @see #TYPE_PHONE
162 * @see #TYPE_SYSTEM_ALERT
163 * @see #TYPE_KEYGUARD
164 * @see #TYPE_TOAST
165 * @see #TYPE_SYSTEM_OVERLAY
166 * @see #TYPE_PRIORITY_PHONE
167 * @see #TYPE_STATUS_BAR_PANEL
168 * @see #TYPE_SYSTEM_DIALOG
169 * @see #TYPE_KEYGUARD_DIALOG
170 * @see #TYPE_SYSTEM_ERROR
171 * @see #TYPE_INPUT_METHOD
172 * @see #TYPE_INPUT_METHOD_DIALOG
173 */
Joe Onorato8f2bd432010-03-25 11:45:28 -0700174 @ViewDebug.ExportedProperty(mapping = {
175 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"),
176 @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"),
177 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"),
178 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"),
179 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"),
180 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"),
181 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"),
Scott Andersonaeb77232012-05-31 18:55:54 -0700182 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY, to = "TYPE_APPLICATION_MEDIA_OVERLAY"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700183 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"),
184 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"),
185 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"),
186 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"),
187 @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"),
188 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"),
189 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"),
190 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700191 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"),
192 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"),
193 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"),
194 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"),
Jeff Brown3b2b3542010-10-15 00:54:27 -0700195 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"),
Jeff Brownbfcb60a2011-09-08 18:51:14 -0700196 @ViewDebug.IntToString(from = TYPE_WALLPAPER, to = "TYPE_WALLPAPER"),
197 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"),
Dianne Hackborn29aae6f2011-08-18 18:30:09 -0700198 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY"),
Jeff Brownbfcb60a2011-09-08 18:51:14 -0700199 @ViewDebug.IntToString(from = TYPE_DRAG, to = "TYPE_DRAG"),
200 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, to = "TYPE_STATUS_BAR_SUB_PANEL"),
201 @ViewDebug.IntToString(from = TYPE_POINTER, to = "TYPE_POINTER"),
202 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR, to = "TYPE_NAVIGATION_BAR"),
203 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY, to = "TYPE_VOLUME_OVERLAY"),
Scott Andersonaeb77232012-05-31 18:55:54 -0700204 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, to = "TYPE_BOOT_PROGRESS"),
205 @ViewDebug.IntToString(from = TYPE_HIDDEN_NAV_CONSUMER, to = "TYPE_HIDDEN_NAV_CONSUMER"),
206 @ViewDebug.IntToString(from = TYPE_DREAM, to = "TYPE_DREAM"),
Jeff Brownbd6e1502012-08-28 03:27:37 -0700207 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL, to = "TYPE_NAVIGATION_BAR_PANEL"),
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -0700208 @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY, to = "TYPE_DISPLAY_OVERLAY"),
209 @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY, to = "TYPE_MAGNIFICATION_OVERLAY")
Joe Onorato8f2bd432010-03-25 11:45:28 -0700210 })
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 public int type;
212
213 /**
214 * Start of window types that represent normal application windows.
215 */
216 public static final int FIRST_APPLICATION_WINDOW = 1;
217
218 /**
219 * Window type: an application window that serves as the "base" window
220 * of the overall application; all other application windows will
221 * appear on top of it.
222 */
223 public static final int TYPE_BASE_APPLICATION = 1;
224
225 /**
226 * Window type: a normal application window. The {@link #token} must be
227 * an Activity token identifying who the window belongs to.
228 */
229 public static final int TYPE_APPLICATION = 2;
230
231 /**
232 * Window type: special application window that is displayed while the
233 * application is starting. Not for use by applications themselves;
234 * this is used by the system to display something until the
235 * application can show its own windows.
236 */
237 public static final int TYPE_APPLICATION_STARTING = 3;
238
239 /**
240 * End of types of application windows.
241 */
242 public static final int LAST_APPLICATION_WINDOW = 99;
243
244 /**
245 * Start of types of sub-windows. The {@link #token} of these windows
246 * must be set to the window they are attached to. These types of
247 * windows are kept next to their attached window in Z-order, and their
248 * coordinate space is relative to their attached window.
249 */
250 public static final int FIRST_SUB_WINDOW = 1000;
251
252 /**
253 * Window type: a panel on top of an application window. These windows
254 * appear on top of their attached window.
255 */
256 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
257
258 /**
259 * Window type: window for showing media (e.g. video). These windows
260 * are displayed behind their attached window.
261 */
262 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1;
263
264 /**
265 * Window type: a sub-panel on top of an application window. These
266 * windows are displayed on top their attached window and any
267 * {@link #TYPE_APPLICATION_PANEL} panels.
268 */
269 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2;
270
271 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
272 * of the window happens as that of a top-level window, <em>not</em>
273 * as a child of its container.
274 */
275 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3;
276
277 /**
Dianne Hackbornc4d5d022009-05-21 17:32:42 -0700278 * Window type: window for showing overlays on top of media windows.
279 * These windows are displayed between TYPE_APPLICATION_MEDIA and the
280 * application window. They should be translucent to be useful. This
281 * is a big ugly hack so:
282 * @hide
283 */
284 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4;
285
286 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287 * End of types of sub-windows.
288 */
289 public static final int LAST_SUB_WINDOW = 1999;
290
291 /**
292 * Start of system-specific window types. These are not normally
293 * created by applications.
294 */
295 public static final int FIRST_SYSTEM_WINDOW = 2000;
296
297 /**
298 * Window type: the status bar. There can be only one status bar
299 * window; it is placed at the top of the screen, and all other
300 * windows are shifted down so they are below it.
301 */
302 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
303
304 /**
305 * Window type: the search bar. There can be only one search bar
306 * window; it is placed at the top of the screen.
307 */
308 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
309
310 /**
311 * Window type: phone. These are non-application windows providing
312 * user interaction with the phone (in particular incoming calls).
313 * These windows are normally placed above all applications, but behind
314 * the status bar.
315 */
316 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
317
318 /**
319 * Window type: system window, such as low power alert. These windows
320 * are always on top of application windows.
321 */
322 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
323
324 /**
325 * Window type: keyguard window.
326 */
327 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
328
329 /**
330 * Window type: transient notifications.
331 */
332 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
333
334 /**
335 * Window type: system overlay windows, which need to be displayed
336 * on top of everything else. These windows must not take input
337 * focus, or they will interfere with the keyguard.
338 */
339 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
340
341 /**
342 * Window type: priority phone UI, which needs to be displayed even if
343 * the keyguard is active. These windows must not take input
344 * focus, or they will interfere with the keyguard.
345 */
346 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7;
347
348 /**
349 * Window type: panel that slides out from the status bar
350 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800351 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
352
353 /**
354 * Window type: dialogs that the keyguard shows
355 */
356 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9;
357
358 /**
359 * Window type: internal system error windows, appear on top of
360 * everything they can.
361 */
362 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
363
364 /**
365 * Window type: internal input methods windows, which appear above
366 * the normal UI. Application windows may be resized or panned to keep
367 * the input focus visible while this window is displayed.
368 */
369 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11;
370
371 /**
372 * Window type: internal input methods dialog windows, which appear above
373 * the current input method window.
374 */
375 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
376
377 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700378 * Window type: wallpaper window, placed behind any window that wants
379 * to sit on top of the wallpaper.
380 */
381 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13;
382
383 /**
Joe Onorato29fc2c92010-11-24 10:26:50 -0800384 * Window type: panel that slides out from over the status bar
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800385 */
386 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14;
Jeff Brown3b2b3542010-10-15 00:54:27 -0700387
388 /**
389 * Window type: secure system overlay windows, which need to be displayed
390 * on top of everything else. These windows must not take input
391 * focus, or they will interfere with the keyguard.
392 *
393 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
394 * system itself is allowed to create these overlays. Applications cannot
395 * obtain permission to create secure system overlays.
396 * @hide
397 */
398 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
399
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800400 /**
Christopher Tatea53146c2010-09-07 11:57:52 -0700401 * Window type: the drag-and-drop pseudowindow. There is only one
402 * drag layer (at most), and it is placed on top of all other windows.
403 * @hide
404 */
Jeff Brown3b2b3542010-10-15 00:54:27 -0700405 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16;
Christopher Tatea53146c2010-09-07 11:57:52 -0700406
407 /**
Joe Onorato29fc2c92010-11-24 10:26:50 -0800408 * Window type: panel that slides out from under the status bar
Joe Onoratoa89e9032010-11-24 11:13:44 -0800409 * @hide
Joe Onorato29fc2c92010-11-24 10:26:50 -0800410 */
411 public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
412
Jeff Brown83c09682010-12-23 17:50:18 -0800413 /**
414 * Window type: (mouse) pointer
415 * @hide
416 */
417 public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
Joe Onorato29fc2c92010-11-24 10:26:50 -0800418
419 /**
Daniel Sandler8956dbb2011-04-22 07:55:02 -0400420 * Window type: Navigation bar (when distinct from status bar)
421 * @hide
422 */
423 public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
424
425 /**
Dianne Hackborne8ecde12011-08-03 18:55:19 -0700426 * Window type: The volume level overlay/dialog shown when the user
427 * changes the system volume.
428 * @hide
429 */
430 public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
431
432 /**
Dianne Hackborn29aae6f2011-08-18 18:30:09 -0700433 * Window type: The boot progress dialog, goes on top of everything
434 * in the world.
435 * @hide
436 */
437 public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
438
439 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -0700440 * Window type: Fake window to consume touch events when the navigation
441 * bar is hidden.
442 * @hide
443 */
444 public static final int TYPE_HIDDEN_NAV_CONSUMER = FIRST_SYSTEM_WINDOW+22;
445
446 /**
Daniel Sandler7d276c32012-01-30 14:33:52 -0500447 * Window type: Dreams (screen saver) window, just above keyguard.
448 * @hide
449 */
450 public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23;
451
452 /**
Jim Millere898ac52012-04-06 17:10:57 -0700453 * Window type: Navigation bar panel (when navigation bar is distinct from status bar)
454 * @hide
455 */
456 public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24;
457
458 /**
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700459 * Window type: Behind the universe of the real windows.
460 * @hide
461 */
462 public static final int TYPE_UNIVERSE_BACKGROUND = FIRST_SYSTEM_WINDOW+25;
463
464 /**
Jeff Brownbd6e1502012-08-28 03:27:37 -0700465 * Window type: Display overlay window. Used to simulate secondary display devices.
466 * @hide
467 */
468 public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26;
469
470 /**
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -0700471 * Window type: Magnification overlay window. Used to highlight the magnified
472 * portion of a display when accessibility magnification is enabled.
473 * @hide
474 */
475 public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27;
476
477 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800478 * End of types of system windows.
479 */
480 public static final int LAST_SYSTEM_WINDOW = 2999;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800481
Mathias Agopiand2112302010-12-07 19:38:17 -0800482 /** @deprecated this is ignored, this value is set automatically when needed. */
483 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800484 public static final int MEMORY_TYPE_NORMAL = 0;
Mathias Agopiand2112302010-12-07 19:38:17 -0800485 /** @deprecated this is ignored, this value is set automatically when needed. */
Mathias Agopian317a6282009-08-13 17:29:02 -0700486 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800487 public static final int MEMORY_TYPE_HARDWARE = 1;
Mathias Agopiand2112302010-12-07 19:38:17 -0800488 /** @deprecated this is ignored, this value is set automatically when needed. */
Mathias Agopian317a6282009-08-13 17:29:02 -0700489 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800490 public static final int MEMORY_TYPE_GPU = 2;
Mathias Agopiand2112302010-12-07 19:38:17 -0800491 /** @deprecated this is ignored, this value is set automatically when needed. */
492 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800493 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700494
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800495 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700496 * @deprecated this is ignored
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800497 */
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700498 @Deprecated
499 public int memoryType;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800500
Mike Lockwoodef731622010-01-27 17:51:34 -0500501 /** Window flag: as long as this window is visible to the user, allow
502 * the lock screen to activate while the screen is on.
503 * This can be used independently, or in combination with
Christopher Tate95f78502010-01-29 15:57:34 -0800504 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
Mike Lockwoodef731622010-01-27 17:51:34 -0500505 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001;
506
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800507 /** Window flag: everything behind this window will be dimmed.
508 * Use {@link #dimAmount} to control the amount of dim. */
509 public static final int FLAG_DIM_BEHIND = 0x00000002;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700510
511 /** Window flag: blur everything behind this window.
512 * @deprecated Blurring is no longer supported. */
513 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800514 public static final int FLAG_BLUR_BEHIND = 0x00000004;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700515
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800516 /** Window flag: this window won't ever get key input focus, so the
517 * user can not send key or other button events to it. Those will
518 * instead go to whatever focusable window is behind it. This flag
519 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
520 * is explicitly set.
521 *
522 * <p>Setting this flag also implies that the window will not need to
523 * interact with
524 * a soft input method, so it will be Z-ordered and positioned
525 * independently of any active input method (typically this means it
526 * gets Z-ordered on top of the input method, so it can use the full
527 * screen for its content and cover the input method if needed. You
528 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
529 public static final int FLAG_NOT_FOCUSABLE = 0x00000008;
530
531 /** Window flag: this window can never receive touch events. */
532 public static final int FLAG_NOT_TOUCHABLE = 0x00000010;
533
534 /** Window flag: Even when this window is focusable (its
535 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events
536 * outside of the window to be sent to the windows behind it. Otherwise
537 * it will consume all pointer events itself, regardless of whether they
538 * are inside of the window. */
539 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020;
540
541 /** Window flag: When set, if the device is asleep when the touch
542 * screen is pressed, you will receive this first touch event. Usually
543 * the first touch event is consumed by the system since the user can
544 * not see what they are pressing on.
545 */
546 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
547
548 /** Window flag: as long as this window is visible to the user, keep
549 * the device's screen turned on and bright. */
550 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080;
551
552 /** Window flag: place the window within the entire screen, ignoring
553 * decorations around the border (a.k.a. the status bar). The
554 * window must correctly position its contents to take the screen
555 * decoration into account. This flag is normally set for you
556 * by Window as described in {@link Window#setFlags}. */
557 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100;
558
559 /** Window flag: allow window to extend outside of the screen. */
560 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200;
561
562 /** Window flag: Hide all screen decorations (e.g. status bar) while
563 * this window is displayed. This allows the window to use the entire
564 * display space for itself -- the status bar will be hidden when
565 * an app window with this flag set is on the top layer. */
566 public static final int FLAG_FULLSCREEN = 0x00000400;
567
568 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the
569 * screen decorations (such as status bar) to be shown. */
570 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800;
571
572 /** Window flag: turn on dithering when compositing this window to
Jeff Brown3cc321e2012-07-16 16:04:23 -0700573 * the screen.
574 * @deprecated This flag is no longer used. */
575 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800576 public static final int FLAG_DITHER = 0x00001000;
577
578 /** Window flag: don't allow screen shots while this window is
Glenn Kastend6f5bde2011-01-19 15:27:27 -0800579 * displayed. Maps to Surface.SECURE. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800580 public static final int FLAG_SECURE = 0x00002000;
581
582 /** Window flag: a special mode where the layout parameters are used
583 * to perform scaling of the surface when it is composited to the
584 * screen. */
585 public static final int FLAG_SCALED = 0x00004000;
586
587 /** Window flag: intended for windows that will often be used when the user is
588 * holding the screen against their face, it will aggressively filter the event
589 * stream to prevent unintended presses in this situation that may not be
590 * desired for a particular window, when such an event stream is detected, the
591 * application will receive a CANCEL motion event to indicate this so applications
592 * can handle this accordingly by taking no action on the event
593 * until the finger is released. */
594 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000;
595
596 /** Window flag: a special option only for use in combination with
597 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the
598 * screen your window may appear on top of or behind screen decorations
599 * such as the status bar. By also including this flag, the window
600 * manager will report the inset rectangle needed to ensure your
601 * content is not covered by screen decorations. This flag is normally
602 * set for you by Window as described in {@link Window#setFlags}.*/
603 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
604
605 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
606 * respect to how this window interacts with the current method. That
607 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
608 * window will behave as if it needs to interact with the input method
609 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
610 * not set and this flag is set, then the window will behave as if it
611 * doesn't need to interact with the input method and can be placed
612 * to use more space and cover the input method.
613 */
614 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
615
616 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
617 * can set this flag to receive a single special MotionEvent with
618 * the action
619 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
620 * touches that occur outside of your window. Note that you will not
621 * receive the full down/move/up gesture, only the location of the
622 * first down as an ACTION_OUTSIDE.
623 */
624 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
625
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700626 /** Window flag: special flag to let windows be shown when the screen
627 * is locked. This will let application windows take precedence over
628 * key guard or any other lock screens. Can be used with
629 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700630 * directly before showing the key guard window. Can be used with
631 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
632 * non-secure keyguards. This flag only applies to the top-most
633 * full-screen window.
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700634 */
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700635 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
636
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700637 /** Window flag: ask that the system wallpaper be shown behind
638 * your window. The window surface must be translucent to be able
639 * to actually see the wallpaper behind it; this flag just ensures
640 * that the wallpaper surface will be there if this window actually
641 * has translucent regions.
642 */
643 public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
644
Dianne Hackborn93e462b2009-09-15 22:50:40 -0700645 /** Window flag: when set as a window is being added or made
646 * visible, once the window has been shown then the system will
647 * poke the power manager's user activity (as if the user had woken
648 * up the device) to turn the screen on. */
649 public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
650
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700651 /** Window flag: when set the window will cause the keyguard to
652 * be dismissed, only if it is not a secure lock keyguard. Because such
653 * a keyguard is not needed for security, it will never re-appear if
654 * the user navigates to another window (in contrast to
655 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily
656 * hide both secure and non-secure keyguards but ensure they reappear
657 * when the user moves to another UI that doesn't hide them).
658 * If the keyguard is currently active and is secure (requires an
659 * unlock pattern) than the user will still need to confirm it before
660 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has
Daniel Sandlerae069f72010-06-17 21:56:26 -0400661 * also been set.
662 */
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700663 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
Jeff Brown01ce2e92010-09-26 22:20:12 -0700664
665 /** Window flag: when set the window will accept for touch events
666 * outside of its bounds to be sent to other windows that also
667 * support split touch. When this flag is not set, the first pointer
668 * that goes down determines the window to which all subsequent touches
669 * go until all pointers go up. When this flag is set, each pointer
670 * (not necessarily the first) that goes down determines the window
671 * to which all subsequent touches of that pointer will go until that
672 * pointer goes up thereby enabling touches with multiple pointers
673 * to be split across multiple windows.
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800674 */
Jeff Brown01ce2e92010-09-26 22:20:12 -0700675 public static final int FLAG_SPLIT_TOUCH = 0x00800000;
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800676
677 /**
Romain Guy72f0a272011-01-09 16:01:46 -0800678 * <p>Indicates whether this window should be hardware accelerated.
679 * Requesting hardware acceleration does not guarantee it will happen.</p>
680 *
681 * <p>This flag can be controlled programmatically <em>only</em> to enable
682 * hardware acceleration. To enable hardware acceleration for a given
683 * window programmatically, do the following:</p>
684 *
685 * <pre>
686 * Window w = activity.getWindow(); // in Activity's onCreate() for instance
687 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
688 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
689 * </pre>
690 *
691 * <p>It is important to remember that this flag <strong>must</strong>
692 * be set before setting the content view of your activity or dialog.</p>
693 *
694 * <p>This flag cannot be used to disable hardware acceleration after it
695 * was enabled in your manifest using
696 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively
697 * and programmatically disable hardware acceleration (for automated testing
698 * for instance), make sure it is turned off in your manifest and enable it
699 * on your activity or dialog when you need it instead, using the method
700 * described above.</p>
701 *
702 * <p>This flag is automatically set by the system if the
703 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
704 * XML attribute is set to true on an activity or on the application.</p>
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800705 */
706 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
Daniel Sandler611fae42010-06-17 10:45:00 -0400707
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800708 // ----- HIDDEN FLAGS.
709 // These start at the high bit and go down.
Jeff Brown98db5fa2011-06-08 15:37:10 -0700710
711 /** Window flag: Enable touches to slide out of a window into neighboring
712 * windows in mid-gesture instead of being captured for the duration of
713 * the gesture.
714 *
715 * This flag changes the behavior of touch focus for this window only.
716 * Touches can slide out of the window but they cannot necessarily slide
717 * back in (unless the other window with touch focus permits it).
718 *
719 * {@hide}
720 */
721 public static final int FLAG_SLIPPERY = 0x04000000;
722
Daniel Sandlere02d8082010-10-08 15:13:22 -0400723 /**
724 * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU}
725 * and therefore needs a Menu key. For devices where Menu is a physical button this flag is
726 * ignored, but on devices where the Menu key is drawn in software it may be hidden unless
727 * this flag is set.
728 *
729 * (Note that Action Bars, when available, are the preferred way to offer additional
730 * functions otherwise accessed via an options menu.)
731 *
732 * {@hide}
733 */
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800734 public static final int FLAG_NEEDS_MENU_KEY = 0x08000000;
Daniel Sandlere02d8082010-10-08 15:13:22 -0400735
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700736 /** Window flag: special flag to limit the size of the window to be
737 * original size ([320x480] x density). Used to create window for applications
738 * running under compatibility mode.
739 *
740 * {@hide} */
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700741 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000;
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700742
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800743 /** Window flag: a special option intended for system dialogs. When
744 * this flag is set, the window will demand focus unconditionally when
745 * it is created.
746 * {@hide} */
747 public static final int FLAG_SYSTEM_ERROR = 0x40000000;
748
749 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700750 * Various behavioral options/flags. Default is none.
751 *
752 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
753 * @see #FLAG_DIM_BEHIND
754 * @see #FLAG_NOT_FOCUSABLE
755 * @see #FLAG_NOT_TOUCHABLE
756 * @see #FLAG_NOT_TOUCH_MODAL
757 * @see #FLAG_TOUCHABLE_WHEN_WAKING
758 * @see #FLAG_KEEP_SCREEN_ON
759 * @see #FLAG_LAYOUT_IN_SCREEN
760 * @see #FLAG_LAYOUT_NO_LIMITS
761 * @see #FLAG_FULLSCREEN
762 * @see #FLAG_FORCE_NOT_FULLSCREEN
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700763 * @see #FLAG_SECURE
764 * @see #FLAG_SCALED
765 * @see #FLAG_IGNORE_CHEEK_PRESSES
766 * @see #FLAG_LAYOUT_INSET_DECOR
767 * @see #FLAG_ALT_FOCUSABLE_IM
768 * @see #FLAG_WATCH_OUTSIDE_TOUCH
769 * @see #FLAG_SHOW_WHEN_LOCKED
770 * @see #FLAG_SHOW_WALLPAPER
771 * @see #FLAG_TURN_SCREEN_ON
772 * @see #FLAG_DISMISS_KEYGUARD
773 * @see #FLAG_SPLIT_TOUCH
774 * @see #FLAG_HARDWARE_ACCELERATED
775 */
776 @ViewDebug.ExportedProperty(flagMapping = {
777 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
778 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
779 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
780 name = "FLAG_DIM_BEHIND"),
781 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
782 name = "FLAG_BLUR_BEHIND"),
783 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
784 name = "FLAG_NOT_FOCUSABLE"),
785 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
786 name = "FLAG_NOT_TOUCHABLE"),
787 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
788 name = "FLAG_NOT_TOUCH_MODAL"),
789 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING,
790 name = "FLAG_TOUCHABLE_WHEN_WAKING"),
791 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
792 name = "FLAG_KEEP_SCREEN_ON"),
793 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
794 name = "FLAG_LAYOUT_IN_SCREEN"),
795 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS,
796 name = "FLAG_LAYOUT_NO_LIMITS"),
797 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
798 name = "FLAG_FULLSCREEN"),
799 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN,
800 name = "FLAG_FORCE_NOT_FULLSCREEN"),
801 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
802 name = "FLAG_DITHER"),
803 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE,
804 name = "FLAG_SECURE"),
805 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED,
806 name = "FLAG_SCALED"),
807 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES,
808 name = "FLAG_IGNORE_CHEEK_PRESSES"),
809 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR,
810 name = "FLAG_LAYOUT_INSET_DECOR"),
811 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM,
812 name = "FLAG_ALT_FOCUSABLE_IM"),
813 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH,
814 name = "FLAG_WATCH_OUTSIDE_TOUCH"),
815 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
816 name = "FLAG_SHOW_WHEN_LOCKED"),
817 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER,
818 name = "FLAG_SHOW_WALLPAPER"),
819 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
820 name = "FLAG_TURN_SCREEN_ON"),
821 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
822 name = "FLAG_DISMISS_KEYGUARD"),
823 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH,
824 name = "FLAG_SPLIT_TOUCH"),
825 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
826 name = "FLAG_HARDWARE_ACCELERATED")
827 })
828 public int flags;
829
830 /**
831 * If the window has requested hardware acceleration, but this is not
832 * allowed in the process it is in, then still render it as if it is
833 * hardware accelerated. This is used for the starting preview windows
834 * in the system process, which don't need to have the overhead of
835 * hardware acceleration (they are just a static rendering), but should
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900836 * be rendered as such to match the actual window of the app even if it
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700837 * is hardware accelerated.
838 * Even if the window isn't hardware accelerated, still do its rendering
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900839 * as if it was.
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700840 * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
841 * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
842 * is generally disabled. This flag must be specified in addition to
843 * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
844 * windows.
845 *
846 * @hide
847 */
848 public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
849
850 /**
851 * In the system process, we globally do not use hardware acceleration
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900852 * because there are many threads doing UI there and they conflict.
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700853 * If certain parts of the UI that really do want to use hardware
854 * acceleration, this flag can be set to force it. This is basically
855 * for the lock screen. Anyone else using it, you are probably wrong.
856 *
857 * @hide
858 */
859 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002;
860
861 /**
Chet Haasea8e5a2b2011-10-28 13:18:16 -0700862 * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900863 * may elect to skip these notifications if they are not doing anything productive with
Chet Haasea8e5a2b2011-10-28 13:18:16 -0700864 * them (they do not affect the wallpaper scrolling operation) by calling
865 * {@link
866 * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}.
867 *
868 * @hide
869 */
870 public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004;
871
872 /**
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800873 * This is set for a window that has explicitly specified its
874 * FLAG_NEEDS_MENU_KEY, so we know the value on this window is the
875 * appropriate one to use. If this is not set, we should look at
876 * windows behind it to determine the appropriate value.
877 *
878 * @hide
879 */
880 public static final int PRIVATE_FLAG_SET_NEEDS_MENU_KEY = 0x00000008;
881
882 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700883 * Control flags that are private to the platform.
884 * @hide
885 */
886 public int privateFlags;
887
888 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800889 * Given a particular set of window manager flags, determine whether
890 * such a window may be a target for an input method when it has
891 * focus. In particular, this checks the
892 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
893 * flags and returns true if the combination of the two corresponds
894 * to a window that needs to be behind the input method so that the
895 * user can type into it.
896 *
897 * @param flags The current window manager flags.
898 *
899 * @return Returns true if such a window should be behind/interact
900 * with an input method, false if not.
901 */
902 public static boolean mayUseInputMethod(int flags) {
903 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
904 case 0:
905 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
906 return true;
907 }
908 return false;
909 }
910
911 /**
912 * Mask for {@link #softInputMode} of the bits that determine the
913 * desired visibility state of the soft input area for this window.
914 */
915 public static final int SOFT_INPUT_MASK_STATE = 0x0f;
916
917 /**
918 * Visibility state for {@link #softInputMode}: no state has been specified.
919 */
920 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
921
922 /**
923 * Visibility state for {@link #softInputMode}: please don't change the state of
924 * the soft input area.
925 */
926 public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
927
928 /**
929 * Visibility state for {@link #softInputMode}: please hide any soft input
930 * area when normally appropriate (when the user is navigating
931 * forward to your window).
932 */
933 public static final int SOFT_INPUT_STATE_HIDDEN = 2;
934
935 /**
936 * Visibility state for {@link #softInputMode}: please always hide any
937 * soft input area when this window receives focus.
938 */
939 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
940
941 /**
942 * Visibility state for {@link #softInputMode}: please show the soft
943 * input area when normally appropriate (when the user is navigating
944 * forward to your window).
945 */
946 public static final int SOFT_INPUT_STATE_VISIBLE = 4;
947
948 /**
949 * Visibility state for {@link #softInputMode}: please always make the
950 * soft input area visible when this window receives input focus.
951 */
952 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
953
954 /**
955 * Mask for {@link #softInputMode} of the bits that determine the
956 * way that the window should be adjusted to accommodate the soft
957 * input window.
958 */
959 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
960
961 /** Adjustment option for {@link #softInputMode}: nothing specified.
962 * The system will try to pick one or
963 * the other depending on the contents of the window.
964 */
965 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
966
967 /** Adjustment option for {@link #softInputMode}: set to allow the
968 * window to be resized when an input
969 * method is shown, so that its contents are not covered by the input
Scott Mainf10e6332010-06-11 09:03:22 -0700970 * method. This can <em>not</em> be combined with
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800971 * {@link #SOFT_INPUT_ADJUST_PAN}; if
972 * neither of these are set, then the system will try to pick one or
973 * the other depending on the contents of the window.
974 */
975 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
976
977 /** Adjustment option for {@link #softInputMode}: set to have a window
978 * pan when an input method is
979 * shown, so it doesn't need to deal with resizing but just panned
980 * by the framework to ensure the current input focus is visible. This
Scott Mainf10e6332010-06-11 09:03:22 -0700981 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800982 * neither of these are set, then the system will try to pick one or
983 * the other depending on the contents of the window.
984 */
985 public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
986
Dianne Hackborndea3ef72010-10-28 14:24:22 -0700987 /** Adjustment option for {@link #softInputMode}: set to have a window
988 * not adjust for a shown input method. The window will not be resized,
989 * and it will not be panned to make its focus visible.
990 */
991 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30;
992
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800993 /**
994 * Bit for {@link #softInputMode}: set when the user has navigated
995 * forward to the window. This is normally set automatically for
996 * you by the system, though you may want to set it in certain cases
997 * when you are displaying a window yourself. This flag will always
998 * be cleared automatically after the window is displayed.
999 */
1000 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001001
1002 /**
Gilles Debunnebe2c4f92011-01-17 15:14:32 -08001003 * Desired operating mode for any soft input area. May be any combination
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001004 * of:
1005 *
1006 * <ul>
1007 * <li> One of the visibility states
1008 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
1009 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or
1010 * {@link #SOFT_INPUT_STATE_VISIBLE}.
1011 * <li> One of the adjustment options
1012 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED},
1013 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or
1014 * {@link #SOFT_INPUT_ADJUST_PAN}.
1015 */
1016 public int softInputMode;
1017
1018 /**
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001019 * Placement of window within the screen as per {@link Gravity}. Both
1020 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
1021 * android.graphics.Rect) Gravity.apply} and
1022 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
1023 * Gravity.applyDisplay} are used during window layout, with this value
1024 * given as the desired gravity. For example you can specify
1025 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and
1026 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here
1027 * to control the behavior of
1028 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
1029 * Gravity.applyDisplay}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001030 *
1031 * @see Gravity
1032 */
1033 public int gravity;
1034
1035 /**
1036 * The horizontal margin, as a percentage of the container's width,
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001037 * between the container and the widget. See
1038 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
1039 * android.graphics.Rect) Gravity.apply} for how this is used. This
1040 * field is added with {@link #x} to supply the <var>xAdj</var> parameter.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001041 */
1042 public float horizontalMargin;
1043
1044 /**
1045 * The vertical margin, as a percentage of the container's height,
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001046 * between the container and the widget. See
1047 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
1048 * android.graphics.Rect) Gravity.apply} for how this is used. This
1049 * field is added with {@link #y} to supply the <var>yAdj</var> parameter.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001050 */
1051 public float verticalMargin;
1052
1053 /**
1054 * The desired bitmap format. May be one of the constants in
1055 * {@link android.graphics.PixelFormat}. Default is OPAQUE.
1056 */
1057 public int format;
1058
1059 /**
1060 * A style resource defining the animations to use for this window.
1061 * This must be a system resource; it can not be an application resource
1062 * because the window manager does not have access to applications.
1063 */
1064 public int windowAnimations;
1065
1066 /**
1067 * An alpha value to apply to this entire window.
1068 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
1069 */
1070 public float alpha = 1.0f;
1071
1072 /**
1073 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
1074 * to apply. Range is from 1.0 for completely opaque to 0.0 for no
1075 * dim.
1076 */
1077 public float dimAmount = 1.0f;
Dianne Hackborndea3ef72010-10-28 14:24:22 -07001078
1079 /**
1080 * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
1081 * indicating that the brightness value is not overridden for this window
1082 * and normal brightness policy should be used.
1083 */
1084 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
1085
1086 /**
1087 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
1088 * indicating that the screen or button backlight brightness should be set
1089 * to the lowest value when this window is in front.
1090 */
1091 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
1092
1093 /**
1094 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
1095 * indicating that the screen or button backlight brightness should be set
1096 * to the hightest value when this window is in front.
1097 */
1098 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001099
1100 /**
1101 * This can be used to override the user's preferred brightness of
1102 * the screen. A value of less than 0, the default, means to use the
1103 * preferred screen brightness. 0 to 1 adjusts the brightness from
1104 * dark to full bright.
1105 */
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001106 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001107
1108 /**
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001109 * This can be used to override the standard behavior of the button and
1110 * keyboard backlights. A value of less than 0, the default, means to
1111 * use the standard backlight behavior. 0 to 1 adjusts the brightness
1112 * from dark to full bright.
1113 */
1114 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
1115
1116 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001117 * Identifier for this window. This will usually be filled in for
1118 * you.
1119 */
1120 public IBinder token = null;
1121
1122 /**
1123 * Name of the package owning this window.
1124 */
1125 public String packageName = null;
1126
1127 /**
1128 * Specific orientation value for a window.
1129 * May be any of the same values allowed
1130 * for {@link android.content.pm.ActivityInfo#screenOrientation}.
1131 * If not set, a default value of
1132 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
1133 * will be used.
1134 */
1135 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Joe Onorato664644d2011-01-23 17:53:23 -08001136
1137 /**
1138 * Control the visibility of the status bar.
Joe Onorato14782f72011-01-25 19:53:17 -08001139 *
1140 * @see View#STATUS_BAR_VISIBLE
1141 * @see View#STATUS_BAR_HIDDEN
Joe Onorato664644d2011-01-23 17:53:23 -08001142 */
1143 public int systemUiVisibility;
1144
1145 /**
Joe Onorato14782f72011-01-25 19:53:17 -08001146 * @hide
1147 * The ui visibility as requested by the views in this hierarchy.
1148 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility.
1149 */
1150 public int subtreeSystemUiVisibility;
1151
1152 /**
Joe Onorato664644d2011-01-23 17:53:23 -08001153 * Get callbacks about the system ui visibility changing.
1154 *
1155 * TODO: Maybe there should be a bitfield of optional callbacks that we need.
1156 *
1157 * @hide
1158 */
1159 public boolean hasSystemUiListeners;
1160
Jeff Brown474dcb52011-06-14 20:22:50 -07001161 /**
1162 * When this window has focus, disable touch pad pointer gesture processing.
1163 * The window will receive raw position updates from the touch pad instead
1164 * of pointer movements and synthetic touch events.
1165 *
1166 * @hide
1167 */
1168 public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001;
1169
1170 /**
Jeff Browncc4f7db2011-08-30 20:34:48 -07001171 * Does not construct an input channel for this window. The channel will therefore
1172 * be incapable of receiving input.
1173 *
1174 * @hide
1175 */
1176 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002;
1177
1178 /**
Jeff Brown1e3b98d2012-09-30 18:58:59 -07001179 * When this window has focus, does not call user activity for all input events so
1180 * the application will have to do it itself. Should only be used by
1181 * the keyguard and phone app.
1182 * <p>
1183 * Should only be used by the keyguard and phone app.
1184 * </p>
1185 *
1186 * @hide
1187 */
1188 public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004;
1189
1190 /**
Jeff Brown474dcb52011-06-14 20:22:50 -07001191 * Control special features of the input subsystem.
1192 *
1193 * @see #INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES
Jeff Browncc4f7db2011-08-30 20:34:48 -07001194 * @see #INPUT_FEATURE_NO_INPUT_CHANNEL
Jeff Brown1e3b98d2012-09-30 18:58:59 -07001195 * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY
Jeff Brown474dcb52011-06-14 20:22:50 -07001196 * @hide
1197 */
1198 public int inputFeatures;
1199
Jeff Brown1e3b98d2012-09-30 18:58:59 -07001200 /**
1201 * Sets the number of milliseconds before the user activity timeout occurs
1202 * when this window has focus. A value of -1 uses the standard timeout.
1203 * A value of 0 uses the minimum support display timeout.
1204 * <p>
1205 * This property can only be used to reduce the user specified display timeout;
1206 * it can never make the timeout longer than it normally would be.
1207 * </p><p>
1208 * Should only be used by the keyguard and phone app.
1209 * </p>
1210 *
1211 * @hide
1212 */
1213 public long userActivityTimeout = -1;
1214
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001215 public LayoutParams() {
Romain Guy980a9382010-01-08 15:06:28 -08001216 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001217 type = TYPE_APPLICATION;
1218 format = PixelFormat.OPAQUE;
1219 }
1220
1221 public LayoutParams(int _type) {
Romain Guy980a9382010-01-08 15:06:28 -08001222 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001223 type = _type;
1224 format = PixelFormat.OPAQUE;
1225 }
1226
1227 public LayoutParams(int _type, int _flags) {
Romain Guy980a9382010-01-08 15:06:28 -08001228 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001229 type = _type;
1230 flags = _flags;
1231 format = PixelFormat.OPAQUE;
1232 }
1233
1234 public LayoutParams(int _type, int _flags, int _format) {
Romain Guy980a9382010-01-08 15:06:28 -08001235 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001236 type = _type;
1237 flags = _flags;
1238 format = _format;
1239 }
1240
1241 public LayoutParams(int w, int h, int _type, int _flags, int _format) {
1242 super(w, h);
1243 type = _type;
1244 flags = _flags;
1245 format = _format;
1246 }
1247
1248 public LayoutParams(int w, int h, int xpos, int ypos, int _type,
1249 int _flags, int _format) {
1250 super(w, h);
1251 x = xpos;
1252 y = ypos;
1253 type = _type;
1254 flags = _flags;
1255 format = _format;
1256 }
1257
1258 public final void setTitle(CharSequence title) {
1259 if (null == title)
1260 title = "";
1261
1262 mTitle = TextUtils.stringOrSpannedString(title);
1263 }
1264
1265 public final CharSequence getTitle() {
1266 return mTitle;
1267 }
1268
1269 public int describeContents() {
1270 return 0;
1271 }
1272
1273 public void writeToParcel(Parcel out, int parcelableFlags) {
1274 out.writeInt(width);
1275 out.writeInt(height);
1276 out.writeInt(x);
1277 out.writeInt(y);
1278 out.writeInt(type);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001279 out.writeInt(flags);
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001280 out.writeInt(privateFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001281 out.writeInt(softInputMode);
1282 out.writeInt(gravity);
1283 out.writeFloat(horizontalMargin);
1284 out.writeFloat(verticalMargin);
1285 out.writeInt(format);
1286 out.writeInt(windowAnimations);
1287 out.writeFloat(alpha);
1288 out.writeFloat(dimAmount);
1289 out.writeFloat(screenBrightness);
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001290 out.writeFloat(buttonBrightness);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001291 out.writeStrongBinder(token);
1292 out.writeString(packageName);
1293 TextUtils.writeToParcel(mTitle, out, parcelableFlags);
1294 out.writeInt(screenOrientation);
Joe Onorato664644d2011-01-23 17:53:23 -08001295 out.writeInt(systemUiVisibility);
Joe Onorato14782f72011-01-25 19:53:17 -08001296 out.writeInt(subtreeSystemUiVisibility);
Joe Onorato664644d2011-01-23 17:53:23 -08001297 out.writeInt(hasSystemUiListeners ? 1 : 0);
Jeff Brown474dcb52011-06-14 20:22:50 -07001298 out.writeInt(inputFeatures);
Jeff Brown1e3b98d2012-09-30 18:58:59 -07001299 out.writeLong(userActivityTimeout);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001300 }
1301
1302 public static final Parcelable.Creator<LayoutParams> CREATOR
1303 = new Parcelable.Creator<LayoutParams>() {
1304 public LayoutParams createFromParcel(Parcel in) {
1305 return new LayoutParams(in);
1306 }
1307
1308 public LayoutParams[] newArray(int size) {
1309 return new LayoutParams[size];
1310 }
1311 };
1312
1313
1314 public LayoutParams(Parcel in) {
1315 width = in.readInt();
1316 height = in.readInt();
1317 x = in.readInt();
1318 y = in.readInt();
1319 type = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001320 flags = in.readInt();
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001321 privateFlags = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001322 softInputMode = in.readInt();
1323 gravity = in.readInt();
1324 horizontalMargin = in.readFloat();
1325 verticalMargin = in.readFloat();
1326 format = in.readInt();
1327 windowAnimations = in.readInt();
1328 alpha = in.readFloat();
1329 dimAmount = in.readFloat();
1330 screenBrightness = in.readFloat();
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001331 buttonBrightness = in.readFloat();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001332 token = in.readStrongBinder();
1333 packageName = in.readString();
1334 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
1335 screenOrientation = in.readInt();
Joe Onorato664644d2011-01-23 17:53:23 -08001336 systemUiVisibility = in.readInt();
Joe Onorato14782f72011-01-25 19:53:17 -08001337 subtreeSystemUiVisibility = in.readInt();
Joe Onorato664644d2011-01-23 17:53:23 -08001338 hasSystemUiListeners = in.readInt() != 0;
Jeff Brown474dcb52011-06-14 20:22:50 -07001339 inputFeatures = in.readInt();
Jeff Brown1e3b98d2012-09-30 18:58:59 -07001340 userActivityTimeout = in.readLong();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001341 }
1342
Romain Guy72998072009-06-22 11:09:20 -07001343 @SuppressWarnings({"PointlessBitwiseExpression"})
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001344 public static final int LAYOUT_CHANGED = 1<<0;
1345 public static final int TYPE_CHANGED = 1<<1;
1346 public static final int FLAGS_CHANGED = 1<<2;
1347 public static final int FORMAT_CHANGED = 1<<3;
1348 public static final int ANIMATION_CHANGED = 1<<4;
1349 public static final int DIM_AMOUNT_CHANGED = 1<<5;
1350 public static final int TITLE_CHANGED = 1<<6;
1351 public static final int ALPHA_CHANGED = 1<<7;
1352 public static final int MEMORY_TYPE_CHANGED = 1<<8;
1353 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
1354 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
1355 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001356 /** {@hide} */
1357 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12;
Joe Onorato664644d2011-01-23 17:53:23 -08001358 /** {@hide} */
1359 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<13;
1360 /** {@hide} */
1361 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<14;
Jeff Brown474dcb52011-06-14 20:22:50 -07001362 /** {@hide} */
1363 public static final int INPUT_FEATURES_CHANGED = 1<<15;
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001364 /** {@hide} */
1365 public static final int PRIVATE_FLAGS_CHANGED = 1<<16;
Romain Guyf21c9b02011-09-06 16:56:54 -07001366 /** {@hide} */
Jeff Brown1e3b98d2012-09-30 18:58:59 -07001367 public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<17;
1368 /** {@hide} */
Romain Guyf21c9b02011-09-06 16:56:54 -07001369 public static final int EVERYTHING_CHANGED = 0xffffffff;
1370
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001371 // internal buffer to backup/restore parameters under compatibility mode.
1372 private int[] mCompatibilityParamsBackup = null;
1373
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001374 public final int copyFrom(LayoutParams o) {
1375 int changes = 0;
1376
1377 if (width != o.width) {
1378 width = o.width;
Chet Haase40e03832011-10-06 08:34:13 -07001379 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001380 }
1381 if (height != o.height) {
1382 height = o.height;
Chet Haase40e03832011-10-06 08:34:13 -07001383 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001384 }
1385 if (x != o.x) {
1386 x = o.x;
1387 changes |= LAYOUT_CHANGED;
1388 }
1389 if (y != o.y) {
1390 y = o.y;
1391 changes |= LAYOUT_CHANGED;
1392 }
1393 if (horizontalWeight != o.horizontalWeight) {
1394 horizontalWeight = o.horizontalWeight;
Chet Haase40e03832011-10-06 08:34:13 -07001395 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001396 }
1397 if (verticalWeight != o.verticalWeight) {
1398 verticalWeight = o.verticalWeight;
Chet Haase40e03832011-10-06 08:34:13 -07001399 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001400 }
1401 if (horizontalMargin != o.horizontalMargin) {
1402 horizontalMargin = o.horizontalMargin;
Chet Haase40e03832011-10-06 08:34:13 -07001403 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001404 }
1405 if (verticalMargin != o.verticalMargin) {
1406 verticalMargin = o.verticalMargin;
Chet Haase40e03832011-10-06 08:34:13 -07001407 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001408 }
1409 if (type != o.type) {
1410 type = o.type;
1411 changes |= TYPE_CHANGED;
1412 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001413 if (flags != o.flags) {
1414 flags = o.flags;
Chet Haase40e03832011-10-06 08:34:13 -07001415 changes |= FLAGS_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001416 }
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001417 if (privateFlags != o.privateFlags) {
1418 privateFlags = o.privateFlags;
1419 changes |= PRIVATE_FLAGS_CHANGED;
1420 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001421 if (softInputMode != o.softInputMode) {
1422 softInputMode = o.softInputMode;
1423 changes |= SOFT_INPUT_MODE_CHANGED;
1424 }
1425 if (gravity != o.gravity) {
1426 gravity = o.gravity;
Chet Haase40e03832011-10-06 08:34:13 -07001427 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001428 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001429 if (format != o.format) {
1430 format = o.format;
Chet Haase40e03832011-10-06 08:34:13 -07001431 changes |= FORMAT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001432 }
1433 if (windowAnimations != o.windowAnimations) {
1434 windowAnimations = o.windowAnimations;
1435 changes |= ANIMATION_CHANGED;
1436 }
1437 if (token == null) {
1438 // NOTE: token only copied if the recipient doesn't
1439 // already have one.
1440 token = o.token;
1441 }
1442 if (packageName == null) {
1443 // NOTE: packageName only copied if the recipient doesn't
1444 // already have one.
1445 packageName = o.packageName;
1446 }
1447 if (!mTitle.equals(o.mTitle)) {
1448 mTitle = o.mTitle;
1449 changes |= TITLE_CHANGED;
1450 }
1451 if (alpha != o.alpha) {
1452 alpha = o.alpha;
1453 changes |= ALPHA_CHANGED;
1454 }
1455 if (dimAmount != o.dimAmount) {
1456 dimAmount = o.dimAmount;
1457 changes |= DIM_AMOUNT_CHANGED;
1458 }
1459 if (screenBrightness != o.screenBrightness) {
1460 screenBrightness = o.screenBrightness;
1461 changes |= SCREEN_BRIGHTNESS_CHANGED;
1462 }
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001463 if (buttonBrightness != o.buttonBrightness) {
1464 buttonBrightness = o.buttonBrightness;
1465 changes |= BUTTON_BRIGHTNESS_CHANGED;
1466 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001467
1468 if (screenOrientation != o.screenOrientation) {
1469 screenOrientation = o.screenOrientation;
Chet Haase40e03832011-10-06 08:34:13 -07001470 changes |= SCREEN_ORIENTATION_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001471 }
Romain Guy529b60a2010-08-03 18:05:47 -07001472
Joe Onorato14782f72011-01-25 19:53:17 -08001473 if (systemUiVisibility != o.systemUiVisibility
1474 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
Joe Onorato664644d2011-01-23 17:53:23 -08001475 systemUiVisibility = o.systemUiVisibility;
Joe Onorato14782f72011-01-25 19:53:17 -08001476 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility;
Joe Onorato664644d2011-01-23 17:53:23 -08001477 changes |= SYSTEM_UI_VISIBILITY_CHANGED;
1478 }
1479
1480 if (hasSystemUiListeners != o.hasSystemUiListeners) {
1481 hasSystemUiListeners = o.hasSystemUiListeners;
1482 changes |= SYSTEM_UI_LISTENER_CHANGED;
1483 }
1484
Jeff Brown474dcb52011-06-14 20:22:50 -07001485 if (inputFeatures != o.inputFeatures) {
1486 inputFeatures = o.inputFeatures;
1487 changes |= INPUT_FEATURES_CHANGED;
1488 }
1489
Jeff Brown1e3b98d2012-09-30 18:58:59 -07001490 if (userActivityTimeout != o.userActivityTimeout) {
1491 userActivityTimeout = o.userActivityTimeout;
1492 changes |= USER_ACTIVITY_TIMEOUT_CHANGED;
1493 }
1494
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001495 return changes;
1496 }
1497
1498 @Override
1499 public String debug(String output) {
1500 output += "Contents of " + this + ":";
1501 Log.d("Debug", output);
1502 output = super.debug("");
1503 Log.d("Debug", output);
1504 Log.d("Debug", "");
1505 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
1506 return "";
1507 }
1508
1509 @Override
1510 public String toString() {
1511 StringBuilder sb = new StringBuilder(256);
1512 sb.append("WM.LayoutParams{");
1513 sb.append("(");
1514 sb.append(x);
1515 sb.append(',');
1516 sb.append(y);
1517 sb.append(")(");
Romain Guy980a9382010-01-08 15:06:28 -08001518 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001519 sb.append('x');
Romain Guy980a9382010-01-08 15:06:28 -08001520 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001521 sb.append(")");
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001522 if (horizontalMargin != 0) {
1523 sb.append(" hm=");
1524 sb.append(horizontalMargin);
1525 }
1526 if (verticalMargin != 0) {
1527 sb.append(" vm=");
1528 sb.append(verticalMargin);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001529 }
1530 if (gravity != 0) {
1531 sb.append(" gr=#");
1532 sb.append(Integer.toHexString(gravity));
1533 }
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001534 if (softInputMode != 0) {
1535 sb.append(" sim=#");
1536 sb.append(Integer.toHexString(softInputMode));
1537 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001538 sb.append(" ty=");
1539 sb.append(type);
1540 sb.append(" fl=#");
1541 sb.append(Integer.toHexString(flags));
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001542 if (privateFlags != 0) {
1543 sb.append(" pfl=0x").append(Integer.toHexString(privateFlags));
1544 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001545 if (format != PixelFormat.OPAQUE) {
1546 sb.append(" fmt=");
1547 sb.append(format);
1548 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001549 if (windowAnimations != 0) {
1550 sb.append(" wanim=0x");
1551 sb.append(Integer.toHexString(windowAnimations));
1552 }
1553 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
1554 sb.append(" or=");
1555 sb.append(screenOrientation);
1556 }
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001557 if (alpha != 1.0f) {
1558 sb.append(" alpha=");
1559 sb.append(alpha);
1560 }
1561 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) {
1562 sb.append(" sbrt=");
1563 sb.append(screenBrightness);
1564 }
1565 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) {
1566 sb.append(" bbrt=");
1567 sb.append(buttonBrightness);
1568 }
Mitsuru Oshima5a2b91d2009-07-16 16:30:02 -07001569 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) {
1570 sb.append(" compatible=true");
1571 }
Joe Onorato664644d2011-01-23 17:53:23 -08001572 if (systemUiVisibility != 0) {
1573 sb.append(" sysui=0x");
1574 sb.append(Integer.toHexString(systemUiVisibility));
1575 }
Joe Onorato14782f72011-01-25 19:53:17 -08001576 if (subtreeSystemUiVisibility != 0) {
1577 sb.append(" vsysui=0x");
1578 sb.append(Integer.toHexString(subtreeSystemUiVisibility));
1579 }
Joe Onorato664644d2011-01-23 17:53:23 -08001580 if (hasSystemUiListeners) {
1581 sb.append(" sysuil=");
1582 sb.append(hasSystemUiListeners);
1583 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001584 if (inputFeatures != 0) {
1585 sb.append(" if=0x").append(Integer.toHexString(inputFeatures));
1586 }
Jeff Brown1e3b98d2012-09-30 18:58:59 -07001587 if (userActivityTimeout >= 0) {
1588 sb.append(" userActivityTimeout=").append(userActivityTimeout);
1589 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001590 sb.append('}');
1591 return sb.toString();
1592 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001593
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001594 /**
1595 * Scale the layout params' coordinates and size.
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001596 * @hide
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001597 */
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001598 public void scale(float scale) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001599 x = (int) (x * scale + 0.5f);
1600 y = (int) (y * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001601 if (width > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001602 width = (int) (width * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001603 }
1604 if (height > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001605 height = (int) (height * scale + 0.5f);
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001606 }
1607 }
1608
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001609 /**
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001610 * Backup the layout parameters used in compatibility mode.
1611 * @see LayoutParams#restore()
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001612 */
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001613 void backup() {
1614 int[] backup = mCompatibilityParamsBackup;
1615 if (backup == null) {
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001616 // we backup 4 elements, x, y, width, height
1617 backup = mCompatibilityParamsBackup = new int[4];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001618 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001619 backup[0] = x;
1620 backup[1] = y;
1621 backup[2] = width;
1622 backup[3] = height;
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001623 }
1624
1625 /**
1626 * Restore the layout params' coordinates, size and gravity
1627 * @see LayoutParams#backup()
1628 */
1629 void restore() {
1630 int[] backup = mCompatibilityParamsBackup;
1631 if (backup != null) {
1632 x = backup[0];
1633 y = backup[1];
1634 width = backup[2];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001635 height = backup[3];
1636 }
1637 }
1638
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001639 private CharSequence mTitle = "";
1640 }
1641}