Debian Codegraph @

core/java/android/content/pm/ActivityInfo.java

raw symbols SCIP
1 /*
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
17 package android.content.pm;
18
19 import android.annotation.FloatRange;
20 import android.annotation.IntDef;
21 import android.annotation.NonNull;
22 import android.annotation.Nullable;
23 import android.annotation.TestApi;
24 import android.app.Activity;
25 import android.app.compat.CompatChanges;
26 import android.compat.annotation.ChangeId;
27 import android.compat.annotation.Disabled;
28 import android.compat.annotation.EnabledSince;
29 import android.compat.annotation.Overridable;
30 import android.compat.annotation.UnsupportedAppUsage;
31 import android.content.ComponentName;
32 import android.content.Intent;
33 import android.content.res.Configuration;
34 import android.content.res.Configuration.NativeConfig;
35 import android.content.res.TypedArray;
36 import android.os.Build;
37 import android.os.Parcel;
38 import android.os.Parcelable;
39 import android.os.UserHandle;
40 import android.util.ArraySet;
41 import android.util.Printer;
42
43 import com.android.internal.util.Parcelling;
44
45 import java.lang.annotation.Retention;
46 import java.lang.annotation.RetentionPolicy;
47 import java.util.Collections;
48 import java.util.Locale;
49 import java.util.Set;
50
51 /**
52 * Information you can retrieve about a particular application
53 * activity or receiver. This corresponds to information collected
54 * from the AndroidManifest.xml's <activity> and
55 * <receiver> tags.
56 */
57 public class ActivityInfo extends ComponentInfo implements Parcelable {
58
59 private static final Parcelling.BuiltIn.ForStringSet sForStringSet =
60 Parcelling.Cache.getOrCreate(Parcelling.BuiltIn.ForStringSet.class);
61
62 // NOTE: When adding new data members be sure to update the copy-constructor, Parcel
63 // constructor, and writeToParcel.
64
65 /**
66 * A style resource identifier (in the package's resources) of this
67 * activity's theme. From the "theme" attribute or, if not set, 0.
68 */
69 public int theme;
70
71 /**
72 * Constant corresponding to <code>standard</code> in
73 * the {@link android.R.attr#launchMode} attribute.
74 */
75 public static final int LAUNCH_MULTIPLE = 0;
76 /**
77 * Constant corresponding to <code>singleTop</code> in
78 * the {@link android.R.attr#launchMode} attribute.
79 */
80 public static final int LAUNCH_SINGLE_TOP = 1;
81 /**
82 * Constant corresponding to <code>singleTask</code> in
83 * the {@link android.R.attr#launchMode} attribute.
84 */
85 public static final int LAUNCH_SINGLE_TASK = 2;
86 /**
87 * Constant corresponding to <code>singleInstance</code> in
88 * the {@link android.R.attr#launchMode} attribute.
89 */
90 public static final int LAUNCH_SINGLE_INSTANCE = 3;
91 /**
92 * Constant corresponding to <code>singleInstancePerTask</code> in
93 * the {@link android.R.attr#launchMode} attribute.
94 */
95 public static final int LAUNCH_SINGLE_INSTANCE_PER_TASK = 4;
96
97 /** @hide */
98 @IntDef(prefix = "LAUNCH_", value = {
99 LAUNCH_MULTIPLE,
100 LAUNCH_SINGLE_TOP,
101 LAUNCH_SINGLE_TASK,
102 LAUNCH_SINGLE_INSTANCE,
103 LAUNCH_SINGLE_INSTANCE_PER_TASK
104 })
105 @Retention(RetentionPolicy.SOURCE)
106 public @interface LaunchMode {
107 }
108
109 /** @hide */
110 public static String launchModeToString(@LaunchMode int launchMode) {
111 switch(launchMode) {
112 case LAUNCH_MULTIPLE:
113 return "LAUNCH_MULTIPLE";
114 case LAUNCH_SINGLE_TOP:
115 return "LAUNCH_SINGLE_TOP";
116 case LAUNCH_SINGLE_TASK:
117 return "LAUNCH_SINGLE_TASK";
118 case LAUNCH_SINGLE_INSTANCE:
119 return "LAUNCH_SINGLE_INSTANCE";
120 case LAUNCH_SINGLE_INSTANCE_PER_TASK:
121 return "LAUNCH_SINGLE_INSTANCE_PER_TASK";
122 default:
123 return "unknown=" + launchMode;
124 }
125 }
126
127 /**
128 * The launch mode style requested by the activity. From the
129 * {@link android.R.attr#launchMode} attribute.
130 */
131 @LaunchMode
132 public int launchMode;
133
134 /**
135 * Constant corresponding to <code>none</code> in
136 * the {@link android.R.attr#documentLaunchMode} attribute.
137 */
138 public static final int DOCUMENT_LAUNCH_NONE = 0;
139 /**
140 * Constant corresponding to <code>intoExisting</code> in
141 * the {@link android.R.attr#documentLaunchMode} attribute.
142 */
143 public static final int DOCUMENT_LAUNCH_INTO_EXISTING = 1;
144 /**
145 * Constant corresponding to <code>always</code> in
146 * the {@link android.R.attr#documentLaunchMode} attribute.
147 */
148 public static final int DOCUMENT_LAUNCH_ALWAYS = 2;
149 /**
150 * Constant corresponding to <code>never</code> in
151 * the {@link android.R.attr#documentLaunchMode} attribute.
152 */
153 public static final int DOCUMENT_LAUNCH_NEVER = 3;
154 /**
155 * The document launch mode style requested by the activity. From the
156 * {@link android.R.attr#documentLaunchMode} attribute, one of
157 * {@link #DOCUMENT_LAUNCH_NONE}, {@link #DOCUMENT_LAUNCH_INTO_EXISTING},
158 * {@link #DOCUMENT_LAUNCH_ALWAYS}.
159 *
160 * <p>Modes DOCUMENT_LAUNCH_ALWAYS
161 * and DOCUMENT_LAUNCH_INTO_EXISTING are equivalent to {@link
162 * android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT
163 * Intent.FLAG_ACTIVITY_NEW_DOCUMENT} with and without {@link
164 * android.content.Intent#FLAG_ACTIVITY_MULTIPLE_TASK
165 * Intent.FLAG_ACTIVITY_MULTIPLE_TASK} respectively.
166 */
167 public int documentLaunchMode;
168
169 /**
170 * Constant corresponding to <code>persistRootOnly</code> in
171 * the {@link android.R.attr#persistableMode} attribute.
172 */
173 public static final int PERSIST_ROOT_ONLY = 0;
174 /**
175 * Constant corresponding to <code>doNotPersist</code> in
176 * the {@link android.R.attr#persistableMode} attribute.
177 */
178 public static final int PERSIST_NEVER = 1;
179 /**
180 * Constant corresponding to <code>persistAcrossReboots</code> in
181 * the {@link android.R.attr#persistableMode} attribute.
182 */
183 public static final int PERSIST_ACROSS_REBOOTS = 2;
184 /**
185 * Value indicating how this activity is to be persisted across
186 * reboots for restoring in the Recents list.
187 * {@link android.R.attr#persistableMode}
188 */
189 public int persistableMode;
190
191 /**
192 * The maximum number of tasks rooted at this activity that can be in the recent task list.
193 * Refer to {@link android.R.attr#maxRecents}.
194 */
195 public int maxRecents;
196
197 /**
198 * Optional name of a permission required to be able to access this
199 * Activity. From the "permission" attribute.
200 */
201 public String permission;
202
203 /**
204 * The affinity this activity has for another task in the system. The
205 * string here is the name of the task, often the package name of the
206 * overall package. If null, the activity has no affinity. Set from the
207 * {@link android.R.attr#taskAffinity} attribute.
208 */
209 public String taskAffinity;
210
211 /**
212 * If this is an activity alias, this is the real activity class to run
213 * for it. Otherwise, this is null.
214 */
215 public String targetActivity;
216
217 /**
218 * Token used to string together multiple events within a single launch action.
219 * @hide
220 */
221 public String launchToken;
222
223 /**
224 * Activity can not be resized and always occupies the fullscreen area with all windows fully
225 * visible.
226 * @hide
227 */
228 public static final int RESIZE_MODE_UNRESIZEABLE = 0;
229 /**
230 * Activity didn't explicitly request to be resizeable, but we are making it resizeable because
231 * of the SDK version it targets. Only affects apps with target SDK >= N where the app is
232 * implied to be resizeable if it doesn't explicitly set the attribute to any value.
233 * @hide
234 */
235 public static final int RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION = 1;
236 /**
237 * Activity explicitly requested to be resizeable.
238 * @hide
239 */
240 @TestApi
241 public static final int RESIZE_MODE_RESIZEABLE = 2;
242 /**
243 * Activity is resizeable and supported picture-in-picture mode. This flag is now deprecated
244 * since activities do not need to be resizeable to support picture-in-picture.
245 * See {@link #FLAG_SUPPORTS_PICTURE_IN_PICTURE}.
246 *
247 * @hide
248 * @deprecated
249 */
250 public static final int RESIZE_MODE_RESIZEABLE_AND_PIPABLE_DEPRECATED = 3;
251 /**
252 * Activity does not support resizing, but we are forcing it to be resizeable. Only affects
253 * certain pre-N apps where we force them to be resizeable.
254 * @hide
255 */
256 public static final int RESIZE_MODE_FORCE_RESIZEABLE = 4;
257 /**
258 * Activity does not support resizing, but we are forcing it to be resizeable as long
259 * as the size remains landscape.
260 * @hide
261 */
262 public static final int RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY = 5;
263 /**
264 * Activity does not support resizing, but we are forcing it to be resizeable as long
265 * as the size remains portrait.
266 * @hide
267 */
268 public static final int RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY = 6;
269 /**
270 * Activity does not support resizing, but we are forcing it to be resizeable as long
271 * as the bounds remain in the same orientation as they are.
272 * @hide
273 */
274 public static final int RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION = 7;
275 /**
276 * Value indicating if the resizing mode the activity supports.
277 * See {@link android.R.attr#resizeableActivity}.
278 * @hide
279 */
280 @UnsupportedAppUsage
281 public int resizeMode = RESIZE_MODE_RESIZEABLE;
282
283 /**
284 * Value indicating the maximum aspect ratio the activity supports.
285 * <p>
286 * 0 means unset.
287 * @See {@link android.R.attr#maxAspectRatio}.
288 * @hide
289 */
290 private float mMaxAspectRatio;
291
292 /**
293 * Value indicating the minimum aspect ratio the activity supports.
294 * <p>
295 * 0 means unset.
296 * @See {@link android.R.attr#minAspectRatio}.
297 * @hide
298 */
299 private float mMinAspectRatio;
300
301 /**
302 * Indicates that the activity works well with size changes like display changing size.
303 *
304 * @hide
305 */
306 public boolean supportsSizeChanges;
307
308 /**
309 * Name of the VrListenerService component to run for this activity.
310 * @see android.R.attr#enableVrMode
311 * @hide
312 */
313 public String requestedVrComponent;
314
315 /**
316 * Value for {@link #colorMode} indicating that the activity should use the
317 * default color mode (sRGB, low dynamic range).
318 *
319 * @see android.R.attr#colorMode
320 */
321 public static final int COLOR_MODE_DEFAULT = 0;
322 /**
323 * Value of {@link #colorMode} indicating that the activity should use a
324 * wide color gamut if the presentation display supports it.
325 *
326 * @see android.R.attr#colorMode
327 */
328 public static final int COLOR_MODE_WIDE_COLOR_GAMUT = 1;
329 /**
330 * Value of {@link #colorMode} indicating that the activity should use a
331 * high dynamic range if the presentation display supports it.
332 *
333 * @see android.R.attr#colorMode
334 */
335 public static final int COLOR_MODE_HDR = 2;
336 // 3 Corresponds to android::uirenderer::ColorMode::Hdr10.
337 /**
338 * Value of {@link #colorMode} indicating that the activity should use an
339 * 8 bit alpha buffer if the presentation display supports it.
340 *
341 * @see android.R.attr#colorMode
342 * @hide
343 */
344 public static final int COLOR_MODE_A8 = 4;
345
346
347 /** @hide */
348 @IntDef(prefix = { "COLOR_MODE_" }, value = {
349 COLOR_MODE_DEFAULT,
350 COLOR_MODE_WIDE_COLOR_GAMUT,
351 COLOR_MODE_HDR,
352 COLOR_MODE_A8,
353 })
354 @Retention(RetentionPolicy.SOURCE)
355 public @interface ColorMode {}
356
357 /**
358 * The color mode requested by this activity. The target display may not be
359 * able to honor the request.
360 */
361 @ColorMode
362 public int colorMode = COLOR_MODE_DEFAULT;
363
364 /**
365 * Bit in {@link #flags} indicating whether this activity is able to
366 * run in multiple processes. If
367 * true, the system may instantiate it in the some process as the
368 * process starting it in order to conserve resources. If false, the
369 * default, it always runs in {@link #processName}. Set from the
370 * {@link android.R.attr#multiprocess} attribute.
371 */
372 public static final int FLAG_MULTIPROCESS = 0x0001;
373 /**
374 * Bit in {@link #flags} indicating that, when the activity's task is
375 * relaunched from home, this activity should be finished.
376 * Set from the
377 * {@link android.R.attr#finishOnTaskLaunch} attribute.
378 */
379 public static final int FLAG_FINISH_ON_TASK_LAUNCH = 0x0002;
380 /**
381 * Bit in {@link #flags} indicating that, when the activity is the root
382 * of a task, that task's stack should be cleared each time the user
383 * re-launches it from home. As a result, the user will always
384 * return to the original activity at the top of the task.
385 * This flag only applies to activities that
386 * are used to start the root of a new task. Set from the
387 * {@link android.R.attr#clearTaskOnLaunch} attribute.
388 */
389 public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 0x0004;
390 /**
391 * Bit in {@link #flags} indicating that, when the activity is the root
392 * of a task, that task's stack should never be cleared when it is
393 * relaunched from home. Set from the
394 * {@link android.R.attr#alwaysRetainTaskState} attribute.
395 */
396 public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 0x0008;
397 /**
398 * Bit in {@link #flags} indicating that the activity's state
399 * is not required to be saved, so that if there is a failure the
400 * activity will not be removed from the activity stack. Set from the
401 * {@link android.R.attr#stateNotNeeded} attribute.
402 */
403 public static final int FLAG_STATE_NOT_NEEDED = 0x0010;
404 /**
405 * Bit in {@link #flags} that indicates that the activity should not
406 * appear in the list of recently launched activities. Set from the
407 * {@link android.R.attr#excludeFromRecents} attribute.
408 */
409 public static final int FLAG_EXCLUDE_FROM_RECENTS = 0x0020;
410 /**
411 * Bit in {@link #flags} that indicates that the activity can be moved
412 * between tasks based on its task affinity. Set from the
413 * {@link android.R.attr#allowTaskReparenting} attribute.
414 */
415 public static final int FLAG_ALLOW_TASK_REPARENTING = 0x0040;
416 /**
417 * Bit in {@link #flags} indicating that, when the user navigates away
418 * from an activity, it should be finished.
419 * Set from the
420 * {@link android.R.attr#noHistory} attribute.
421 */
422 public static final int FLAG_NO_HISTORY = 0x0080;
423 /**
424 * Bit in {@link #flags} indicating that, when a request to close system
425 * windows happens, this activity is finished.
426 * Set from the
427 * {@link android.R.attr#finishOnCloseSystemDialogs} attribute.
428 */
429 public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 0x0100;
430 /**
431 * Value for {@link #flags}: true when the application's rendering should
432 * be hardware accelerated.
433 */
434 public static final int FLAG_HARDWARE_ACCELERATED = 0x0200;
435 /**
436 * Value for {@link #flags}: true when the application can be displayed for all users
437 * regardless of if the user of the application is the current user. Set from the
438 * {@link android.R.attr#showForAllUsers} attribute.
439 * @hide
440 */
441 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
442 public static final int FLAG_SHOW_FOR_ALL_USERS = 0x0400;
443 /**
444 * Bit in {@link #flags} corresponding to an immersive activity
445 * that wishes not to be interrupted by notifications.
446 * Applications that hide the system notification bar with
447 * {@link android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN}
448 * may still be interrupted by high-priority notifications; for example, an
449 * incoming phone call may use
450 * {@link android.app.Notification#fullScreenIntent fullScreenIntent}
451 * to present a full-screen in-call activity to the user, pausing the
452 * current activity as a side-effect. An activity with
453 * {@link #FLAG_IMMERSIVE} set, however, will not be interrupted; the
454 * notification may be shown in some other way (such as a small floating
455 * "toast" window).
456 *
457 * Note that this flag will always reflect the Activity's
458 * <code>android:immersive</code> manifest definition, even if the Activity's
459 * immersive state is changed at runtime via
460 * {@link android.app.Activity#setImmersive(boolean)}.
461 *
462 * @see android.app.Notification#FLAG_HIGH_PRIORITY
463 * @see android.app.Activity#setImmersive(boolean)
464 */
465 public static final int FLAG_IMMERSIVE = 0x0800;
466 /**
467 * Bit in {@link #flags}: If set, a task rooted at this activity will have its
468 * baseIntent replaced by the activity immediately above this. Each activity may further
469 * relinquish its identity to the activity above it using this flag. Set from the
470 * {@link android.R.attr#relinquishTaskIdentity} attribute.
471 */
472 public static final int FLAG_RELINQUISH_TASK_IDENTITY = 0x1000;
473 /**
474 * Bit in {@link #flags} indicating that tasks started with this activity are to be
475 * removed from the recent list of tasks when the last activity in the task is finished.
476 * Corresponds to {@link android.R.attr#autoRemoveFromRecents}
477 */
478 public static final int FLAG_AUTO_REMOVE_FROM_RECENTS = 0x2000;
479 /**
480 * Bit in {@link #flags} indicating that this activity can start is creation/resume
481 * while the previous activity is still pausing. Corresponds to
482 * {@link android.R.attr#resumeWhilePausing}
483 */
484 public static final int FLAG_RESUME_WHILE_PAUSING = 0x4000;
485 /**
486 * Bit in {@link #flags} indicating that this activity should be run with VR mode enabled.
487 *
488 * @see android.app.Activity#setVrModeEnabled(boolean, ComponentName)
489 */
490 public static final int FLAG_ENABLE_VR_MODE = 0x8000;
491 /**
492 * Bit in {@link #flags} indicating if the activity can be displayed on a remote device.
493 * Corresponds to {@link android.R.attr#canDisplayOnRemoteDevices}
494 * @hide
495 */
496 public static final int FLAG_CAN_DISPLAY_ON_REMOTE_DEVICES = 0x10000;
497
498 /**
499 * Bit in {@link #flags} indicating if the activity is always focusable regardless of if it is
500 * in a task/stack whose activities are normally not focusable.
501 * See android.R.attr#alwaysFocusable.
502 * @hide
503 */
504 public static final int FLAG_ALWAYS_FOCUSABLE = 0x40000;
505
506 /**
507 * Bit in {@link #flags} indicating if the activity is visible to instant
508 * applications. The activity is visible if it's either implicitly or
509 * explicitly exposed.
510 * @hide
511 */
512 public static final int FLAG_VISIBLE_TO_INSTANT_APP = 0x100000;
513
514 /**
515 * Bit in {@link #flags} indicating if the activity is implicitly visible
516 * to instant applications. Implicitly visible activities are those that
517 * implement certain intent-filters:
518 * <ul>
519 * <li>action {@link Intent#CATEGORY_BROWSABLE}</li>
520 * <li>action {@link Intent#ACTION_SEND}</li>
521 * <li>action {@link Intent#ACTION_SENDTO}</li>
522 * <li>action {@link Intent#ACTION_SEND_MULTIPLE}</li>
523 * </ul>
524 * @hide
525 */
526 public static final int FLAG_IMPLICITLY_VISIBLE_TO_INSTANT_APP = 0x200000;
527
528 /**
529 * Bit in {@link #flags} indicating if the activity supports picture-in-picture mode.
530 * See {@link android.R.attr#supportsPictureInPicture}.
531 * @hide
532 */
533 public static final int FLAG_SUPPORTS_PICTURE_IN_PICTURE = 0x400000;
534
535 /**
536 * Bit in {@link #flags} indicating if the activity should be shown when locked.
537 * See {@link android.R.attr#showWhenLocked}
538 * @hide
539 */
540 public static final int FLAG_SHOW_WHEN_LOCKED = 0x800000;
541
542 /**
543 * Bit in {@link #flags} indicating if the screen should turn on when starting the activity.
544 * See {@link android.R.attr#turnScreenOn}
545 * @hide
546 */
547 public static final int FLAG_TURN_SCREEN_ON = 0x1000000;
548
549 /**
550 * Bit in {@link #flags} indicating whether the display should preferably be switched to a
551 * minimal post processing mode.
552 * See {@link android.R.attr#preferMinimalPostProcessing}
553 */
554 public static final int FLAG_PREFER_MINIMAL_POST_PROCESSING = 0x2000000;
555
556 /**
557 * Bit in {@link #flags}: If set, indicates that the activity can be embedded by untrusted
558 * hosts. In this case the interactions with and visibility of the embedded activity may be
559 * limited. Set from the {@link android.R.attr#allowUntrustedActivityEmbedding} attribute.
560 */
561 public static final int FLAG_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING = 0x10000000;
562
563 /**
564 * @hide Bit in {@link #flags}: If set, this component will only be seen
565 * by the system user. Only works with broadcast receivers. Set from the
566 * android.R.attr#systemUserOnly attribute.
567 */
568 public static final int FLAG_SYSTEM_USER_ONLY = 0x20000000;
569 /**
570 * Bit in {@link #flags}: If set, a single instance of the receiver will
571 * run for all users on the device. Set from the
572 * {@link android.R.attr#singleUser} attribute. Note that this flag is
573 * only relevant for ActivityInfo structures that are describing receiver
574 * components; it is not applied to activities.
575 */
576 public static final int FLAG_SINGLE_USER = 0x40000000;
577 /**
578 * @hide Bit in {@link #flags}: If set, this activity may be launched into an
579 * owned ActivityContainer such as that within an ActivityView. If not set and
580 * this activity is launched into such a container a SecurityException will be
581 * thrown. Set from the {@link android.R.attr#allowEmbedded} attribute.
582 *
583 * @deprecated this flag is no longer needed since ActivityView is now fully removed
584 * TODO(b/191165536): delete this flag since is no longer used
585 */
586 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
587 @Deprecated
588 public static final int FLAG_ALLOW_EMBEDDED = 0x80000000;
589
590 /**
591 * Options that have been set in the activity declaration in the
592 * manifest.
593 * These include:
594 * {@link #FLAG_MULTIPROCESS},
595 * {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH},
596 * {@link #FLAG_ALWAYS_RETAIN_TASK_STATE},
597 * {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS},
598 * {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY},
599 * {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS},
600 * {@link #FLAG_HARDWARE_ACCELERATED}, {@link #FLAG_SINGLE_USER},
601 * {@link #FLAG_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING}.
602 */
603 public int flags;
604
605 /**
606 * Bit in {@link #privateFlags} indicating if the activity should be shown when locked in case
607 * an activity behind this can also be shown when locked.
608 * See {@link android.R.attr#inheritShowWhenLocked}.
609 * @hide
610 */
611 public static final int FLAG_INHERIT_SHOW_WHEN_LOCKED = 0x1;
612
613 /**
614 * Bit in {@link #privateFlags} indicating whether a home sound effect should be played if the
615 * home app moves to front after the activity with this flag set.
616 * Set from the {@link android.R.attr#playHomeTransitionSound} attribute.
617 * @hide
618 */
619 public static final int PRIVATE_FLAG_HOME_TRANSITION_SOUND = 0x2;
620
621 /**
622 * Options that have been set in the activity declaration in the manifest.
623 * These include:
624 * {@link #FLAG_INHERIT_SHOW_WHEN_LOCKED},
625 * {@link #PRIVATE_FLAG_HOME_TRANSITION_SOUND}.
626 * @hide
627 */
628 public int privateFlags;
629
630 /** @hide */
631 @IntDef(prefix = { "SCREEN_ORIENTATION_" }, value = {
632 SCREEN_ORIENTATION_UNSET,
633 SCREEN_ORIENTATION_UNSPECIFIED,
634 SCREEN_ORIENTATION_LANDSCAPE,
635 SCREEN_ORIENTATION_PORTRAIT,
636 SCREEN_ORIENTATION_USER,
637 SCREEN_ORIENTATION_BEHIND,
638 SCREEN_ORIENTATION_SENSOR,
639 SCREEN_ORIENTATION_NOSENSOR,
640 SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
641 SCREEN_ORIENTATION_SENSOR_PORTRAIT,
642 SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
643 SCREEN_ORIENTATION_REVERSE_PORTRAIT,
644 SCREEN_ORIENTATION_FULL_SENSOR,
645 SCREEN_ORIENTATION_USER_LANDSCAPE,
646 SCREEN_ORIENTATION_USER_PORTRAIT,
647 SCREEN_ORIENTATION_FULL_USER,
648 SCREEN_ORIENTATION_LOCKED
649 })
650 @Retention(RetentionPolicy.SOURCE)
651 public @interface ScreenOrientation {}
652
653 /**
654 * Internal constant used to indicate that the app didn't set a specific orientation value.
655 * Different from {@link #SCREEN_ORIENTATION_UNSPECIFIED} below as the app can set its
656 * orientation to {@link #SCREEN_ORIENTATION_UNSPECIFIED} while this means that the app didn't
657 * set anything. The system will mostly treat this similar to
658 * {@link #SCREEN_ORIENTATION_UNSPECIFIED}.
659 * @hide
660 */
661 public static final int SCREEN_ORIENTATION_UNSET = -2;
662 /**
663 * Constant corresponding to <code>unspecified</code> in
664 * the {@link android.R.attr#screenOrientation} attribute.
665 */
666 public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1;
667 /**
668 * Constant corresponding to <code>landscape</code> in
669 * the {@link android.R.attr#screenOrientation} attribute.
670 */
671 public static final int SCREEN_ORIENTATION_LANDSCAPE = 0;
672 /**
673 * Constant corresponding to <code>portrait</code> in
674 * the {@link android.R.attr#screenOrientation} attribute.
675 */
676 public static final int SCREEN_ORIENTATION_PORTRAIT = 1;
677 /**
678 * Constant corresponding to <code>user</code> in
679 * the {@link android.R.attr#screenOrientation} attribute.
680 */
681 public static final int SCREEN_ORIENTATION_USER = 2;
682 /**
683 * Constant corresponding to <code>behind</code> in
684 * the {@link android.R.attr#screenOrientation} attribute.
685 */
686 public static final int SCREEN_ORIENTATION_BEHIND = 3;
687 /**
688 * Constant corresponding to <code>sensor</code> in
689 * the {@link android.R.attr#screenOrientation} attribute.
690 */
691 public static final int SCREEN_ORIENTATION_SENSOR = 4;
692
693 /**
694 * Constant corresponding to <code>nosensor</code> in
695 * the {@link android.R.attr#screenOrientation} attribute.
696 */
697 public static final int SCREEN_ORIENTATION_NOSENSOR = 5;
698
699 /**
700 * Constant corresponding to <code>sensorLandscape</code> in
701 * the {@link android.R.attr#screenOrientation} attribute.
702 */
703 public static final int SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 6;
704
705 /**
706 * Constant corresponding to <code>sensorPortrait</code> in
707 * the {@link android.R.attr#screenOrientation} attribute.
708 */
709 public static final int SCREEN_ORIENTATION_SENSOR_PORTRAIT = 7;
710
711 /**
712 * Constant corresponding to <code>reverseLandscape</code> in
713 * the {@link android.R.attr#screenOrientation} attribute.
714 */
715 public static final int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8;
716
717 /**
718 * Constant corresponding to <code>reversePortrait</code> in
719 * the {@link android.R.attr#screenOrientation} attribute.
720 */
721 public static final int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9;
722
723 /**
724 * Constant corresponding to <code>fullSensor</code> in
725 * the {@link android.R.attr#screenOrientation} attribute.
726 */
727 public static final int SCREEN_ORIENTATION_FULL_SENSOR = 10;
728
729 /**
730 * Constant corresponding to <code>userLandscape</code> in
731 * the {@link android.R.attr#screenOrientation} attribute.
732 */
733 public static final int SCREEN_ORIENTATION_USER_LANDSCAPE = 11;
734
735 /**
736 * Constant corresponding to <code>userPortrait</code> in
737 * the {@link android.R.attr#screenOrientation} attribute.
738 */
739 public static final int SCREEN_ORIENTATION_USER_PORTRAIT = 12;
740
741 /**
742 * Constant corresponding to <code>fullUser</code> in
743 * the {@link android.R.attr#screenOrientation} attribute.
744 */
745 public static final int SCREEN_ORIENTATION_FULL_USER = 13;
746
747 /**
748 * Constant corresponding to <code>locked</code> in
749 * the {@link android.R.attr#screenOrientation} attribute.
750 */
751 public static final int SCREEN_ORIENTATION_LOCKED = 14;
752
753 /**
754 * The preferred screen orientation this activity would like to run in.
755 * From the {@link android.R.attr#screenOrientation} attribute, one of
756 * {@link #SCREEN_ORIENTATION_UNSPECIFIED},
757 * {@link #SCREEN_ORIENTATION_LANDSCAPE},
758 * {@link #SCREEN_ORIENTATION_PORTRAIT},
759 * {@link #SCREEN_ORIENTATION_USER},
760 * {@link #SCREEN_ORIENTATION_BEHIND},
761 * {@link #SCREEN_ORIENTATION_SENSOR},
762 * {@link #SCREEN_ORIENTATION_NOSENSOR},
763 * {@link #SCREEN_ORIENTATION_SENSOR_LANDSCAPE},
764 * {@link #SCREEN_ORIENTATION_SENSOR_PORTRAIT},
765 * {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE},
766 * {@link #SCREEN_ORIENTATION_REVERSE_PORTRAIT},
767 * {@link #SCREEN_ORIENTATION_FULL_SENSOR},
768 * {@link #SCREEN_ORIENTATION_USER_LANDSCAPE},
769 * {@link #SCREEN_ORIENTATION_USER_PORTRAIT},
770 * {@link #SCREEN_ORIENTATION_FULL_USER},
771 * {@link #SCREEN_ORIENTATION_LOCKED},
772 */
773 @ScreenOrientation
774 public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED;
775
776 /** @hide */
777 @IntDef(flag = true, prefix = { "CONFIG_" }, value = {
778 CONFIG_MCC,
779 CONFIG_MNC,
780 CONFIG_LOCALE,
781 CONFIG_TOUCHSCREEN,
782 CONFIG_KEYBOARD,
783 CONFIG_KEYBOARD_HIDDEN,
784 CONFIG_NAVIGATION,
785 CONFIG_ORIENTATION,
786 CONFIG_SCREEN_LAYOUT,
787 CONFIG_UI_MODE,
788 CONFIG_SCREEN_SIZE,
789 CONFIG_SMALLEST_SCREEN_SIZE,
790 CONFIG_DENSITY,
791 CONFIG_LAYOUT_DIRECTION,
792 CONFIG_COLOR_MODE,
793 CONFIG_FONT_SCALE,
794 })
795 @Retention(RetentionPolicy.SOURCE)
796 public @interface Config {}
797
798 /**
799 * Bit in {@link #configChanges} that indicates that the activity
800 * can itself handle changes to the IMSI MCC. Set from the
801 * {@link android.R.attr#configChanges} attribute.
802 */
803 public static final int CONFIG_MCC = 0x0001;
804 /**
805 * Bit in {@link #configChanges} that indicates that the activity
806 * can itself handle changes to the IMSI MNC. Set from the
807 * {@link android.R.attr#configChanges} attribute.
808 */
809 public static final int CONFIG_MNC = 0x0002;
810 /**
811 * Bit in {@link #configChanges} that indicates that the activity
812 * can itself handle changes to the locale. Set from the
813 * {@link android.R.attr#configChanges} attribute.
814 */
815 public static final int CONFIG_LOCALE = 0x0004;
816 /**
817 * Bit in {@link #configChanges} that indicates that the activity
818 * can itself handle changes to the touchscreen type. Set from the
819 * {@link android.R.attr#configChanges} attribute.
820 */
821 public static final int CONFIG_TOUCHSCREEN = 0x0008;
822 /**
823 * Bit in {@link #configChanges} that indicates that the activity
824 * can itself handle changes to the keyboard type. Set from the
825 * {@link android.R.attr#configChanges} attribute.
826 */
827 public static final int CONFIG_KEYBOARD = 0x0010;
828 /**
829 * Bit in {@link #configChanges} that indicates that the activity
830 * can itself handle changes to the keyboard or navigation being hidden/exposed.
831 * Note that inspite of the name, this applies to the changes to any
832 * hidden states: keyboard or navigation.
833 * Set from the {@link android.R.attr#configChanges} attribute.
834 */
835 public static final int CONFIG_KEYBOARD_HIDDEN = 0x0020;
836 /**
837 * Bit in {@link #configChanges} that indicates that the activity
838 * can itself handle changes to the navigation type. Set from the
839 * {@link android.R.attr#configChanges} attribute.
840 */
841 public static final int CONFIG_NAVIGATION = 0x0040;
842 /**
843 * Bit in {@link #configChanges} that indicates that the activity
844 * can itself handle changes to the screen orientation. Set from the
845 * {@link android.R.attr#configChanges} attribute.
846 */
847 public static final int CONFIG_ORIENTATION = 0x0080;
848 /**
849 * Bit in {@link #configChanges} that indicates that the activity
850 * can itself handle changes to the screen layout. Set from the
851 * {@link android.R.attr#configChanges} attribute.
852 */
853 public static final int CONFIG_SCREEN_LAYOUT = 0x0100;
854 /**
855 * Bit in {@link #configChanges} that indicates that the activity
856 * can itself handle the ui mode. Set from the
857 * {@link android.R.attr#configChanges} attribute.
858 */
859 public static final int CONFIG_UI_MODE = 0x0200;
860 /**
861 * Bit in {@link #configChanges} that indicates that the activity
862 * can itself handle the screen size. Set from the
863 * {@link android.R.attr#configChanges} attribute. This will be
864 * set by default for applications that target an earlier version
865 * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}...
866 * <b>however</b>, you will not see the bit set here becomes some
867 * applications incorrectly compare {@link #configChanges} against
868 * an absolute value rather than correctly masking out the bits
869 * they are interested in. Please don't do that, thanks.
870 */
871 public static final int CONFIG_SCREEN_SIZE = 0x0400;
872 /**
873 * Bit in {@link #configChanges} that indicates that the activity
874 * can itself handle the smallest screen size. Set from the
875 * {@link android.R.attr#configChanges} attribute. This will be
876 * set by default for applications that target an earlier version
877 * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}...
878 * <b>however</b>, you will not see the bit set here becomes some
879 * applications incorrectly compare {@link #configChanges} against
880 * an absolute value rather than correctly masking out the bits
881 * they are interested in. Please don't do that, thanks.
882 */
883 public static final int CONFIG_SMALLEST_SCREEN_SIZE = 0x0800;
884 /**
885 * Bit in {@link #configChanges} that indicates that the activity
886 * can itself handle density changes. Set from the
887 * {@link android.R.attr#configChanges} attribute.
888 */
889 public static final int CONFIG_DENSITY = 0x1000;
890 /**
891 * Bit in {@link #configChanges} that indicates that the activity
892 * can itself handle the change to layout direction. Set from the
893 * {@link android.R.attr#configChanges} attribute.
894 */
895 public static final int CONFIG_LAYOUT_DIRECTION = 0x2000;
896 /**
897 * Bit in {@link #configChanges} that indicates that the activity
898 * can itself handle the change to the display color gamut or dynamic
899 * range. Set from the {@link android.R.attr#configChanges} attribute.
900 */
901 public static final int CONFIG_COLOR_MODE = 0x4000;
902 /**
903 * Bit in {@link #configChanges} that indicates that the activity
904 * can itself handle asset path changes. Set from the {@link android.R.attr#configChanges}
905 * attribute. This is not a core resource configuration, but a higher-level value, so its
906 * constant starts at the high bits.
907 * @hide We do not want apps handling this yet, but we do need some kind of bit for diffs.
908 */
909 public static final int CONFIG_ASSETS_PATHS = 0x80000000;
910 /**
911 * Bit in {@link #configChanges} that indicates that the activity
912 * can itself handle changes to the font scaling factor. Set from the
913 * {@link android.R.attr#configChanges} attribute. This is
914 * not a core resource configuration, but a higher-level value, so its
915 * constant starts at the high bits.
916 */
917 public static final int CONFIG_FONT_SCALE = 0x40000000;
918 /**
919 * Bit indicating changes to window configuration that isn't exposed to apps.
920 * This is for internal use only and apps don't handle it.
921 * @hide
922 * {@link Configuration}.
923 */
924 public static final int CONFIG_WINDOW_CONFIGURATION = 0x20000000;
925
926 /**
927 * Bit in {@link #configChanges} that indicates that the activity
928 * can itself handle changes to font weight. Set from the
929 * {@link android.R.attr#configChanges} attribute. This is
930 * not a core resource configuration, but a higher-level value, so its
931 * constant starts at the high bits.
932 */
933
934 public static final int CONFIG_FONT_WEIGHT_ADJUSTMENT = 0x10000000;
935
936 /** @hide
937 * Unfortunately the constants for config changes in native code are
938 * different from ActivityInfo. :( Here are the values we should use for the
939 * native side given the bit we have assigned in ActivityInfo.
940 */
941 public static int[] CONFIG_NATIVE_BITS = new int[] {
942 Configuration.NATIVE_CONFIG_MNC, // MNC
943 Configuration.NATIVE_CONFIG_MCC, // MCC
944 Configuration.NATIVE_CONFIG_LOCALE, // LOCALE
945 Configuration.NATIVE_CONFIG_TOUCHSCREEN, // TOUCH SCREEN
946 Configuration.NATIVE_CONFIG_KEYBOARD, // KEYBOARD
947 Configuration.NATIVE_CONFIG_KEYBOARD_HIDDEN, // KEYBOARD HIDDEN
948 Configuration.NATIVE_CONFIG_NAVIGATION, // NAVIGATION
949 Configuration.NATIVE_CONFIG_ORIENTATION, // ORIENTATION
950 Configuration.NATIVE_CONFIG_SCREEN_LAYOUT, // SCREEN LAYOUT
951 Configuration.NATIVE_CONFIG_UI_MODE, // UI MODE
952 Configuration.NATIVE_CONFIG_SCREEN_SIZE, // SCREEN SIZE
953 Configuration.NATIVE_CONFIG_SMALLEST_SCREEN_SIZE, // SMALLEST SCREEN SIZE
954 Configuration.NATIVE_CONFIG_DENSITY, // DENSITY
955 Configuration.NATIVE_CONFIG_LAYOUTDIR, // LAYOUT DIRECTION
956 Configuration.NATIVE_CONFIG_COLOR_MODE, // COLOR_MODE
957 };
958
959 /**
960 * This change id forces the packages it is applied to be resizable. It won't change whether
961 * the app can be put into multi-windowing mode, but allow the app to resize when the window
962 * container resizes, such as display size change.
963 * @hide
964 */
965 @ChangeId
966 @Overridable
967 @Disabled
968 @TestApi
969 public static final long FORCE_RESIZE_APP = 174042936L; // buganizer id
970
971 /**
972 * This change id forces the packages it is applied to to be non-resizable.
973 * @hide
974 */
975 @ChangeId
976 @Overridable
977 @Disabled
978 @TestApi
979 public static final long FORCE_NON_RESIZE_APP = 181136395L; // buganizer id
980
981 /**
982 * Return value for {@link #supportsSizeChanges()} indicating that this activity does not
983 * support size changes due to the android.supports_size_changes metadata flag either being
984 * unset or set to {@code false} on application or activity level.
985 *
986 * @hide
987 */
988 public static final int SIZE_CHANGES_UNSUPPORTED_METADATA = 0;
989
990 /**
991 * Return value for {@link #supportsSizeChanges()} indicating that this activity has been
992 * overridden to not support size changes through the compat framework change id
993 * {@link #FORCE_NON_RESIZE_APP}.
994 * @hide
995 */
996 public static final int SIZE_CHANGES_UNSUPPORTED_OVERRIDE = 1;
997
998 /**
999 * Return value for {@link #supportsSizeChanges()} indicating that this activity supports size
1000 * changes due to the android.supports_size_changes metadata flag being set to {@code true}
1001 * either on application or activity level.
1002 * @hide
1003 */
1004 public static final int SIZE_CHANGES_SUPPORTED_METADATA = 2;
1005
1006 /**
1007 * Return value for {@link #supportsSizeChanges()} indicating that this activity has been
1008 * overridden to support size changes through the compat framework change id
1009 * {@link #FORCE_RESIZE_APP}.
1010 * @hide
1011 */
1012 public static final int SIZE_CHANGES_SUPPORTED_OVERRIDE = 3;
1013
1014 /** @hide */
1015 @IntDef(prefix = { "SIZE_CHANGES_" }, value = {
1016 SIZE_CHANGES_UNSUPPORTED_METADATA,
1017 SIZE_CHANGES_UNSUPPORTED_OVERRIDE,
1018 SIZE_CHANGES_SUPPORTED_METADATA,
1019 SIZE_CHANGES_SUPPORTED_OVERRIDE,
1020 })
1021 @Retention(RetentionPolicy.SOURCE)
1022 public @interface SizeChangesSupportMode {}
1023
1024 /**
1025 * This change id enables compat policy that ignores app requested orientation in
1026 * response to an app calling {@link android.app.Activity#setRequestedOrientation}. See
1027 * com.android.server.wm.LetterboxUiController#shouldIgnoreRequestedOrientation for
1028 * details.
1029 * @hide
1030 */
1031 @ChangeId
1032 @Overridable
1033 @Disabled
1034 public static final long OVERRIDE_ENABLE_COMPAT_IGNORE_REQUESTED_ORIENTATION =
1035 254631730L; // buganizer id
1036
1037 /**
1038 * This change id forces the packages it is applied to never have Display API sandboxing
1039 * applied for a letterbox or SCM activity. The Display APIs will continue to provide
1040 * DisplayArea bounds.
1041 * @hide
1042 */
1043 @ChangeId
1044 @Overridable
1045 @Disabled
1046 @TestApi
1047 public static final long NEVER_SANDBOX_DISPLAY_APIS = 184838306L; // buganizer id
1048
1049 /**
1050 * This change id forces the packages it is applied to always have Display API sandboxing
1051 * applied, regardless of windowing mode. The Display APIs will always provide the app bounds.
1052 * @hide
1053 */
1054 @ChangeId
1055 @Overridable
1056 @Disabled
1057 @TestApi
1058 public static final long ALWAYS_SANDBOX_DISPLAY_APIS = 185004937L; // buganizer id
1059
1060 /**
1061 * This change id is the gatekeeper for all treatments that force a given min aspect ratio.
1062 * Enabling this change will allow the following min aspect ratio treatments to be applied:
1063 * OVERRIDE_MIN_ASPECT_RATIO_MEDIUM
1064 * OVERRIDE_MIN_ASPECT_RATIO_LARGE
1065 *
1066 * If OVERRIDE_MIN_ASPECT_RATIO is applied, the min aspect ratio given in the app's manifest
1067 * will be overridden to the largest enabled aspect ratio treatment unless the app's manifest
1068 * value is higher.
1069 * @hide
1070 */
1071 @ChangeId
1072 @Overridable
1073 @Disabled
1074 @TestApi
1075 public static final long OVERRIDE_MIN_ASPECT_RATIO = 174042980L; // buganizer id
1076
1077 /**
1078 * This change id restricts treatments that force a given min aspect ratio to activities
1079 * whose orientation is fixed to portrait.
1080 *
1081 * This treatment is enabled by default and only takes effect if OVERRIDE_MIN_ASPECT_RATIO is
1082 * also enabled.
1083 * @hide
1084 */
1085 @ChangeId
1086 @Overridable
1087 @TestApi
1088 public static final long OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY = 203647190L; // buganizer id
1089
1090 /**
1091 * This change id sets the activity's min aspect ratio to a medium value as defined by
1092 * OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE.
1093 *
1094 * This treatment only takes effect if OVERRIDE_MIN_ASPECT_RATIO is also enabled.
1095 * @hide
1096 */
1097 @ChangeId
1098 @Overridable
1099 @Disabled
1100 @TestApi
1101 public static final long OVERRIDE_MIN_ASPECT_RATIO_MEDIUM = 180326845L; // buganizer id
1102
1103 /** @hide Medium override aspect ratio, currently 3:2. */
1104 @TestApi
1105 public static final float OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE = 3 / 2f;
1106
1107 /**
1108 * This change id sets the activity's min aspect ratio to a large value as defined by
1109 * OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE.
1110 *
1111 * This treatment only takes effect if OVERRIDE_MIN_ASPECT_RATIO is also enabled.
1112 * @hide
1113 */
1114 @ChangeId
1115 @Overridable
1116 @Disabled
1117 @TestApi
1118 public static final long OVERRIDE_MIN_ASPECT_RATIO_LARGE = 180326787L; // buganizer id
1119
1120 /** @hide Large override aspect ratio, currently 16:9 */
1121 @TestApi
1122 public static final float OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE = 16 / 9f;
1123
1124 /**
1125 * Enables the use of split screen aspect ratio. This allows an app to use all the available
1126 * space in split mode avoiding letterboxing.
1127 * @hide
1128 */
1129 @ChangeId
1130 @Disabled
1131 @Overridable
1132 public static final long OVERRIDE_MIN_ASPECT_RATIO_TO_ALIGN_WITH_SPLIT_SCREEN = 208648326L;
1133
1134 /**
1135 * Overrides the min aspect ratio restriction in portrait fullscreen in order to use all
1136 * available screen space.
1137 * @hide
1138 */
1139 @ChangeId
1140 @Disabled
1141 @Overridable
1142 public static final long OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN = 218959984L;
1143
1144 /**
1145 * Enables sending fake focus for unfocused apps in splitscreen. Some game engines
1146 * wait to get focus before drawing the content of the app so fake focus helps them to avoid
1147 * staying blacked out when they are resumed and do not have focus yet.
1148 * @hide
1149 */
1150 @ChangeId
1151 @Disabled
1152 @Overridable
1153 public static final long OVERRIDE_ENABLE_COMPAT_FAKE_FOCUS = 263259275L;
1154
1155 /**
1156 * Compares activity window layout min width/height with require space for multi window to
1157 * determine if it can be put into multi window mode.
1158 */
1159 @ChangeId
1160 @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S)
1161 private static final long CHECK_MIN_WIDTH_HEIGHT_FOR_MULTI_WINDOW = 197654537L;
1162
1163 /**
1164 * Optional set of a certificates identifying apps that are allowed to embed this activity. From
1165 * the "knownActivityEmbeddingCerts" attribute.
1166 */
1167 @Nullable
1168 private Set<String> mKnownActivityEmbeddingCerts;
1169
1170 /**
1171 * Convert Java change bits to native.
1172 *
1173 * @hide
1174 */
1175 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
1176 public static @NativeConfig int activityInfoConfigJavaToNative(@Config int input) {
1177 int output = 0;
1178 for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) {
1179 if ((input & (1 << i)) != 0) {
1180 output |= CONFIG_NATIVE_BITS[i];
1181 }
1182 }
1183 return output;
1184 }
1185
1186 /**
1187 * Convert native change bits to Java.
1188 *
1189 * @hide
1190 */
1191 public static @Config int activityInfoConfigNativeToJava(@NativeConfig int input) {
1192 int output = 0;
1193 for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) {
1194 if ((input & CONFIG_NATIVE_BITS[i]) != 0) {
1195 output |= (1 << i);
1196 }
1197 }
1198 return output;
1199 }
1200
1201 /**
1202 * @hide
1203 * Unfortunately some developers (OpenFeint I am looking at you) have
1204 * compared the configChanges bit field against absolute values, so if we
1205 * introduce a new bit they break. To deal with that, we will make sure
1206 * the public field will not have a value that breaks them, and let the
1207 * framework call here to get the real value.
1208 */
1209 public int getRealConfigChanged() {
1210 return applicationInfo.targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB_MR2
1211 ? (configChanges | ActivityInfo.CONFIG_SCREEN_SIZE
1212 | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE)
1213 : configChanges;
1214 }
1215
1216 /**
1217 * Bit mask of kinds of configuration changes that this activity
1218 * can handle itself (without being restarted by the system).
1219 * Contains any combination of {@link #CONFIG_FONT_SCALE},
1220 * {@link #CONFIG_MCC}, {@link #CONFIG_MNC},
1221 * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN},
1222 * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION},
1223 * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT},
1224 * {@link #CONFIG_DENSITY}, {@link #CONFIG_LAYOUT_DIRECTION} and
1225 * {@link #CONFIG_COLOR_MODE}.
1226 * Set from the {@link android.R.attr#configChanges} attribute.
1227 */
1228 public int configChanges;
1229
1230 /**
1231 * The desired soft input mode for this activity's main window.
1232 * Set from the {@link android.R.attr#windowSoftInputMode} attribute
1233 * in the activity's manifest. May be any of the same values allowed
1234 * for {@link android.view.WindowManager.LayoutParams#softInputMode
1235 * WindowManager.LayoutParams.softInputMode}. If 0 (unspecified),
1236 * the mode from the theme will be used.
1237 */
1238 @android.view.WindowManager.LayoutParams.SoftInputModeFlags
1239 public int softInputMode;
1240
1241 /**
1242 * The desired extra UI options for this activity and its main window.
1243 * Set from the {@link android.R.attr#uiOptions} attribute in the
1244 * activity's manifest.
1245 */
1246 public int uiOptions = 0;
1247
1248 /**
1249 * Flag for use with {@link #uiOptions}.
1250 * Indicates that the action bar should put all action items in a separate bar when
1251 * the screen is narrow.
1252 * <p>This value corresponds to "splitActionBarWhenNarrow" for the {@link #uiOptions} XML
1253 * attribute.
1254 */
1255 public static final int UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW = 1;
1256
1257 /**
1258 * If defined, the activity named here is the logical parent of this activity.
1259 */
1260 public String parentActivityName;
1261
1262 /**
1263 * Screen rotation animation desired by the activity, with values as defined
1264 * for {@link android.view.WindowManager.LayoutParams#rotationAnimation}.
1265 *
1266 * -1 means to use the system default.
1267 *
1268 * @hide
1269 */
1270 public int rotationAnimation = -1;
1271
1272 /** @hide */
1273 public static final int LOCK_TASK_LAUNCH_MODE_DEFAULT = 0;
1274 /** @hide */
1275 public static final int LOCK_TASK_LAUNCH_MODE_NEVER = 1;
1276 /** @hide */
1277 public static final int LOCK_TASK_LAUNCH_MODE_ALWAYS = 2;
1278 /** @hide */
1279 public static final int LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED = 3;
1280
1281 /** @hide */
1282 public static final String lockTaskLaunchModeToString(int lockTaskLaunchMode) {
1283 switch (lockTaskLaunchMode) {
1284 case LOCK_TASK_LAUNCH_MODE_DEFAULT:
1285 return "LOCK_TASK_LAUNCH_MODE_DEFAULT";
1286 case LOCK_TASK_LAUNCH_MODE_NEVER:
1287 return "LOCK_TASK_LAUNCH_MODE_NEVER";
1288 case LOCK_TASK_LAUNCH_MODE_ALWAYS:
1289 return "LOCK_TASK_LAUNCH_MODE_ALWAYS";
1290 case LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED:
1291 return "LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED";
1292 default:
1293 return "unknown=" + lockTaskLaunchMode;
1294 }
1295 }
1296 /**
1297 * Value indicating if the activity is to be locked at startup. Takes on the values from
1298 * {@link android.R.attr#lockTaskMode}.
1299 * @hide
1300 */
1301 public int lockTaskLaunchMode;
1302
1303 /**
1304 * Information about desired position and size of activity on the display when
1305 * it is first started.
1306 */
1307 public WindowLayout windowLayout;
1308
1309 public ActivityInfo() {
1310 }
1311
1312 public ActivityInfo(ActivityInfo orig) {
1313 super(orig);
1314 theme = orig.theme;
1315 launchMode = orig.launchMode;
1316 documentLaunchMode = orig.documentLaunchMode;
1317 permission = orig.permission;
1318 mKnownActivityEmbeddingCerts = orig.mKnownActivityEmbeddingCerts;
1319 taskAffinity = orig.taskAffinity;
1320 targetActivity = orig.targetActivity;
1321 flags = orig.flags;
1322 privateFlags = orig.privateFlags;
1323 screenOrientation = orig.screenOrientation;
1324 configChanges = orig.configChanges;
1325 softInputMode = orig.softInputMode;
1326 uiOptions = orig.uiOptions;
1327 parentActivityName = orig.parentActivityName;
1328 maxRecents = orig.maxRecents;
1329 lockTaskLaunchMode = orig.lockTaskLaunchMode;
1330 windowLayout = orig.windowLayout;
1331 resizeMode = orig.resizeMode;
1332 requestedVrComponent = orig.requestedVrComponent;
1333 rotationAnimation = orig.rotationAnimation;
1334 colorMode = orig.colorMode;
1335 mMaxAspectRatio = orig.mMaxAspectRatio;
1336 mMinAspectRatio = orig.mMinAspectRatio;
1337 supportsSizeChanges = orig.supportsSizeChanges;
1338 }
1339
1340 /**
1341 * Return the theme resource identifier to use for this activity. If
1342 * the activity defines a theme, that is used; else, the application
1343 * theme is used.
1344 *
1345 * @return The theme associated with this activity.
1346 */
1347 public final int getThemeResource() {
1348 return theme != 0 ? theme : applicationInfo.theme;
1349 }
1350
1351 private String persistableModeToString() {
1352 switch(persistableMode) {
1353 case PERSIST_ROOT_ONLY: return "PERSIST_ROOT_ONLY";
1354 case PERSIST_NEVER: return "PERSIST_NEVER";
1355 case PERSIST_ACROSS_REBOOTS: return "PERSIST_ACROSS_REBOOTS";
1356 default: return "UNKNOWN=" + persistableMode;
1357 }
1358 }
1359
1360 /**
1361 * Returns true if the activity has maximum or minimum aspect ratio.
1362 * @hide
1363 */
1364 public boolean hasFixedAspectRatio() {
1365 return getMaxAspectRatio() != 0 || getMinAspectRatio() != 0;
1366 }
1367
1368 /**
1369 * Returns true if the activity's orientation is fixed.
1370 * @hide
1371 */
1372 public boolean isFixedOrientation() {
1373 return isFixedOrientationLandscape() || isFixedOrientationPortrait()
1374 || screenOrientation == SCREEN_ORIENTATION_LOCKED;
1375 }
1376
1377 /**
1378 * Returns true if the activity's orientation is fixed to landscape.
1379 * @hide
1380 */
1381 boolean isFixedOrientationLandscape() {
1382 return isFixedOrientationLandscape(screenOrientation);
1383 }
1384
1385 /**
1386 * Returns true if the activity's orientation is fixed to landscape.
1387 * @hide
1388 */
1389 public static boolean isFixedOrientationLandscape(@ScreenOrientation int orientation) {
1390 return orientation == SCREEN_ORIENTATION_LANDSCAPE
1391 || orientation == SCREEN_ORIENTATION_SENSOR_LANDSCAPE
1392 || orientation == SCREEN_ORIENTATION_REVERSE_LANDSCAPE
1393 || orientation == SCREEN_ORIENTATION_USER_LANDSCAPE;
1394 }
1395
1396 /**
1397 * Returns true if the activity's orientation is fixed to portrait.
1398 * @hide
1399 */
1400 boolean isFixedOrientationPortrait() {
1401 return isFixedOrientationPortrait(screenOrientation);
1402 }
1403
1404 /**
1405 * Returns true if the activity's orientation is fixed to portrait.
1406 * @hide
1407 */
1408 public static boolean isFixedOrientationPortrait(@ScreenOrientation int orientation) {
1409 return orientation == SCREEN_ORIENTATION_PORTRAIT
1410 || orientation == SCREEN_ORIENTATION_SENSOR_PORTRAIT
1411 || orientation == SCREEN_ORIENTATION_REVERSE_PORTRAIT
1412 || orientation == SCREEN_ORIENTATION_USER_PORTRAIT;
1413 }
1414
1415 /**
1416 * Returns the reversed orientation.
1417 * @hide
1418 */
1419 @ActivityInfo.ScreenOrientation
1420 public static int reverseOrientation(@ActivityInfo.ScreenOrientation int orientation) {
1421 switch (orientation) {
1422 case SCREEN_ORIENTATION_LANDSCAPE:
1423 return SCREEN_ORIENTATION_PORTRAIT;
1424 case SCREEN_ORIENTATION_PORTRAIT:
1425 return SCREEN_ORIENTATION_LANDSCAPE;
1426 case SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
1427 return SCREEN_ORIENTATION_SENSOR_PORTRAIT;
1428 case SCREEN_ORIENTATION_SENSOR_PORTRAIT:
1429 return SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
1430 case SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
1431 return SCREEN_ORIENTATION_REVERSE_PORTRAIT;
1432 case SCREEN_ORIENTATION_REVERSE_PORTRAIT:
1433 return SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
1434 case SCREEN_ORIENTATION_USER_LANDSCAPE:
1435 return SCREEN_ORIENTATION_USER_PORTRAIT;
1436 case SCREEN_ORIENTATION_USER_PORTRAIT:
1437 return SCREEN_ORIENTATION_USER_LANDSCAPE;
1438 default:
1439 return orientation;
1440 }
1441 }
1442
1443 /**
1444 * Returns true if the activity supports picture-in-picture.
1445 * @hide
1446 */
1447 @UnsupportedAppUsage
1448 public boolean supportsPictureInPicture() {
1449 return (flags & FLAG_SUPPORTS_PICTURE_IN_PICTURE) != 0;
1450 }
1451
1452 /**
1453 * Returns whether the activity supports size changes.
1454 * @hide
1455 */
1456 @SizeChangesSupportMode
1457 public int supportsSizeChanges() {
1458 if (isChangeEnabled(FORCE_NON_RESIZE_APP)) {
1459 return SIZE_CHANGES_UNSUPPORTED_OVERRIDE;
1460 }
1461
1462 if (supportsSizeChanges) {
1463 return SIZE_CHANGES_SUPPORTED_METADATA;
1464 }
1465
1466 if (isChangeEnabled(FORCE_RESIZE_APP)) {
1467 return SIZE_CHANGES_SUPPORTED_OVERRIDE;
1468 }
1469
1470 return SIZE_CHANGES_UNSUPPORTED_METADATA;
1471 }
1472
1473 /**
1474 * Returns if the activity should never be sandboxed to the activity window bounds.
1475 * @hide
1476 */
1477 public boolean neverSandboxDisplayApis(ConstrainDisplayApisConfig constrainDisplayApisConfig) {
1478 return isChangeEnabled(NEVER_SANDBOX_DISPLAY_APIS)
1479 || constrainDisplayApisConfig.getNeverConstrainDisplayApis(applicationInfo);
1480 }
1481
1482 /**
1483 * Returns if the activity should always be sandboxed to the activity window bounds.
1484 * @hide
1485 */
1486 public boolean alwaysSandboxDisplayApis(ConstrainDisplayApisConfig constrainDisplayApisConfig) {
1487 return isChangeEnabled(ALWAYS_SANDBOX_DISPLAY_APIS)
1488 || constrainDisplayApisConfig.getAlwaysConstrainDisplayApis(applicationInfo);
1489 }
1490
1491 /** @hide */
1492 public void setMaxAspectRatio(@FloatRange(from = 0f) float maxAspectRatio) {
1493 this.mMaxAspectRatio = maxAspectRatio >= 0f ? maxAspectRatio : 0f;
1494 }
1495
1496 /** @hide */
1497 public float getMaxAspectRatio() {
1498 return mMaxAspectRatio;
1499 }
1500
1501 /** @hide */
1502 public void setMinAspectRatio(@FloatRange(from = 0f) float minAspectRatio) {
1503 this.mMinAspectRatio = minAspectRatio >= 0f ? minAspectRatio : 0f;
1504 }
1505
1506 /**
1507 * Returns the min aspect ratio of this activity as defined in the manifest file.
1508 * @hide
1509 */
1510 public float getMinAspectRatio() {
1511 return mMinAspectRatio;
1512 }
1513
1514 /**
1515 * Gets the trusted host certificate digests of apps that are allowed to embed this activity.
1516 * The digests are computed using the SHA-256 digest algorithm.
1517 * @see android.R.attr#knownActivityEmbeddingCerts
1518 */
1519 @NonNull
1520 public Set<String> getKnownActivityEmbeddingCerts() {
1521 return mKnownActivityEmbeddingCerts == null ? Collections.emptySet()
1522 : mKnownActivityEmbeddingCerts;
1523 }
1524
1525 /**
1526 * Sets the trusted host certificates of apps that are allowed to embed this activity.
1527 * @see #getKnownActivityEmbeddingCerts()
1528 * @hide
1529 */
1530 public void setKnownActivityEmbeddingCerts(@NonNull Set<String> knownActivityEmbeddingCerts) {
1531 // Convert the provided digest to upper case for consistent Set membership
1532 // checks when verifying the signing certificate digests of requesting apps.
1533 mKnownActivityEmbeddingCerts = new ArraySet<>();
1534 for (String knownCert : knownActivityEmbeddingCerts) {
1535 mKnownActivityEmbeddingCerts.add(knownCert.toUpperCase(Locale.US));
1536 }
1537 }
1538
1539 /**
1540 * Checks if a changeId is enabled for the current user
1541 * @param changeId The changeId to verify
1542 * @return True of the changeId is enabled
1543 * @hide
1544 */
1545 public boolean isChangeEnabled(long changeId) {
1546 return CompatChanges.isChangeEnabled(changeId, applicationInfo.packageName,
1547 UserHandle.getUserHandleForUid(applicationInfo.uid));
1548 }
1549
1550 /** @hide */
1551 public float getManifestMinAspectRatio() {
1552 return mMinAspectRatio;
1553 }
1554
1555 /** @hide */
1556 @UnsupportedAppUsage
1557 public static boolean isResizeableMode(int mode) {
1558 return mode == RESIZE_MODE_RESIZEABLE
1559 || mode == RESIZE_MODE_FORCE_RESIZEABLE
1560 || mode == RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY
1561 || mode == RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY
1562 || mode == RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION
1563 || mode == RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
1564 }
1565
1566 /** @hide */
1567 public static boolean isPreserveOrientationMode(int mode) {
1568 return mode == RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY
1569 || mode == RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY
1570 || mode == RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION;
1571 }
1572
1573 /** @hide */
1574 public static String resizeModeToString(int mode) {
1575 switch (mode) {
1576 case RESIZE_MODE_UNRESIZEABLE:
1577 return "RESIZE_MODE_UNRESIZEABLE";
1578 case RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION:
1579 return "RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION";
1580 case RESIZE_MODE_RESIZEABLE:
1581 return "RESIZE_MODE_RESIZEABLE";
1582 case RESIZE_MODE_FORCE_RESIZEABLE:
1583 return "RESIZE_MODE_FORCE_RESIZEABLE";
1584 case RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY:
1585 return "RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY";
1586 case RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY:
1587 return "RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY";
1588 case RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION:
1589 return "RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION";
1590 default:
1591 return "unknown=" + mode;
1592 }
1593 }
1594
1595 /** @hide */
1596 public static String sizeChangesSupportModeToString(@SizeChangesSupportMode int mode) {
1597 switch (mode) {
1598 case SIZE_CHANGES_UNSUPPORTED_METADATA:
1599 return "SIZE_CHANGES_UNSUPPORTED_METADATA";
1600 case SIZE_CHANGES_UNSUPPORTED_OVERRIDE:
1601 return "SIZE_CHANGES_UNSUPPORTED_OVERRIDE";
1602 case SIZE_CHANGES_SUPPORTED_METADATA:
1603 return "SIZE_CHANGES_SUPPORTED_METADATA";
1604 case SIZE_CHANGES_SUPPORTED_OVERRIDE:
1605 return "SIZE_CHANGES_SUPPORTED_OVERRIDE";
1606 default:
1607 return "unknown=" + mode;
1608 }
1609 }
1610
1611 /**
1612 * Whether we should compare activity window layout min width/height with require space for
1613 * multi window to determine if it can be put into multi window mode.
1614 * @hide
1615 */
1616 public boolean shouldCheckMinWidthHeightForMultiWindow() {
1617 return isChangeEnabled(CHECK_MIN_WIDTH_HEIGHT_FOR_MULTI_WINDOW);
1618 }
1619
1620 public void dump(Printer pw, String prefix) {
1621 dump(pw, prefix, DUMP_FLAG_ALL);
1622 }
1623
1624 /** @hide */
1625 public void dump(Printer pw, String prefix, int dumpFlags) {
1626 super.dumpFront(pw, prefix);
1627 if (permission != null) {
1628 pw.println(prefix + "permission=" + permission);
1629 }
1630 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1631 pw.println(prefix + "taskAffinity=" + taskAffinity
1632 + " targetActivity=" + targetActivity
1633 + " persistableMode=" + persistableModeToString());
1634 }
1635 if (launchMode != 0 || flags != 0 || privateFlags != 0 || theme != 0) {
1636 pw.println(prefix + "launchMode=" + launchModeToString(launchMode)
1637 + " flags=0x" + Integer.toHexString(flags)
1638 + " privateFlags=0x" + Integer.toHexString(privateFlags)
1639 + " theme=0x" + Integer.toHexString(theme));
1640 }
1641 if (screenOrientation != SCREEN_ORIENTATION_UNSPECIFIED
1642 || configChanges != 0 || softInputMode != 0) {
1643 pw.println(prefix + "screenOrientation=" + screenOrientation
1644 + " configChanges=0x" + Integer.toHexString(configChanges)
1645 + " softInputMode=0x" + Integer.toHexString(softInputMode));
1646 }
1647 if (uiOptions != 0) {
1648 pw.println(prefix + " uiOptions=0x" + Integer.toHexString(uiOptions));
1649 }
1650 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1651 pw.println(prefix + "lockTaskLaunchMode="
1652 + lockTaskLaunchModeToString(lockTaskLaunchMode));
1653 }
1654 if (windowLayout != null) {
1655 pw.println(prefix + "windowLayout=" + windowLayout.width + "|"
1656 + windowLayout.widthFraction + ", " + windowLayout.height + "|"
1657 + windowLayout.heightFraction + ", " + windowLayout.gravity);
1658 }
1659 pw.println(prefix + "resizeMode=" + resizeModeToString(resizeMode));
1660 if (requestedVrComponent != null) {
1661 pw.println(prefix + "requestedVrComponent=" + requestedVrComponent);
1662 }
1663 if (getMaxAspectRatio() != 0) {
1664 pw.println(prefix + "maxAspectRatio=" + getMaxAspectRatio());
1665 }
1666 final float minAspectRatio = getMinAspectRatio();
1667 if (minAspectRatio != 0) {
1668 pw.println(prefix + "minAspectRatio=" + minAspectRatio);
1669 }
1670 if (supportsSizeChanges) {
1671 pw.println(prefix + "supportsSizeChanges=true");
1672 }
1673 if (mKnownActivityEmbeddingCerts != null) {
1674 pw.println(prefix + "knownActivityEmbeddingCerts=" + mKnownActivityEmbeddingCerts);
1675 }
1676 super.dumpBack(pw, prefix, dumpFlags);
1677 }
1678
1679 public String toString() {
1680 return "ActivityInfo{"
1681 + Integer.toHexString(System.identityHashCode(this))
1682 + " " + name + "}";
1683 }
1684
1685 public int describeContents() {
1686 return 0;
1687 }
1688
1689 public void writeToParcel(Parcel dest, int parcelableFlags) {
1690 super.writeToParcel(dest, parcelableFlags);
1691 dest.writeInt(theme);
1692 dest.writeInt(launchMode);
1693 dest.writeInt(documentLaunchMode);
1694 dest.writeString8(permission);
1695 dest.writeString8(taskAffinity);
1696 dest.writeString8(targetActivity);
1697 dest.writeString8(launchToken);
1698 dest.writeInt(flags);
1699 dest.writeInt(privateFlags);
1700 dest.writeInt(screenOrientation);
1701 dest.writeInt(configChanges);
1702 dest.writeInt(softInputMode);
1703 dest.writeInt(uiOptions);
1704 dest.writeString8(parentActivityName);
1705 dest.writeInt(persistableMode);
1706 dest.writeInt(maxRecents);
1707 dest.writeInt(lockTaskLaunchMode);
1708 if (windowLayout != null) {
1709 dest.writeInt(1);
1710 windowLayout.writeToParcel(dest);
1711 } else {
1712 dest.writeInt(0);
1713 }
1714 dest.writeInt(resizeMode);
1715 dest.writeString8(requestedVrComponent);
1716 dest.writeInt(rotationAnimation);
1717 dest.writeInt(colorMode);
1718 dest.writeFloat(mMaxAspectRatio);
1719 dest.writeFloat(mMinAspectRatio);
1720 dest.writeBoolean(supportsSizeChanges);
1721 sForStringSet.parcel(mKnownActivityEmbeddingCerts, dest, flags);
1722 }
1723
1724 /**
1725 * Determines whether the {@link Activity} is considered translucent or floating.
1726 * @hide
1727 */
1728 @UnsupportedAppUsage
1729 @TestApi
1730 public static boolean isTranslucentOrFloating(TypedArray attributes) {
1731 final boolean isTranslucent =
1732 attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsTranslucent,
1733 false);
1734 final boolean isFloating =
1735 attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsFloating,
1736 false);
1737
1738 return isFloating || isTranslucent;
1739 }
1740
1741 /**
1742 * Convert the screen orientation constant to a human readable format.
1743 * @hide
1744 */
1745 public static String screenOrientationToString(int orientation) {
1746 switch (orientation) {
1747 case SCREEN_ORIENTATION_UNSET:
1748 return "SCREEN_ORIENTATION_UNSET";
1749 case SCREEN_ORIENTATION_UNSPECIFIED:
1750 return "SCREEN_ORIENTATION_UNSPECIFIED";
1751 case SCREEN_ORIENTATION_LANDSCAPE:
1752 return "SCREEN_ORIENTATION_LANDSCAPE";
1753 case SCREEN_ORIENTATION_PORTRAIT:
1754 return "SCREEN_ORIENTATION_PORTRAIT";
1755 case SCREEN_ORIENTATION_USER:
1756 return "SCREEN_ORIENTATION_USER";
1757 case SCREEN_ORIENTATION_BEHIND:
1758 return "SCREEN_ORIENTATION_BEHIND";
1759 case SCREEN_ORIENTATION_SENSOR:
1760 return "SCREEN_ORIENTATION_SENSOR";
1761 case SCREEN_ORIENTATION_NOSENSOR:
1762 return "SCREEN_ORIENTATION_NOSENSOR";
1763 case SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
1764 return "SCREEN_ORIENTATION_SENSOR_LANDSCAPE";
1765 case SCREEN_ORIENTATION_SENSOR_PORTRAIT:
1766 return "SCREEN_ORIENTATION_SENSOR_PORTRAIT";
1767 case SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
1768 return "SCREEN_ORIENTATION_REVERSE_LANDSCAPE";
1769 case SCREEN_ORIENTATION_REVERSE_PORTRAIT:
1770 return "SCREEN_ORIENTATION_REVERSE_PORTRAIT";
1771 case SCREEN_ORIENTATION_FULL_SENSOR:
1772 return "SCREEN_ORIENTATION_FULL_SENSOR";
1773 case SCREEN_ORIENTATION_USER_LANDSCAPE:
1774 return "SCREEN_ORIENTATION_USER_LANDSCAPE";
1775 case SCREEN_ORIENTATION_USER_PORTRAIT:
1776 return "SCREEN_ORIENTATION_USER_PORTRAIT";
1777 case SCREEN_ORIENTATION_FULL_USER:
1778 return "SCREEN_ORIENTATION_FULL_USER";
1779 case SCREEN_ORIENTATION_LOCKED:
1780 return "SCREEN_ORIENTATION_LOCKED";
1781 default:
1782 return Integer.toString(orientation);
1783 }
1784 }
1785
1786 /**
1787 * @hide
1788 */
1789 public static String colorModeToString(@ColorMode int colorMode) {
1790 switch (colorMode) {
1791 case COLOR_MODE_DEFAULT:
1792 return "COLOR_MODE_DEFAULT";
1793 case COLOR_MODE_WIDE_COLOR_GAMUT:
1794 return "COLOR_MODE_WIDE_COLOR_GAMUT";
1795 case COLOR_MODE_HDR:
1796 return "COLOR_MODE_HDR";
1797 case COLOR_MODE_A8:
1798 return "COLOR_MODE_A8";
1799 default:
1800 return Integer.toString(colorMode);
1801 }
1802 }
1803
1804 public static final @android.annotation.NonNull Parcelable.Creator<ActivityInfo> CREATOR
1805 = new Parcelable.Creator<ActivityInfo>() {
1806 public ActivityInfo createFromParcel(Parcel source) {
1807 return new ActivityInfo(source);
1808 }
1809 public ActivityInfo[] newArray(int size) {
1810 return new ActivityInfo[size];
1811 }
1812 };
1813
1814 private ActivityInfo(Parcel source) {
1815 super(source);
1816 theme = source.readInt();
1817 launchMode = source.readInt();
1818 documentLaunchMode = source.readInt();
1819 permission = source.readString8();
1820 taskAffinity = source.readString8();
1821 targetActivity = source.readString8();
1822 launchToken = source.readString8();
1823 flags = source.readInt();
1824 privateFlags = source.readInt();
1825 screenOrientation = source.readInt();
1826 configChanges = source.readInt();
1827 softInputMode = source.readInt();
1828 uiOptions = source.readInt();
1829 parentActivityName = source.readString8();
1830 persistableMode = source.readInt();
1831 maxRecents = source.readInt();
1832 lockTaskLaunchMode = source.readInt();
1833 if (source.readInt() == 1) {
1834 windowLayout = new WindowLayout(source);
1835 }
1836 resizeMode = source.readInt();
1837 requestedVrComponent = source.readString8();
1838 rotationAnimation = source.readInt();
1839 colorMode = source.readInt();
1840 mMaxAspectRatio = source.readFloat();
1841 mMinAspectRatio = source.readFloat();
1842 supportsSizeChanges = source.readBoolean();
1843 mKnownActivityEmbeddingCerts = sForStringSet.unparcel(source);
1844 if (mKnownActivityEmbeddingCerts.isEmpty()) {
1845 mKnownActivityEmbeddingCerts = null;
1846 }
1847 }
1848
1849 /**
1850 * Contains information about position and size of the activity on the display.
1851 *
1852 * Used in freeform mode to set desired position when activity is first launched.
1853 * It describes how big the activity wants to be in both width and height,
1854 * the minimal allowed size, and the gravity to be applied.
1855 *
1856 * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth
1857 * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight
1858 * @attr ref android.R.styleable#AndroidManifestLayout_gravity
1859 * @attr ref android.R.styleable#AndroidManifestLayout_minWidth
1860 * @attr ref android.R.styleable#AndroidManifestLayout_minHeight
1861 */
1862 public static final class WindowLayout {
1863 public WindowLayout(int width, float widthFraction, int height, float heightFraction,
1864 int gravity, int minWidth, int minHeight) {
1865 this(width, widthFraction, height, heightFraction, gravity, minWidth, minHeight,
1866 null /* windowLayoutAffinity */);
1867 }
1868
1869 /** @hide */
1870 public WindowLayout(int width, float widthFraction, int height, float heightFraction,
1871 int gravity, int minWidth, int minHeight, String windowLayoutAffinity) {
1872 this.width = width;
1873 this.widthFraction = widthFraction;
1874 this.height = height;
1875 this.heightFraction = heightFraction;
1876 this.gravity = gravity;
1877 this.minWidth = minWidth;
1878 this.minHeight = minHeight;
1879 this.windowLayoutAffinity = windowLayoutAffinity;
1880 }
1881
1882 /** @hide */
1883 public WindowLayout(Parcel source) {
1884 width = source.readInt();
1885 widthFraction = source.readFloat();
1886 height = source.readInt();
1887 heightFraction = source.readFloat();
1888 gravity = source.readInt();
1889 minWidth = source.readInt();
1890 minHeight = source.readInt();
1891 windowLayoutAffinity = source.readString8();
1892 }
1893
1894 /**
1895 * Width of activity in pixels.
1896 *
1897 * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth
1898 */
1899 public final int width;
1900
1901 /**
1902 * Width of activity as a fraction of available display width.
1903 * If both {@link #width} and this value are set this one will be preferred.
1904 *
1905 * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth
1906 */
1907 public final float widthFraction;
1908
1909 /**
1910 * Height of activity in pixels.
1911 *
1912 * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight
1913 */
1914 public final int height;
1915
1916 /**
1917 * Height of activity as a fraction of available display height.
1918 * If both {@link #height} and this value are set this one will be preferred.
1919 *
1920 * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight
1921 */
1922 public final float heightFraction;
1923
1924 /**
1925 * Gravity of activity.
1926 * Currently {@link android.view.Gravity#TOP}, {@link android.view.Gravity#BOTTOM},
1927 * {@link android.view.Gravity#LEFT} and {@link android.view.Gravity#RIGHT} are supported.
1928 *
1929 * @attr ref android.R.styleable#AndroidManifestLayout_gravity
1930 */
1931 public final int gravity;
1932
1933 /**
1934 * Minimal width of activity in pixels to be able to display its content.
1935 *
1936 * <p><strong>NOTE:</strong> A task's root activity value is applied to all additional
1937 * activities launched in the task. That is if the root activity of a task set minimal
1938 * width, then the system will set the same minimal width on all other activities in the
1939 * task. It will also ignore any other minimal width attributes of non-root activities.
1940 *
1941 * @attr ref android.R.styleable#AndroidManifestLayout_minWidth
1942 */
1943 public final int minWidth;
1944
1945 /**
1946 * Minimal height of activity in pixels to be able to display its content.
1947 *
1948 * <p><strong>NOTE:</strong> A task's root activity value is applied to all additional
1949 * activities launched in the task. That is if the root activity of a task set minimal
1950 * height, then the system will set the same minimal height on all other activities in the
1951 * task. It will also ignore any other minimal height attributes of non-root activities.
1952 *
1953 * @attr ref android.R.styleable#AndroidManifestLayout_minHeight
1954 */
1955 public final int minHeight;
1956
1957 /**
1958 * Affinity of window layout parameters. Activities with the same UID and window layout
1959 * affinity will share the same window dimension record.
1960 *
1961 * @attr ref android.R.styleable#AndroidManifestLayout_windowLayoutAffinity
1962 * @hide
1963 */
1964 public String windowLayoutAffinity;
1965
1966 /**
1967 * Returns if this {@link WindowLayout} has specified bounds.
1968 * @hide
1969 */
1970 public boolean hasSpecifiedSize() {
1971 return width >= 0 || height >= 0 || widthFraction >= 0 || heightFraction >= 0;
1972 }
1973
1974 /** @hide */
1975 public void writeToParcel(Parcel dest) {
1976 dest.writeInt(width);
1977 dest.writeFloat(widthFraction);
1978 dest.writeInt(height);
1979 dest.writeFloat(heightFraction);
1980 dest.writeInt(gravity);
1981 dest.writeInt(minWidth);
1982 dest.writeInt(minHeight);
1983 dest.writeString8(windowLayoutAffinity);
1984 }
1985 }
1986 }