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 | |
Jeff Brown | 0733079 | 2010-03-30 19:57:08 -0700 | [diff] [blame] | 19 | import android.content.pm.PackageManager.NameNotFoundException; |
| 20 | import android.content.res.Resources; |
| 21 | import android.graphics.drawable.Drawable; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
| 24 | import android.util.Printer; |
| 25 | |
| 26 | import java.text.Collator; |
| 27 | import java.util.Comparator; |
| 28 | |
| 29 | /** |
| 30 | * Information you can retrieve about a particular application. This |
| 31 | * corresponds to information collected from the AndroidManifest.xml's |
| 32 | * <application> tag. |
| 33 | */ |
| 34 | public class ApplicationInfo extends PackageItemInfo implements Parcelable { |
| 35 | |
| 36 | /** |
| 37 | * Default task affinity of all activities in this application. See |
| 38 | * {@link ActivityInfo#taskAffinity} for more information. This comes |
| 39 | * from the "taskAffinity" attribute. |
| 40 | */ |
| 41 | public String taskAffinity; |
| 42 | |
| 43 | /** |
| 44 | * Optional name of a permission required to be able to access this |
| 45 | * application's components. From the "permission" attribute. |
| 46 | */ |
| 47 | public String permission; |
| 48 | |
| 49 | /** |
| 50 | * The name of the process this application should run in. From the |
| 51 | * "process" attribute or, if not set, the same as |
| 52 | * <var>packageName</var>. |
| 53 | */ |
| 54 | public String processName; |
| 55 | |
| 56 | /** |
| 57 | * Class implementing the Application object. From the "class" |
| 58 | * attribute. |
| 59 | */ |
| 60 | public String className; |
| 61 | |
| 62 | /** |
| 63 | * A style resource identifier (in the package's resources) of the |
| 64 | * description of an application. From the "description" attribute |
| 65 | * or, if not set, 0. |
| 66 | */ |
| 67 | public int descriptionRes; |
| 68 | |
| 69 | /** |
| 70 | * A style resource identifier (in the package's resources) of the |
| 71 | * default visual theme of the application. From the "theme" attribute |
| 72 | * or, if not set, 0. |
| 73 | */ |
| 74 | public int theme; |
| 75 | |
| 76 | /** |
| 77 | * Class implementing the Application's manage space |
| 78 | * functionality. From the "manageSpaceActivity" |
| 79 | * attribute. This is an optional attribute and will be null if |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 80 | * applications don't specify it in their manifest |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | */ |
| 82 | public String manageSpaceActivityName; |
| 83 | |
| 84 | /** |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 85 | * Class implementing the Application's backup functionality. From |
| 86 | * the "backupAgent" attribute. This is an optional attribute and |
| 87 | * will be null if the application does not specify it in its manifest. |
| 88 | * |
| 89 | * <p>If android:allowBackup is set to false, this attribute is ignored. |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 90 | */ |
| 91 | public String backupAgentName; |
| 92 | |
| 93 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | * Value for {@link #flags}: if set, this application is installed in the |
| 95 | * device's system image. |
| 96 | */ |
| 97 | public static final int FLAG_SYSTEM = 1<<0; |
| 98 | |
| 99 | /** |
| 100 | * Value for {@link #flags}: set to true if this application would like to |
| 101 | * allow debugging of its |
| 102 | * code, even when installed on a non-development system. Comes |
| 103 | * from {@link android.R.styleable#AndroidManifestApplication_debuggable |
| 104 | * android:debuggable} of the <application> tag. |
| 105 | */ |
| 106 | public static final int FLAG_DEBUGGABLE = 1<<1; |
| 107 | |
| 108 | /** |
| 109 | * Value for {@link #flags}: set to true if this application has code |
| 110 | * associated with it. Comes |
| 111 | * from {@link android.R.styleable#AndroidManifestApplication_hasCode |
| 112 | * android:hasCode} of the <application> tag. |
| 113 | */ |
| 114 | public static final int FLAG_HAS_CODE = 1<<2; |
| 115 | |
| 116 | /** |
| 117 | * Value for {@link #flags}: set to true if this application is persistent. |
| 118 | * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent |
| 119 | * android:persistent} of the <application> tag. |
| 120 | */ |
| 121 | public static final int FLAG_PERSISTENT = 1<<3; |
| 122 | |
| 123 | /** |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 124 | * Value for {@link #flags}: set to true if this application holds the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 125 | * {@link android.Manifest.permission#FACTORY_TEST} permission and the |
| 126 | * device is running in factory test mode. |
| 127 | */ |
| 128 | public static final int FLAG_FACTORY_TEST = 1<<4; |
| 129 | |
| 130 | /** |
| 131 | * Value for {@link #flags}: default value for the corresponding ActivityInfo flag. |
| 132 | * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting |
| 133 | * android:allowTaskReparenting} of the <application> tag. |
| 134 | */ |
| 135 | public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5; |
| 136 | |
| 137 | /** |
| 138 | * Value for {@link #flags}: default value for the corresponding ActivityInfo flag. |
| 139 | * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData |
| 140 | * android:allowClearUserData} of the <application> tag. |
| 141 | */ |
| 142 | public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6; |
| 143 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 144 | /** |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 145 | * Value for {@link #flags}: this is set if this application has been |
| 146 | * install as an update to a built-in system application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 147 | */ |
| 148 | public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7; |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 151 | * Value for {@link #flags}: this is set of the application has specified |
| 152 | * {@link android.R.styleable#AndroidManifestApplication_testOnly |
| 153 | * android:testOnly} to be true. |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 154 | */ |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 155 | public static final int FLAG_TEST_ONLY = 1<<8; |
Dianne Hackborn | ade3eca | 2009-05-11 18:54:45 -0700 | [diff] [blame] | 156 | |
| 157 | /** |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 158 | * Value for {@link #flags}: true when the application's window can be |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 159 | * reduced in size for smaller screens. Corresponds to |
| 160 | * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens |
| 161 | * android:smallScreens}. |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 162 | */ |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 163 | public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9; |
| 164 | |
| 165 | /** |
| 166 | * Value for {@link #flags}: true when the application's window can be |
| 167 | * displayed on normal screens. Corresponds to |
| 168 | * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens |
| 169 | * android:normalScreens}. |
| 170 | */ |
| 171 | public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10; |
| 172 | |
| 173 | /** |
| 174 | * Value for {@link #flags}: true when the application's window can be |
| 175 | * increased in size for larger screens. Corresponds to |
| 176 | * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens |
| 177 | * android:smallScreens}. |
| 178 | */ |
| 179 | public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11; |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 180 | |
| 181 | /** |
Dianne Hackborn | c4db95c | 2009-07-21 17:46:02 -0700 | [diff] [blame] | 182 | * Value for {@link #flags}: true when the application knows how to adjust |
| 183 | * its UI for different screen sizes. Corresponds to |
| 184 | * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable |
| 185 | * android:resizeable}. |
| 186 | */ |
| 187 | public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12; |
| 188 | |
| 189 | /** |
Dianne Hackborn | 11b822d | 2009-07-21 20:03:02 -0700 | [diff] [blame] | 190 | * Value for {@link #flags}: true when the application knows how to |
| 191 | * accomodate different screen densities. Corresponds to |
| 192 | * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity |
| 193 | * android:anyDensity}. |
| 194 | */ |
| 195 | public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13; |
| 196 | |
| 197 | /** |
Ben Cheng | 23085b7 | 2010-02-08 16:06:32 -0800 | [diff] [blame] | 198 | * Value for {@link #flags}: set to true if this application would like to |
| 199 | * request the VM to operate under the safe mode. Comes from |
Ben Cheng | ef3f5dd | 2010-03-29 15:47:26 -0700 | [diff] [blame] | 200 | * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode |
| 201 | * android:vmSafeMode} of the <application> tag. |
Ben Cheng | 23085b7 | 2010-02-08 16:06:32 -0800 | [diff] [blame] | 202 | */ |
| 203 | public static final int FLAG_VM_SAFE_MODE = 1<<14; |
| 204 | |
| 205 | /** |
Christopher Tate | 3de55bc | 2010-03-12 17:28:08 -0800 | [diff] [blame] | 206 | * Value for {@link #flags}: set to <code>false</code> if the application does not wish |
| 207 | * to permit any OS-driven backups of its data; <code>true</code> otherwise. |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 208 | * |
Christopher Tate | 3de55bc | 2010-03-12 17:28:08 -0800 | [diff] [blame] | 209 | * <p>Comes from the |
| 210 | * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup} |
| 211 | * attribute of the <application> tag. |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 212 | */ |
Ben Cheng | 23085b7 | 2010-02-08 16:06:32 -0800 | [diff] [blame] | 213 | public static final int FLAG_ALLOW_BACKUP = 1<<15; |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 214 | |
| 215 | /** |
Christopher Tate | 3de55bc | 2010-03-12 17:28:08 -0800 | [diff] [blame] | 216 | * Value for {@link #flags}: set to <code>false</code> if the application must be kept |
| 217 | * in memory following a full-system restore operation; <code>true</code> otherwise. |
| 218 | * Ordinarily, during a full system restore operation each application is shut down |
| 219 | * following execution of its agent's onRestore() method. Setting this attribute to |
| 220 | * <code>false</code> prevents this. Most applications will not need to set this attribute. |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 221 | * |
Christopher Tate | 3de55bc | 2010-03-12 17:28:08 -0800 | [diff] [blame] | 222 | * <p>If |
| 223 | * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup} |
| 224 | * is set to <code>false</code> or no |
| 225 | * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent} |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 226 | * is specified, this flag will be ignored. |
| 227 | * |
Christopher Tate | 3de55bc | 2010-03-12 17:28:08 -0800 | [diff] [blame] | 228 | * <p>Comes from the |
| 229 | * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore} |
| 230 | * attribute of the <application> tag. |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 231 | */ |
Ben Cheng | 23085b7 | 2010-02-08 16:06:32 -0800 | [diff] [blame] | 232 | public static final int FLAG_KILL_AFTER_RESTORE = 1<<16; |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 233 | |
| 234 | /** |
Christopher Tate | 3de55bc | 2010-03-12 17:28:08 -0800 | [diff] [blame] | 235 | * Value for {@link #flags}: Set to <code>true</code> if the application's backup |
| 236 | * agent claims to be able to handle restore data even "from the future," |
| 237 | * i.e. from versions of the application with a versionCode greater than |
| 238 | * the one currently installed on the device. <i>Use with caution!</i> By default |
| 239 | * this attribute is <code>false</code> and the Backup Manager will ensure that data |
| 240 | * from "future" versions of the application are never supplied during a restore operation. |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 241 | * |
Christopher Tate | 3de55bc | 2010-03-12 17:28:08 -0800 | [diff] [blame] | 242 | * <p>If |
| 243 | * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup} |
| 244 | * is set to <code>false</code> or no |
| 245 | * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent} |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 246 | * is specified, this flag will be ignored. |
| 247 | * |
Christopher Tate | 3de55bc | 2010-03-12 17:28:08 -0800 | [diff] [blame] | 248 | * <p>Comes from the |
| 249 | * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion} |
| 250 | * attribute of the <application> tag. |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 251 | */ |
Christopher Tate | 3de55bc | 2010-03-12 17:28:08 -0800 | [diff] [blame] | 252 | public static final int FLAG_RESTORE_ANY_VERSION = 1<<17; |
Christopher Tate | 5e1ab33 | 2009-09-01 20:32:49 -0700 | [diff] [blame] | 253 | |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 254 | /** |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 255 | * Value for {@link #flags}: Set to true if the application has been |
| 256 | * installed using the forward lock option. |
| 257 | * |
Dianne Hackborn | 3202d38 | 2010-04-26 17:51:34 -0700 | [diff] [blame] | 258 | * Value for {@link #flags}: Set to true if the application is |
| 259 | * currently installed on external/removable/unprotected storage. Such |
| 260 | * applications may not be available if their storage is not currently |
| 261 | * mounted. When the storage it is on is not available, it will look like |
| 262 | * the application has been uninstalled (its .apk is no longer available) |
| 263 | * but its persistent data is not removed. |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 264 | */ |
Dianne Hackborn | 94c567e | 2010-04-26 18:13:10 -0700 | [diff] [blame] | 265 | public static final int FLAG_EXTERNAL_STORAGE = 1<<18; |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 266 | |
| 267 | /** |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 268 | * Value for {@link #flags}: true when the application's window can be |
| 269 | * increased in size for extra large screens. Corresponds to |
| 270 | * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens |
| 271 | * android:smallScreens}. |
| 272 | */ |
| 273 | public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19; |
| 274 | |
| 275 | /** |
| 276 | * Value for {@link #flags}: this is true if the application has set |
| 277 | * its android:neverEncrypt to true, false otherwise. It is used to specify |
| 278 | * that this package specifically "opts-out" of a secured file system solution, |
| 279 | * and will always store its data in-the-clear. |
| 280 | * |
| 281 | * {@hide} |
| 282 | */ |
| 283 | public static final int FLAG_NEVER_ENCRYPT = 1<<30; |
| 284 | |
| 285 | /** |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 286 | * Value for {@link #flags}: Set to true if the application has been |
| 287 | * installed using the forward lock option. |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 288 | * |
| 289 | * {@hide} |
| 290 | */ |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 291 | public static final int FLAG_FORWARD_LOCK = 1<<29; |
Suchi Amalapurapu | af8e9f4 | 2010-01-12 10:17:28 -0800 | [diff] [blame] | 292 | |
| 293 | /** |
David 'Digit' Turner | 1edab2b | 2010-01-21 15:15:23 -0800 | [diff] [blame] | 294 | * Value for {@link #flags}: Set to true if the application is |
| 295 | * native-debuggable, i.e. embeds a gdbserver binary in its .apk |
| 296 | * |
| 297 | * {@hide} |
| 298 | */ |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 299 | public static final int FLAG_NATIVE_DEBUGGABLE = 1<<28; |
David 'Digit' Turner | 1edab2b | 2010-01-21 15:15:23 -0800 | [diff] [blame] | 300 | |
| 301 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 302 | * Flags associated with the application. Any combination of |
| 303 | * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE}, |
| 304 | * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and |
| 305 | * {@link #FLAG_ALLOW_TASK_REPARENTING} |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 306 | * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP}, |
Dianne Hackborn | 723738c | 2009-06-25 19:48:04 -0700 | [diff] [blame] | 307 | * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS}, |
| 308 | * {@link #FLAG_SUPPORTS_NORMAL_SCREENS}, |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 309 | * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS}, |
| 310 | * {@link #FLAG_RESIZEABLE_FOR_SCREENS}, |
Ben Cheng | 23085b7 | 2010-02-08 16:06:32 -0800 | [diff] [blame] | 311 | * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 312 | */ |
| 313 | public int flags = 0; |
| 314 | |
| 315 | /** |
| 316 | * Full path to the location of this package. |
| 317 | */ |
| 318 | public String sourceDir; |
| 319 | |
| 320 | /** |
Kenny Root | d1ab016 | 2010-01-21 17:27:14 -0800 | [diff] [blame] | 321 | * Full path to the location of the publicly available parts of this |
| 322 | * package (i.e. the primary resource package and manifest). For |
| 323 | * non-forward-locked apps this will be the same as {@link #sourceDir). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 324 | */ |
| 325 | public String publicSourceDir; |
| 326 | |
| 327 | /** |
Kenny Root | d1ab016 | 2010-01-21 17:27:14 -0800 | [diff] [blame] | 328 | * Full paths to the locations of extra resource packages this application |
| 329 | * uses. This field is only used if there are extra resource packages, |
| 330 | * otherwise it is null. |
Kenny Root | ace5a3f | 2010-02-05 12:59:28 -0800 | [diff] [blame] | 331 | * |
| 332 | * {@hide} |
Kenny Root | d1ab016 | 2010-01-21 17:27:14 -0800 | [diff] [blame] | 333 | */ |
| 334 | public String[] resourceDirs; |
| 335 | |
| 336 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 337 | * Paths to all shared libraries this application is linked against. This |
| 338 | * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES |
| 339 | * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving |
| 340 | * the structure. |
| 341 | */ |
| 342 | public String[] sharedLibraryFiles; |
| 343 | |
| 344 | /** |
| 345 | * Full path to a directory assigned to the package for its persistent |
| 346 | * data. |
| 347 | */ |
| 348 | public String dataDir; |
| 349 | |
| 350 | /** |
| 351 | * The kernel user-ID that has been assigned to this application; |
| 352 | * currently this is not a unique ID (multiple applications can have |
| 353 | * the same uid). |
| 354 | */ |
| 355 | public int uid; |
| 356 | |
Mitsuru Oshima | 8d11267 | 2009-04-27 12:01:23 -0700 | [diff] [blame] | 357 | /** |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 358 | * The minimum SDK version this application targets. It may run on earlier |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 359 | * versions, but it knows how to work with any new behavior added at this |
| 360 | * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT} |
| 361 | * if this is a development build and the app is targeting that. You should |
| 362 | * compare that this number is >= the SDK version number at which your |
| 363 | * behavior was introduced. |
| 364 | */ |
| 365 | public int targetSdkVersion; |
| 366 | |
| 367 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 368 | * When false, indicates that all components within this application are |
| 369 | * considered disabled, regardless of their individually set enabled status. |
| 370 | */ |
| 371 | public boolean enabled = true; |
| 372 | |
| 373 | public void dump(Printer pw, String prefix) { |
| 374 | super.dumpFront(pw, prefix); |
Dianne Hackborn | 12527f9 | 2009-11-11 17:39:50 -0800 | [diff] [blame] | 375 | if (className != null) { |
| 376 | pw.println(prefix + "className=" + className); |
| 377 | } |
| 378 | if (permission != null) { |
| 379 | pw.println(prefix + "permission=" + permission); |
| 380 | } |
| 381 | pw.println(prefix + "uid=" + uid + " taskAffinity=" + taskAffinity); |
| 382 | if (theme != 0) { |
| 383 | pw.println(prefix + "theme=0x" + Integer.toHexString(theme)); |
| 384 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 385 | pw.println(prefix + "flags=0x" + Integer.toHexString(flags) |
| 386 | + " processName=" + processName); |
| 387 | pw.println(prefix + "sourceDir=" + sourceDir); |
| 388 | pw.println(prefix + "publicSourceDir=" + publicSourceDir); |
Kenny Root | d1ab016 | 2010-01-21 17:27:14 -0800 | [diff] [blame] | 389 | pw.println(prefix + "resourceDirs=" + resourceDirs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 390 | pw.println(prefix + "dataDir=" + dataDir); |
Dianne Hackborn | 12527f9 | 2009-11-11 17:39:50 -0800 | [diff] [blame] | 391 | if (sharedLibraryFiles != null) { |
| 392 | pw.println(prefix + "sharedLibraryFiles=" + sharedLibraryFiles); |
| 393 | } |
| 394 | pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion); |
| 395 | if (manageSpaceActivityName != null) { |
| 396 | pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName); |
| 397 | } |
| 398 | if (descriptionRes != 0) { |
| 399 | pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes)); |
| 400 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 401 | super.dumpBack(pw, prefix); |
| 402 | } |
| 403 | |
| 404 | public static class DisplayNameComparator |
| 405 | implements Comparator<ApplicationInfo> { |
| 406 | public DisplayNameComparator(PackageManager pm) { |
| 407 | mPM = pm; |
| 408 | } |
| 409 | |
| 410 | public final int compare(ApplicationInfo aa, ApplicationInfo ab) { |
| 411 | CharSequence sa = mPM.getApplicationLabel(aa); |
| 412 | if (sa == null) { |
| 413 | sa = aa.packageName; |
| 414 | } |
| 415 | CharSequence sb = mPM.getApplicationLabel(ab); |
| 416 | if (sb == null) { |
| 417 | sb = ab.packageName; |
| 418 | } |
| 419 | |
| 420 | return sCollator.compare(sa.toString(), sb.toString()); |
| 421 | } |
| 422 | |
| 423 | private final Collator sCollator = Collator.getInstance(); |
| 424 | private PackageManager mPM; |
| 425 | } |
| 426 | |
| 427 | public ApplicationInfo() { |
| 428 | } |
| 429 | |
| 430 | public ApplicationInfo(ApplicationInfo orig) { |
| 431 | super(orig); |
| 432 | taskAffinity = orig.taskAffinity; |
| 433 | permission = orig.permission; |
| 434 | processName = orig.processName; |
| 435 | className = orig.className; |
| 436 | theme = orig.theme; |
| 437 | flags = orig.flags; |
| 438 | sourceDir = orig.sourceDir; |
| 439 | publicSourceDir = orig.publicSourceDir; |
Kenny Root | d1ab016 | 2010-01-21 17:27:14 -0800 | [diff] [blame] | 440 | resourceDirs = orig.resourceDirs; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 441 | sharedLibraryFiles = orig.sharedLibraryFiles; |
| 442 | dataDir = orig.dataDir; |
| 443 | uid = orig.uid; |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 444 | targetSdkVersion = orig.targetSdkVersion; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 445 | enabled = orig.enabled; |
| 446 | manageSpaceActivityName = orig.manageSpaceActivityName; |
| 447 | descriptionRes = orig.descriptionRes; |
| 448 | } |
| 449 | |
| 450 | |
| 451 | public String toString() { |
| 452 | return "ApplicationInfo{" |
| 453 | + Integer.toHexString(System.identityHashCode(this)) |
| 454 | + " " + packageName + "}"; |
| 455 | } |
| 456 | |
| 457 | public int describeContents() { |
| 458 | return 0; |
| 459 | } |
| 460 | |
| 461 | public void writeToParcel(Parcel dest, int parcelableFlags) { |
| 462 | super.writeToParcel(dest, parcelableFlags); |
| 463 | dest.writeString(taskAffinity); |
| 464 | dest.writeString(permission); |
| 465 | dest.writeString(processName); |
| 466 | dest.writeString(className); |
| 467 | dest.writeInt(theme); |
| 468 | dest.writeInt(flags); |
| 469 | dest.writeString(sourceDir); |
| 470 | dest.writeString(publicSourceDir); |
Kenny Root | d1ab016 | 2010-01-21 17:27:14 -0800 | [diff] [blame] | 471 | dest.writeStringArray(resourceDirs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 472 | dest.writeStringArray(sharedLibraryFiles); |
| 473 | dest.writeString(dataDir); |
| 474 | dest.writeInt(uid); |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 475 | dest.writeInt(targetSdkVersion); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 476 | dest.writeInt(enabled ? 1 : 0); |
| 477 | dest.writeString(manageSpaceActivityName); |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 478 | dest.writeString(backupAgentName); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 479 | dest.writeInt(descriptionRes); |
| 480 | } |
| 481 | |
| 482 | public static final Parcelable.Creator<ApplicationInfo> CREATOR |
| 483 | = new Parcelable.Creator<ApplicationInfo>() { |
| 484 | public ApplicationInfo createFromParcel(Parcel source) { |
| 485 | return new ApplicationInfo(source); |
| 486 | } |
| 487 | public ApplicationInfo[] newArray(int size) { |
| 488 | return new ApplicationInfo[size]; |
| 489 | } |
| 490 | }; |
| 491 | |
| 492 | private ApplicationInfo(Parcel source) { |
| 493 | super(source); |
| 494 | taskAffinity = source.readString(); |
| 495 | permission = source.readString(); |
| 496 | processName = source.readString(); |
| 497 | className = source.readString(); |
| 498 | theme = source.readInt(); |
| 499 | flags = source.readInt(); |
| 500 | sourceDir = source.readString(); |
| 501 | publicSourceDir = source.readString(); |
Kenny Root | d1ab016 | 2010-01-21 17:27:14 -0800 | [diff] [blame] | 502 | resourceDirs = source.readStringArray(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 503 | sharedLibraryFiles = source.readStringArray(); |
| 504 | dataDir = source.readString(); |
| 505 | uid = source.readInt(); |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 506 | targetSdkVersion = source.readInt(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 507 | enabled = source.readInt() != 0; |
| 508 | manageSpaceActivityName = source.readString(); |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 509 | backupAgentName = source.readString(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 510 | descriptionRes = source.readInt(); |
| 511 | } |
Mitsuru Oshima | 8d11267 | 2009-04-27 12:01:23 -0700 | [diff] [blame] | 512 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 513 | /** |
| 514 | * Retrieve the textual description of the application. This |
| 515 | * will call back on the given PackageManager to load the description from |
| 516 | * the application. |
| 517 | * |
| 518 | * @param pm A PackageManager from which the label can be loaded; usually |
| 519 | * the PackageManager from which you originally retrieved this item. |
| 520 | * |
| 521 | * @return Returns a CharSequence containing the application's description. |
| 522 | * If there is no description, null is returned. |
| 523 | */ |
| 524 | public CharSequence loadDescription(PackageManager pm) { |
| 525 | if (descriptionRes != 0) { |
Jeff Brown | 0733079 | 2010-03-30 19:57:08 -0700 | [diff] [blame] | 526 | CharSequence label = pm.getText(packageName, descriptionRes, this); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 527 | if (label != null) { |
| 528 | return label; |
| 529 | } |
| 530 | } |
| 531 | return null; |
| 532 | } |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 533 | |
| 534 | /** |
| 535 | * Disable compatibility mode |
| 536 | * |
| 537 | * @hide |
| 538 | */ |
| 539 | public void disableCompatibilityMode() { |
Mitsuru Oshima | 69fff4a | 2009-07-21 09:51:05 -0700 | [diff] [blame] | 540 | flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS | |
Dianne Hackborn | 11b822d | 2009-07-21 20:03:02 -0700 | [diff] [blame] | 541 | FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS | |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 542 | FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS); |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 543 | } |
Jeff Brown | 0733079 | 2010-03-30 19:57:08 -0700 | [diff] [blame] | 544 | |
| 545 | /** |
| 546 | * @hide |
| 547 | */ |
| 548 | @Override protected Drawable loadDefaultIcon(PackageManager pm) { |
| 549 | if ((flags & FLAG_EXTERNAL_STORAGE) != 0 |
| 550 | && isPackageUnavailable(pm)) { |
| 551 | return Resources.getSystem().getDrawable( |
| 552 | com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon); |
| 553 | } |
| 554 | return pm.getDefaultActivityIcon(); |
| 555 | } |
| 556 | |
| 557 | private boolean isPackageUnavailable(PackageManager pm) { |
| 558 | try { |
| 559 | return pm.getPackageInfo(packageName, 0) == null; |
| 560 | } catch (NameNotFoundException ex) { |
| 561 | return true; |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | /** |
| 566 | * @hide |
| 567 | */ |
| 568 | @Override protected ApplicationInfo getApplicationInfo() { |
| 569 | return this; |
| 570 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 571 | } |