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 | |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 17 | package android.content.pm; |
| 18 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 19 | import android.annotation.UnsupportedAppUsage; |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 20 | import android.os.Build; |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 21 | import android.os.Parcel; |
| 22 | import android.os.Parcelable; |
| 23 | |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 24 | import com.android.internal.content.PackageHelper; |
| 25 | |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 26 | /** |
| 27 | * Basic information about a package as specified in its manifest. |
| 28 | * Utility class used in PackageManager methods |
| 29 | * @hide |
| 30 | */ |
| 31 | public 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 Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 38 | /** Names of any split APKs, ordered by parsed splitName */ |
| 39 | public String[] splitNames; |
| 40 | |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 41 | /** |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 42 | * The android:versionCode of the package. |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 43 | * @deprecated Use {@link #getLongVersionCode()} instead, which includes both |
| 44 | * this and the additional |
| 45 | * {@link android.R.styleable#AndroidManifest_versionCode versionCodeMajor} attribute. |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 46 | */ |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 47 | @Deprecated |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 48 | public int versionCode; |
| 49 | |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 50 | /** |
| 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 Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 64 | /** 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 Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 69 | /** |
Narayan Kamath | ff110bd | 2014-07-04 18:30:45 +0100 | [diff] [blame] | 70 | * 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 Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 77 | * Specifies the recommended install location. Can be one of |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 78 | * {@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 Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 82 | */ |
| 83 | public int recommendedInstallLocation; |
| 84 | public int installLocation; |
| 85 | |
Kenny Root | 05ca4c9 | 2011-09-15 10:36:25 -0700 | [diff] [blame] | 86 | public VerifierInfo[] verifiers; |
| 87 | |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 88 | 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 Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 103 | dest.writeStringArray(splitNames); |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 104 | dest.writeInt(versionCode); |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 105 | dest.writeInt(versionCodeMajor); |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 106 | dest.writeInt(baseRevisionCode); |
| 107 | dest.writeIntArray(splitRevisionCodes); |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 108 | dest.writeInt(recommendedInstallLocation); |
| 109 | dest.writeInt(installLocation); |
Narayan Kamath | a8755a8 | 2014-07-15 12:26:35 +0100 | [diff] [blame] | 110 | dest.writeInt(multiArch ? 1 : 0); |
Kenny Root | 05ca4c9 | 2011-09-15 10:36:25 -0700 | [diff] [blame] | 111 | |
| 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 Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 118 | } |
| 119 | |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 120 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 121 | public static final @android.annotation.NonNull Parcelable.Creator<PackageInfoLite> CREATOR |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 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 Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 134 | splitNames = source.createStringArray(); |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 135 | versionCode = source.readInt(); |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 136 | versionCodeMajor = source.readInt(); |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 137 | baseRevisionCode = source.readInt(); |
| 138 | splitRevisionCodes = source.createIntArray(); |
Suchi Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 139 | recommendedInstallLocation = source.readInt(); |
| 140 | installLocation = source.readInt(); |
Narayan Kamath | a8755a8 | 2014-07-15 12:26:35 +0100 | [diff] [blame] | 141 | multiArch = (source.readInt() != 0); |
Kenny Root | 05ca4c9 | 2011-09-15 10:36:25 -0700 | [diff] [blame] | 142 | |
| 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 Amalapurapu | a2b6c37 | 2010-03-05 17:40:11 -0800 | [diff] [blame] | 150 | } |
Kenny Root | 15a4d2f | 2010-03-11 18:20:12 -0800 | [diff] [blame] | 151 | } |