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