115a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root/*
215a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * Copyright (C) 2007 The Android Open Source Project
315a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root *
415a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * Licensed under the Apache License, Version 2.0 (the "License");
515a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * you may not use this file except in compliance with the License.
615a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * You may obtain a copy of the License at
715a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root *
815a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root *      http://www.apache.org/licenses/LICENSE-2.0
915a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root *
1015a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * Unless required by applicable law or agreed to in writing, software
1115a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * distributed under the License is distributed on an "AS IS" BASIS,
1215a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1315a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * See the License for the specific language governing permissions and
1415a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root * limitations under the License.
1515a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root */
1615a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root
17a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapupackage android.content.pm;
18a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu
19a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapuimport android.os.Parcel;
20a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapuimport android.os.Parcelable;
21a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu
22a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu/**
23a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu * Basic information about a package as specified in its manifest.
24a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu * Utility class used in PackageManager methods
25a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu * @hide
26a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu */
27a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapupublic class PackageInfoLite implements Parcelable {
28a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    /**
29a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu     * The name of this package.  From the <manifest> tag's "name"
30a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu     * attribute.
31a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu     */
32a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    public String packageName;
33a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu
34a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    /**
357767eac3232ba2fb9828766813cdb481d6a97584Dianne Hackborn     * The android:versionCode of the package.
367767eac3232ba2fb9828766813cdb481d6a97584Dianne Hackborn     */
377767eac3232ba2fb9828766813cdb481d6a97584Dianne Hackborn    public int versionCode;
387767eac3232ba2fb9828766813cdb481d6a97584Dianne Hackborn
397767eac3232ba2fb9828766813cdb481d6a97584Dianne Hackborn    /**
40a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu     * Specifies the recommended install location. Can be one of
41a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu     * {@link #PackageHelper.RECOMMEND_INSTALL_INTERNAL} to install on internal storage
42a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu     * {@link #PackageHelper.RECOMMEND_INSTALL_EXTERNAL} to install on external media
43a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu     * {@link PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE} for storage errors
44a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu     * {@link PackageHelper.RECOMMEND_FAILED_INVALID_APK} for parse errors.
45a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu     */
46a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    public int recommendedInstallLocation;
47a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    public int installLocation;
48a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu
4905ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root    public VerifierInfo[] verifiers;
5005ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root
51a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    public PackageInfoLite() {
52a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    }
53a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu
54a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    public String toString() {
55a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        return "PackageInfoLite{"
56a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu            + Integer.toHexString(System.identityHashCode(this))
57a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu            + " " + packageName + "}";
58a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    }
59a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu
60a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    public int describeContents() {
61a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        return 0;
62a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    }
63a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu
64a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    public void writeToParcel(Parcel dest, int parcelableFlags) {
65a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        dest.writeString(packageName);
667767eac3232ba2fb9828766813cdb481d6a97584Dianne Hackborn        dest.writeInt(versionCode);
67a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        dest.writeInt(recommendedInstallLocation);
68a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        dest.writeInt(installLocation);
6905ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root
7005ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root        if (verifiers == null || verifiers.length == 0) {
7105ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root            dest.writeInt(0);
7205ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root        } else {
7305ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root            dest.writeInt(verifiers.length);
7405ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root            dest.writeTypedArray(verifiers, parcelableFlags);
7505ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root        }
76a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    }
77a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu
78a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    public static final Parcelable.Creator<PackageInfoLite> CREATOR
79a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu            = new Parcelable.Creator<PackageInfoLite>() {
80a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        public PackageInfoLite createFromParcel(Parcel source) {
81a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu            return new PackageInfoLite(source);
82a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        }
83a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu
84a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        public PackageInfoLite[] newArray(int size) {
85a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu            return new PackageInfoLite[size];
86a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        }
87a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    };
88a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu
89a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    private PackageInfoLite(Parcel source) {
90a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        packageName = source.readString();
917767eac3232ba2fb9828766813cdb481d6a97584Dianne Hackborn        versionCode = source.readInt();
92a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        recommendedInstallLocation = source.readInt();
93a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu        installLocation = source.readInt();
9405ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root
9505ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root        final int verifiersLength = source.readInt();
9605ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root        if (verifiersLength == 0) {
9705ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root            verifiers = new VerifierInfo[0];
9805ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root        } else {
9905ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root            verifiers = new VerifierInfo[verifiersLength];
10005ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root            source.readTypedArray(verifiers, VerifierInfo.CREATOR);
10105ca4c90644921df9193d92b2abdc81ef77e4a62Kenny Root        }
102a2b6c3775ed6b8924232d6a01bae4a19740a15f8Suchi Amalapurapu    }
10315a4d2ffd04dc6c70f2cd17dae12ac6bc14c69abKenny Root}
104