Home | History | Annotate | Download | only in pm
      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      */
     42     public int versionCode;
     43 
     44     /** Revision code of base APK */
     45     public int baseRevisionCode;
     46     /** Revision codes of any split APKs, ordered by parsed splitName */
     47     public int[] splitRevisionCodes;
     48 
     49     /**
     50      * The android:multiArch flag from the package manifest. If set,
     51      * we will extract all native libraries for the given app, not just those
     52      * from the preferred ABI.
     53      */
     54     public boolean multiArch;
     55 
     56     /**
     57      * Specifies the recommended install location. Can be one of
     58      * {@link #PackageHelper.RECOMMEND_INSTALL_INTERNAL} to install on internal storage
     59      * {@link #PackageHelper.RECOMMEND_INSTALL_EXTERNAL} to install on external media
     60      * {@link PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE} for storage errors
     61      * {@link PackageHelper.RECOMMEND_FAILED_INVALID_APK} for parse errors.
     62      */
     63     public int recommendedInstallLocation;
     64     public int installLocation;
     65 
     66     public VerifierInfo[] verifiers;
     67 
     68     public PackageInfoLite() {
     69     }
     70 
     71     public String toString() {
     72         return "PackageInfoLite{"
     73             + Integer.toHexString(System.identityHashCode(this))
     74             + " " + packageName + "}";
     75     }
     76 
     77     public int describeContents() {
     78         return 0;
     79     }
     80 
     81     public void writeToParcel(Parcel dest, int parcelableFlags) {
     82         dest.writeString(packageName);
     83         dest.writeStringArray(splitNames);
     84         dest.writeInt(versionCode);
     85         dest.writeInt(baseRevisionCode);
     86         dest.writeIntArray(splitRevisionCodes);
     87         dest.writeInt(recommendedInstallLocation);
     88         dest.writeInt(installLocation);
     89         dest.writeInt(multiArch ? 1 : 0);
     90 
     91         if (verifiers == null || verifiers.length == 0) {
     92             dest.writeInt(0);
     93         } else {
     94             dest.writeInt(verifiers.length);
     95             dest.writeTypedArray(verifiers, parcelableFlags);
     96         }
     97     }
     98 
     99     public static final Parcelable.Creator<PackageInfoLite> CREATOR
    100             = new Parcelable.Creator<PackageInfoLite>() {
    101         public PackageInfoLite createFromParcel(Parcel source) {
    102             return new PackageInfoLite(source);
    103         }
    104 
    105         public PackageInfoLite[] newArray(int size) {
    106             return new PackageInfoLite[size];
    107         }
    108     };
    109 
    110     private PackageInfoLite(Parcel source) {
    111         packageName = source.readString();
    112         splitNames = source.createStringArray();
    113         versionCode = source.readInt();
    114         baseRevisionCode = source.readInt();
    115         splitRevisionCodes = source.createIntArray();
    116         recommendedInstallLocation = source.readInt();
    117         installLocation = source.readInt();
    118         multiArch = (source.readInt() != 0);
    119 
    120         final int verifiersLength = source.readInt();
    121         if (verifiersLength == 0) {
    122             verifiers = new VerifierInfo[0];
    123         } else {
    124             verifiers = new VerifierInfo[verifiersLength];
    125             source.readTypedArray(verifiers, VerifierInfo.CREATOR);
    126         }
    127     }
    128 }
    129