Android 的manifest解析,深度好文

  1. /**

  2. * Class implementing the Application object.  From the “class”

  3. * attribute.

  4. */

  5. public String className;

  6. /**

  7. * A style resource identifier (in the package’s resources) of the

  8. * description of an application.  From the “description” attribute

  9. * or, if not set, 0.

  10. */

  11. public int descriptionRes;

  12. /**

  13. * A style resource identifier (in the package’s resources) of the

  14. * default visual theme of the application.  From the “theme” attribute

  15. * or, if not set, 0.

  16. */

  17. public int theme;

  18. /**

  19. * Class implementing the Application’s manage space

  20. * functionality.  From the “manageSpaceActivity”

  21. * attribute. This is an optional attribute and will be null if

  22. * applications don’t specify it in their manifest

  23. */

  24. public String manageSpaceActivityName;

  25. /**

  26. * Class implementing the Application’s backup functionality.  From

  27. * the “backupAgent” attribute.  This is an optional attribute and

  28. * will be null if the application does not specify it in its manifest.

  29. *

  30. If android:allowBackup is set to false, this attribute is ignored.

  31. */

  32. public String backupAgentName;

  33. /**

  34. * The default extra UI options for activities in this application.

  35. * Set from the {@link android.R.attr#uiOptions} attribute in the

  36. * activity’s manifest.

  37. */

  38. public int uiOptions = 0;

  39. /**

  40. * Value for {@link #flags}: if set, this application is installed in the

  41. * device’s system image.

  42. */

  43. public static final int FLAG_SYSTEM = 1<<0;

  44. /**

  45. * Value for {@link #flags}: set to true if this application would like to

  46. * allow debugging of its

  47. * code, even when installed on a non-development system.  Comes

  48. * from {@link android.R.styleable#AndroidManifestApplication_debuggable

  49. * android:debuggable} of the  tag.

  50. */

  51. public static final int FLAG_DEBUGGABLE = 1<<1;

  52. /**

  53. * Value for {@link #flags}: set to true if this application has code

  54. * associated with it.  Comes

  55. * from {@link android.R.styleable#AndroidManifestApplication_hasCode

  56. * android:hasCode} of the  tag.

  57. */

  58. public static final int FLAG_HAS_CODE = 1<<2;

  59. /**

  60. * Value for {@link #flags}: set to true if this application is persistent.

  61. * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent

  62. * android:persistent} of the  tag.

  63. */

  64. public static final int FLAG_PERSISTENT = 1<<3;

  65. /**

  66. * Value for {@link #flags}: set to true if this application holds the

  67. * {@link android.Manifest.permission#FACTORY_TEST} permission and the

  68. * device is running in factory test mode.

  69. */

  70. public static final int FLAG_FACTORY_TEST = 1<<4;

  71. /**

  72. * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.

  73. * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting

  74. * android:allowTaskReparenting} of the  tag.

  75. */

  76. public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;

  77. /**

  78. * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.

  79. * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData

  80. * android:allowClearUserData} of the  tag.

  81. */

  82. public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;

  83. /**

  84. * Value for {@link #flags}: this is set if this application has been

  85. * install as an update to a built-in system application.

  86. */

  87. public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;

  88. /**

  89. * Value for {@link #flags}: this is set of the application has specified

  90. * {@link android.R.styleable#AndroidManifestApplication_testOnly

  91. * android:testOnly} to be true.

  92. */

  93. public static final int FLAG_TEST_ONLY = 1<<8;

  94. /**

  95. * Value for {@link #flags}: true when the application’s window can be

  96. * reduced in size for smaller screens.  Corresponds to

  97. * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens

  98. * android:smallScreens}.

  99. */

  100. public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;

  101. /**

  102. * Value for {@link #flags}: true when the application’s window can be

  103. * displayed on normal screens.  Corresponds to

  104. * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens

  105. * android:normalScreens}.

  106. */

  107. public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;

  108. /**

  109. * Value for {@link #flags}: true when the application’s window can be

  110. * increased in size for larger screens.  Corresponds to

  111. * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens

  112. * android:largeScreens}.

  113. */

  114. public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;

  115. /**

  116. * Value for {@link #flags}: true when the application knows how to adjust

  117. * its UI for different screen sizes.  Corresponds to

  118. * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable

  119. * android:resizeable}.

  120. */

  121. public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;

  122. /**

  123. * Value for {@link #flags}: true when the application knows how to

  124. * accomodate different screen densities.  Corresponds to

  125. * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity

  126. * android:anyDensity}.

  127. */

  128. public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;

  129. /**

  130. * Value for {@link #flags}: set to true if this application would like to

  131. * request the VM to operate under the safe mode. Comes from

  132. * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode

  133. * android:vmSafeMode} of the  tag.

  134. */

  135. public static final int FLAG_VM_SAFE_MODE = 1<<14;

  136. /**

  137. * Value for {@link #flags}: set to false if the application does not wish

  138. * to permit any OS-driven backups of its data; true otherwise.

  139. *

  140. Comes from the

  141. * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}

  142. * attribute of the  tag.

  143. */

  144. public static final int FLAG_ALLOW_BACKUP = 1<<15;

  145. /**

  146. * Value for {@link #flags}: set to false if the application must be kept

  147. * in memory following a full-system restore operation; true otherwise.

  148. * Ordinarily, during a full system restore operation each application is shut down

  149. * following execution of its agent’s onRestore() method.  Setting this attribute to

  150. false prevents this.  Most applications will not need to set this attribute.

  151. *

  152. If

  153. * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}

  154. * is set to false or no

  155. * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}

  156. * is specified, this flag will be ignored.

  157. *

  158. Comes from the

  159. * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}

  160. * attribute of the  tag.

  161. */

  162. public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;

  163. /**

  164. * Value for {@link #flags}: Set to true if the application’s backup

  165. * agent claims to be able to handle restore data even “from the future,”

  166. * i.e. from versions of the application with a versionCode greater than

  167. * the one currently installed on the device.  Use with caution!  By default

  168. * this attribute is false and the Backup Manager will ensure that data

  169. * from “future” versions of the application are never supplied during a restore operation.

  170. *

  171. If

  172. * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}

  173. * is set to false or no

  174. * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}

  175. * is specified, this flag will be ignored.

  176. *

  177. Comes from the

  178. * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}

  179. * attribute of the  tag.

  180. */

  181. public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;

  182. /**

  183. * Value for {@link #flags}: Set to true if the application is

  184. * currently installed on external/removable/unprotected storage.  Such

  185. * applications may not be available if their storage is not currently

  186. * mounted.  When the storage it is on is not available, it will look like

  187. * the application has been uninstalled (its .apk is no longer available)

  188. * but its persistent data is not removed.

  189. */

  190. public static final int FLAG_EXTERNAL_STORAGE = 1<<18;

  191. /**

  192. * Value for {@link #flags}: true when the application’s window can be

  193. * increased in size for extra large screens.  Corresponds to

  194. * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens

  195. * android:xlargeScreens}.

  196. */

  197. public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;

  198. /**

  199. * Value for {@link #flags}: true when the application has requested a

  200. * large heap for its processes.  Corresponds to

  201. * {@link android.R.styleable#AndroidManifestApplication_largeHeap

  202. * android:largeHeap}.

  203. */

  204. public static final int FLAG_LARGE_HEAP = 1<<20;

  205. /**

  206. * Value for {@link #flags}: true if this application’s package is in

  207. * the stopped state.

  208. */

  209. public static final int FLAG_STOPPED = 1<<21;

  210. /**

  211. * Value for {@link #flags}: true  when the application is willing to support

  212. * RTL (right to left). All activities will inherit this value.

  213. *

  214. * Set from the {@link android.R.attr#supportsRtl} attribute in the

  215. * activity’s manifest.

  216. *

  217. * Default value is false (no support for RTL).

  218. */

  219. public static final int FLAG_SUPPORTS_RTL = 1<<22;

  220. /**

  221. * Value for {@link #flags}: true if the application is currently

  222. * installed for the calling user.

  223. */

  224. public static final int FLAG_INSTALLED = 1<<23;

  225. /**

  226. * Value for {@link #flags}: true if the application only has its

  227. * data installed; the application package itself does not currently

  228. * exist on the device.

  229. */

  230. public static final int FLAG_IS_DATA_ONLY = 1<<24;

  231. /**

  232. * Value for {@link #flags}: Set to true if the application has been

  233. * installed using the forward lock option.

  234. *

  235. * NOTE: DO NOT CHANGE THIS VALUE!  It is saved in packages.xml.

  236. *

  237. * {@hide}

  238. */

  239. public static final int FLAG_FORWARD_LOCK = 1<<29;

  240. /**

  241. * Value for {@link #flags}: set to true if the application

  242. * has reported that it is heavy-weight, and thus can not participate in

  243. * the normal application lifecycle.

  244. *

  245. Comes from the

  246. * {@link android.R.styleable#AndroidManifestApplication_cantSaveState android:cantSaveState}

  247. * attribute of the  tag.

  248. *

  249. * {@hide}

  250. */

  251. public static final int FLAG_CANT_SAVE_STATE = 1<<28;

  252. /**

  253. * Flags associated with the application.  Any combination of

  254. * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},

  255. * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and

  256. * {@link #FLAG_ALLOW_TASK_REPARENTING}

  257. * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},

  258. * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},

  259. * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},

  260. * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},

  261. * {@link #FLAG_RESIZEABLE_FOR_SCREENS},

  262. * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},

  263. * {@link #FLAG_INSTALLED}.

  264. */

  265. public int flags = 0;

  266. /**

  267. * The required smallest screen width the application can run on.  If 0,

  268. * nothing has been specified.  Comes from

  269. * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp

  270. * android:requiresSmallestWidthDp} attribute of the  tag.

  271. */

  272. public int requiresSmallestWidthDp = 0;

  273. /**

  274. * The maximum smallest screen width the application is designed for.  If 0,

  275. * nothing has been specified.  Comes from

  276. * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp

  277. * android:compatibleWidthLimitDp} attribute of the  tag.

  278. */

  279. public int compatibleWidthLimitDp = 0;

  280. /**

  281. * The maximum smallest screen width the application will work on.  If 0,

  282. * nothing has been specified.  Comes from

  283. * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp

  284. * android:largestWidthLimitDp} attribute of the  tag.

  285. */

  286. public int largestWidthLimitDp = 0;

  287. /**

  288. * Full path to the location of this package.

  289. */

  290. public String sourceDir;

  291. /**

  292. * Full path to the location of the publicly available parts of this

  293. * package (i.e. the primary resource package and manifest).  For

  294. * non-forward-locked apps this will be the same as {@link #sourceDir).

  295. */

  296. public String publicSourceDir;

  297. /**

  298. * Full paths to the locations of extra resource packages this application

  299. * uses. This field is only used if there are extra resource packages,

  300. * otherwise it is null.

  301. *

  302. * {@hide}

  303. */

  304. public String[] resourceDirs;

  305. /**

  306. * Paths to all shared libraries this application is linked against.  This

  307. * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES

  308. * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving

  309. * the structure.

  310. */

  311. public String[] sharedLibraryFiles;

  312. /**

  313. * Full path to a directory assigned to the package for its persistent

  314. * data.

  315. */

  316. public String dataDir;

  317. /**

  318. * Full path to the directory where native JNI libraries are stored.

  319. */

  320. public String nativeLibraryDir;

  321. /**

  322. * The kernel user-ID that has been assigned to this application;

  323. * currently this is not a unique ID (multiple applications can have

  324. * the same uid).

  325. */

  326. public int uid;

  327. /**

  328. * The minimum SDK version this application targets.  It may run on earlier

  329. * versions, but it knows how to work with any new behavior added at this

  330. * version.  Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}

  331. * if this is a development build and the app is targeting that.  You should

  332. * compare that this number is >= the SDK version number at which your

  333. * behavior was introduced.

  334. */

  335. public int targetSdkVersion;

  336. /**

  337. * When false, indicates that all components within this application are

  338. * considered disabled, regardless of their individually set enabled status.

  339. */

  340. public boolean enabled = true;

  341. /**

  342. * For convenient access to the current enabled setting of this app.

  343. * @hide

  344. */

  345. public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;

  346. /**

  347. * For convenient access to package’s install location.

  348. * @hide

  349. */

  350. public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;

  351. public void dump(Printer pw, String prefix) {

  352. super.dumpFront(pw, prefix);

  353. if (className != null) {

  354. pw.println(prefix + “className=” + className);

  355. }

  356. if (permission != null) {

  357. pw.println(prefix + “permission=” + permission);

  358. }

  359. pw.println(prefix + “processName=” + processName);

  360. pw.println(prefix + “taskAffinity=” + taskAffinity);

  361. pw.println(prefix + “uid=” + uid + " flags=0x" + Integer.toHexString(flags)

  362. + " theme=0x" + Integer.toHexString(theme));

  363. pw.println(prefix + “requiresSmallestWidthDp=” + requiresSmallestWidthDp

  364. + " compatibleWidthLimitDp=" + compatibleWidthLimitDp

  365. + " largestWidthLimitDp=" + largestWidthLimitDp);

  366. pw.println(prefix + “sourceDir=” + sourceDir);

  367. if (sourceDir == null) {

  368. if (publicSourceDir != null) {

  369. pw.println(prefix + “publicSourceDir=” + publicSourceDir);

  370. }

  371. } else if (!sourceDir.equals(publicSourceDir)) {

  372. pw.println(prefix + “publicSourceDir=” + publicSourceDir);

  373. }

  374. if (resourceDirs != null) {

  375. pw.println(prefix + “resourceDirs=” + resourceDirs);

  376. }

  377. pw.println(prefix + “dataDir=” + dataDir);

  378. if (sharedLibraryFiles != null) {

  379. pw.println(prefix + “sharedLibraryFiles=” + sharedLibraryFiles);

  380. }

  381. pw.println(prefix + “enabled=” + enabled + " targetSdkVersion=" + targetSdkVersion);

  382. if (manageSpaceActivityName != null) {

  383. pw.println(prefix + “manageSpaceActivityName=”+manageSpaceActivityName);

  384. }

  385. if (descriptionRes != 0) {

  386. pw.println(prefix + “description=0x”+Integer.toHexString(descriptionRes));

  387. }

  388. if (uiOptions != 0) {

  389. pw.println(prefix + “uiOptions=0x” + Integer.toHexString(uiOptions));

  390. }

  391. pw.println(prefix + “supportsRtl=” + (hasRtlSupport() ? “true” : “false”));

  392. super.dumpBack(pw, prefix);

  393. }

  394. /**

  395. * @return true if “supportsRtl” has been set to true in the AndroidManifest

  396. * @hide

  397. */

  398. public boolean hasRtlSupport() {

  399. return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;

  400. }

  401. public static class DisplayNameComparator

  402. implements Comparator {

  403. public DisplayNameComparator(PackageManager pm) {

  404. mPM = pm;

  405. }

  406. public final int compare(ApplicationInfo aa, ApplicationInfo ab) {

  407. CharSequence  sa = mPM.getApplicationLabel(aa);

  408. if (sa == null) {

  409. sa = aa.packageName;

  410. }

  411. CharSequence  sb = mPM.getApplicationLabel(ab);

  412. if (sb == null) {

  413. sb = ab.packageName;

  414. }

  415. return sCollator.compare(sa.toString(), sb.toString());

  416. }

  417. private final Collator   sCollator = Collator.getInstance();

  418. private PackageManager   mPM;

  419. }

  420. public ApplicationInfo() {

  421. }

  422. public ApplicationInfo(ApplicationInfo orig) {

  423. super(orig);

  424. taskAffinity = orig.taskAffinity;

  425. permission = orig.permission;

  426. processName = orig.processName;

  427. className = orig.className;

  428. theme = orig.theme;

  429. flags = orig.flags;

  430. requiresSmallestWidthDp = orig.requiresSmallestWidthDp;

  431. compatibleWidthLimitDp = orig.compatibleWidthLimitDp;

  432. largestWidthLimitDp = orig.largestWidthLimitDp;

  433. sourceDir = orig.sourceDir;

  434. publicSourceDir = orig.publicSourceDir;

  435. nativeLibraryDir = orig.nativeLibraryDir;

  436. resourceDirs = orig.resourceDirs;

  437. sharedLibraryFiles = orig.sharedLibraryFiles;

  438. dataDir = orig.dataDir;

  439. uid = orig.uid;

  440. targetSdkVersion = orig.targetSdkVersion;

  441. enabled = orig.enabled;

  442. enabledSetting = orig.enabledSetting;

  443. installLocation = orig.installLocation;

  444. manageSpaceActivityName = orig.manageSpaceActivityName;

  445. descriptionRes = orig.descriptionRes;

  446. uiOptions = orig.uiOptions;

  447. backupAgentName = orig.backupAgentName;

  448. }

  449. public String toString() {

  450. return “ApplicationInfo{”

  451. + Integer.toHexString(System.identityHashCode(this))

  452. + " " + packageName + “}”;

  453. }

  454. public int describeContents() {

  455. return 0;

  456. }

  457. public void writeToParcel(Parcel dest, int parcelableFlags) {

  458. super.writeToParcel(dest, parcelableFlags);

  459. dest.writeString(taskAffinity);

  460. dest.writeString(permission);

  461. dest.writeString(processName);

  462. dest.writeString(className);

  463. dest.writeInt(theme);

  464. dest.writeInt(flags);

  465. dest.writeInt(requiresSmallestWidthDp);

  466. dest.writeInt(compatibleWidthLimitDp);

  467. dest.writeInt(largestWidthLimitDp);

  468. dest.writeString(sourceDir);

  469. dest.writeString(publicSourceDir);

  470. dest.writeString(nativeLibraryDir);

  471. dest.writeStringArray(resourceDirs);

  472. dest.writeStringArray(sharedLibraryFiles);

  473. dest.writeString(dataDir);

  474. dest.writeInt(uid);

  475. dest.writeInt(targetSdkVersion);

  476. dest.writeInt(enabled ? 1 : 0);

  477. dest.writeInt(enabledSetting);

  478. dest.writeInt(installLocation);

  479. dest.writeString(manageSpaceActivityName);

  480. dest.writeString(backupAgentName);

  481. dest.writeInt(descriptionRes);

  482. dest.writeInt(uiOptions);

  483. }

  484. public static final Parcelable.Creator CREATOR

  485. = new Parcelable.Creator() {

  486. public ApplicationInfo createFromParcel(Parcel source) {

  487. return new ApplicationInfo(source);

  488. }

  489. public ApplicationInfo[] newArray(int size) {

  490. return new ApplicationInfo[size];

  491. }

  492. };

  493. private ApplicationInfo(Parcel source) {

  494. super(source);

  495. taskAffinity = source.readString();

  496. permission = source.readString();

  497. processName = source.readString();

  498. className = source.readString();

  499. theme = source.readInt();

  500. flags = source.readInt();

  501. requiresSmallestWidthDp = source.readInt();

  502. compatibleWidthLimitDp = source.readInt();

  503. largestWidthLimitDp = source.readInt();

  504. sourceDir = source.readString();

  505. publicSourceDir = source.readString();

  506. nativeLibraryDir = source.readString();

  507. resourceDirs = source.readStringArray();

  508. sharedLibraryFiles = source.readStringArray();

  509. dataDir = source.readString();

  510. uid = source.readInt();

  511. targetSdkVersion = source.readInt();

  512. enabled = source.readInt() != 0;

  513. enabledSetting = source.readInt();

  514. installLocation = source.readInt();

  515. manageSpaceActivityName = source.readString();

  516. backupAgentName = source.readString();

  517. descriptionRes = source.readInt();

  518. uiOptions = source.readInt();

  519. }

  520. /**

  521. * Retrieve the textual description of the application.  This

  522. * will call back on the given PackageManager to load the description from

  523. * the application.

  524. *

  525. * @param pm A PackageManager from which the label can be loaded; usually

  526. * the PackageManager from which you originally retrieved this item.

  527. *

  528. * @return Returns a CharSequence containing the application’s description.

  529. * If there is no description, null is returned.

  530. */

  531. public CharSequence loadDescription(PackageManager pm) {

  532. if (descriptionRes != 0) {

  533. CharSequence label = pm.getText(packageName, descriptionRes, this);

  534. if (label != null) {

  535. return label;

  536. }

  537. }

  538. return null;

  539. }

  540. /**

  541. * Disable compatibility mode

  542. *

  543. * @hide

  544. */

  545. public void disableCompatibilityMode() {

  546. flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |

  547. FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |

  548. FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);

  549. }

  550. /**

  551. * @hide

  552. */

  553. @Override protected Drawable loadDefaultIcon(PackageManager pm) {

  554. if ((flags & FLAG_EXTERNAL_STORAGE) != 0

  555. && isPackageUnavailable(pm)) {

  556. return Resources.getSystem().getDrawable(

  557. com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);

  558. }

  559. return pm.getDefaultActivityIcon();

  560. }

  561. private boolean isPackageUnavailable(PackageManager pm) {

  562. try {

  563. return pm.getPackageInfo(packageName, 0) == null;

  564. } catch (NameNotFoundException ex) {

  565. return true;

  566. }

  567. }

  568. /**

  569. * @hide

  570. */

  571. @Override protected ApplicationInfo getApplicationInfo() {

  572. return this;

  573. }

  574. }

