blob: af327c30e666c8bc71f03f33f318b15ae97e2f06 [file] [log] [blame]
Kenny Root15a4d2f2010-03-11 18:20:12 -08001/*
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
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080017package android.content.pm;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * Overall information about the contents of a package. This corresponds
24 * to all of the information collected from AndroidManifest.xml.
25 */
26public class PackageInfo implements Parcelable {
27 /**
28 * The name of this package. From the <manifest> tag's "name"
29 * attribute.
30 */
31 public String packageName;
32
33 /**
34 * The version number of this package, as specified by the <manifest>
35 * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode}
36 * attribute.
37 */
38 public int versionCode;
39
40 /**
41 * The version name of this package, as specified by the <manifest>
42 * tag's {@link android.R.styleable#AndroidManifest_versionName versionName}
43 * attribute.
44 */
45 public String versionName;
46
47 /**
48 * The shared user ID name of this package, as specified by the <manifest>
49 * tag's {@link android.R.styleable#AndroidManifest_sharedUserId sharedUserId}
50 * attribute.
51 */
52 public String sharedUserId;
53
54 /**
55 * The shared user ID label of this package, as specified by the <manifest>
56 * tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel}
57 * attribute.
58 */
59 public int sharedUserLabel;
60
61 /**
62 * Information collected from the <application> tag, or null if
63 * there was none.
64 */
65 public ApplicationInfo applicationInfo;
66
67 /**
68 * All kernel group-IDs that have been assigned to this package.
69 * This is only filled in if the flag {@link PackageManager#GET_GIDS} was set.
70 */
71 public int[] gids;
72
73 /**
74 * Array of all {@link android.R.styleable#AndroidManifestActivity
75 * <activity>} tags included under <application>,
76 * or null if there were none. This is only filled in if the flag
77 * {@link PackageManager#GET_ACTIVITIES} was set.
78 */
79 public ActivityInfo[] activities;
80
81 /**
82 * Array of all {@link android.R.styleable#AndroidManifestReceiver
83 * <receiver>} tags included under <application>,
84 * or null if there were none. This is only filled in if the flag
85 * {@link PackageManager#GET_RECEIVERS} was set.
86 */
87 public ActivityInfo[] receivers;
88
89 /**
90 * Array of all {@link android.R.styleable#AndroidManifestService
91 * <service>} tags included under <application>,
92 * or null if there were none. This is only filled in if the flag
93 * {@link PackageManager#GET_SERVICES} was set.
94 */
95 public ServiceInfo[] services;
96
97 /**
98 * Array of all {@link android.R.styleable#AndroidManifestProvider
99 * <provider>} tags included under <application>,
100 * or null if there were none. This is only filled in if the flag
101 * {@link PackageManager#GET_PROVIDERS} was set.
102 */
103 public ProviderInfo[] providers;
104
105 /**
106 * Array of all {@link android.R.styleable#AndroidManifestInstrumentation
107 * <instrumentation>} tags included under <manifest>,
108 * or null if there were none. This is only filled in if the flag
109 * {@link PackageManager#GET_INSTRUMENTATION} was set.
110 */
111 public InstrumentationInfo[] instrumentation;
112
113 /**
114 * Array of all {@link android.R.styleable#AndroidManifestPermission
115 * <permission>} tags included under <manifest>,
116 * or null if there were none. This is only filled in if the flag
117 * {@link PackageManager#GET_PERMISSIONS} was set.
118 */
119 public PermissionInfo[] permissions;
120
121 /**
122 * Array of all {@link android.R.styleable#AndroidManifestUsesPermission
123 * <uses-permission>} tags included under <manifest>,
124 * or null if there were none. This is only filled in if the flag
125 * {@link PackageManager#GET_PERMISSIONS} was set. This list includes
126 * all permissions requested, even those that were not granted or known
127 * by the system at install time.
128 */
129 public String[] requestedPermissions;
130
131 /**
132 * Array of all signatures read from the package file. This is only filled
133 * in if the flag {@link PackageManager#GET_SIGNATURES} was set.
134 */
135 public Signature[] signatures;
136
137 /**
138 * Application specified preferred configuration
139 * {@link android.R.styleable#AndroidManifestUsesConfiguration
140 * <uses-configuration>} tags included under <manifest>,
141 * or null if there were none. This is only filled in if the flag
142 * {@link PackageManager#GET_CONFIGURATIONS} was set.
143 */
144 public ConfigurationInfo[] configPreferences;
145
Dianne Hackborn49237342009-08-27 20:08:01 -0700146 /**
147 * The features that this application has said it requires.
148 */
149 public FeatureInfo[] reqFeatures;
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800150
151 /**
152 * Constant corresponding to <code>auto</code> in
153 * the {@link android.R.attr#installLocation} attribute.
154 * @hide
155 */
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700156 public static final int INSTALL_LOCATION_UNSPECIFIED = -1;
157 /**
158 * Constant corresponding to <code>auto</code> in
159 * the {@link android.R.attr#installLocation} attribute.
160 * @hide
161 */
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800162 public static final int INSTALL_LOCATION_AUTO = 0;
163 /**
164 * Constant corresponding to <code>internalOnly</code> in
165 * the {@link android.R.attr#installLocation} attribute.
166 * @hide
167 */
168 public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1;
169 /**
170 * Constant corresponding to <code>preferExternal</code> in
171 * the {@link android.R.attr#installLocation} attribute.
172 * @hide
173 */
174 public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
175 /**
Suchi Amalapurapua2b6c372010-03-05 17:40:11 -0800176 * The install location requested by the activity. From the
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800177 * {@link android.R.attr#installLocation} attribute, one of
178 * {@link #INSTALL_LOCATION_AUTO},
179 * {@link #INSTALL_LOCATION_INTERNAL_ONLY},
180 * {@link #INSTALL_LOCATION_PREFER_EXTERNAL}
181 * @hide
182 */
183 public int installLocation = INSTALL_LOCATION_INTERNAL_ONLY;
Dianne Hackborn49237342009-08-27 20:08:01 -0700184
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800185 public PackageInfo() {
186 }
187
188 public String toString() {
189 return "PackageInfo{"
190 + Integer.toHexString(System.identityHashCode(this))
191 + " " + packageName + "}";
192 }
193
194 public int describeContents() {
195 return 0;
196 }
197
198 public void writeToParcel(Parcel dest, int parcelableFlags) {
199 dest.writeString(packageName);
200 dest.writeInt(versionCode);
201 dest.writeString(versionName);
202 dest.writeString(sharedUserId);
203 dest.writeInt(sharedUserLabel);
204 if (applicationInfo != null) {
205 dest.writeInt(1);
206 applicationInfo.writeToParcel(dest, parcelableFlags);
207 } else {
208 dest.writeInt(0);
209 }
210 dest.writeIntArray(gids);
211 dest.writeTypedArray(activities, parcelableFlags);
212 dest.writeTypedArray(receivers, parcelableFlags);
213 dest.writeTypedArray(services, parcelableFlags);
214 dest.writeTypedArray(providers, parcelableFlags);
215 dest.writeTypedArray(instrumentation, parcelableFlags);
216 dest.writeTypedArray(permissions, parcelableFlags);
217 dest.writeStringArray(requestedPermissions);
218 dest.writeTypedArray(signatures, parcelableFlags);
219 dest.writeTypedArray(configPreferences, parcelableFlags);
Dianne Hackborn49237342009-08-27 20:08:01 -0700220 dest.writeTypedArray(reqFeatures, parcelableFlags);
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800221 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800222 }
223
224 public static final Parcelable.Creator<PackageInfo> CREATOR
225 = new Parcelable.Creator<PackageInfo>() {
226 public PackageInfo createFromParcel(Parcel source) {
227 return new PackageInfo(source);
228 }
229
230 public PackageInfo[] newArray(int size) {
231 return new PackageInfo[size];
232 }
233 };
234
235 private PackageInfo(Parcel source) {
236 packageName = source.readString();
237 versionCode = source.readInt();
238 versionName = source.readString();
239 sharedUserId = source.readString();
240 sharedUserLabel = source.readInt();
241 int hasApp = source.readInt();
242 if (hasApp != 0) {
243 applicationInfo = ApplicationInfo.CREATOR.createFromParcel(source);
244 }
245 gids = source.createIntArray();
246 activities = source.createTypedArray(ActivityInfo.CREATOR);
247 receivers = source.createTypedArray(ActivityInfo.CREATOR);
248 services = source.createTypedArray(ServiceInfo.CREATOR);
249 providers = source.createTypedArray(ProviderInfo.CREATOR);
250 instrumentation = source.createTypedArray(InstrumentationInfo.CREATOR);
251 permissions = source.createTypedArray(PermissionInfo.CREATOR);
252 requestedPermissions = source.createStringArray();
253 signatures = source.createTypedArray(Signature.CREATOR);
254 configPreferences = source.createTypedArray(ConfigurationInfo.CREATOR);
Dianne Hackborn49237342009-08-27 20:08:01 -0700255 reqFeatures = source.createTypedArray(FeatureInfo.CREATOR);
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800256 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800257 }
258}