1 /*
2 **
3 ** Copyright 2007, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 **     http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17 
18 package android.content.pm;
19 
20 import android.content.ComponentName;
21 import android.content.Intent;
22 import android.content.IntentFilter;
23 import android.content.pm.ActivityInfo;
24 import android.content.pm.ApplicationInfo;
25 import android.content.pm.ChangedPackages;
26 import android.content.pm.InstantAppInfo;
27 import android.content.pm.FeatureInfo;
28 import android.content.pm.IDexModuleRegisterCallback;
29 import android.content.pm.InstallSourceInfo;
30 import android.content.pm.IOnChecksumsReadyListener;
31 import android.content.pm.IPackageInstaller;
32 import android.content.pm.IPackageDeleteObserver;
33 import android.content.pm.IPackageDeleteObserver2;
34 import android.content.pm.IPackageDataObserver;
35 import android.content.pm.IPackageMoveObserver;
36 import android.content.pm.IPackageStatsObserver;
37 import android.content.pm.IntentFilterVerificationInfo;
38 import android.content.pm.InstrumentationInfo;
39 import android.content.pm.KeySet;
40 import android.content.pm.ModuleInfo;
41 import android.content.pm.PackageInfo;
42 import android.content.pm.PackageManager;
43 import android.content.pm.PackageManager.ComponentEnabledSetting;
44 import android.content.pm.ParceledListSlice;
45 import android.content.pm.ProviderInfo;
46 import android.content.pm.PermissionGroupInfo;
47 import android.content.pm.PermissionInfo;
48 import android.content.pm.ResolveInfo;
49 import android.content.pm.ServiceInfo;
50 import android.content.pm.SuspendDialogInfo;
51 import android.content.pm.UserInfo;
52 import android.content.pm.VerifierDeviceIdentity;
53 import android.content.pm.VersionedPackage;
54 import android.content.pm.dex.IArtManager;
55 import android.graphics.Bitmap;
56 import android.net.Uri;
57 import android.os.Bundle;
58 import android.os.ParcelFileDescriptor;
59 import android.os.PersistableBundle;
60 import android.content.IntentSender;
61 
62 /**
63  *  See {@link PackageManager} for documentation on most of the APIs
64  *  here.
65  *
66  *  {@hide}
67  */
68 interface IPackageManager {
checkPackageStartable(String packageName, int userId)69     void checkPackageStartable(String packageName, int userId);
70     @UnsupportedAppUsage(trackingBug = 171933273)
isPackageAvailable(String packageName, int userId)71     boolean isPackageAvailable(String packageName, int userId);
getPackageInfo(String packageName, long flags, int userId)72     PackageInfo getPackageInfo(String packageName, long flags, int userId);
getPackageInfoVersioned(in VersionedPackage versionedPackage, long flags, int userId)73     PackageInfo getPackageInfoVersioned(in VersionedPackage versionedPackage,
74             long flags, int userId);
getPackageUid(String packageName, long flags, int userId)75     int getPackageUid(String packageName, long flags, int userId);
getPackageGids(String packageName, long flags, int userId)76     int[] getPackageGids(String packageName, long flags, int userId);
77 
78     @UnsupportedAppUsage
currentToCanonicalPackageNames(in String[] names)79     String[] currentToCanonicalPackageNames(in String[] names);
80     @UnsupportedAppUsage
canonicalToCurrentPackageNames(in String[] names)81     String[] canonicalToCurrentPackageNames(in String[] names);
82 
getApplicationInfo(String packageName, long flags, int userId)83     ApplicationInfo getApplicationInfo(String packageName, long flags, int userId);
84 
85     /**
86      * @return the target SDK for the given package name, or -1 if it cannot be retrieved
87      */
getTargetSdkVersion(String packageName)88     int getTargetSdkVersion(String packageName);
89 
getActivityInfo(in ComponentName className, long flags, int userId)90     ActivityInfo getActivityInfo(in ComponentName className, long flags, int userId);
91 
activitySupportsIntentAsUser(in ComponentName className, in Intent intent, String resolvedType, int userId)92     boolean activitySupportsIntentAsUser(in ComponentName className, in Intent intent,
93             String resolvedType, int userId);
94 
getReceiverInfo(in ComponentName className, long flags, int userId)95     ActivityInfo getReceiverInfo(in ComponentName className, long flags, int userId);
96 
getServiceInfo(in ComponentName className, long flags, int userId)97     ServiceInfo getServiceInfo(in ComponentName className, long flags, int userId);
98 
getProviderInfo(in ComponentName className, long flags, int userId)99     ProviderInfo getProviderInfo(in ComponentName className, long flags, int userId);
100 
isProtectedBroadcast(String actionName)101     boolean isProtectedBroadcast(String actionName);
102 
checkSignatures(String pkg1, String pkg2, int userId)103     int checkSignatures(String pkg1, String pkg2, int userId);
104 
105     @UnsupportedAppUsage
checkUidSignatures(int uid1, int uid2)106     int checkUidSignatures(int uid1, int uid2);
107 
getAllPackages()108     List<String> getAllPackages();
109 
110     @UnsupportedAppUsage
getPackagesForUid(int uid)111     String[] getPackagesForUid(int uid);
112 
113     @UnsupportedAppUsage
getNameForUid(int uid)114     String getNameForUid(int uid);
getNamesForUids(in int[] uids)115     String[] getNamesForUids(in int[] uids);
116 
117     @UnsupportedAppUsage
getUidForSharedUser(String sharedUserName)118     int getUidForSharedUser(String sharedUserName);
119 
120     @UnsupportedAppUsage
getFlagsForUid(int uid)121     int getFlagsForUid(int uid);
122 
getPrivateFlagsForUid(int uid)123     int getPrivateFlagsForUid(int uid);
124 
125     @UnsupportedAppUsage
isUidPrivileged(int uid)126     boolean isUidPrivileged(int uid);
127 
resolveIntent(in Intent intent, String resolvedType, long flags, int userId)128     ResolveInfo resolveIntent(in Intent intent, String resolvedType, long flags, int userId);
129 
findPersistentPreferredActivity(in Intent intent, int userId)130     ResolveInfo findPersistentPreferredActivity(in Intent intent, int userId);
131 
canForwardTo(in Intent intent, String resolvedType, int sourceUserId, int targetUserId)132     boolean canForwardTo(in Intent intent, String resolvedType, int sourceUserId, int targetUserId);
133 
queryIntentActivities(in Intent intent, String resolvedType, long flags, int userId)134     ParceledListSlice queryIntentActivities(in Intent intent,
135             String resolvedType, long flags, int userId);
136 
queryIntentActivityOptions( in ComponentName caller, in Intent[] specifics, in String[] specificTypes, in Intent intent, String resolvedType, long flags, int userId)137     ParceledListSlice queryIntentActivityOptions(
138             in ComponentName caller, in Intent[] specifics,
139             in String[] specificTypes, in Intent intent,
140             String resolvedType, long flags, int userId);
141 
queryIntentReceivers(in Intent intent, String resolvedType, long flags, int userId)142     ParceledListSlice queryIntentReceivers(in Intent intent,
143             String resolvedType, long flags, int userId);
144 
resolveService(in Intent intent, String resolvedType, long flags, int userId)145     ResolveInfo resolveService(in Intent intent,
146             String resolvedType, long flags, int userId);
147 
queryIntentServices(in Intent intent, String resolvedType, long flags, int userId)148     ParceledListSlice queryIntentServices(in Intent intent,
149             String resolvedType, long flags, int userId);
150 
queryIntentContentProviders(in Intent intent, String resolvedType, long flags, int userId)151     ParceledListSlice queryIntentContentProviders(in Intent intent,
152             String resolvedType, long flags, int userId);
153 
154     /**
155      * This implements getInstalledPackages via a "last returned row"
156      * mechanism that is not exposed in the API. This is to get around the IPC
157      * limit that kicks in when flags are included that bloat up the data
158      * returned.
159      */
getInstalledPackages(long flags, in int userId)160     ParceledListSlice getInstalledPackages(long flags, in int userId);
161 
getAppMetadataFd(String packageName, int userId)162     @nullable ParcelFileDescriptor getAppMetadataFd(String packageName,
163                 int userId);
164 
165     /**
166      * This implements getPackagesHoldingPermissions via a "last returned row"
167      * mechanism that is not exposed in the API. This is to get around the IPC
168      * limit that kicks in when flags are included that bloat up the data
169      * returned.
170      */
getPackagesHoldingPermissions(in String[] permissions, long flags, int userId)171     ParceledListSlice getPackagesHoldingPermissions(in String[] permissions,
172             long flags, int userId);
173 
174     /**
175      * This implements getInstalledApplications via a "last returned row"
176      * mechanism that is not exposed in the API. This is to get around the IPC
177      * limit that kicks in when flags are included that bloat up the data
178      * returned.
179      */
getInstalledApplications(long flags, int userId)180     ParceledListSlice getInstalledApplications(long flags, int userId);
181 
182     /**
183      * Retrieve all applications that are marked as persistent.
184      *
185      * @return A List<ApplicationInfo> containing one entry for each persistent
186      *         application.
187      */
getPersistentApplications(int flags)188     ParceledListSlice getPersistentApplications(int flags);
189 
resolveContentProvider(String name, long flags, int userId)190     ProviderInfo resolveContentProvider(String name, long flags, int userId);
191 
192     /**
193      * Retrieve sync information for all content providers.
194      *
195      * @param outNames Filled in with a list of the root names of the content
196      *                 providers that can sync.
197      * @param outInfo Filled in with a list of the ProviderInfo for each
198      *                name in 'outNames'.
199      */
200     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
querySyncProviders(inout List<String> outNames, inout List<ProviderInfo> outInfo)201     void querySyncProviders(inout List<String> outNames,
202             inout List<ProviderInfo> outInfo);
203 
queryContentProviders( String processName, int uid, long flags, String metaDataKey)204     ParceledListSlice queryContentProviders(
205             String processName, int uid, long flags, String metaDataKey);
206 
getInstrumentationInfoAsUser( in ComponentName className, int flags, int userId)207     InstrumentationInfo getInstrumentationInfoAsUser(
208             in ComponentName className, int flags, int userId);
209 
queryInstrumentationAsUser( String targetPackage, int flags, int userId)210     ParceledListSlice queryInstrumentationAsUser(
211             String targetPackage, int flags, int userId);
212 
finishPackageInstall(int token, boolean didLaunch)213     void finishPackageInstall(int token, boolean didLaunch);
214 
215     @UnsupportedAppUsage
setInstallerPackageName(in String targetPackage, in String installerPackageName)216     void setInstallerPackageName(in String targetPackage, in String installerPackageName);
217 
relinquishUpdateOwnership(in String targetPackage)218     void relinquishUpdateOwnership(in String targetPackage);
219 
setApplicationCategoryHint(String packageName, int categoryHint, String callerPackageName)220     void setApplicationCategoryHint(String packageName, int categoryHint, String callerPackageName);
221 
222     /** @deprecated rawr, don't call AIDL methods directly! */
deletePackageAsUser(in String packageName, int versionCode, IPackageDeleteObserver observer, int userId, int flags)223     void deletePackageAsUser(in String packageName, int versionCode,
224             IPackageDeleteObserver observer, int userId, int flags);
225 
226     /**
227      * Delete a package for a specific user.
228      *
229      * @param versionedPackage The package to delete.
230      * @param observer a callback to use to notify when the package deletion in finished.
231      * @param userId the id of the user for whom to delete the package
232      * @param flags - possible values: {@link #DELETE_KEEP_DATA}
233      */
deletePackageVersioned(in VersionedPackage versionedPackage, IPackageDeleteObserver2 observer, int userId, int flags)234     void deletePackageVersioned(in VersionedPackage versionedPackage,
235             IPackageDeleteObserver2 observer, int userId, int flags);
236 
237     /**
238      * Delete a package for a specific user.
239      *
240      * @param versionedPackage The package to delete.
241      * @param observer a callback to use to notify when the package deletion in finished.
242      * @param userId the id of the user for whom to delete the package
243      */
deleteExistingPackageAsUser(in VersionedPackage versionedPackage, IPackageDeleteObserver2 observer, int userId)244     void deleteExistingPackageAsUser(in VersionedPackage versionedPackage,
245             IPackageDeleteObserver2 observer, int userId);
246 
247     @UnsupportedAppUsage
getInstallerPackageName(in String packageName)248     String getInstallerPackageName(in String packageName);
249 
getInstallSourceInfo(in String packageName, int userId)250     InstallSourceInfo getInstallSourceInfo(in String packageName, int userId);
251 
resetApplicationPreferences(int userId)252     void resetApplicationPreferences(int userId);
253 
254     @UnsupportedAppUsage
getLastChosenActivity(in Intent intent, String resolvedType, int flags)255     ResolveInfo getLastChosenActivity(in Intent intent,
256             String resolvedType, int flags);
257 
258     @UnsupportedAppUsage
setLastChosenActivity(in Intent intent, String resolvedType, int flags, in IntentFilter filter, int match, in ComponentName activity)259     void setLastChosenActivity(in Intent intent, String resolvedType, int flags,
260             in IntentFilter filter, int match, in ComponentName activity);
261 
addPreferredActivity(in IntentFilter filter, int match, in ComponentName[] set, in ComponentName activity, int userId, boolean removeExisting)262     void addPreferredActivity(in IntentFilter filter, int match,
263             in ComponentName[] set, in ComponentName activity, int userId, boolean removeExisting);
264 
265     @UnsupportedAppUsage
replacePreferredActivity(in IntentFilter filter, int match, in ComponentName[] set, in ComponentName activity, int userId)266     void replacePreferredActivity(in IntentFilter filter, int match,
267             in ComponentName[] set, in ComponentName activity, int userId);
268 
269     @UnsupportedAppUsage
clearPackagePreferredActivities(String packageName)270     void clearPackagePreferredActivities(String packageName);
271 
272     @UnsupportedAppUsage
getPreferredActivities(out List<IntentFilter> outFilters, out List<ComponentName> outActivities, String packageName)273     int getPreferredActivities(out List<IntentFilter> outFilters,
274             out List<ComponentName> outActivities, String packageName);
275 
addPersistentPreferredActivity(in IntentFilter filter, in ComponentName activity, int userId)276     void addPersistentPreferredActivity(in IntentFilter filter, in ComponentName activity, int userId);
277 
clearPackagePersistentPreferredActivities(String packageName, int userId)278     void clearPackagePersistentPreferredActivities(String packageName, int userId);
279 
clearPersistentPreferredActivity(in IntentFilter filter, int userId)280     void clearPersistentPreferredActivity(in IntentFilter filter, int userId);
281 
addCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage, int sourceUserId, int targetUserId, int flags)282     void addCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage,
283             int sourceUserId, int targetUserId, int flags);
284 
removeCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage, int sourceUserId, int targetUserId, int flags)285     boolean removeCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage,
286                 int sourceUserId, int targetUserId, int flags);
287 
clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage)288     void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage);
289 
setDistractingPackageRestrictionsAsUser(in String[] packageNames, int restrictionFlags, int userId)290     String[] setDistractingPackageRestrictionsAsUser(in String[] packageNames, int restrictionFlags,
291             int userId);
292 
setPackagesSuspendedAsUser(in String[] packageNames, boolean suspended, in PersistableBundle appExtras, in PersistableBundle launcherExtras, in SuspendDialogInfo dialogInfo, String callingPackage, int userId)293     String[] setPackagesSuspendedAsUser(in String[] packageNames, boolean suspended,
294             in PersistableBundle appExtras, in PersistableBundle launcherExtras,
295             in SuspendDialogInfo dialogInfo, String callingPackage, int userId);
296 
getUnsuspendablePackagesForUser(in String[] packageNames, int userId)297     String[] getUnsuspendablePackagesForUser(in String[] packageNames, int userId);
298 
isPackageSuspendedForUser(String packageName, int userId)299     boolean isPackageSuspendedForUser(String packageName, int userId);
300 
getSuspendedPackageAppExtras(String packageName, int userId)301     Bundle getSuspendedPackageAppExtras(String packageName, int userId);
302 
303     /**
304      * Backup/restore support - only the system uid may use these.
305      */
getPreferredActivityBackup(int userId)306     byte[] getPreferredActivityBackup(int userId);
restorePreferredActivities(in byte[] backup, int userId)307     void restorePreferredActivities(in byte[] backup, int userId);
getDefaultAppsBackup(int userId)308     byte[] getDefaultAppsBackup(int userId);
restoreDefaultApps(in byte[] backup, int userId)309     void restoreDefaultApps(in byte[] backup, int userId);
getDomainVerificationBackup(int userId)310     byte[] getDomainVerificationBackup(int userId);
restoreDomainVerification(in byte[] backup, int userId)311     void restoreDomainVerification(in byte[] backup, int userId);
312 
313     /**
314      * Report the set of 'Home' activity candidates, plus (if any) which of them
315      * is the current "always use this one" setting.
316      */
317      @UnsupportedAppUsage
getHomeActivities(out List<ResolveInfo> outHomeCandidates)318      ComponentName getHomeActivities(out List<ResolveInfo> outHomeCandidates);
319 
setHomeActivity(in ComponentName className, int userId)320     void setHomeActivity(in ComponentName className, int userId);
321 
322     /**
323      * Overrides the label and icon of the component specified by the component name. The component
324      * must belong to the calling app.
325      *
326      * These changes will be reset on the next boot and whenever the package is updated.
327      *
328      * Only the app defined as com.android.internal.R.config_overrideComponentUiPackage is allowed
329      * to call this.
330      *
331      * @param componentName The component name to override the label/icon of.
332      * @param nonLocalizedLabel The label to be displayed.
333      * @param icon The icon to be displayed.
334      * @param userId The user id.
335      */
overrideLabelAndIcon(in ComponentName componentName, String nonLocalizedLabel, int icon, int userId)336     void overrideLabelAndIcon(in ComponentName componentName, String nonLocalizedLabel,
337             int icon, int userId);
338 
339     /**
340      * Restores the label and icon of the activity specified by the component name if either has
341      * been overridden. The component must belong to the calling app.
342      *
343      * Only the app defined as com.android.internal.R.config_overrideComponentUiPackage is allowed
344      * to call this.
345      *
346      * @param componentName The component name.
347      * @param userId The user id.
348      */
restoreLabelAndIcon(in ComponentName componentName, int userId)349     void restoreLabelAndIcon(in ComponentName componentName, int userId);
350 
351     /**
352      * As per {@link android.content.pm.PackageManager#setComponentEnabledSetting}.
353      */
354     @UnsupportedAppUsage
setComponentEnabledSetting(in ComponentName componentName, in int newState, in int flags, int userId, String callingPackage)355     void setComponentEnabledSetting(in ComponentName componentName,
356             in int newState, in int flags, int userId, String callingPackage);
357 
358     /**
359      * As per {@link android.content.pm.PackageManager#setComponentEnabledSettings}.
360      */
setComponentEnabledSettings(in List<ComponentEnabledSetting> settings, int userId, String callingPackage)361     void setComponentEnabledSettings(in List<ComponentEnabledSetting> settings, int userId,
362             String callingPackage);
363 
364     /**
365      * As per {@link android.content.pm.PackageManager#getComponentEnabledSetting}.
366      */
367     @UnsupportedAppUsage
getComponentEnabledSetting(in ComponentName componentName, int userId)368     int getComponentEnabledSetting(in ComponentName componentName, int userId);
369 
370     /**
371      * As per {@link android.content.pm.PackageManager#setApplicationEnabledSetting}.
372      */
373     @UnsupportedAppUsage
setApplicationEnabledSetting(in String packageName, in int newState, int flags, int userId, String callingPackage)374     void setApplicationEnabledSetting(in String packageName, in int newState, int flags,
375             int userId, String callingPackage);
376 
377     /**
378      * As per {@link android.content.pm.PackageManager#getApplicationEnabledSetting}.
379      */
380     @UnsupportedAppUsage
getApplicationEnabledSetting(in String packageName, int userId)381     int getApplicationEnabledSetting(in String packageName, int userId);
382 
383     /**
384      * Logs process start information (including APK hash) to the security log.
385      */
logAppProcessStartIfNeeded(String packageName, String processName, int uid, String seinfo, String apkFile, int pid)386     void logAppProcessStartIfNeeded(String packageName, String processName, int uid, String seinfo, String apkFile, int pid);
387 
388     /**
389      * As per {@link android.content.pm.PackageManager#flushPackageRestrictionsAsUser}.
390      */
flushPackageRestrictionsAsUser(in int userId)391     void flushPackageRestrictionsAsUser(in int userId);
392 
393     /**
394      * Set whether the given package should be considered stopped, making
395      * it not visible to implicit intents that filter out stopped packages.
396      */
397     @UnsupportedAppUsage
setPackageStoppedState(String packageName, boolean stopped, int userId)398     void setPackageStoppedState(String packageName, boolean stopped, int userId);
399 
400     /**
401      * Free storage by deleting LRU sorted list of cache files across
402      * all applications. If the currently available free storage
403      * on the device is greater than or equal to the requested
404      * free storage, no cache files are cleared. If the currently
405      * available storage on the device is less than the requested
406      * free storage, some or all of the cache files across
407      * all applications are deleted (based on last accessed time)
408      * to increase the free storage space on the device to
409      * the requested value. There is no guarantee that clearing all
410      * the cache files from all applications will clear up
411      * enough storage to achieve the desired value.
412      * @param freeStorageSize The number of bytes of storage to be
413      * freed by the system. Say if freeStorageSize is XX,
414      * and the current free storage is YY,
415      * if XX is less than YY, just return. if not free XX-YY number
416      * of bytes if possible.
417      * @param observer call back used to notify when
418      * the operation is completed
419      */
freeStorageAndNotify(in String volumeUuid, in long freeStorageSize, int storageFlags, IPackageDataObserver observer)420      void freeStorageAndNotify(in String volumeUuid, in long freeStorageSize,
421              int storageFlags, IPackageDataObserver observer);
422 
423     /**
424      * Free storage by deleting LRU sorted list of cache files across
425      * all applications. If the currently available free storage
426      * on the device is greater than or equal to the requested
427      * free storage, no cache files are cleared. If the currently
428      * available storage on the device is less than the requested
429      * free storage, some or all of the cache files across
430      * all applications are deleted (based on last accessed time)
431      * to increase the free storage space on the device to
432      * the requested value. There is no guarantee that clearing all
433      * the cache files from all applications will clear up
434      * enough storage to achieve the desired value.
435      * @param freeStorageSize The number of bytes of storage to be
436      * freed by the system. Say if freeStorageSize is XX,
437      * and the current free storage is YY,
438      * if XX is less than YY, just return. if not free XX-YY number
439      * of bytes if possible.
440      * @param pi IntentSender call back used to
441      * notify when the operation is completed.May be null
442      * to indicate that no call back is desired.
443      */
freeStorage(in String volumeUuid, in long freeStorageSize, int storageFlags, in IntentSender pi)444      void freeStorage(in String volumeUuid, in long freeStorageSize,
445              int storageFlags, in IntentSender pi);
446 
447     /**
448      * Delete all the cache files in an applications cache directory
449      * @param packageName The package name of the application whose cache
450      * files need to be deleted
451      * @param observer a callback used to notify when the deletion is finished.
452      */
453     @UnsupportedAppUsage
deleteApplicationCacheFiles(in String packageName, IPackageDataObserver observer)454     void deleteApplicationCacheFiles(in String packageName, IPackageDataObserver observer);
455 
456     /**
457      * Delete all the cache files in an applications cache directory
458      * @param packageName The package name of the application whose cache
459      * files need to be deleted
460      * @param userId the user to delete application cache for
461      * @param observer a callback used to notify when the deletion is finished.
462      */
deleteApplicationCacheFilesAsUser(in String packageName, int userId, IPackageDataObserver observer)463     void deleteApplicationCacheFilesAsUser(in String packageName, int userId, IPackageDataObserver observer);
464 
465     /**
466      * Clear the user data directory of an application.
467      * @param packageName The package name of the application whose cache
468      * files need to be deleted
469      * @param observer a callback used to notify when the operation is completed.
470      */
clearApplicationUserData(in String packageName, IPackageDataObserver observer, int userId)471     void clearApplicationUserData(in String packageName, IPackageDataObserver observer, int userId);
472 
473     /**
474      * Clear the profile data of an application.
475      * @param packageName The package name of the application whose profile data
476      * need to be deleted
477      */
clearApplicationProfileData(in String packageName)478     void clearApplicationProfileData(in String packageName);
479 
480    /**
481      * Get package statistics including the code, data and cache size for
482      * an already installed package
483      * @param packageName The package name of the application
484      * @param userHandle Which user the size should be retrieved for
485      * @param observer a callback to use to notify when the asynchronous
486      * retrieval of information is complete.
487      */
getPackageSizeInfo(in String packageName, int userHandle, IPackageStatsObserver observer)488     void getPackageSizeInfo(in String packageName, int userHandle, IPackageStatsObserver observer);
489 
490     /**
491      * Get a list of shared libraries that are available on the
492      * system.
493      */
494     @UnsupportedAppUsage
getSystemSharedLibraryNames()495     String[] getSystemSharedLibraryNames();
496 
497     /**
498      * Get a list of features that are available on the
499      * system.
500      */
getSystemAvailableFeatures()501     ParceledListSlice getSystemAvailableFeatures();
502 
hasSystemFeature(String name, int version)503     boolean hasSystemFeature(String name, int version);
504 
getInitialNonStoppedSystemPackages()505     List<String> getInitialNonStoppedSystemPackages();
506 
enterSafeMode()507     void enterSafeMode();
508     @UnsupportedAppUsage
isSafeMode()509     boolean isSafeMode();
510     @UnsupportedAppUsage
hasSystemUidErrors()511     boolean hasSystemUidErrors();
512 
513     /**
514      * Notify the package manager that a package is going to be used and why.
515      *
516      * See PackageManager.NOTIFY_PACKAGE_USE_* for reasons.
517      */
notifyPackageUse(String packageName, int reason)518     oneway void notifyPackageUse(String packageName, int reason);
519 
520     /**
521      * Notify the package manager that a list of dex files have been loaded.
522      *
523      * @param loadingPackageName the name of the package who performs the load
524      * @param classLoaderContextMap a map from file paths to dex files that have been loaded to
525      *     the class loader context that was used to load them.
526      * @param loaderIsa the ISA of the loader process
527      */
notifyDexLoad(String loadingPackageName, in Map<String, String> classLoaderContextMap, String loaderIsa)528     oneway void notifyDexLoad(String loadingPackageName,
529             in Map<String, String> classLoaderContextMap, String loaderIsa);
530 
531     /**
532      * Register an application dex module with the package manager.
533      * The package manager will keep track of the given module for future optimizations.
534      *
535      * Dex module optimizations will disable the classpath checking at runtime. The client bares
536      * the responsibility to ensure that the static assumptions on classes in the optimized code
537      * hold at runtime (e.g. there's no duplicate classes in the classpath).
538      *
539      * Note that the package manager already keeps track of dex modules loaded with
540      * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}.
541      * This can be called for an eager registration.
542      *
543      * The call might take a while and the results will be posted on the main thread, using
544      * the given callback.
545      *
546      * If the module is intended to be shared with other apps, make sure that the file
547      * permissions allow for it.
548      * If at registration time the permissions allow for others to read it, the module would
549      * be marked as a shared module which might undergo a different optimization strategy.
550      * (usually shared modules will generated larger optimizations artifacts,
551      * taking more disk space).
552      *
553      * @param packageName the package name to which the dex module belongs
554      * @param dexModulePath the absolute path of the dex module.
555      * @param isSharedModule whether or not the module is intended to be used by other apps.
556      * @param callback if not null,
557      *   {@link android.content.pm.IDexModuleRegisterCallback.IDexModuleRegisterCallback#onDexModuleRegistered}
558      *   will be called once the registration finishes.
559      */
registerDexModule(in String packageName, in String dexModulePath, in boolean isSharedModule, IDexModuleRegisterCallback callback)560      oneway void registerDexModule(in String packageName, in String dexModulePath,
561              in boolean isSharedModule, IDexModuleRegisterCallback callback);
562 
563     /**
564      * Ask the package manager to perform a dex-opt with the given compiler filter.
565      *
566      * Note: exposed only for the shell command to allow moving packages explicitly to a
567      *       definite state.
568      */
performDexOptMode(String packageName, boolean checkProfiles, String targetCompilerFilter, boolean force, boolean bootComplete, String splitName)569     boolean performDexOptMode(String packageName, boolean checkProfiles,
570             String targetCompilerFilter, boolean force, boolean bootComplete, String splitName);
571 
572     /**
573      * Ask the package manager to perform a dex-opt with the given compiler filter on the
574      * secondary dex files belonging to the given package.
575      *
576      * Note: exposed only for the shell command to allow moving packages explicitly to a
577      *       definite state.
578      */
performDexOptSecondary(String packageName, String targetCompilerFilter, boolean force)579     boolean performDexOptSecondary(String packageName,
580             String targetCompilerFilter, boolean force);
581 
getMoveStatus(int moveId)582     int getMoveStatus(int moveId);
583 
registerMoveCallback(in IPackageMoveObserver callback)584     void registerMoveCallback(in IPackageMoveObserver callback);
unregisterMoveCallback(in IPackageMoveObserver callback)585     void unregisterMoveCallback(in IPackageMoveObserver callback);
586 
movePackage(in String packageName, in String volumeUuid)587     int movePackage(in String packageName, in String volumeUuid);
movePrimaryStorage(in String volumeUuid)588     int movePrimaryStorage(in String volumeUuid);
589 
setInstallLocation(int loc)590     boolean setInstallLocation(int loc);
591     @UnsupportedAppUsage
getInstallLocation()592     int getInstallLocation();
593 
installExistingPackageAsUser(String packageName, int userId, int installFlags, int installReason, in List<String> whiteListedPermissions)594     int installExistingPackageAsUser(String packageName, int userId, int installFlags,
595             int installReason, in List<String> whiteListedPermissions);
596 
verifyPendingInstall(int id, int verificationCode)597     void verifyPendingInstall(int id, int verificationCode);
extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay)598     void extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay);
599 
600     /** @deprecated */
verifyIntentFilter(int id, int verificationCode, in List<String> failedDomains)601     void verifyIntentFilter(int id, int verificationCode, in List<String> failedDomains);
602     /** @deprecated */
getIntentVerificationStatus(String packageName, int userId)603     int getIntentVerificationStatus(String packageName, int userId);
604     /** @deprecated */
updateIntentVerificationStatus(String packageName, int status, int userId)605     boolean updateIntentVerificationStatus(String packageName, int status, int userId);
606     /** @deprecated */
getIntentFilterVerifications(String packageName)607     ParceledListSlice getIntentFilterVerifications(String packageName);
getAllIntentFilters(String packageName)608     ParceledListSlice getAllIntentFilters(String packageName);
609 
getVerifierDeviceIdentity()610     VerifierDeviceIdentity getVerifierDeviceIdentity();
611 
isFirstBoot()612     boolean isFirstBoot();
isDeviceUpgrading()613     boolean isDeviceUpgrading();
614 
615     /** Reflects current DeviceStorageMonitorService state */
616     @UnsupportedAppUsage
isStorageLow()617     boolean isStorageLow();
618 
619     @UnsupportedAppUsage
setApplicationHiddenSettingAsUser(String packageName, boolean hidden, int userId)620     boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, int userId);
getApplicationHiddenSettingAsUser(String packageName, int userId)621     boolean getApplicationHiddenSettingAsUser(String packageName, int userId);
622 
setSystemAppHiddenUntilInstalled(String packageName, boolean hidden)623     void setSystemAppHiddenUntilInstalled(String packageName, boolean hidden);
setSystemAppInstallState(String packageName, boolean installed, int userId)624     boolean setSystemAppInstallState(String packageName, boolean installed, int userId);
625 
626     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
getPackageInstaller()627     IPackageInstaller getPackageInstaller();
628 
setBlockUninstallForUser(String packageName, boolean blockUninstall, int userId)629     boolean setBlockUninstallForUser(String packageName, boolean blockUninstall, int userId);
630     @UnsupportedAppUsage
getBlockUninstallForUser(String packageName, int userId)631     boolean getBlockUninstallForUser(String packageName, int userId);
632 
getKeySetByAlias(String packageName, String alias)633     KeySet getKeySetByAlias(String packageName, String alias);
getSigningKeySet(String packageName)634     KeySet getSigningKeySet(String packageName);
isPackageSignedByKeySet(String packageName, in KeySet ks)635     boolean isPackageSignedByKeySet(String packageName, in KeySet ks);
isPackageSignedByKeySetExactly(String packageName, in KeySet ks)636     boolean isPackageSignedByKeySetExactly(String packageName, in KeySet ks);
637 
638     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
getPermissionControllerPackageName()639     String getPermissionControllerPackageName();
getSdkSandboxPackageName()640     String getSdkSandboxPackageName();
641 
getInstantApps(int userId)642     ParceledListSlice getInstantApps(int userId);
getInstantAppCookie(String packageName, int userId)643     byte[] getInstantAppCookie(String packageName, int userId);
setInstantAppCookie(String packageName, in byte[] cookie, int userId)644     boolean setInstantAppCookie(String packageName, in byte[] cookie, int userId);
getInstantAppIcon(String packageName, int userId)645     Bitmap getInstantAppIcon(String packageName, int userId);
isInstantApp(String packageName, int userId)646     boolean isInstantApp(String packageName, int userId);
647 
setRequiredForSystemUser(String packageName, boolean systemUserApp)648     boolean setRequiredForSystemUser(String packageName, boolean systemUserApp);
649 
650     /**
651      * Sets whether or not an update is available. Ostensibly for instant apps
652      * to force exteranl resolution.
653      */
setUpdateAvailable(String packageName, boolean updateAvaialble)654     void setUpdateAvailable(String packageName, boolean updateAvaialble);
655 
656     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
getServicesSystemSharedLibraryPackageName()657     String getServicesSystemSharedLibraryPackageName();
658     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
getSharedSystemSharedLibraryPackageName()659     String getSharedSystemSharedLibraryPackageName();
660 
getChangedPackages(int sequenceNumber, int userId)661     ChangedPackages getChangedPackages(int sequenceNumber, int userId);
662 
isPackageDeviceAdminOnAnyUser(String packageName)663     boolean isPackageDeviceAdminOnAnyUser(String packageName);
664 
getInstallReason(String packageName, int userId)665     int getInstallReason(String packageName, int userId);
666 
getSharedLibraries(in String packageName, long flags, int userId)667     ParceledListSlice getSharedLibraries(in String packageName, long flags, int userId);
668 
getDeclaredSharedLibraries(in String packageName, long flags, int userId)669     ParceledListSlice getDeclaredSharedLibraries(in String packageName, long flags, int userId);
670 
canRequestPackageInstalls(String packageName, int userId)671     boolean canRequestPackageInstalls(String packageName, int userId);
672 
deletePreloadsFileCache()673     void deletePreloadsFileCache();
674 
getInstantAppResolverComponent()675     ComponentName getInstantAppResolverComponent();
676 
getInstantAppResolverSettingsComponent()677     ComponentName getInstantAppResolverSettingsComponent();
678 
getInstantAppInstallerComponent()679     ComponentName getInstantAppInstallerComponent();
680 
getInstantAppAndroidId(String packageName, int userId)681     String getInstantAppAndroidId(String packageName, int userId);
682 
getArtManager()683     IArtManager getArtManager();
684 
setHarmfulAppWarning(String packageName, CharSequence warning, int userId)685     void setHarmfulAppWarning(String packageName, CharSequence warning, int userId);
686 
getHarmfulAppWarning(String packageName, int userId)687     CharSequence getHarmfulAppWarning(String packageName, int userId);
688 
hasSigningCertificate(String packageName, in byte[] signingCertificate, int flags)689     boolean hasSigningCertificate(String packageName, in byte[] signingCertificate, int flags);
690 
hasUidSigningCertificate(int uid, in byte[] signingCertificate, int flags)691     boolean hasUidSigningCertificate(int uid, in byte[] signingCertificate, int flags);
692 
getDefaultTextClassifierPackageName()693     String getDefaultTextClassifierPackageName();
694 
getSystemTextClassifierPackageName()695     String getSystemTextClassifierPackageName();
696 
getAttentionServicePackageName()697     String getAttentionServicePackageName();
698 
getRotationResolverPackageName()699     String getRotationResolverPackageName();
700 
getWellbeingPackageName()701     String getWellbeingPackageName();
702 
getAppPredictionServicePackageName()703     String getAppPredictionServicePackageName();
704 
getSystemCaptionsServicePackageName()705     String getSystemCaptionsServicePackageName();
706 
getSetupWizardPackageName()707     String getSetupWizardPackageName();
708 
getIncidentReportApproverPackageName()709     String getIncidentReportApproverPackageName();
710 
isPackageStateProtected(String packageName, int userId)711     boolean isPackageStateProtected(String packageName, int userId);
712 
sendDeviceCustomizationReadyBroadcast()713     void sendDeviceCustomizationReadyBroadcast();
714 
getInstalledModules(int flags)715     List<ModuleInfo> getInstalledModules(int flags);
716 
getModuleInfo(String packageName, int flags)717     ModuleInfo getModuleInfo(String packageName, int flags);
718 
getRuntimePermissionsVersion(int userId)719     int getRuntimePermissionsVersion(int userId);
720 
setRuntimePermissionsVersion(int version, int userId)721     void setRuntimePermissionsVersion(int version, int userId);
722 
notifyPackagesReplacedReceived(in String[] packages)723     void notifyPackagesReplacedReceived(in String[] packages);
724 
requestPackageChecksums(in String packageName, boolean includeSplits, int optional, int required, in List trustedInstallers, in IOnChecksumsReadyListener onChecksumsReadyListener, int userId)725     void requestPackageChecksums(in String packageName, boolean includeSplits, int optional, int required, in List trustedInstallers, in IOnChecksumsReadyListener onChecksumsReadyListener, int userId);
726 
getLaunchIntentSenderForPackage(String packageName, String callingPackage, String featureId, int userId)727     IntentSender getLaunchIntentSenderForPackage(String packageName, String callingPackage,
728                 String featureId, int userId);
729 
730     //------------------------------------------------------------------------
731     //
732     // The following binder interfaces have been moved to IPermissionManager
733     //
734     //------------------------------------------------------------------------
735 
736     //------------------------------------------------------------------------
737     // We need to keep these in IPackageManager for app compatibility
738     //------------------------------------------------------------------------
739     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
getAppOpPermissionPackages(String permissionName, int userId)740     String[] getAppOpPermissionPackages(String permissionName, int userId);
741 
742     @UnsupportedAppUsage
getPermissionGroupInfo(String name, int flags)743     PermissionGroupInfo getPermissionGroupInfo(String name, int flags);
744 
745     @UnsupportedAppUsage
addPermission(in PermissionInfo info)746     boolean addPermission(in PermissionInfo info);
747 
748     @UnsupportedAppUsage
addPermissionAsync(in PermissionInfo info)749     boolean addPermissionAsync(in PermissionInfo info);
750 
751     @UnsupportedAppUsage
removePermission(String name)752     void removePermission(String name);
753 
754     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
checkPermission(String permName, String pkgName, int userId)755     int checkPermission(String permName, String pkgName, int userId);
756 
757     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
grantRuntimePermission(String packageName, String permissionName, int userId)758     void grantRuntimePermission(String packageName, String permissionName, int userId);
759 
760     //------------------------------------------------------------------------
761     // We need to keep these in IPackageManager for convenience in splitting
762     // out the permission manager. This should be cleaned up, but, will require
763     // a large change that modifies many repos.
764     //------------------------------------------------------------------------
checkUidPermission(String permName, int uid)765     int checkUidPermission(String permName, int uid);
766 
setMimeGroup(String packageName, String group, in List<String> mimeTypes)767     void setMimeGroup(String packageName, String group, in List<String> mimeTypes);
768 
getSplashScreenTheme(String packageName, int userId)769     String getSplashScreenTheme(String packageName, int userId);
770 
setSplashScreenTheme(String packageName, String themeName, int userId)771     void setSplashScreenTheme(String packageName, String themeName, int userId);
772 
getUserMinAspectRatio(String packageName, int userId)773     int getUserMinAspectRatio(String packageName, int userId);
774 
775     @EnforcePermission("INSTALL_PACKAGES")
setUserMinAspectRatio(String packageName, int userId, int aspectRatio)776     void setUserMinAspectRatio(String packageName, int userId, int aspectRatio);
777 
getMimeGroup(String packageName, String group)778     List<String> getMimeGroup(String packageName, String group);
779 
isAutoRevokeWhitelisted(String packageName)780     boolean isAutoRevokeWhitelisted(String packageName);
781 
makeProviderVisible(int recipientAppId, String visibleAuthority)782     void makeProviderVisible(int recipientAppId, String visibleAuthority);
783 
784     @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
785             + ".permission.MAKE_UID_VISIBLE)")
makeUidVisible(int recipientAppId, int visibleUid)786     void makeUidVisible(int recipientAppId, int visibleUid);
787 
getHoldLockToken()788     IBinder getHoldLockToken();
789 
holdLock(in IBinder token, in int durationMs)790     void holdLock(in IBinder token, in int durationMs);
791 
getPropertyAsUser(String propertyName, String packageName, String className, int userId)792     PackageManager.Property getPropertyAsUser(String propertyName, String packageName,
793             String className, int userId);
queryProperty(String propertyName, int componentType)794     ParceledListSlice queryProperty(String propertyName, int componentType);
795 
setKeepUninstalledPackages(in List<String> packageList)796     void setKeepUninstalledPackages(in List<String> packageList);
797 
canPackageQuery(String sourcePackageName, in String[] targetPackageNames, int userId)798     boolean[] canPackageQuery(String sourcePackageName, in String[] targetPackageNames, int userId);
799 
waitForHandler(long timeoutMillis, boolean forBackgroundHandler)800     boolean waitForHandler(long timeoutMillis, boolean forBackgroundHandler);
801 }
802