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 /** 23 * Basic information about a package as specified in its manifest. 24 * Utility class used in PackageManager methods 25 * @hide 26 */ 27 public class PackageInfoLite implements Parcelable { 28 /** 29 * The name of this package. From the <manifest> tag's "name" 30 * attribute. 31 */ 32 public String packageName; 33 34 /** 35 * The android:versionCode of the package. 36 */ 37 public int versionCode; 38 39 /** 40 * Specifies the recommended install location. Can be one of 41 * {@link #PackageHelper.RECOMMEND_INSTALL_INTERNAL} to install on internal storage 42 * {@link #PackageHelper.RECOMMEND_INSTALL_EXTERNAL} to install on external media 43 * {@link PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE} for storage errors 44 * {@link PackageHelper.RECOMMEND_FAILED_INVALID_APK} for parse errors. 45 */ 46 public int recommendedInstallLocation; 47 public int installLocation; 48 49 public VerifierInfo[] verifiers; 50 51 public PackageInfoLite() { 52 } 53 54 public String toString() { 55 return "PackageInfoLite{" 56 + Integer.toHexString(System.identityHashCode(this)) 57 + " " + packageName + "}"; 58 } 59 60 public int describeContents() { 61 return 0; 62 } 63 64 public void writeToParcel(Parcel dest, int parcelableFlags) { 65 dest.writeString(packageName); 66 dest.writeInt(versionCode); 67 dest.writeInt(recommendedInstallLocation); 68 dest.writeInt(installLocation); 69 70 if (verifiers == null || verifiers.length == 0) { 71 dest.writeInt(0); 72 } else { 73 dest.writeInt(verifiers.length); 74 dest.writeTypedArray(verifiers, parcelableFlags); 75 } 76 } 77 78 public static final Parcelable.Creator<PackageInfoLite> CREATOR 79 = new Parcelable.Creator<PackageInfoLite>() { 80 public PackageInfoLite createFromParcel(Parcel source) { 81 return new PackageInfoLite(source); 82 } 83 84 public PackageInfoLite[] newArray(int size) { 85 return new PackageInfoLite[size]; 86 } 87 }; 88 89 private PackageInfoLite(Parcel source) { 90 packageName = source.readString(); 91 versionCode = source.readInt(); 92 recommendedInstallLocation = source.readInt(); 93 installLocation = source.readInt(); 94 95 final int verifiersLength = source.readInt(); 96 if (verifiersLength == 0) { 97 verifiers = new VerifierInfo[0]; 98 } else { 99 verifiers = new VerifierInfo[verifiersLength]; 100 source.readTypedArray(verifiers, VerifierInfo.CREATOR); 101 } 102 } 103 } 104