blob: 8d82aa268020bc0df5f56d6c37c7d421a1cfe19a [file] [log] [blame]
Kenny Root15a4d2f2010-03-11 18:20:12 -08001/*
2 * Copyright (C) 2007 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
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080017package android.content.pm;
18
Tor Norbyed9273d62013-05-30 15:59:53 -070019import android.annotation.IntDef;
Dianne Hackborn1d0b1772013-09-06 14:02:54 -070020import android.content.res.Configuration;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.os.Parcel;
22import android.os.Parcelable;
23import android.util.Printer;
24
Tor Norbyed9273d62013-05-30 15:59:53 -070025import java.lang.annotation.Retention;
26import java.lang.annotation.RetentionPolicy;
27
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028/**
29 * Information you can retrieve about a particular application
30 * activity or receiver. This corresponds to information collected
31 * from the AndroidManifest.xml's <activity> and
32 * <receiver> tags.
33 */
34public class ActivityInfo extends ComponentInfo
35 implements Parcelable {
36 /**
37 * A style resource identifier (in the package's resources) of this
38 * activity's theme. From the "theme" attribute or, if not set, 0.
39 */
40 public int theme;
41
42 /**
43 * Constant corresponding to <code>standard</code> in
44 * the {@link android.R.attr#launchMode} attribute.
45 */
46 public static final int LAUNCH_MULTIPLE = 0;
47 /**
48 * Constant corresponding to <code>singleTop</code> in
49 * the {@link android.R.attr#launchMode} attribute.
50 */
51 public static final int LAUNCH_SINGLE_TOP = 1;
52 /**
53 * Constant corresponding to <code>singleTask</code> in
54 * the {@link android.R.attr#launchMode} attribute.
55 */
56 public static final int LAUNCH_SINGLE_TASK = 2;
57 /**
58 * Constant corresponding to <code>singleInstance</code> in
59 * the {@link android.R.attr#launchMode} attribute.
60 */
61 public static final int LAUNCH_SINGLE_INSTANCE = 3;
62 /**
63 * The launch mode style requested by the activity. From the
64 * {@link android.R.attr#launchMode} attribute, one of
65 * {@link #LAUNCH_MULTIPLE},
66 * {@link #LAUNCH_SINGLE_TOP}, {@link #LAUNCH_SINGLE_TASK}, or
67 * {@link #LAUNCH_SINGLE_INSTANCE}.
68 */
69 public int launchMode;
Craig Mautner2dac0562014-05-06 09:06:44 -070070
71 /**
72 * Constant corresponding to <code>none</code> in
73 * the {@link android.R.attr#documentLaunchMode} attribute.
74 */
75 public static final int DOCUMENT_LAUNCH_NONE = 0;
76 /**
77 * Constant corresponding to <code>intoExisting</code> in
78 * the {@link android.R.attr#documentLaunchMode} attribute.
79 */
80 public static final int DOCUMENT_LAUNCH_INTO_EXISTING = 1;
81 /**
82 * Constant corresponding to <code>always</code> in
83 * the {@link android.R.attr#documentLaunchMode} attribute.
84 */
85 public static final int DOCUMENT_LAUNCH_ALWAYS = 2;
86 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -070087 * Constant corresponding to <code>never</code> in
88 * the {@link android.R.attr#documentLaunchMode} attribute.
89 */
90 public static final int DOCUMENT_LAUNCH_NEVER = 3;
91 /**
Craig Mautner2dac0562014-05-06 09:06:44 -070092 * The document launch mode style requested by the activity. From the
93 * {@link android.R.attr#documentLaunchMode} attribute, one of
94 * {@link #DOCUMENT_LAUNCH_NONE}, {@link #DOCUMENT_LAUNCH_INTO_EXISTING},
95 * {@link #DOCUMENT_LAUNCH_ALWAYS}.
96 *
97 * <p>Modes DOCUMENT_LAUNCH_ALWAYS
98 * and DOCUMENT_LAUNCH_INTO_EXISTING are equivalent to {@link
99 * android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT
100 * Intent.FLAG_ACTIVITY_NEW_DOCUMENT} with and without {@link
101 * android.content.Intent#FLAG_ACTIVITY_MULTIPLE_TASK
102 * Intent.FLAG_ACTIVITY_MULTIPLE_TASK} respectively.
103 */
104 public int documentLaunchMode;
105
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106 /**
Craig Mautner43e52ed2014-06-16 17:18:52 -0700107 * Constant corresponding to <code>persistRootOnly</code> in
108 * the {@link android.R.attr#persistableMode} attribute.
109 */
110 public static final int PERSIST_ROOT_ONLY = 0;
111 /**
112 * Constant corresponding to <code>doNotPersist</code> in
113 * the {@link android.R.attr#persistableMode} attribute.
114 */
Craig Mautner7f72f532014-07-21 10:07:12 -0700115 public static final int PERSIST_NEVER = 1;
Craig Mautner43e52ed2014-06-16 17:18:52 -0700116 /**
117 * Constant corresponding to <code>persistAcrossReboots</code> in
118 * the {@link android.R.attr#persistableMode} attribute.
119 */
120 public static final int PERSIST_ACROSS_REBOOTS = 2;
121 /**
122 * Value indicating how this activity is to be persisted across
123 * reboots for restoring in the Recents list.
124 * {@link android.R.attr#persistableMode}
125 */
126 public int persistableMode;
127
128 /**
Craig Mautnerffcfcaa2014-06-05 09:54:38 -0700129 * The maximum number of tasks rooted at this activity that can be in the recent task list.
130 * Refer to {@link android.R.attr#maxRecents}.
131 */
132 public int maxRecents;
133
134 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800135 * Optional name of a permission required to be able to access this
136 * Activity. From the "permission" attribute.
137 */
138 public String permission;
139
140 /**
141 * The affinity this activity has for another task in the system. The
142 * string here is the name of the task, often the package name of the
143 * overall package. If null, the activity has no affinity. Set from the
144 * {@link android.R.attr#taskAffinity} attribute.
145 */
146 public String taskAffinity;
147
148 /**
149 * If this is an activity alias, this is the real activity class to run
150 * for it. Otherwise, this is null.
151 */
152 public String targetActivity;
153
154 /**
155 * Bit in {@link #flags} indicating whether this activity is able to
156 * run in multiple processes. If
157 * true, the system may instantiate it in the some process as the
158 * process starting it in order to conserve resources. If false, the
159 * default, it always runs in {@link #processName}. Set from the
160 * {@link android.R.attr#multiprocess} attribute.
161 */
162 public static final int FLAG_MULTIPROCESS = 0x0001;
163 /**
164 * Bit in {@link #flags} indicating that, when the activity's task is
165 * relaunched from home, this activity should be finished.
166 * Set from the
167 * {@link android.R.attr#finishOnTaskLaunch} attribute.
168 */
169 public static final int FLAG_FINISH_ON_TASK_LAUNCH = 0x0002;
170 /**
171 * Bit in {@link #flags} indicating that, when the activity is the root
172 * of a task, that task's stack should be cleared each time the user
173 * re-launches it from home. As a result, the user will always
174 * return to the original activity at the top of the task.
175 * This flag only applies to activities that
176 * are used to start the root of a new task. Set from the
177 * {@link android.R.attr#clearTaskOnLaunch} attribute.
178 */
179 public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 0x0004;
180 /**
181 * Bit in {@link #flags} indicating that, when the activity is the root
182 * of a task, that task's stack should never be cleared when it is
183 * relaunched from home. Set from the
184 * {@link android.R.attr#alwaysRetainTaskState} attribute.
185 */
186 public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 0x0008;
187 /**
188 * Bit in {@link #flags} indicating that the activity's state
189 * is not required to be saved, so that if there is a failure the
190 * activity will not be removed from the activity stack. Set from the
191 * {@link android.R.attr#stateNotNeeded} attribute.
192 */
193 public static final int FLAG_STATE_NOT_NEEDED = 0x0010;
194 /**
195 * Bit in {@link #flags} that indicates that the activity should not
196 * appear in the list of recently launched activities. Set from the
197 * {@link android.R.attr#excludeFromRecents} attribute.
198 */
199 public static final int FLAG_EXCLUDE_FROM_RECENTS = 0x0020;
200 /**
201 * Bit in {@link #flags} that indicates that the activity can be moved
202 * between tasks based on its task affinity. Set from the
203 * {@link android.R.attr#allowTaskReparenting} attribute.
204 */
205 public static final int FLAG_ALLOW_TASK_REPARENTING = 0x0040;
206 /**
207 * Bit in {@link #flags} indicating that, when the user navigates away
208 * from an activity, it should be finished.
209 * Set from the
210 * {@link android.R.attr#noHistory} attribute.
211 */
212 public static final int FLAG_NO_HISTORY = 0x0080;
213 /**
Dianne Hackbornffa42482009-09-23 22:20:11 -0700214 * Bit in {@link #flags} indicating that, when a request to close system
215 * windows happens, this activity is finished.
216 * Set from the
217 * {@link android.R.attr#finishOnCloseSystemDialogs} attribute.
218 */
219 public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 0x0100;
Dianne Hackborn327fbd22011-01-17 14:38:50 -0800220 /**
221 * Value for {@link #flags}: true when the application's rendering should
222 * be hardware accelerated.
223 */
224 public static final int FLAG_HARDWARE_ACCELERATED = 0x0200;
225 /**
Craig Mautner5962b122012-10-05 14:45:52 -0700226 * Value for {@link #flags}: true when the application can be displayed over the lockscreen
227 * and consequently over all users' windows.
228 * @hide
229 */
230 public static final int FLAG_SHOW_ON_LOCK_SCREEN = 0x0400;
231 /**
John Spurlock322d7712013-09-05 02:39:46 +0000232 * Bit in {@link #flags} corresponding to an immersive activity
Daniel Sandler613dde42010-06-21 13:46:39 -0400233 * that wishes not to be interrupted by notifications.
234 * Applications that hide the system notification bar with
235 * {@link android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN}
236 * may still be interrupted by high-priority notifications; for example, an
237 * incoming phone call may use
Daniel Sandler8091ca52010-06-22 13:58:46 -0400238 * {@link android.app.Notification#fullScreenIntent fullScreenIntent}
Daniel Sandler613dde42010-06-21 13:46:39 -0400239 * to present a full-screen in-call activity to the user, pausing the
240 * current activity as a side-effect. An activity with
241 * {@link #FLAG_IMMERSIVE} set, however, will not be interrupted; the
242 * notification may be shown in some other way (such as a small floating
243 * "toast" window).
Christopher Tate73c2aee2012-03-15 16:27:14 -0700244 *
245 * Note that this flag will always reflect the Activity's
246 * <code>android:immersive</code> manifest definition, even if the Activity's
247 * immersive state is changed at runtime via
248 * {@link android.app.Activity#setImmersive(boolean)}.
249 *
250 * @see android.app.Notification#FLAG_HIGH_PRIORITY
251 * @see android.app.Activity#setImmersive(boolean)
Daniel Sandler613dde42010-06-21 13:46:39 -0400252 */
Craig Mautner5962b122012-10-05 14:45:52 -0700253 public static final int FLAG_IMMERSIVE = 0x0800;
Romain Guy529b60a2010-08-03 18:05:47 -0700254 /**
Craig Mautner9d4e9bc2014-06-18 18:34:56 -0700255 * Bit in {@link #flags}: If set, a task rooted at this activity will have its
256 * baseIntent replaced by the activity immediately above this. Each activity may further
257 * relinquish its identity to the activity above it using this flag. Set from the
Dianne Hackborna4e102e2014-09-04 22:52:27 -0700258 * {@link android.R.attr#relinquishTaskIdentity} attribute.
Craig Mautner9d4e9bc2014-06-18 18:34:56 -0700259 */
260 public static final int FLAG_RELINQUISH_TASK_IDENTITY = 0x1000;
261 /**
Craig Mautner2dac0562014-05-06 09:06:44 -0700262 * Bit in {@link #flags} indicating that tasks started with this activity are to be
263 * removed from the recent list of tasks when the last activity in the task is finished.
Dianne Hackborna4e102e2014-09-04 22:52:27 -0700264 * Corresponds to {@link android.R.attr#autoRemoveFromRecents}
Craig Mautner2dac0562014-05-06 09:06:44 -0700265 */
266 public static final int FLAG_AUTO_REMOVE_FROM_RECENTS = 0x2000;
267 /**
Dianne Hackborna4e102e2014-09-04 22:52:27 -0700268 * Bit in {@link #flags} indicating that this activity can start is creation/resume
269 * while the previous activity is still pausing. Corresponds to
270 * {@link android.R.attr#resumeWhilePausing}
271 */
272 public static final int FLAG_RESUME_WHILE_PAUSING = 0x4000;
273 /**
Dianne Hackbornd4ac8d72012-09-27 23:20:10 -0700274 * @hide Bit in {@link #flags}: If set, this component will only be seen
275 * by the primary user. Only works with broadcast receivers. Set from the
Craig Mautnerffd14a12014-04-23 21:38:50 -0700276 * android.R.attr#primaryUserOnly attribute.
Dianne Hackbornd4ac8d72012-09-27 23:20:10 -0700277 */
278 public static final int FLAG_PRIMARY_USER_ONLY = 0x20000000;
279 /**
Dianne Hackborn7d19e022012-08-07 19:12:33 -0700280 * Bit in {@link #flags}: If set, a single instance of the receiver will
281 * run for all users on the device. Set from the
282 * {@link android.R.attr#singleUser} attribute. Note that this flag is
Dianne Hackbornd4ac8d72012-09-27 23:20:10 -0700283 * only relevant for ActivityInfo structures that are describing receiver
Dianne Hackborn7d19e022012-08-07 19:12:33 -0700284 * components; it is not applied to activities.
285 */
286 public static final int FLAG_SINGLE_USER = 0x40000000;
287 /**
Craig Mautnerffd14a12014-04-23 21:38:50 -0700288 * @hide Bit in {@link #flags}: If set, this activity may be launched into an
289 * owned ActivityContainer such as that within an ActivityView. If not set and
290 * this activity is launched into such a container a SecurityExcception will be
291 * thrown. Set from the {@link android.R.attr#allowEmbedded} attribute.
292 */
293 public static final int FLAG_ALLOW_EMBEDDED = 0x80000000;
294 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800295 * Options that have been set in the activity declaration in the
Daniel Sandler613dde42010-06-21 13:46:39 -0400296 * manifest.
297 * These include:
298 * {@link #FLAG_MULTIPROCESS},
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800299 * {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH},
300 * {@link #FLAG_ALWAYS_RETAIN_TASK_STATE},
301 * {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS},
Dianne Hackbornffa42482009-09-23 22:20:11 -0700302 * {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY},
Daniel Sandler613dde42010-06-21 13:46:39 -0400303 * {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS},
Dianne Hackborn7d19e022012-08-07 19:12:33 -0700304 * {@link #FLAG_HARDWARE_ACCELERATED}, {@link #FLAG_SINGLE_USER}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800305 */
306 public int flags;
307
Tor Norbyed9273d62013-05-30 15:59:53 -0700308 /** @hide */
309 @IntDef({
310 SCREEN_ORIENTATION_UNSPECIFIED,
311 SCREEN_ORIENTATION_LANDSCAPE,
312 SCREEN_ORIENTATION_PORTRAIT,
313 SCREEN_ORIENTATION_USER,
314 SCREEN_ORIENTATION_BEHIND,
315 SCREEN_ORIENTATION_SENSOR,
316 SCREEN_ORIENTATION_NOSENSOR,
317 SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
318 SCREEN_ORIENTATION_SENSOR_PORTRAIT,
319 SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
320 SCREEN_ORIENTATION_REVERSE_PORTRAIT,
321 SCREEN_ORIENTATION_FULL_SENSOR,
322 SCREEN_ORIENTATION_USER_LANDSCAPE,
323 SCREEN_ORIENTATION_USER_PORTRAIT,
324 SCREEN_ORIENTATION_FULL_USER,
325 SCREEN_ORIENTATION_LOCKED
326 })
327 @Retention(RetentionPolicy.SOURCE)
328 public @interface ScreenOrientation {}
329
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800330 /**
331 * Constant corresponding to <code>unspecified</code> in
332 * the {@link android.R.attr#screenOrientation} attribute.
333 */
334 public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1;
335 /**
336 * Constant corresponding to <code>landscape</code> in
337 * the {@link android.R.attr#screenOrientation} attribute.
338 */
339 public static final int SCREEN_ORIENTATION_LANDSCAPE = 0;
340 /**
341 * Constant corresponding to <code>portrait</code> in
342 * the {@link android.R.attr#screenOrientation} attribute.
343 */
344 public static final int SCREEN_ORIENTATION_PORTRAIT = 1;
345 /**
346 * Constant corresponding to <code>user</code> in
347 * the {@link android.R.attr#screenOrientation} attribute.
348 */
349 public static final int SCREEN_ORIENTATION_USER = 2;
350 /**
351 * Constant corresponding to <code>behind</code> in
352 * the {@link android.R.attr#screenOrientation} attribute.
353 */
354 public static final int SCREEN_ORIENTATION_BEHIND = 3;
355 /**
356 * Constant corresponding to <code>sensor</code> in
357 * the {@link android.R.attr#screenOrientation} attribute.
358 */
359 public static final int SCREEN_ORIENTATION_SENSOR = 4;
360
361 /**
Dianne Hackborne5439f22010-10-02 16:53:50 -0700362 * Constant corresponding to <code>nosensor</code> in
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800363 * the {@link android.R.attr#screenOrientation} attribute.
364 */
365 public static final int SCREEN_ORIENTATION_NOSENSOR = 5;
Dianne Hackborne5439f22010-10-02 16:53:50 -0700366
367 /**
368 * Constant corresponding to <code>sensorLandscape</code> in
369 * the {@link android.R.attr#screenOrientation} attribute.
370 */
371 public static final int SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 6;
372
373 /**
374 * Constant corresponding to <code>sensorPortrait</code> in
375 * the {@link android.R.attr#screenOrientation} attribute.
376 */
377 public static final int SCREEN_ORIENTATION_SENSOR_PORTRAIT = 7;
378
379 /**
380 * Constant corresponding to <code>reverseLandscape</code> in
381 * the {@link android.R.attr#screenOrientation} attribute.
382 */
383 public static final int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8;
384
385 /**
386 * Constant corresponding to <code>reversePortrait</code> in
387 * the {@link android.R.attr#screenOrientation} attribute.
388 */
389 public static final int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9;
390
391 /**
392 * Constant corresponding to <code>fullSensor</code> in
393 * the {@link android.R.attr#screenOrientation} attribute.
394 */
395 public static final int SCREEN_ORIENTATION_FULL_SENSOR = 10;
396
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800397 /**
Dianne Hackbornb9ec1ac2013-04-10 17:34:25 -0700398 * Constant corresponding to <code>userLandscape</code> in
399 * the {@link android.R.attr#screenOrientation} attribute.
400 */
401 public static final int SCREEN_ORIENTATION_USER_LANDSCAPE = 11;
402
403 /**
404 * Constant corresponding to <code>userPortrait</code> in
405 * the {@link android.R.attr#screenOrientation} attribute.
406 */
407 public static final int SCREEN_ORIENTATION_USER_PORTRAIT = 12;
408
409 /**
410 * Constant corresponding to <code>fullUser</code> in
411 * the {@link android.R.attr#screenOrientation} attribute.
412 */
413 public static final int SCREEN_ORIENTATION_FULL_USER = 13;
414
415 /**
416 * Constant corresponding to <code>locked</code> in
417 * the {@link android.R.attr#screenOrientation} attribute.
418 */
419 public static final int SCREEN_ORIENTATION_LOCKED = 14;
420
421 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800422 * The preferred screen orientation this activity would like to run in.
423 * From the {@link android.R.attr#screenOrientation} attribute, one of
424 * {@link #SCREEN_ORIENTATION_UNSPECIFIED},
425 * {@link #SCREEN_ORIENTATION_LANDSCAPE},
426 * {@link #SCREEN_ORIENTATION_PORTRAIT},
427 * {@link #SCREEN_ORIENTATION_USER},
428 * {@link #SCREEN_ORIENTATION_BEHIND},
429 * {@link #SCREEN_ORIENTATION_SENSOR},
Dianne Hackborne5439f22010-10-02 16:53:50 -0700430 * {@link #SCREEN_ORIENTATION_NOSENSOR},
431 * {@link #SCREEN_ORIENTATION_SENSOR_LANDSCAPE},
432 * {@link #SCREEN_ORIENTATION_SENSOR_PORTRAIT},
433 * {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE},
434 * {@link #SCREEN_ORIENTATION_REVERSE_PORTRAIT},
Dianne Hackbornb9ec1ac2013-04-10 17:34:25 -0700435 * {@link #SCREEN_ORIENTATION_FULL_SENSOR},
436 * {@link #SCREEN_ORIENTATION_USER_LANDSCAPE},
437 * {@link #SCREEN_ORIENTATION_USER_PORTRAIT},
438 * {@link #SCREEN_ORIENTATION_FULL_USER},
439 * {@link #SCREEN_ORIENTATION_LOCKED},
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700441 @ScreenOrientation
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800442 public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED;
443
444 /**
445 * Bit in {@link #configChanges} that indicates that the activity
446 * can itself handle changes to the IMSI MCC. Set from the
447 * {@link android.R.attr#configChanges} attribute.
448 */
449 public static final int CONFIG_MCC = 0x0001;
450 /**
451 * Bit in {@link #configChanges} that indicates that the activity
452 * can itself handle changes to the IMSI MNC. Set from the
453 * {@link android.R.attr#configChanges} attribute.
454 */
455 public static final int CONFIG_MNC = 0x0002;
456 /**
457 * Bit in {@link #configChanges} that indicates that the activity
458 * can itself handle changes to the locale. Set from the
459 * {@link android.R.attr#configChanges} attribute.
460 */
461 public static final int CONFIG_LOCALE = 0x0004;
462 /**
463 * Bit in {@link #configChanges} that indicates that the activity
464 * can itself handle changes to the touchscreen type. Set from the
465 * {@link android.R.attr#configChanges} attribute.
466 */
467 public static final int CONFIG_TOUCHSCREEN = 0x0008;
468 /**
469 * Bit in {@link #configChanges} that indicates that the activity
470 * can itself handle changes to the keyboard type. Set from the
471 * {@link android.R.attr#configChanges} attribute.
472 */
473 public static final int CONFIG_KEYBOARD = 0x0010;
474 /**
475 * Bit in {@link #configChanges} that indicates that the activity
Dianne Hackborn93e462b2009-09-15 22:50:40 -0700476 * can itself handle changes to the keyboard or navigation being hidden/exposed.
477 * Note that inspite of the name, this applies to the changes to any
478 * hidden states: keyboard or navigation.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800479 * Set from the {@link android.R.attr#configChanges} attribute.
480 */
481 public static final int CONFIG_KEYBOARD_HIDDEN = 0x0020;
482 /**
483 * Bit in {@link #configChanges} that indicates that the activity
484 * can itself handle changes to the navigation type. Set from the
485 * {@link android.R.attr#configChanges} attribute.
486 */
487 public static final int CONFIG_NAVIGATION = 0x0040;
488 /**
489 * Bit in {@link #configChanges} that indicates that the activity
490 * can itself handle changes to the screen orientation. Set from the
491 * {@link android.R.attr#configChanges} attribute.
492 */
493 public static final int CONFIG_ORIENTATION = 0x0080;
494 /**
495 * Bit in {@link #configChanges} that indicates that the activity
Dianne Hackborn723738c2009-06-25 19:48:04 -0700496 * can itself handle changes to the screen layout. Set from the
497 * {@link android.R.attr#configChanges} attribute.
498 */
499 public static final int CONFIG_SCREEN_LAYOUT = 0x0100;
500 /**
501 * Bit in {@link #configChanges} that indicates that the activity
Tobias Haamel27b28b32010-02-09 23:09:17 +0100502 * can itself handle the ui mode. Set from the
503 * {@link android.R.attr#configChanges} attribute.
Tobias Haamel27b28b32010-02-09 23:09:17 +0100504 */
505 public static final int CONFIG_UI_MODE = 0x0200;
506 /**
507 * Bit in {@link #configChanges} that indicates that the activity
Dianne Hackbornebff8f92011-05-12 18:07:47 -0700508 * can itself handle the screen size. Set from the
Dianne Hackborne6676352011-06-01 16:51:20 -0700509 * {@link android.R.attr#configChanges} attribute. This will be
510 * set by default for applications that target an earlier version
511 * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}...
512 * <b>however</b>, you will not see the bit set here becomes some
513 * applications incorrectly compare {@link #configChanges} against
514 * an absolute value rather than correctly masking out the bits
515 * they are interested in. Please don't do that, thanks.
Dianne Hackbornebff8f92011-05-12 18:07:47 -0700516 */
517 public static final int CONFIG_SCREEN_SIZE = 0x0400;
518 /**
519 * Bit in {@link #configChanges} that indicates that the activity
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700520 * can itself handle the smallest screen size. Set from the
Dianne Hackborne6676352011-06-01 16:51:20 -0700521 * {@link android.R.attr#configChanges} attribute. This will be
522 * set by default for applications that target an earlier version
523 * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}...
524 * <b>however</b>, you will not see the bit set here becomes some
525 * applications incorrectly compare {@link #configChanges} against
526 * an absolute value rather than correctly masking out the bits
527 * they are interested in. Please don't do that, thanks.
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700528 */
529 public static final int CONFIG_SMALLEST_SCREEN_SIZE = 0x0800;
530 /**
531 * Bit in {@link #configChanges} that indicates that the activity
Dianne Hackborn908aecc2012-07-31 16:37:34 -0700532 * can itself handle density changes. Set from the
533 * {@link android.R.attr#configChanges} attribute.
534 */
535 public static final int CONFIG_DENSITY = 0x1000;
536 /**
537 * Bit in {@link #configChanges} that indicates that the activity
Fabrice Di Meglio5f797992012-06-15 20:16:41 -0700538 * can itself handle the change to layout direction. Set from the
539 * {@link android.R.attr#configChanges} attribute.
540 */
541 public static final int CONFIG_LAYOUT_DIRECTION = 0x2000;
542 /**
543 * Bit in {@link #configChanges} that indicates that the activity
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800544 * can itself handle changes to the font scaling factor. Set from the
545 * {@link android.R.attr#configChanges} attribute. This is
Fabrice Di Megliodc25d252013-04-09 18:04:29 -0700546 * not a core resource configuration, but a higher-level value, so its
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800547 * constant starts at the high bits.
548 */
549 public static final int CONFIG_FONT_SCALE = 0x40000000;
550
Dianne Hackbornebff8f92011-05-12 18:07:47 -0700551 /** @hide
552 * Unfortunately the constants for config changes in native code are
553 * different from ActivityInfo. :( Here are the values we should use for the
554 * native side given the bit we have assigned in ActivityInfo.
555 */
556 public static int[] CONFIG_NATIVE_BITS = new int[] {
Dianne Hackborn1d0b1772013-09-06 14:02:54 -0700557 Configuration.NATIVE_CONFIG_MNC, // MNC
558 Configuration.NATIVE_CONFIG_MCC, // MCC
559 Configuration.NATIVE_CONFIG_LOCALE, // LOCALE
560 Configuration.NATIVE_CONFIG_TOUCHSCREEN, // TOUCH SCREEN
561 Configuration.NATIVE_CONFIG_KEYBOARD, // KEYBOARD
562 Configuration.NATIVE_CONFIG_KEYBOARD_HIDDEN, // KEYBOARD HIDDEN
563 Configuration.NATIVE_CONFIG_NAVIGATION, // NAVIGATION
564 Configuration.NATIVE_CONFIG_ORIENTATION, // ORIENTATION
565 Configuration.NATIVE_CONFIG_SCREEN_LAYOUT, // SCREEN LAYOUT
566 Configuration.NATIVE_CONFIG_UI_MODE, // UI MODE
567 Configuration.NATIVE_CONFIG_SCREEN_SIZE, // SCREEN SIZE
568 Configuration.NATIVE_CONFIG_SMALLEST_SCREEN_SIZE, // SMALLEST SCREEN SIZE
569 Configuration.NATIVE_CONFIG_DENSITY, // DENSITY
570 Configuration.NATIVE_CONFIG_LAYOUTDIR, // LAYOUT DIRECTION
Dianne Hackbornebff8f92011-05-12 18:07:47 -0700571 };
572 /** @hide
573 * Convert Java change bits to native.
574 */
575 public static int activityInfoConfigToNative(int input) {
576 int output = 0;
577 for (int i=0; i<CONFIG_NATIVE_BITS.length; i++) {
578 if ((input&(1<<i)) != 0) {
579 output |= CONFIG_NATIVE_BITS[i];
580 }
581 }
582 return output;
583 }
584
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800585 /**
Dianne Hackborne6676352011-06-01 16:51:20 -0700586 * @hide
587 * Unfortunately some developers (OpenFeint I am looking at you) have
588 * compared the configChanges bit field against absolute values, so if we
589 * introduce a new bit they break. To deal with that, we will make sure
590 * the public field will not have a value that breaks them, and let the
591 * framework call here to get the real value.
592 */
593 public int getRealConfigChanged() {
594 return applicationInfo.targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB_MR2
595 ? (configChanges | ActivityInfo.CONFIG_SCREEN_SIZE
596 | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE)
597 : configChanges;
598 }
599
600 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800601 * Bit mask of kinds of configuration changes that this activity
602 * can handle itself (without being restarted by the system).
603 * Contains any combination of {@link #CONFIG_FONT_SCALE},
604 * {@link #CONFIG_MCC}, {@link #CONFIG_MNC},
605 * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700606 * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION},
Fabrice Di Meglio5f797992012-06-15 20:16:41 -0700607 * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT} and
608 * {@link #CONFIG_LAYOUT_DIRECTION}. Set from the {@link android.R.attr#configChanges}
609 * attribute.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800610 */
611 public int configChanges;
Craig Mautner15df08a2015-04-01 12:17:18 -0700612
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800613 /**
614 * The desired soft input mode for this activity's main window.
615 * Set from the {@link android.R.attr#windowSoftInputMode} attribute
616 * in the activity's manifest. May be any of the same values allowed
617 * for {@link android.view.WindowManager.LayoutParams#softInputMode
618 * WindowManager.LayoutParams.softInputMode}. If 0 (unspecified),
619 * the mode from the theme will be used.
620 */
621 public int softInputMode;
Adam Powell269248d2011-08-02 10:26:54 -0700622
623 /**
624 * The desired extra UI options for this activity and its main window.
625 * Set from the {@link android.R.attr#uiOptions} attribute in the
626 * activity's manifest.
627 */
628 public int uiOptions = 0;
629
630 /**
Scott Maine797ed62011-09-22 16:17:45 -0700631 * Flag for use with {@link #uiOptions}.
632 * Indicates that the action bar should put all action items in a separate bar when
633 * the screen is narrow.
634 * <p>This value corresponds to "splitActionBarWhenNarrow" for the {@link #uiOptions} XML
635 * attribute.
Adam Powell269248d2011-08-02 10:26:54 -0700636 */
637 public static final int UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW = 1;
638
Adam Powelldd8fab22012-03-22 17:47:27 -0700639 /**
640 * If defined, the activity named here is the logical parent of this activity.
641 */
642 public String parentActivityName;
643
Wale Ogunwale9d3de4c2015-02-01 16:49:44 -0800644 /**
645 * Value indicating if the activity is resizeable to any dimension.
646 * See {@link android.R.attr#resizeableActivity}.
Wale Ogunwale4aab1bb2015-02-03 09:29:00 -0800647 * @hide
Wale Ogunwale9d3de4c2015-02-01 16:49:44 -0800648 */
649 public boolean resizeable;
650
Craig Mautner15df08a2015-04-01 12:17:18 -0700651 /** @hide */
652 public static final int LOCK_TASK_LAUNCH_MODE_DEFAULT = 0;
653 /** @hide */
654 public static final int LOCK_TASK_LAUNCH_MODE_NEVER = 1;
655 /** @hide */
656 public static final int LOCK_TASK_LAUNCH_MODE_ALWAYS = 2;
657 /** @hide */
658 public static final int LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED = 3;
659
660 /** @hide */
661 public static final String lockTaskLaunchModeToString(int lockTaskLaunchMode) {
662 switch (lockTaskLaunchMode) {
663 case LOCK_TASK_LAUNCH_MODE_DEFAULT:
664 return "LOCK_TASK_LAUNCH_MODE_DEFAULT";
665 case LOCK_TASK_LAUNCH_MODE_NEVER:
666 return "LOCK_TASK_LAUNCH_MODE_NEVER";
667 case LOCK_TASK_LAUNCH_MODE_ALWAYS:
668 return "LOCK_TASK_LAUNCH_MODE_ALWAYS";
669 case LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED:
670 return "LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED";
671 default:
672 return "unknown=" + lockTaskLaunchMode;
673 }
674 }
675 /**
676 * Value indicating if the activity is to be locked at startup. Takes on the values from
677 * {@link android.R.attr#lockTaskMode}.
678 * @hide
679 */
680 public int lockTaskLaunchMode;
681
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800682 public ActivityInfo() {
683 }
684
685 public ActivityInfo(ActivityInfo orig) {
686 super(orig);
687 theme = orig.theme;
688 launchMode = orig.launchMode;
689 permission = orig.permission;
690 taskAffinity = orig.taskAffinity;
691 targetActivity = orig.targetActivity;
692 flags = orig.flags;
693 screenOrientation = orig.screenOrientation;
694 configChanges = orig.configChanges;
695 softInputMode = orig.softInputMode;
Adam Powell269248d2011-08-02 10:26:54 -0700696 uiOptions = orig.uiOptions;
Adam Powelldd8fab22012-03-22 17:47:27 -0700697 parentActivityName = orig.parentActivityName;
Craig Mautner8307ea72014-09-11 15:03:53 -0700698 maxRecents = orig.maxRecents;
Craig Mautner15df08a2015-04-01 12:17:18 -0700699 resizeable = orig.resizeable;
700 lockTaskLaunchMode = orig.lockTaskLaunchMode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800701 }
Craig Mautner15df08a2015-04-01 12:17:18 -0700702
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800703 /**
704 * Return the theme resource identifier to use for this activity. If
705 * the activity defines a theme, that is used; else, the application
706 * theme is used.
Craig Mautner15df08a2015-04-01 12:17:18 -0700707 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800708 * @return The theme associated with this activity.
709 */
710 public final int getThemeResource() {
711 return theme != 0 ? theme : applicationInfo.theme;
712 }
713
Craig Mautner43e52ed2014-06-16 17:18:52 -0700714 private String persistableModeToString() {
715 switch(persistableMode) {
716 case PERSIST_ROOT_ONLY: return "PERSIST_ROOT_ONLY";
Craig Mautner7f72f532014-07-21 10:07:12 -0700717 case PERSIST_NEVER: return "PERSIST_NEVER";
Craig Mautner43e52ed2014-06-16 17:18:52 -0700718 case PERSIST_ACROSS_REBOOTS: return "PERSIST_ACROSS_REBOOTS";
719 default: return "UNKNOWN=" + persistableMode;
720 }
721 }
722
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800723 public void dump(Printer pw, String prefix) {
724 super.dumpFront(pw, prefix);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800725 if (permission != null) {
726 pw.println(prefix + "permission=" + permission);
727 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800728 pw.println(prefix + "taskAffinity=" + taskAffinity
Craig Mautner43e52ed2014-06-16 17:18:52 -0700729 + " targetActivity=" + targetActivity
730 + " persistableMode=" + persistableModeToString());
Dianne Hackborn12527f92009-11-11 17:39:50 -0800731 if (launchMode != 0 || flags != 0 || theme != 0) {
732 pw.println(prefix + "launchMode=" + launchMode
733 + " flags=0x" + Integer.toHexString(flags)
734 + " theme=0x" + Integer.toHexString(theme));
735 }
736 if (screenOrientation != SCREEN_ORIENTATION_UNSPECIFIED
737 || configChanges != 0 || softInputMode != 0) {
738 pw.println(prefix + "screenOrientation=" + screenOrientation
739 + " configChanges=0x" + Integer.toHexString(configChanges)
740 + " softInputMode=0x" + Integer.toHexString(softInputMode));
741 }
Adam Powell269248d2011-08-02 10:26:54 -0700742 if (uiOptions != 0) {
743 pw.println(prefix + " uiOptions=0x" + Integer.toHexString(uiOptions));
744 }
Craig Mautner15df08a2015-04-01 12:17:18 -0700745 pw.println(prefix + "resizeable=" + resizeable + " lockTaskLaunchMode="
746 + lockTaskLaunchModeToString(lockTaskLaunchMode));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800747 super.dumpBack(pw, prefix);
748 }
749
750 public String toString() {
751 return "ActivityInfo{"
752 + Integer.toHexString(System.identityHashCode(this))
753 + " " + name + "}";
754 }
755
756 public int describeContents() {
757 return 0;
758 }
759
760 public void writeToParcel(Parcel dest, int parcelableFlags) {
761 super.writeToParcel(dest, parcelableFlags);
762 dest.writeInt(theme);
763 dest.writeInt(launchMode);
764 dest.writeString(permission);
765 dest.writeString(taskAffinity);
766 dest.writeString(targetActivity);
767 dest.writeInt(flags);
768 dest.writeInt(screenOrientation);
769 dest.writeInt(configChanges);
770 dest.writeInt(softInputMode);
Adam Powell269248d2011-08-02 10:26:54 -0700771 dest.writeInt(uiOptions);
Adam Powelldd8fab22012-03-22 17:47:27 -0700772 dest.writeString(parentActivityName);
Craig Mautner43e52ed2014-06-16 17:18:52 -0700773 dest.writeInt(persistableMode);
Craig Mautner8307ea72014-09-11 15:03:53 -0700774 dest.writeInt(maxRecents);
Wale Ogunwale9d3de4c2015-02-01 16:49:44 -0800775 dest.writeInt(resizeable ? 1 : 0);
Craig Mautner15df08a2015-04-01 12:17:18 -0700776 dest.writeInt(lockTaskLaunchMode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800777 }
778
779 public static final Parcelable.Creator<ActivityInfo> CREATOR
780 = new Parcelable.Creator<ActivityInfo>() {
781 public ActivityInfo createFromParcel(Parcel source) {
782 return new ActivityInfo(source);
783 }
784 public ActivityInfo[] newArray(int size) {
785 return new ActivityInfo[size];
786 }
787 };
788
789 private ActivityInfo(Parcel source) {
790 super(source);
791 theme = source.readInt();
792 launchMode = source.readInt();
793 permission = source.readString();
794 taskAffinity = source.readString();
795 targetActivity = source.readString();
796 flags = source.readInt();
797 screenOrientation = source.readInt();
798 configChanges = source.readInt();
799 softInputMode = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -0700800 uiOptions = source.readInt();
Adam Powelldd8fab22012-03-22 17:47:27 -0700801 parentActivityName = source.readString();
Craig Mautner43e52ed2014-06-16 17:18:52 -0700802 persistableMode = source.readInt();
Craig Mautner8307ea72014-09-11 15:03:53 -0700803 maxRecents = source.readInt();
Wale Ogunwale9d3de4c2015-02-01 16:49:44 -0800804 resizeable = (source.readInt() == 1);
Craig Mautner15df08a2015-04-01 12:17:18 -0700805 lockTaskLaunchMode = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800806 }
807}