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