PackageItemInfo.java源码:

[java]  view plain copy 外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传 外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

  1. /*

  2. * Copyright © 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. package android.content.pm;

  17. import android.content.res.XmlResourceParser;

  18. import android.graphics.drawable.Drawable;

  19. import android.os.Bundle;

  20. import android.os.Parcel;

  21. import android.text.TextUtils;

  22. import android.util.Printer;

  23. import java.text.Collator;

  24. import java.util.Comparator;

  25. /**

  26. * Base class containing information common to all package items held by

  27. * the package manager.  This provides a very common basic set of attributes:

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级安卓工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
img

最后

如果你看到了这里,觉得文章写得不错就给个赞呗?如果你觉得那里值得改进的,请给我留言。一定会认真查询,修正不足。谢谢。

最后针对Android程序员,我这边给大家整理了一些资料,包括不限于高级UI、性能优化、移动架构师、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter等全方面的Android进阶实践技术;希望能帮助到大家,也节省大家在网上搜索资料的时间来学习,也可以分享动态给身边好友一起学习!

需要资料的朋友可以点击我的GitHub免费领取

  1. import android.graphics.drawable.Drawable;

  2. import android.os.Bundle;

  3. import android.os.Parcel;

  4. import android.text.TextUtils;

  5. import android.util.Printer;

  6. import java.text.Collator;

  7. import java.util.Comparator;

  8. /**

  9. * Base class containing information common to all package items held by

  10. * the package manager.  This provides a very common basic set of attributes:

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级安卓工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
[外链图片转存中…(img-m1twTDqa-1711136907034)]
[外链图片转存中…(img-U7YhjyXI-1711136907035)]
[外链图片转存中…(img-RCbdetYk-1711136907035)]
[外链图片转存中…(img-0aYChBMm-1711136907036)]

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
[外链图片转存中…(img-TOppt6WF-1711136907036)]

最后

如果你看到了这里,觉得文章写得不错就给个赞呗?如果你觉得那里值得改进的,请给我留言。一定会认真查询,修正不足。谢谢。

[外链图片转存中…(img-psQmtdsd-1711136907037)]

最后针对Android程序员,我这边给大家整理了一些资料,包括不限于高级UI、性能优化、移动架构师、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter等全方面的Android进阶实践技术;希望能帮助到大家,也节省大家在网上搜索资料的时间来学习,也可以分享动态给身边好友一起学习!

需要资料的朋友可以点击我的GitHub免费领取
  • 25
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值