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 17 package android.content.pm; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 import com.android.internal.content.PackageHelper; 23 24 /** 25 * Basic information about a package as specified in its manifest. 26 * Utility class used in PackageManager methods 27 * @hide 28 */ 29 public class PackageInfoLite implements Parcelable { 30 /** 31 * The name of this package. From the <manifest> tag's "name" 32 * attribute. 33 */ 34 public String packageName; 35 36 /** Names of any split APKs, ordered by parsed splitName */ 37 public String[] splitNames; 38 39 /** 40 * The android:versionCode of the package. 41 * @deprecated Use {@link #getLongVersionCode()} instead, which includes both 42 * this and the additional 43 * {@link android.R.styleable#AndroidManifest_versionCode versionCodeMajor} attribute. 44 */ 45 @Deprecated 46 public int versionCode; 47 48 /** 49 * @hide 50 * The android:versionCodeMajor of the package. 51 */ 52 public int versionCodeMajor; 53 54 /** 55 * Return {@link #versionCode} and {@link #versionCodeMajor} combined together as a 56 * single long value. The {@link #versionCodeMajor} is placed in the upper 32 bits. 57 */ 58 public long getLongVersionCode() { 59 return PackageInfo.composeLongVersionCode(versionCodeMajor, versionCode); 60 } 61 62 /** Revision code of base APK */ 63 public int baseRevisionCode; 64 /** Revision codes of any split APKs, ordered by parsed splitName */ 65 public int[] splitRevisionCodes; 66 67 /** 68 * The android:multiArch flag from the package manifest. If set, 69 * we will extract all native libraries for the given app, not just those 70 * from the preferred ABI. 71 */ 72 public boolean multiArch; 73 74 /** 75 * Specifies the recommended install location. Can be one of 76 * {@link PackageHelper#RECOMMEND_INSTALL_INTERNAL} to install on internal storage, 77 * {@link PackageHelper#RECOMMEND_INSTALL_EXTERNAL} to install on external media, 78 * {@link PackageHelper#RECOMMEND_FAILED_INSUFFICIENT_STORAGE} for storage errors, 79 * or {@link PackageHelper#RECOMMEND_FAILED_INVALID_APK} for parse errors. 80 */ 81 public int recommendedInstallLocation; 82 public int installLocation; 83 84 public VerifierInfo[] verifiers; 85 86 public PackageInfoLite() { 87 } 88 89 public String toString() { 90 return "PackageInfoLite{" 91 + Integer.toHexString(System.identityHashCode(this)) 92 + " " + packageName + "}"; 93 } 94 95 public int describeContents() { 96 return 0; 97 } 98 99 public void writeToParcel(Parcel dest, int parcelableFlags) { 100 dest.writeString(packageName); 101 dest.writeStringArray(splitNames); 102 dest.writeInt(versionCode); 103 dest.writeInt(versionCodeMajor); 104 dest.writeInt(baseRevisionCode); 105 dest.writeIntArray(splitRevisionCodes); 106 dest.writeInt(recommendedInstallLocation); 107 dest.writeInt(installLocation); 108 dest.writeInt(multiArch ? 1 : 0); 109 110 if (verifiers == null || verifiers.length == 0) { 111 dest.writeInt(0); 112 } else { 113 dest.writeInt(verifiers.length); 114 dest.writeTypedArray(verifiers, parcelableFlags); 115 } 116 } 117 118 public static final Parcelable.Creator<PackageInfoLite> CREATOR 119 = new Parcelable.Creator<PackageInfoLite>() { 120 public PackageInfoLite createFromParcel(Parcel source) { 121 return new PackageInfoLite(source); 122 } 123 124 public PackageInfoLite[] newArray(int size) { 125 return new PackageInfoLite[size]; 126 } 127 }; 128 129 private PackageInfoLite(Parcel source) { 130 packageName = source.readString(); 131 splitNames = source.createStringArray(); 132 versionCode = source.readInt(); 133 versionCodeMajor = source.readInt(); 134 baseRevisionCode = source.readInt(); 135 splitRevisionCodes = source.createIntArray(); 136 recommendedInstallLocation = source.readInt(); 137 installLocation = source.readInt(); 138 multiArch = (source.readInt() != 0); 139 140 final int verifiersLength = source.readInt(); 141 if (verifiersLength == 0) { 142 verifiers = new VerifierInfo[0]; 143 } else { 144 verifiers = new VerifierInfo[verifiersLength]; 145 source.readTypedArray(verifiers, VerifierInfo.CREATOR); 146 } 147 } 148 } 149