Kenny Root | 15a4d2f | 2010-03-11 18:20:12 -0800 | [diff] [blame] | 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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | package android.content.pm; |
| 18 | |
Dianne Hackborn | 1d0b177 | 2013-09-06 14:02:54 -0700 | [diff] [blame] | 19 | import android.content.res.Configuration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | import android.util.Printer; |
| 23 | |
| 24 | /** |
| 25 | * Information you can retrieve about a particular application |
| 26 | * activity or receiver. This corresponds to information collected |
| 27 | * from the AndroidManifest.xml's <activity> and |
| 28 | * <receiver> tags. |
| 29 | */ |
| 30 | public class ActivityInfo extends ComponentInfo |
| 31 | implements Parcelable { |
| 32 | /** |
| 33 | * A style resource identifier (in the package's resources) of this |
| 34 | * activity's theme. From the "theme" attribute or, if not set, 0. |
| 35 | */ |
| 36 | public int theme; |
| 37 | |
| 38 | /** |
| 39 | * Constant corresponding to <code>standard</code> in |
| 40 | * the {@link android.R.attr#launchMode} attribute. |
| 41 | */ |
| 42 | public static final int LAUNCH_MULTIPLE = 0; |
| 43 | /** |
| 44 | * Constant corresponding to <code>singleTop</code> in |
| 45 | * the {@link android.R.attr#launchMode} attribute. |
| 46 | */ |
| 47 | public static final int LAUNCH_SINGLE_TOP = 1; |
| 48 | /** |
| 49 | * Constant corresponding to <code>singleTask</code> in |
| 50 | * the {@link android.R.attr#launchMode} attribute. |
| 51 | */ |
| 52 | public static final int LAUNCH_SINGLE_TASK = 2; |
| 53 | /** |
| 54 | * Constant corresponding to <code>singleInstance</code> in |
| 55 | * the {@link android.R.attr#launchMode} attribute. |
| 56 | */ |
| 57 | public static final int LAUNCH_SINGLE_INSTANCE = 3; |
| 58 | /** |
| 59 | * The launch mode style requested by the activity. From the |
| 60 | * {@link android.R.attr#launchMode} attribute, one of |
| 61 | * {@link #LAUNCH_MULTIPLE}, |
| 62 | * {@link #LAUNCH_SINGLE_TOP}, {@link #LAUNCH_SINGLE_TASK}, or |
| 63 | * {@link #LAUNCH_SINGLE_INSTANCE}. |
| 64 | */ |
| 65 | public int launchMode; |
| 66 | |
| 67 | /** |
| 68 | * Optional name of a permission required to be able to access this |
| 69 | * Activity. From the "permission" attribute. |
| 70 | */ |
| 71 | public String permission; |
| 72 | |
| 73 | /** |
| 74 | * The affinity this activity has for another task in the system. The |
| 75 | * string here is the name of the task, often the package name of the |
| 76 | * overall package. If null, the activity has no affinity. Set from the |
| 77 | * {@link android.R.attr#taskAffinity} attribute. |
| 78 | */ |
| 79 | public String taskAffinity; |
| 80 | |
| 81 | /** |
| 82 | * If this is an activity alias, this is the real activity class to run |
| 83 | * for it. Otherwise, this is null. |
| 84 | */ |
| 85 | public String targetActivity; |
| 86 | |
| 87 | /** |
| 88 | * Bit in {@link #flags} indicating whether this activity is able to |
| 89 | * run in multiple processes. If |
| 90 | * true, the system may instantiate it in the some process as the |
| 91 | * process starting it in order to conserve resources. If false, the |
| 92 | * default, it always runs in {@link #processName}. Set from the |
| 93 | * {@link android.R.attr#multiprocess} attribute. |
| 94 | */ |
| 95 | public static final int FLAG_MULTIPROCESS = 0x0001; |
| 96 | /** |
| 97 | * Bit in {@link #flags} indicating that, when the activity's task is |
| 98 | * relaunched from home, this activity should be finished. |
| 99 | * Set from the |
| 100 | * {@link android.R.attr#finishOnTaskLaunch} attribute. |
| 101 | */ |
| 102 | public static final int FLAG_FINISH_ON_TASK_LAUNCH = 0x0002; |
| 103 | /** |
| 104 | * Bit in {@link #flags} indicating that, when the activity is the root |
| 105 | * of a task, that task's stack should be cleared each time the user |
| 106 | * re-launches it from home. As a result, the user will always |
| 107 | * return to the original activity at the top of the task. |
| 108 | * This flag only applies to activities that |
| 109 | * are used to start the root of a new task. Set from the |
| 110 | * {@link android.R.attr#clearTaskOnLaunch} attribute. |
| 111 | */ |
| 112 | public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 0x0004; |
| 113 | /** |
| 114 | * Bit in {@link #flags} indicating that, when the activity is the root |
| 115 | * of a task, that task's stack should never be cleared when it is |
| 116 | * relaunched from home. Set from the |
| 117 | * {@link android.R.attr#alwaysRetainTaskState} attribute. |
| 118 | */ |
| 119 | public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 0x0008; |
| 120 | /** |
| 121 | * Bit in {@link #flags} indicating that the activity's state |
| 122 | * is not required to be saved, so that if there is a failure the |
| 123 | * activity will not be removed from the activity stack. Set from the |
| 124 | * {@link android.R.attr#stateNotNeeded} attribute. |
| 125 | */ |
| 126 | public static final int FLAG_STATE_NOT_NEEDED = 0x0010; |
| 127 | /** |
| 128 | * Bit in {@link #flags} that indicates that the activity should not |
| 129 | * appear in the list of recently launched activities. Set from the |
| 130 | * {@link android.R.attr#excludeFromRecents} attribute. |
| 131 | */ |
| 132 | public static final int FLAG_EXCLUDE_FROM_RECENTS = 0x0020; |
| 133 | /** |
| 134 | * Bit in {@link #flags} that indicates that the activity can be moved |
| 135 | * between tasks based on its task affinity. Set from the |
| 136 | * {@link android.R.attr#allowTaskReparenting} attribute. |
| 137 | */ |
| 138 | public static final int FLAG_ALLOW_TASK_REPARENTING = 0x0040; |
| 139 | /** |
| 140 | * Bit in {@link #flags} indicating that, when the user navigates away |
| 141 | * from an activity, it should be finished. |
| 142 | * Set from the |
| 143 | * {@link android.R.attr#noHistory} attribute. |
| 144 | */ |
| 145 | public static final int FLAG_NO_HISTORY = 0x0080; |
| 146 | /** |
Dianne Hackborn | ffa4248 | 2009-09-23 22:20:11 -0700 | [diff] [blame] | 147 | * Bit in {@link #flags} indicating that, when a request to close system |
| 148 | * windows happens, this activity is finished. |
| 149 | * Set from the |
| 150 | * {@link android.R.attr#finishOnCloseSystemDialogs} attribute. |
| 151 | */ |
| 152 | public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 0x0100; |
Dianne Hackborn | 327fbd2 | 2011-01-17 14:38:50 -0800 | [diff] [blame] | 153 | /** |
| 154 | * Value for {@link #flags}: true when the application's rendering should |
| 155 | * be hardware accelerated. |
| 156 | */ |
| 157 | public static final int FLAG_HARDWARE_ACCELERATED = 0x0200; |
| 158 | /** |
Craig Mautner | 5962b12 | 2012-10-05 14:45:52 -0700 | [diff] [blame] | 159 | * Value for {@link #flags}: true when the application can be displayed over the lockscreen |
| 160 | * and consequently over all users' windows. |
| 161 | * @hide |
| 162 | */ |
| 163 | public static final int FLAG_SHOW_ON_LOCK_SCREEN = 0x0400; |
| 164 | /** |
John Spurlock | 322d771 | 2013-09-05 02:39:46 +0000 | [diff] [blame] | 165 | * Bit in {@link #flags} corresponding to an immersive activity |
Daniel Sandler | 613dde4 | 2010-06-21 13:46:39 -0400 | [diff] [blame] | 166 | * that wishes not to be interrupted by notifications. |
| 167 | * Applications that hide the system notification bar with |
| 168 | * {@link android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN} |
| 169 | * may still be interrupted by high-priority notifications; for example, an |
| 170 | * incoming phone call may use |
Daniel Sandler | 8091ca5 | 2010-06-22 13:58:46 -0400 | [diff] [blame] | 171 | * {@link android.app.Notification#fullScreenIntent fullScreenIntent} |
Daniel Sandler | 613dde4 | 2010-06-21 13:46:39 -0400 | [diff] [blame] | 172 | * to present a full-screen in-call activity to the user, pausing the |
| 173 | * current activity as a side-effect. An activity with |
| 174 | * {@link #FLAG_IMMERSIVE} set, however, will not be interrupted; the |
| 175 | * notification may be shown in some other way (such as a small floating |
| 176 | * "toast" window). |
Christopher Tate | 73c2aee | 2012-03-15 16:27:14 -0700 | [diff] [blame] | 177 | * |
| 178 | * Note that this flag will always reflect the Activity's |
| 179 | * <code>android:immersive</code> manifest definition, even if the Activity's |
| 180 | * immersive state is changed at runtime via |
| 181 | * {@link android.app.Activity#setImmersive(boolean)}. |
| 182 | * |
| 183 | * @see android.app.Notification#FLAG_HIGH_PRIORITY |
| 184 | * @see android.app.Activity#setImmersive(boolean) |
Daniel Sandler | 613dde4 | 2010-06-21 13:46:39 -0400 | [diff] [blame] | 185 | */ |
Craig Mautner | 5962b12 | 2012-10-05 14:45:52 -0700 | [diff] [blame] | 186 | public static final int FLAG_IMMERSIVE = 0x0800; |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 187 | /** |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 188 | * @hide Bit in {@link #flags}: If set, this component will only be seen |
| 189 | * by the primary user. Only works with broadcast receivers. Set from the |
| 190 | * {@link android.R.attr#primaryUserOnly} attribute. |
| 191 | */ |
| 192 | public static final int FLAG_PRIMARY_USER_ONLY = 0x20000000; |
| 193 | /** |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 194 | * Bit in {@link #flags}: If set, a single instance of the receiver will |
| 195 | * run for all users on the device. Set from the |
| 196 | * {@link android.R.attr#singleUser} attribute. Note that this flag is |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 197 | * only relevant for ActivityInfo structures that are describing receiver |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 198 | * components; it is not applied to activities. |
| 199 | */ |
| 200 | public static final int FLAG_SINGLE_USER = 0x40000000; |
| 201 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 202 | * Options that have been set in the activity declaration in the |
Daniel Sandler | 613dde4 | 2010-06-21 13:46:39 -0400 | [diff] [blame] | 203 | * manifest. |
| 204 | * These include: |
| 205 | * {@link #FLAG_MULTIPROCESS}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 206 | * {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH}, |
| 207 | * {@link #FLAG_ALWAYS_RETAIN_TASK_STATE}, |
| 208 | * {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS}, |
Dianne Hackborn | ffa4248 | 2009-09-23 22:20:11 -0700 | [diff] [blame] | 209 | * {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY}, |
Daniel Sandler | 613dde4 | 2010-06-21 13:46:39 -0400 | [diff] [blame] | 210 | * {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS}, |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 211 | * {@link #FLAG_HARDWARE_ACCELERATED}, {@link #FLAG_SINGLE_USER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 212 | */ |
| 213 | public int flags; |
| 214 | |
| 215 | /** |
| 216 | * Constant corresponding to <code>unspecified</code> in |
| 217 | * the {@link android.R.attr#screenOrientation} attribute. |
| 218 | */ |
| 219 | public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1; |
| 220 | /** |
| 221 | * Constant corresponding to <code>landscape</code> in |
| 222 | * the {@link android.R.attr#screenOrientation} attribute. |
| 223 | */ |
| 224 | public static final int SCREEN_ORIENTATION_LANDSCAPE = 0; |
| 225 | /** |
| 226 | * Constant corresponding to <code>portrait</code> in |
| 227 | * the {@link android.R.attr#screenOrientation} attribute. |
| 228 | */ |
| 229 | public static final int SCREEN_ORIENTATION_PORTRAIT = 1; |
| 230 | /** |
| 231 | * Constant corresponding to <code>user</code> in |
| 232 | * the {@link android.R.attr#screenOrientation} attribute. |
| 233 | */ |
| 234 | public static final int SCREEN_ORIENTATION_USER = 2; |
| 235 | /** |
| 236 | * Constant corresponding to <code>behind</code> in |
| 237 | * the {@link android.R.attr#screenOrientation} attribute. |
| 238 | */ |
| 239 | public static final int SCREEN_ORIENTATION_BEHIND = 3; |
| 240 | /** |
| 241 | * Constant corresponding to <code>sensor</code> in |
| 242 | * the {@link android.R.attr#screenOrientation} attribute. |
| 243 | */ |
| 244 | public static final int SCREEN_ORIENTATION_SENSOR = 4; |
| 245 | |
| 246 | /** |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 247 | * Constant corresponding to <code>nosensor</code> in |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 248 | * the {@link android.R.attr#screenOrientation} attribute. |
| 249 | */ |
| 250 | public static final int SCREEN_ORIENTATION_NOSENSOR = 5; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 251 | |
| 252 | /** |
| 253 | * Constant corresponding to <code>sensorLandscape</code> in |
| 254 | * the {@link android.R.attr#screenOrientation} attribute. |
| 255 | */ |
| 256 | public static final int SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 6; |
| 257 | |
| 258 | /** |
| 259 | * Constant corresponding to <code>sensorPortrait</code> in |
| 260 | * the {@link android.R.attr#screenOrientation} attribute. |
| 261 | */ |
| 262 | public static final int SCREEN_ORIENTATION_SENSOR_PORTRAIT = 7; |
| 263 | |
| 264 | /** |
| 265 | * Constant corresponding to <code>reverseLandscape</code> in |
| 266 | * the {@link android.R.attr#screenOrientation} attribute. |
| 267 | */ |
| 268 | public static final int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8; |
| 269 | |
| 270 | /** |
| 271 | * Constant corresponding to <code>reversePortrait</code> in |
| 272 | * the {@link android.R.attr#screenOrientation} attribute. |
| 273 | */ |
| 274 | public static final int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9; |
| 275 | |
| 276 | /** |
| 277 | * Constant corresponding to <code>fullSensor</code> in |
| 278 | * the {@link android.R.attr#screenOrientation} attribute. |
| 279 | */ |
| 280 | public static final int SCREEN_ORIENTATION_FULL_SENSOR = 10; |
| 281 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 282 | /** |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 283 | * Constant corresponding to <code>userLandscape</code> in |
| 284 | * the {@link android.R.attr#screenOrientation} attribute. |
| 285 | */ |
| 286 | public static final int SCREEN_ORIENTATION_USER_LANDSCAPE = 11; |
| 287 | |
| 288 | /** |
| 289 | * Constant corresponding to <code>userPortrait</code> in |
| 290 | * the {@link android.R.attr#screenOrientation} attribute. |
| 291 | */ |
| 292 | public static final int SCREEN_ORIENTATION_USER_PORTRAIT = 12; |
| 293 | |
| 294 | /** |
| 295 | * Constant corresponding to <code>fullUser</code> in |
| 296 | * the {@link android.R.attr#screenOrientation} attribute. |
| 297 | */ |
| 298 | public static final int SCREEN_ORIENTATION_FULL_USER = 13; |
| 299 | |
| 300 | /** |
| 301 | * Constant corresponding to <code>locked</code> in |
| 302 | * the {@link android.R.attr#screenOrientation} attribute. |
| 303 | */ |
| 304 | public static final int SCREEN_ORIENTATION_LOCKED = 14; |
| 305 | |
| 306 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 307 | * The preferred screen orientation this activity would like to run in. |
| 308 | * From the {@link android.R.attr#screenOrientation} attribute, one of |
| 309 | * {@link #SCREEN_ORIENTATION_UNSPECIFIED}, |
| 310 | * {@link #SCREEN_ORIENTATION_LANDSCAPE}, |
| 311 | * {@link #SCREEN_ORIENTATION_PORTRAIT}, |
| 312 | * {@link #SCREEN_ORIENTATION_USER}, |
| 313 | * {@link #SCREEN_ORIENTATION_BEHIND}, |
| 314 | * {@link #SCREEN_ORIENTATION_SENSOR}, |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 315 | * {@link #SCREEN_ORIENTATION_NOSENSOR}, |
| 316 | * {@link #SCREEN_ORIENTATION_SENSOR_LANDSCAPE}, |
| 317 | * {@link #SCREEN_ORIENTATION_SENSOR_PORTRAIT}, |
| 318 | * {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE}, |
| 319 | * {@link #SCREEN_ORIENTATION_REVERSE_PORTRAIT}, |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 320 | * {@link #SCREEN_ORIENTATION_FULL_SENSOR}, |
| 321 | * {@link #SCREEN_ORIENTATION_USER_LANDSCAPE}, |
| 322 | * {@link #SCREEN_ORIENTATION_USER_PORTRAIT}, |
| 323 | * {@link #SCREEN_ORIENTATION_FULL_USER}, |
| 324 | * {@link #SCREEN_ORIENTATION_LOCKED}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 325 | */ |
| 326 | public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; |
| 327 | |
| 328 | /** |
| 329 | * Bit in {@link #configChanges} that indicates that the activity |
| 330 | * can itself handle changes to the IMSI MCC. Set from the |
| 331 | * {@link android.R.attr#configChanges} attribute. |
| 332 | */ |
| 333 | public static final int CONFIG_MCC = 0x0001; |
| 334 | /** |
| 335 | * Bit in {@link #configChanges} that indicates that the activity |
| 336 | * can itself handle changes to the IMSI MNC. Set from the |
| 337 | * {@link android.R.attr#configChanges} attribute. |
| 338 | */ |
| 339 | public static final int CONFIG_MNC = 0x0002; |
| 340 | /** |
| 341 | * Bit in {@link #configChanges} that indicates that the activity |
| 342 | * can itself handle changes to the locale. Set from the |
| 343 | * {@link android.R.attr#configChanges} attribute. |
| 344 | */ |
| 345 | public static final int CONFIG_LOCALE = 0x0004; |
| 346 | /** |
| 347 | * Bit in {@link #configChanges} that indicates that the activity |
| 348 | * can itself handle changes to the touchscreen type. Set from the |
| 349 | * {@link android.R.attr#configChanges} attribute. |
| 350 | */ |
| 351 | public static final int CONFIG_TOUCHSCREEN = 0x0008; |
| 352 | /** |
| 353 | * Bit in {@link #configChanges} that indicates that the activity |
| 354 | * can itself handle changes to the keyboard type. Set from the |
| 355 | * {@link android.R.attr#configChanges} attribute. |
| 356 | */ |
| 357 | public static final int CONFIG_KEYBOARD = 0x0010; |
| 358 | /** |
| 359 | * Bit in {@link #configChanges} that indicates that the activity |
Dianne Hackborn | 93e462b | 2009-09-15 22:50:40 -0700 | [diff] [blame] | 360 | * can itself handle changes to the keyboard or navigation being hidden/exposed. |
| 361 | * Note that inspite of the name, this applies to the changes to any |
| 362 | * hidden states: keyboard or navigation. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 363 | * Set from the {@link android.R.attr#configChanges} attribute. |
| 364 | */ |
| 365 | public static final int CONFIG_KEYBOARD_HIDDEN = 0x0020; |
| 366 | /** |
| 367 | * Bit in {@link #configChanges} that indicates that the activity |
| 368 | * can itself handle changes to the navigation type. Set from the |
| 369 | * {@link android.R.attr#configChanges} attribute. |
| 370 | */ |
| 371 | public static final int CONFIG_NAVIGATION = 0x0040; |
| 372 | /** |
| 373 | * Bit in {@link #configChanges} that indicates that the activity |
| 374 | * can itself handle changes to the screen orientation. Set from the |
| 375 | * {@link android.R.attr#configChanges} attribute. |
| 376 | */ |
| 377 | public static final int CONFIG_ORIENTATION = 0x0080; |
| 378 | /** |
| 379 | * Bit in {@link #configChanges} that indicates that the activity |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 380 | * can itself handle changes to the screen layout. Set from the |
| 381 | * {@link android.R.attr#configChanges} attribute. |
| 382 | */ |
| 383 | public static final int CONFIG_SCREEN_LAYOUT = 0x0100; |
| 384 | /** |
| 385 | * Bit in {@link #configChanges} that indicates that the activity |
Tobias Haamel | 27b28b3 | 2010-02-09 23:09:17 +0100 | [diff] [blame] | 386 | * can itself handle the ui mode. Set from the |
| 387 | * {@link android.R.attr#configChanges} attribute. |
Tobias Haamel | 27b28b3 | 2010-02-09 23:09:17 +0100 | [diff] [blame] | 388 | */ |
| 389 | public static final int CONFIG_UI_MODE = 0x0200; |
| 390 | /** |
| 391 | * Bit in {@link #configChanges} that indicates that the activity |
Dianne Hackborn | ebff8f9 | 2011-05-12 18:07:47 -0700 | [diff] [blame] | 392 | * can itself handle the screen size. Set from the |
Dianne Hackborn | e667635 | 2011-06-01 16:51:20 -0700 | [diff] [blame] | 393 | * {@link android.R.attr#configChanges} attribute. This will be |
| 394 | * set by default for applications that target an earlier version |
| 395 | * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}... |
| 396 | * <b>however</b>, you will not see the bit set here becomes some |
| 397 | * applications incorrectly compare {@link #configChanges} against |
| 398 | * an absolute value rather than correctly masking out the bits |
| 399 | * they are interested in. Please don't do that, thanks. |
Dianne Hackborn | ebff8f9 | 2011-05-12 18:07:47 -0700 | [diff] [blame] | 400 | */ |
| 401 | public static final int CONFIG_SCREEN_SIZE = 0x0400; |
| 402 | /** |
| 403 | * Bit in {@link #configChanges} that indicates that the activity |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 404 | * can itself handle the smallest screen size. Set from the |
Dianne Hackborn | e667635 | 2011-06-01 16:51:20 -0700 | [diff] [blame] | 405 | * {@link android.R.attr#configChanges} attribute. This will be |
| 406 | * set by default for applications that target an earlier version |
| 407 | * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}... |
| 408 | * <b>however</b>, you will not see the bit set here becomes some |
| 409 | * applications incorrectly compare {@link #configChanges} against |
| 410 | * an absolute value rather than correctly masking out the bits |
| 411 | * they are interested in. Please don't do that, thanks. |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 412 | */ |
| 413 | public static final int CONFIG_SMALLEST_SCREEN_SIZE = 0x0800; |
| 414 | /** |
| 415 | * Bit in {@link #configChanges} that indicates that the activity |
Dianne Hackborn | 908aecc | 2012-07-31 16:37:34 -0700 | [diff] [blame] | 416 | * can itself handle density changes. Set from the |
| 417 | * {@link android.R.attr#configChanges} attribute. |
| 418 | */ |
| 419 | public static final int CONFIG_DENSITY = 0x1000; |
| 420 | /** |
| 421 | * Bit in {@link #configChanges} that indicates that the activity |
Fabrice Di Meglio | 5f79799 | 2012-06-15 20:16:41 -0700 | [diff] [blame] | 422 | * can itself handle the change to layout direction. Set from the |
| 423 | * {@link android.R.attr#configChanges} attribute. |
| 424 | */ |
| 425 | public static final int CONFIG_LAYOUT_DIRECTION = 0x2000; |
| 426 | /** |
| 427 | * Bit in {@link #configChanges} that indicates that the activity |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 428 | * can itself handle changes to the font scaling factor. Set from the |
| 429 | * {@link android.R.attr#configChanges} attribute. This is |
Fabrice Di Meglio | dc25d25 | 2013-04-09 18:04:29 -0700 | [diff] [blame] | 430 | * not a core resource configuration, but a higher-level value, so its |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 431 | * constant starts at the high bits. |
| 432 | */ |
| 433 | public static final int CONFIG_FONT_SCALE = 0x40000000; |
| 434 | |
Dianne Hackborn | ebff8f9 | 2011-05-12 18:07:47 -0700 | [diff] [blame] | 435 | /** @hide |
| 436 | * Unfortunately the constants for config changes in native code are |
| 437 | * different from ActivityInfo. :( Here are the values we should use for the |
| 438 | * native side given the bit we have assigned in ActivityInfo. |
| 439 | */ |
| 440 | public static int[] CONFIG_NATIVE_BITS = new int[] { |
Dianne Hackborn | 1d0b177 | 2013-09-06 14:02:54 -0700 | [diff] [blame] | 441 | Configuration.NATIVE_CONFIG_MNC, // MNC |
| 442 | Configuration.NATIVE_CONFIG_MCC, // MCC |
| 443 | Configuration.NATIVE_CONFIG_LOCALE, // LOCALE |
| 444 | Configuration.NATIVE_CONFIG_TOUCHSCREEN, // TOUCH SCREEN |
| 445 | Configuration.NATIVE_CONFIG_KEYBOARD, // KEYBOARD |
| 446 | Configuration.NATIVE_CONFIG_KEYBOARD_HIDDEN, // KEYBOARD HIDDEN |
| 447 | Configuration.NATIVE_CONFIG_NAVIGATION, // NAVIGATION |
| 448 | Configuration.NATIVE_CONFIG_ORIENTATION, // ORIENTATION |
| 449 | Configuration.NATIVE_CONFIG_SCREEN_LAYOUT, // SCREEN LAYOUT |
| 450 | Configuration.NATIVE_CONFIG_UI_MODE, // UI MODE |
| 451 | Configuration.NATIVE_CONFIG_SCREEN_SIZE, // SCREEN SIZE |
| 452 | Configuration.NATIVE_CONFIG_SMALLEST_SCREEN_SIZE, // SMALLEST SCREEN SIZE |
| 453 | Configuration.NATIVE_CONFIG_DENSITY, // DENSITY |
| 454 | Configuration.NATIVE_CONFIG_LAYOUTDIR, // LAYOUT DIRECTION |
Dianne Hackborn | ebff8f9 | 2011-05-12 18:07:47 -0700 | [diff] [blame] | 455 | }; |
| 456 | /** @hide |
| 457 | * Convert Java change bits to native. |
| 458 | */ |
| 459 | public static int activityInfoConfigToNative(int input) { |
| 460 | int output = 0; |
| 461 | for (int i=0; i<CONFIG_NATIVE_BITS.length; i++) { |
| 462 | if ((input&(1<<i)) != 0) { |
| 463 | output |= CONFIG_NATIVE_BITS[i]; |
| 464 | } |
| 465 | } |
| 466 | return output; |
| 467 | } |
| 468 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 469 | /** |
Dianne Hackborn | e667635 | 2011-06-01 16:51:20 -0700 | [diff] [blame] | 470 | * @hide |
| 471 | * Unfortunately some developers (OpenFeint I am looking at you) have |
| 472 | * compared the configChanges bit field against absolute values, so if we |
| 473 | * introduce a new bit they break. To deal with that, we will make sure |
| 474 | * the public field will not have a value that breaks them, and let the |
| 475 | * framework call here to get the real value. |
| 476 | */ |
| 477 | public int getRealConfigChanged() { |
| 478 | return applicationInfo.targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB_MR2 |
| 479 | ? (configChanges | ActivityInfo.CONFIG_SCREEN_SIZE |
| 480 | | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE) |
| 481 | : configChanges; |
| 482 | } |
| 483 | |
| 484 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 485 | * Bit mask of kinds of configuration changes that this activity |
| 486 | * can handle itself (without being restarted by the system). |
| 487 | * Contains any combination of {@link #CONFIG_FONT_SCALE}, |
| 488 | * {@link #CONFIG_MCC}, {@link #CONFIG_MNC}, |
| 489 | * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN}, |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 490 | * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION}, |
Fabrice Di Meglio | 5f79799 | 2012-06-15 20:16:41 -0700 | [diff] [blame] | 491 | * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT} and |
| 492 | * {@link #CONFIG_LAYOUT_DIRECTION}. Set from the {@link android.R.attr#configChanges} |
| 493 | * attribute. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 494 | */ |
| 495 | public int configChanges; |
| 496 | |
| 497 | /** |
| 498 | * The desired soft input mode for this activity's main window. |
| 499 | * Set from the {@link android.R.attr#windowSoftInputMode} attribute |
| 500 | * in the activity's manifest. May be any of the same values allowed |
| 501 | * for {@link android.view.WindowManager.LayoutParams#softInputMode |
| 502 | * WindowManager.LayoutParams.softInputMode}. If 0 (unspecified), |
| 503 | * the mode from the theme will be used. |
| 504 | */ |
| 505 | public int softInputMode; |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 506 | |
| 507 | /** |
| 508 | * The desired extra UI options for this activity and its main window. |
| 509 | * Set from the {@link android.R.attr#uiOptions} attribute in the |
| 510 | * activity's manifest. |
| 511 | */ |
| 512 | public int uiOptions = 0; |
| 513 | |
| 514 | /** |
Scott Main | e797ed6 | 2011-09-22 16:17:45 -0700 | [diff] [blame] | 515 | * Flag for use with {@link #uiOptions}. |
| 516 | * Indicates that the action bar should put all action items in a separate bar when |
| 517 | * the screen is narrow. |
| 518 | * <p>This value corresponds to "splitActionBarWhenNarrow" for the {@link #uiOptions} XML |
| 519 | * attribute. |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 520 | */ |
| 521 | public static final int UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW = 1; |
| 522 | |
Adam Powell | dd8fab2 | 2012-03-22 17:47:27 -0700 | [diff] [blame] | 523 | /** |
| 524 | * If defined, the activity named here is the logical parent of this activity. |
| 525 | */ |
| 526 | public String parentActivityName; |
| 527 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 528 | public ActivityInfo() { |
| 529 | } |
| 530 | |
| 531 | public ActivityInfo(ActivityInfo orig) { |
| 532 | super(orig); |
| 533 | theme = orig.theme; |
| 534 | launchMode = orig.launchMode; |
| 535 | permission = orig.permission; |
| 536 | taskAffinity = orig.taskAffinity; |
| 537 | targetActivity = orig.targetActivity; |
| 538 | flags = orig.flags; |
| 539 | screenOrientation = orig.screenOrientation; |
| 540 | configChanges = orig.configChanges; |
| 541 | softInputMode = orig.softInputMode; |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 542 | uiOptions = orig.uiOptions; |
Adam Powell | dd8fab2 | 2012-03-22 17:47:27 -0700 | [diff] [blame] | 543 | parentActivityName = orig.parentActivityName; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | /** |
| 547 | * Return the theme resource identifier to use for this activity. If |
| 548 | * the activity defines a theme, that is used; else, the application |
| 549 | * theme is used. |
| 550 | * |
| 551 | * @return The theme associated with this activity. |
| 552 | */ |
| 553 | public final int getThemeResource() { |
| 554 | return theme != 0 ? theme : applicationInfo.theme; |
| 555 | } |
| 556 | |
| 557 | public void dump(Printer pw, String prefix) { |
| 558 | super.dumpFront(pw, prefix); |
Dianne Hackborn | 12527f9 | 2009-11-11 17:39:50 -0800 | [diff] [blame] | 559 | if (permission != null) { |
| 560 | pw.println(prefix + "permission=" + permission); |
| 561 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 562 | pw.println(prefix + "taskAffinity=" + taskAffinity |
| 563 | + " targetActivity=" + targetActivity); |
Dianne Hackborn | 12527f9 | 2009-11-11 17:39:50 -0800 | [diff] [blame] | 564 | if (launchMode != 0 || flags != 0 || theme != 0) { |
| 565 | pw.println(prefix + "launchMode=" + launchMode |
| 566 | + " flags=0x" + Integer.toHexString(flags) |
| 567 | + " theme=0x" + Integer.toHexString(theme)); |
| 568 | } |
| 569 | if (screenOrientation != SCREEN_ORIENTATION_UNSPECIFIED |
| 570 | || configChanges != 0 || softInputMode != 0) { |
| 571 | pw.println(prefix + "screenOrientation=" + screenOrientation |
| 572 | + " configChanges=0x" + Integer.toHexString(configChanges) |
| 573 | + " softInputMode=0x" + Integer.toHexString(softInputMode)); |
| 574 | } |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 575 | if (uiOptions != 0) { |
| 576 | pw.println(prefix + " uiOptions=0x" + Integer.toHexString(uiOptions)); |
| 577 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 578 | super.dumpBack(pw, prefix); |
| 579 | } |
| 580 | |
| 581 | public String toString() { |
| 582 | return "ActivityInfo{" |
| 583 | + Integer.toHexString(System.identityHashCode(this)) |
| 584 | + " " + name + "}"; |
| 585 | } |
| 586 | |
| 587 | public int describeContents() { |
| 588 | return 0; |
| 589 | } |
| 590 | |
| 591 | public void writeToParcel(Parcel dest, int parcelableFlags) { |
| 592 | super.writeToParcel(dest, parcelableFlags); |
| 593 | dest.writeInt(theme); |
| 594 | dest.writeInt(launchMode); |
| 595 | dest.writeString(permission); |
| 596 | dest.writeString(taskAffinity); |
| 597 | dest.writeString(targetActivity); |
| 598 | dest.writeInt(flags); |
| 599 | dest.writeInt(screenOrientation); |
| 600 | dest.writeInt(configChanges); |
| 601 | dest.writeInt(softInputMode); |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 602 | dest.writeInt(uiOptions); |
Adam Powell | dd8fab2 | 2012-03-22 17:47:27 -0700 | [diff] [blame] | 603 | dest.writeString(parentActivityName); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | public static final Parcelable.Creator<ActivityInfo> CREATOR |
| 607 | = new Parcelable.Creator<ActivityInfo>() { |
| 608 | public ActivityInfo createFromParcel(Parcel source) { |
| 609 | return new ActivityInfo(source); |
| 610 | } |
| 611 | public ActivityInfo[] newArray(int size) { |
| 612 | return new ActivityInfo[size]; |
| 613 | } |
| 614 | }; |
| 615 | |
| 616 | private ActivityInfo(Parcel source) { |
| 617 | super(source); |
| 618 | theme = source.readInt(); |
| 619 | launchMode = source.readInt(); |
| 620 | permission = source.readString(); |
| 621 | taskAffinity = source.readString(); |
| 622 | targetActivity = source.readString(); |
| 623 | flags = source.readInt(); |
| 624 | screenOrientation = source.readInt(); |
| 625 | configChanges = source.readInt(); |
| 626 | softInputMode = source.readInt(); |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 627 | uiOptions = source.readInt(); |
Adam Powell | dd8fab2 | 2012-03-22 17:47:27 -0700 | [diff] [blame] | 628 | parentActivityName = source.readString(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 629 | } |
| 630 | } |