• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 com.android.server.pm.pkg.parsing;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.content.Intent;
22 import android.content.pm.ApplicationInfo;
23 import android.content.pm.PackageManager.Property;
24 import android.content.pm.SigningDetails;
25 import android.os.Bundle;
26 import android.util.ArraySet;
27 import android.util.Pair;
28 import android.util.SparseIntArray;
29 
30 import com.android.server.pm.pkg.component.ParsedApexSystemService;
31 import com.android.server.pm.pkg.component.ParsedAttribution;
32 import com.android.server.pm.pkg.component.ParsedIntentInfo;
33 import com.android.server.pm.pkg.component.ParsedPermissionGroup;
34 import com.android.server.pm.pkg.component.ParsedProcess;
35 import com.android.server.pm.pkg.component.ParsedUsesPermission;
36 
37 import java.security.PublicKey;
38 import java.util.List;
39 import java.util.Map;
40 import java.util.Set;
41 
42 /**
43  * Everything written by {@link ParsingPackage} and readable back.
44  *
45  * @hide
46  */
47 public interface ParsingPackageRead extends PkgWithoutStateAppInfo, PkgWithoutStatePackageInfo,
48         ParsingPackageInternal {
49 
50     /**
51      * The names of packages to adopt ownership of permissions from, parsed under {@link
52      * ParsingPackageUtils#TAG_ADOPT_PERMISSIONS}.
53      *
54      * @see R.styleable#AndroidManifestOriginalPackage_name
55      */
56     @NonNull
getAdoptPermissions()57     List<String> getAdoptPermissions();
58 
59     /**
60      * @see R.styleable#AndroidManifestApexSystemService
61      */
62     @NonNull
getApexSystemServices()63     List<ParsedApexSystemService> getApexSystemServices();
64 
65     @NonNull
getAttributions()66     List<ParsedAttribution> getAttributions();
67 
68     /**
69      * Permissions requested but not in the manifest. These may have been split or migrated from
70      * previous versions/definitions.
71      */
72     @NonNull
getImplicitPermissions()73     List<String> getImplicitPermissions();
74 
75     @NonNull
getUsesPermissions()76     List<ParsedUsesPermission> getUsesPermissions();
77 
78     /**
79      * For use with {@link com.android.server.pm.KeySetManagerService}. Parsed in {@link
80      * ParsingPackageUtils#TAG_KEY_SETS}.
81      *
82      * @see R.styleable#AndroidManifestKeySet
83      * @see R.styleable#AndroidManifestPublicKey
84      */
85     @NonNull
getKeySetMapping()86     Map<String, ArraySet<PublicKey>> getKeySetMapping();
87 
88     /**
89      * Library names this package is declared as, for use by other packages with "uses-library".
90      *
91      * @see R.styleable#AndroidManifestLibrary
92      */
93     @NonNull
getLibraryNames()94     List<String> getLibraryNames();
95 
96     /**
97      * TODO(b/135203078): Make all the Bundles immutable (and non-null by shared empty reference?)
98      */
99     @Nullable
getMetaData()100     Bundle getMetaData();
101 
102     @Nullable
getMimeGroups()103     Set<String> getMimeGroups();
104 
105     /**
106      * @see R.styleable#AndroidManifestExtensionSdk
107      */
108     @Nullable
getMinExtensionVersions()109     SparseIntArray getMinExtensionVersions();
110 
111     /**
112      * For system use to migrate from an old package name to a new one, moving over data if
113      * available.
114      *
115      * @see R.styleable#AndroidManifestOriginalPackage}
116      */
117     @NonNull
getOriginalPackages()118     List<String> getOriginalPackages();
119 
120     /**
121      * Map of overlayable name to actor name.
122      */
123     @NonNull
getOverlayables()124     Map<String, String> getOverlayables();
125 
126     /**
127      * @see android.content.pm.PermissionGroupInfo
128      */
129     @NonNull
getPermissionGroups()130     List<ParsedPermissionGroup> getPermissionGroups();
131 
132     /**
133      * Used to determine the default preferred handler of an {@link Intent}.
134      * <p>
135      * Map of component className to intent info inside that component. TODO(b/135203078): Is this
136      * actually used/working?
137      */
138     @NonNull
getPreferredActivityFilters()139     List<Pair<String, ParsedIntentInfo>> getPreferredActivityFilters();
140 
141     /**
142      * @see android.content.pm.ProcessInfo
143      */
144     @NonNull
getProcesses()145     Map<String, ParsedProcess> getProcesses();
146 
147     /**
148      * System protected broadcasts.
149      *
150      * @see R.styleable#AndroidManifestProtectedBroadcast
151      */
152     @NonNull
getProtectedBroadcasts()153     List<String> getProtectedBroadcasts();
154 
155     /**
156      * Intents that this package may query or require and thus requires visibility into.
157      *
158      * @see R.styleable#AndroidManifestQueriesIntent
159      */
160     @NonNull
getQueriesIntents()161     List<Intent> getQueriesIntents();
162 
163     /**
164      * Other packages that this package may query or require and thus requires visibility into.
165      *
166      * @see R.styleable#AndroidManifestQueriesPackage
167      */
168     @NonNull
getQueriesPackages()169     List<String> getQueriesPackages();
170 
171     /**
172      * Authorities that this package may query or require and thus requires visibility into.
173      *
174      * @see R.styleable#AndroidManifestQueriesProvider
175      */
176     @NonNull
getQueriesProviders()177     Set<String> getQueriesProviders();
178 
179     /**
180      * SHA-512 hash of the only APK that can be used to update a system package.
181      *
182      * @see R.styleable#AndroidManifestRestrictUpdate
183      */
184     @Nullable
getRestrictUpdateHash()185     byte[] getRestrictUpdateHash();
186 
187     /**
188      * The signature data of all APKs in this package, which must be exactly the same across the
189      * base and splits.
190      */
getSigningDetails()191     SigningDetails getSigningDetails();
192 
193     /**
194      * Returns the properties set on the application
195      */
196     @NonNull
getProperties()197     Map<String, Property> getProperties();
198 
199     /**
200      * Flags of any split APKs; ordered by parsed splitName
201      */
202     @Nullable
getSplitFlags()203     int[] getSplitFlags();
204 
205     /**
206      * @see R.styleable#AndroidManifestSdkLibrary_name
207      */
208     @Nullable
getSdkLibName()209     String getSdkLibName();
210 
211     /**
212      * @see R.styleable#AndroidManifestSdkLibrary_versionMajor
213      */
getSdkLibVersionMajor()214     int getSdkLibVersionMajor();
215 
216     /**
217      * @see R.styleable#AndroidManifestStaticLibrary_name
218      */
219     @Nullable
getStaticSharedLibName()220     String getStaticSharedLibName();
221 
222     /**
223      * @see R.styleable#AndroidManifestStaticLibrary_version
224      */
getStaticSharedLibVersion()225     long getStaticSharedLibVersion();
226 
227     /**
228      * For use with {@link com.android.server.pm.KeySetManagerService}. Parsed in {@link
229      * ParsingPackageUtils#TAG_KEY_SETS}.
230      *
231      * @see R.styleable#AndroidManifestUpgradeKeySet
232      */
233     @NonNull
getUpgradeKeySets()234     Set<String> getUpgradeKeySets();
235 
236     /**
237      * @see R.styleable#AndroidManifestUsesLibrary
238      */
239     @NonNull
getUsesLibraries()240     List<String> getUsesLibraries();
241 
242     /**
243      * @see R.styleable#AndroidManifestUsesNativeLibrary
244      */
245     @NonNull
getUsesNativeLibraries()246     List<String> getUsesNativeLibraries();
247 
248     /**
249      * Like {@link #getUsesLibraries()}, but marked optional by setting {@link
250      * R.styleable#AndroidManifestUsesLibrary_required} to false . Application is expected to handle
251      * absence manually.
252      *
253      * @see R.styleable#AndroidManifestUsesLibrary
254      */
255     @NonNull
getUsesOptionalLibraries()256     List<String> getUsesOptionalLibraries();
257 
258     /**
259      * Like {@link #getUsesNativeLibraries()}, but marked optional by setting {@link
260      * R.styleable#AndroidManifestUsesNativeLibrary_required} to false . Application is expected to
261      * handle absence manually.
262      *
263      * @see R.styleable#AndroidManifestUsesNativeLibrary
264      */
265     @NonNull
getUsesOptionalNativeLibraries()266     List<String> getUsesOptionalNativeLibraries();
267 
268     /**
269      * TODO(b/135203078): Move static library stuff to an inner data class
270      *
271      * @see R.styleable#AndroidManifestUsesStaticLibrary
272      */
273     @NonNull
getUsesStaticLibraries()274     List<String> getUsesStaticLibraries();
275 
276     /**
277      * @see R.styleable#AndroidManifestUsesStaticLibrary_certDigest
278      */
279     @Nullable
getUsesStaticLibrariesCertDigests()280     String[][] getUsesStaticLibrariesCertDigests();
281 
282     /**
283      * @see R.styleable#AndroidManifestUsesStaticLibrary_version
284      */
285     @Nullable
getUsesStaticLibrariesVersions()286     long[] getUsesStaticLibrariesVersions();
287 
288     /**
289      * TODO(b/135203078): Move SDK library stuff to an inner data class
290      *
291      * @see R.styleable#AndroidManifestUsesSdkLibrary
292      */
293     @NonNull
getUsesSdkLibraries()294     List<String> getUsesSdkLibraries();
295 
296     /**
297      * @see R.styleable#AndroidManifestUsesSdkLibrary_certDigest
298      */
299     @Nullable
getUsesSdkLibrariesCertDigests()300     String[][] getUsesSdkLibrariesCertDigests();
301 
302     /**
303      * @see R.styleable#AndroidManifestUsesSdkLibrary_versionMajor
304      */
305     @Nullable
getUsesSdkLibrariesVersionsMajor()306     long[] getUsesSdkLibrariesVersionsMajor();
307 
hasPreserveLegacyExternalStorage()308     boolean hasPreserveLegacyExternalStorage();
309 
310     /**
311      * @see R.styleable#AndroidManifestApplication_forceQueryable
312      */
isForceQueryable()313     boolean isForceQueryable();
314 
315     /**
316      * @see ApplicationInfo#FLAG_IS_GAME
317      */
318     @Deprecated
isGame()319     boolean isGame();
320 
321     /**
322      * The install time abi override to choose 32bit abi's when multiple abi's are present. This is
323      * only meaningful for multiarch applications. The use32bitAbi attribute is ignored if
324      * cpuAbiOverride is also set.
325      *
326      * @see R.attr#use32bitAbi
327      */
isUse32BitAbi()328     boolean isUse32BitAbi();
329 
330     /**
331      * Set if the any of components are visible to instant applications.
332      *
333      * @see R.styleable#AndroidManifestActivity_visibleToInstantApps
334      * @see R.styleable#AndroidManifestProvider_visibleToInstantApps
335      * @see R.styleable#AndroidManifestService_visibleToInstantApps
336      */
isVisibleToInstantApps()337     boolean isVisibleToInstantApps();
338 
339     /**
340      * Whether the enabled settings of components in the application should be reset to the default,
341      * when the application's user data is cleared.
342      *
343      * @see R.styleable#AndroidManifestApplication_resetEnabledSettingsOnAppDataCleared
344      */
isResetEnabledSettingsOnAppDataCleared()345     boolean isResetEnabledSettingsOnAppDataCleared();
346 
347     /**
348      * The resource ID used to provide the application's locales configuration.
349      *
350      * @see R.styleable#AndroidManifestApplication_localeConfig
351      */
getLocaleConfigRes()352     int getLocaleConfigRes();
353 
354     /**
355      * @see R.styleable.AndroidManifestApplication_enableOnBackInvokedCallback
356      */
isOnBackInvokedCallbackEnabled()357     boolean isOnBackInvokedCallbackEnabled();
358 
359     /**
360      * Returns true if R.styleable#AndroidManifest_sharedUserMaxSdkVersion is set to a value
361      * smaller than the current SDK version.
362      * @see R.styleable#AndroidManifest_sharedUserMaxSdkVersion
363      */
isLeavingSharedUid()364     boolean isLeavingSharedUid();
365 }
366