blob: 46b08df1a52ec6ea175a30420fe83e3d7c2c0c2a [file] [log] [blame]
Winson01e38f42020-01-24 11:50:11 -08001/*
2 * Copyright (C) 2020 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
17package com.android.server.pm.parsing.pkg;
18
Winson01e38f42020-01-24 11:50:11 -080019import android.annotation.NonNull;
20import android.annotation.Nullable;
21import android.content.Intent;
22import android.content.pm.ApplicationInfo;
23import android.content.pm.PackageInfo;
24import android.content.pm.PackageParser;
25import android.content.pm.PermissionGroupInfo;
26import android.content.pm.SharedLibraryInfo;
Winson01e38f42020-01-24 11:50:11 -080027import android.content.pm.parsing.ParsingPackageRead;
Philip P. Moltmann12ac3f42020-03-05 15:01:29 -080028import android.content.pm.parsing.component.ParsedAttribution;
Winsonf00c7552020-01-28 12:52:01 -080029import android.content.pm.parsing.component.ParsedIntentInfo;
30import android.content.pm.parsing.component.ParsedPermissionGroup;
Winson01e38f42020-01-24 11:50:11 -080031import android.os.Bundle;
32import android.os.Parcelable;
33import android.util.ArraySet;
Winsonf00c7552020-01-28 12:52:01 -080034import android.util.Pair;
Winson01e38f42020-01-24 11:50:11 -080035
36import com.android.internal.R;
37
38import java.security.PublicKey;
39import java.util.List;
40import java.util.Map;
41import java.util.Set;
42import java.util.UUID;
43
44/**
45 * The last state of a package during parsing/install before it is available in
46 * {@link com.android.server.pm.PackageManagerService#mPackages}.
47 *
48 * It is the responsibility of the caller to understand what data is available at what step of the
49 * parsing or install process.
50 *
51 * TODO(b/135203078): Nullability annotations
52 * TODO(b/135203078): Remove get/setAppInfo differences
53 *
54 * @hide
55 */
56public interface AndroidPackage extends PkgAppInfo, PkgPackageInfo, ParsingPackageRead, Parcelable {
57
Winson01e38f42020-01-24 11:50:11 -080058 /**
59 * The names of packages to adopt ownership of permissions from, parsed under
60 * {@link PackageParser#TAG_ADOPT_PERMISSIONS}.
61 * @see R.styleable#AndroidManifestOriginalPackage_name
62 */
63 @NonNull
64 List<String> getAdoptPermissions();
65
66 /** Path of base APK */
67 @NonNull
68 String getBaseCodePath();
69
70 /** Revision code of base APK */
71 int getBaseRevisionCode();
72
73 /**
74 * Path where this package was found on disk. For monolithic packages
75 * this is path to single base APK file; for cluster packages this is
76 * path to the cluster directory.
77 */
78 @NonNull
79 String getCodePath();
80
81 /**
Winson01e38f42020-01-24 11:50:11 -080082 * Permissions requested but not in the manifest. These may have been split or migrated from
83 * previous versions/definitions.
84 */
85 @NonNull
86 List<String> getImplicitPermissions();
87
88 /**
89 * For use with {@link com.android.server.pm.KeySetManagerService}. Parsed in
90 * {@link PackageParser#TAG_KEY_SETS}.
91 * @see R.styleable#AndroidManifestKeySet
92 * @see R.styleable#AndroidManifestPublicKey
93 */
94 @NonNull
95 Map<String, ArraySet<PublicKey>> getKeySetMapping();
96
97 /**
98 * Library names this package is declared as, for use by other packages with "uses-library".
99 * @see R.styleable#AndroidManifestLibrary
100 */
101 @NonNull
102 List<String> getLibraryNames();
103
104 /**
105 * The package name as declared in the manifest, since the package can be renamed. For example,
106 * static shared libs use synthetic package names.
107 */
108 @NonNull
109 String getManifestPackageName();
110
111 /**
112 * We store the application meta-data independently to avoid multiple unwanted references
113 * TODO(b/135203078): What does this comment mean?
114 * TODO(b/135203078): Make all the Bundles immutable (and non-null by shared empty reference?)
115 */
116 @Nullable
117 Bundle getMetaData();
118
119 /**
120 * For system use to migrate from an old package name to a new one, moving over data
121 * if available.
122 * @see R.styleable#AndroidManifestOriginalPackage}
123 */
124 @NonNull
125 List<String> getOriginalPackages();
126
127 /**
128 * Map of overlayable name to actor name.
129 */
130 @NonNull
131 Map<String, String> getOverlayables();
132
133 /**
134 * The name of the package as used to identify it in the system. This may be adjusted by the
135 * system from the value declared in the manifest, and may not correspond to a Java code
136 * package.
137 * @see ApplicationInfo#packageName
138 * @see PackageInfo#packageName
139 */
140 @NonNull
141 String getPackageName();
142
143 /**
144 * @see PermissionGroupInfo
145 */
146 @NonNull
147 List<ParsedPermissionGroup> getPermissionGroups();
148
Winsone23ae202020-01-24 11:56:44 -0800149 @NonNull
Philip P. Moltmann12ac3f42020-03-05 15:01:29 -0800150 List<ParsedAttribution> getAttributions();
Winson01e38f42020-01-24 11:50:11 -0800151
152 /**
153 * Used to determine the default preferred handler of an {@link Intent}.
154 *
155 * Map of component className to intent info inside that component.
156 * TODO(b/135203078): Is this actually used/working?
157 */
158 @NonNull
Winsonf00c7552020-01-28 12:52:01 -0800159 List<Pair<String, ParsedIntentInfo>> getPreferredActivityFilters();
Winson01e38f42020-01-24 11:50:11 -0800160
161 /**
162 * System protected broadcasts.
163 * @see R.styleable#AndroidManifestProtectedBroadcast
164 */
165 @NonNull
166 List<String> getProtectedBroadcasts();
167
168 /**
169 * Intents that this package may query or require and thus requires visibility into.
170 * @see R.styleable#AndroidManifestQueriesIntent
171 */
172 @NonNull
173 List<Intent> getQueriesIntents();
174
175 /**
176 * Other packages that this package may query or require and thus requires visibility into.
177 * @see R.styleable#AndroidManifestQueriesPackage
178 */
179 @NonNull
180 List<String> getQueriesPackages();
181
182 /**
183 * If a system app declares {@link #getOriginalPackages()}, and the app was previously installed
184 * under one of those original package names, the {@link #getPackageName()} system identifier
185 * will be changed to that previously installed name. This will then be non-null, set to the
186 * manifest package name, for tracking the package under its true name.
187 *
188 * TODO(b/135203078): Remove this in favor of checking originalPackages.isEmpty and
189 * getManifestPackageName
190 */
191 @Nullable
192 String getRealPackage();
193
194 /**
195 * SHA-512 hash of the only APK that can be used to update a system package.
196 * @see R.styleable#AndroidManifestRestrictUpdate
197 */
198 @Nullable
199 byte[] getRestrictUpdateHash();
200
201 /**
202 * The signature data of all APKs in this package, which must be exactly the same across the
203 * base and splits.
204 */
205 PackageParser.SigningDetails getSigningDetails();
206
207 /**
208 * TODO(b/135203078): Move split stuff to an inner data class
209 * @see ApplicationInfo#splitNames
210 * @see PackageInfo#splitNames
211 */
212 @Nullable
213 String[] getSplitNames();
214
215 /** Flags of any split APKs; ordered by parsed splitName */
216 @Nullable
217 int[] getSplitFlags();
218
219 /** @see R.styleable#AndroidManifestStaticLibrary_name */
220 @Nullable
221 String getStaticSharedLibName();
222
223 /** @see R.styleable#AndroidManifestStaticLibrary_version */
224 long getStaticSharedLibVersion();
225
226 /**
227 * {@link android.os.storage.StorageManager#convert(String)} version of
228 * {@link #getVolumeUuid()}.
229 * TODO(b/135203078): All usages call toString() on this. Can the string be returned directly,
230 * or does the parsing logic in StorageManager have to run?
231 */
232 UUID getStorageUuid();
233
234 /**
235 * For use with {@link com.android.server.pm.KeySetManagerService}. Parsed in
236 * {@link PackageParser#TAG_KEY_SETS}.
237 * @see R.styleable#AndroidManifestUpgradeKeySet
238 */
239 @NonNull
240 Set<String> getUpgradeKeySets();
241
242 /** @see R.styleable#AndroidManifestUsesLibrary */
243 @NonNull
244 List<String> getUsesLibraries();
245
246 /**
247 * Like {@link #getUsesLibraries()}, but marked optional by setting
248 * {@link R.styleable#AndroidManifestUsesLibrary_required} to false . Application is expected
249 * to handle absence manually.
250 * @see R.styleable#AndroidManifestUsesLibrary
251 */
252 @NonNull
253 List<String> getUsesOptionalLibraries();
254
255 /**
256 * TODO(b/135203078): Move static library stuff to an inner data class
257 * @see R.styleable#AndroidManifestUsesStaticLibrary
258 */
259 @NonNull
260 List<String> getUsesStaticLibraries();
261
262 /** @see R.styleable#AndroidManifestUsesStaticLibrary_certDigest */
263 @Nullable
264 String[][] getUsesStaticLibrariesCertDigests();
265
266 /** @see R.styleable#AndroidManifestUsesStaticLibrary_version */
267 @Nullable
268 long[] getUsesStaticLibrariesVersions();
269
270 /** @see R.styleable#AndroidManifestApplication_forceQueryable */
271 boolean isForceQueryable();
272
273 boolean isCrossProfile();
274
275 /**
276 * The install time abi override to choose 32bit abi's when multiple abi's
277 * are present. This is only meaningfull for multiarch applications.
Winson01e38f42020-01-24 11:50:11 -0800278 */
279 boolean isUse32BitAbi();
280
281 /**
282 * Set if the any of components are visible to instant applications.
283 * @see R.styleable#AndroidManifestActivity_visibleToInstantApps
284 * @see R.styleable#AndroidManifestProvider_visibleToInstantApps
285 * @see R.styleable#AndroidManifestService_visibleToInstantApps
286 */
287 boolean isVisibleToInstantApps();
288
289 /**
290 * Generates an {@link ApplicationInfo} object with only the data available in this object.
291 *
292 * TODO(b/135203078): Actually add this
293 * This does not contain any system or user state data, and should be avoided. Prefer
294 * com.android.server.pm.parsing.PackageInfoUtils#generateApplicationInfo(
295 * AndroidPackage, int, PackageUserState, int, com.android.server.pm.PackageSetting)
296 *
297 * @deprecated Access AndroidPackage fields directly.
298 */
299 @Deprecated
300 @NonNull
301 ApplicationInfo toAppInfoWithoutState();
302
303 /**
304 * TODO(b/135203078): Remove usages?
305 * @return a mock of what the previous package.applicationInfo would've returned for logging
306 * @deprecated don't use this in any new code, just print package name directly
307 */
308 @Deprecated
309 @NonNull
310 String toAppInfoToString();
Winson01e38f42020-01-24 11:50:11 -0800311}