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 * Specifies the recommended install location. Can be one of 36 * {@link #PackageHelper.RECOMMEND_INSTALL_INTERNAL} to install on internal storage 37 * {@link #PackageHelper.RECOMMEND_INSTALL_EXTERNAL} to install on external media 38 * {@link PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE} for storage errors 39 * {@link PackageHelper.RECOMMEND_FAILED_INVALID_APK} for parse errors. 40 */ 41 public int recommendedInstallLocation; 42 public int installLocation; 43 44 public VerifierInfo[] verifiers; 45 46 public PackageInfoLite() { 47 } 48 49 public String toString() { 50 return "PackageInfoLite{" 51 + Integer.toHexString(System.identityHashCode(this)) 52 + " " + packageName + "}"; 53 } 54 55 public int describeContents() { 56 return 0; 57 } 58 59 public void writeToParcel(Parcel dest, int parcelableFlags) { 60 dest.writeString(packageName); 61 dest.writeInt(recommendedInstallLocation); 62 dest.writeInt(installLocation); 63 64 if (verifiers == null || verifiers.length == 0) { 65 dest.writeInt(0); 66 } else { 67 dest.writeInt(verifiers.length); 68 dest.writeTypedArray(verifiers, parcelableFlags); 69 } 70 } 71 72 public static final Parcelable.Creator<PackageInfoLite> CREATOR 73 = new Parcelable.Creator<PackageInfoLite>() { 74 public PackageInfoLite createFromParcel(Parcel source) { 75 return new PackageInfoLite(source); 76 } 77 78 public PackageInfoLite[] newArray(int size) { 79 return new PackageInfoLite[size]; 80 } 81 }; 82 83 private PackageInfoLite(Parcel source) { 84 packageName = source.readString(); 85 recommendedInstallLocation = source.readInt(); 86 installLocation = source.readInt(); 87 88 final int verifiersLength = source.readInt(); 89 if (verifiersLength == 0) { 90 verifiers = new VerifierInfo[0]; 91 } else { 92 verifiers = new VerifierInfo[verifiersLength]; 93 source.readTypedArray(verifiers, VerifierInfo.CREATOR); 94 } 95 } 96 } 97