blob: b878a955c223c7e07b242e30d19c2366c4e53ac6 [file] [log] [blame]
Kenny Root15a4d2f2010-03-11 18:20:12 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -080017package android.content.pm;
18
Mathew Inwood5c0d3542018-08-14 13:54:31 +010019import android.annotation.UnsupportedAppUsage;
Mathew Inwood31755f92018-12-20 13:53:36 +000020import android.os.Build;
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -080021import android.os.Parcel;
22import android.os.Parcelable;
23
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -080024import com.android.internal.content.PackageHelper;
25
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -080026/**
27 * Basic information about a package as specified in its manifest.
28 * Utility class used in PackageManager methods
29 * @hide
30 */
31public class PackageInfoLite implements Parcelable {
32 /**
33 * The name of this package. From the <manifest> tag's "name"
34 * attribute.
35 */
36 public String packageName;
37
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -080038 /** Names of any split APKs, ordered by parsed splitName */
39 public String[] splitNames;
40
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -080041 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -070042 * The android:versionCode of the package.
Dianne Hackborn3accca02013-09-20 09:32:11 -070043 * @deprecated Use {@link #getLongVersionCode()} instead, which includes both
44 * this and the additional
45 * {@link android.R.styleable#AndroidManifest_versionCode versionCodeMajor} attribute.
Dianne Hackborn7767eac2012-08-23 18:25:40 -070046 */
Dianne Hackborn3accca02013-09-20 09:32:11 -070047 @Deprecated
Dianne Hackborn7767eac2012-08-23 18:25:40 -070048 public int versionCode;
49
Dianne Hackborn3accca02013-09-20 09:32:11 -070050 /**
51 * @hide
52 * The android:versionCodeMajor of the package.
53 */
54 public int versionCodeMajor;
55
56 /**
57 * Return {@link #versionCode} and {@link #versionCodeMajor} combined together as a
58 * single long value. The {@link #versionCodeMajor} is placed in the upper 32 bits.
59 */
60 public long getLongVersionCode() {
61 return PackageInfo.composeLongVersionCode(versionCodeMajor, versionCode);
62 }
63
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -080064 /** Revision code of base APK */
65 public int baseRevisionCode;
66 /** Revision codes of any split APKs, ordered by parsed splitName */
67 public int[] splitRevisionCodes;
68
Dianne Hackborn7767eac2012-08-23 18:25:40 -070069 /**
Narayan Kamathff110bd2014-07-04 18:30:45 +010070 * The android:multiArch flag from the package manifest. If set,
71 * we will extract all native libraries for the given app, not just those
72 * from the preferred ABI.
73 */
74 public boolean multiArch;
75
76 /**
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -080077 * Specifies the recommended install location. Can be one of
Dianne Hackborn3accca02013-09-20 09:32:11 -070078 * {@link PackageHelper#RECOMMEND_INSTALL_INTERNAL} to install on internal storage,
79 * {@link PackageHelper#RECOMMEND_INSTALL_EXTERNAL} to install on external media,
80 * {@link PackageHelper#RECOMMEND_FAILED_INSUFFICIENT_STORAGE} for storage errors,
81 * or {@link PackageHelper#RECOMMEND_FAILED_INVALID_APK} for parse errors.
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -080082 */
83 public int recommendedInstallLocation;
84 public int installLocation;
85
Kenny Root05ca4c92011-09-15 10:36:25 -070086 public VerifierInfo[] verifiers;
87
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -080088 public PackageInfoLite() {
89 }
90
91 public String toString() {
92 return "PackageInfoLite{"
93 + Integer.toHexString(System.identityHashCode(this))
94 + " " + packageName + "}";
95 }
96
97 public int describeContents() {
98 return 0;
99 }
100
101 public void writeToParcel(Parcel dest, int parcelableFlags) {
102 dest.writeString(packageName);
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800103 dest.writeStringArray(splitNames);
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700104 dest.writeInt(versionCode);
Dianne Hackborn3accca02013-09-20 09:32:11 -0700105 dest.writeInt(versionCodeMajor);
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800106 dest.writeInt(baseRevisionCode);
107 dest.writeIntArray(splitRevisionCodes);
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -0800108 dest.writeInt(recommendedInstallLocation);
109 dest.writeInt(installLocation);
Narayan Kamatha8755a82014-07-15 12:26:35 +0100110 dest.writeInt(multiArch ? 1 : 0);
Kenny Root05ca4c92011-09-15 10:36:25 -0700111
112 if (verifiers == null || verifiers.length == 0) {
113 dest.writeInt(0);
114 } else {
115 dest.writeInt(verifiers.length);
116 dest.writeTypedArray(verifiers, parcelableFlags);
117 }
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -0800118 }
119
Mathew Inwood31755f92018-12-20 13:53:36 +0000120 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -0800121 public static final Parcelable.Creator<PackageInfoLite> CREATOR
122 = new Parcelable.Creator<PackageInfoLite>() {
123 public PackageInfoLite createFromParcel(Parcel source) {
124 return new PackageInfoLite(source);
125 }
126
127 public PackageInfoLite[] newArray(int size) {
128 return new PackageInfoLite[size];
129 }
130 };
131
132 private PackageInfoLite(Parcel source) {
133 packageName = source.readString();
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800134 splitNames = source.createStringArray();
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700135 versionCode = source.readInt();
Dianne Hackborn3accca02013-09-20 09:32:11 -0700136 versionCodeMajor = source.readInt();
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800137 baseRevisionCode = source.readInt();
138 splitRevisionCodes = source.createIntArray();
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -0800139 recommendedInstallLocation = source.readInt();
140 installLocation = source.readInt();
Narayan Kamatha8755a82014-07-15 12:26:35 +0100141 multiArch = (source.readInt() != 0);
Kenny Root05ca4c92011-09-15 10:36:25 -0700142
143 final int verifiersLength = source.readInt();
144 if (verifiersLength == 0) {
145 verifiers = new VerifierInfo[0];
146 } else {
147 verifiers = new VerifierInfo[verifiersLength];
148 source.readTypedArray(verifiers, VerifierInfo.CREATOR);
149 }
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -0800150 }
Kenny Root15a4d2f2010-03-11 18:20:12 -0800151}