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 18package android.content.pm; 19 20import android.content.ComponentName; 21import android.content.Intent; 22import android.content.IntentFilter; 23import android.content.pm.ActivityInfo; 24import android.content.pm.ApplicationInfo; 25import android.content.pm.ContainerEncryptionParams; 26import android.content.pm.FeatureInfo; 27import android.content.pm.IPackageInstallObserver2; 28import android.content.pm.IPackageInstaller; 29import android.content.pm.IPackageDeleteObserver; 30import android.content.pm.IPackageDeleteObserver2; 31import android.content.pm.IPackageDataObserver; 32import android.content.pm.IPackageMoveObserver; 33import android.content.pm.IPackageStatsObserver; 34import android.content.pm.IOnPermissionsChangeListener; 35import android.content.pm.IntentFilterVerificationInfo; 36import android.content.pm.InstrumentationInfo; 37import android.content.pm.KeySet; 38import android.content.pm.PackageInfo; 39import android.content.pm.ManifestDigest; 40import android.content.pm.PackageCleanItem; 41import android.content.pm.ParceledListSlice; 42import android.content.pm.ProviderInfo; 43import android.content.pm.PermissionGroupInfo; 44import android.content.pm.PermissionInfo; 45import android.content.pm.ResolveInfo; 46import android.content.pm.ServiceInfo; 47import android.content.pm.UserInfo; 48import android.content.pm.VerificationParams; 49import android.content.pm.VerifierDeviceIdentity; 50import android.net.Uri; 51import android.os.Bundle; 52import android.os.ParcelFileDescriptor; 53import android.content.IntentSender; 54 55/** 56 * See {@link PackageManager} for documentation on most of the APIs 57 * here. 58 * 59 * {@hide} 60 */ 61interface IPackageManager { 62 boolean isPackageFrozen(String packageName); 63 boolean isPackageAvailable(String packageName, int userId); 64 PackageInfo getPackageInfo(String packageName, int flags, int userId); 65 int getPackageUid(String packageName, int userId); 66 int[] getPackageGids(String packageName, int userId); 67 68 String[] currentToCanonicalPackageNames(in String[] names); 69 String[] canonicalToCurrentPackageNames(in String[] names); 70 71 PermissionInfo getPermissionInfo(String name, int flags); 72 73 List<PermissionInfo> queryPermissionsByGroup(String group, int flags); 74 75 PermissionGroupInfo getPermissionGroupInfo(String name, int flags); 76 77 List<PermissionGroupInfo> getAllPermissionGroups(int flags); 78 79 ApplicationInfo getApplicationInfo(String packageName, int flags ,int userId); 80 81 ActivityInfo getActivityInfo(in ComponentName className, int flags, int userId); 82 83 boolean activitySupportsIntent(in ComponentName className, in Intent intent, 84 String resolvedType); 85 86 ActivityInfo getReceiverInfo(in ComponentName className, int flags, int userId); 87 88 ServiceInfo getServiceInfo(in ComponentName className, int flags, int userId); 89 90 ProviderInfo getProviderInfo(in ComponentName className, int flags, int userId); 91 92 int checkPermission(String permName, String pkgName, int userId); 93 94 int checkUidPermission(String permName, int uid); 95 96 boolean addPermission(in PermissionInfo info); 97 98 void removePermission(String name); 99 100 void grantRuntimePermission(String packageName, String permissionName, int userId); 101 102 void revokeRuntimePermission(String packageName, String permissionName, int userId); 103 104 void resetRuntimePermissions(); 105 106 int getPermissionFlags(String permissionName, String packageName, int userId); 107 108 void updatePermissionFlags(String permissionName, String packageName, int flagMask, 109 int flagValues, int userId); 110 111 void updatePermissionFlagsForAllApps(int flagMask, int flagValues, int userId); 112 113 boolean shouldShowRequestPermissionRationale(String permissionName, 114 String packageName, int userId); 115 116 boolean isProtectedBroadcast(String actionName); 117 118 int checkSignatures(String pkg1, String pkg2); 119 120 int checkUidSignatures(int uid1, int uid2); 121 122 String[] getPackagesForUid(int uid); 123 124 String getNameForUid(int uid); 125 126 int getUidForSharedUser(String sharedUserName); 127 128 int getFlagsForUid(int uid); 129 130 int getPrivateFlagsForUid(int uid); 131 132 boolean isUidPrivileged(int uid); 133 134 String[] getAppOpPermissionPackages(String permissionName); 135 136 ResolveInfo resolveIntent(in Intent intent, String resolvedType, int flags, int userId); 137 138 boolean canForwardTo(in Intent intent, String resolvedType, int sourceUserId, int targetUserId); 139 140 List<ResolveInfo> queryIntentActivities(in Intent intent, 141 String resolvedType, int flags, int userId); 142 143 List<ResolveInfo> queryIntentActivityOptions( 144 in ComponentName caller, in Intent[] specifics, 145 in String[] specificTypes, in Intent intent, 146 String resolvedType, int flags, int userId); 147 148 List<ResolveInfo> queryIntentReceivers(in Intent intent, 149 String resolvedType, int flags, int userId); 150 151 ResolveInfo resolveService(in Intent intent, 152 String resolvedType, int flags, int userId); 153 154 List<ResolveInfo> queryIntentServices(in Intent intent, 155 String resolvedType, int flags, int userId); 156 157 List<ResolveInfo> queryIntentContentProviders(in Intent intent, 158 String resolvedType, int flags, int userId); 159 160 /** 161 * This implements getInstalledPackages via a "last returned row" 162 * mechanism that is not exposed in the API. This is to get around the IPC 163 * limit that kicks in when flags are included that bloat up the data 164 * returned. 165 */ 166 ParceledListSlice getInstalledPackages(int flags, in int userId); 167 168 /** 169 * This implements getPackagesHoldingPermissions via a "last returned row" 170 * mechanism that is not exposed in the API. This is to get around the IPC 171 * limit that kicks in when flags are included that bloat up the data 172 * returned. 173 */ 174 ParceledListSlice getPackagesHoldingPermissions(in String[] permissions, 175 int flags, int userId); 176 177 /** 178 * This implements getInstalledApplications via a "last returned row" 179 * mechanism that is not exposed in the API. This is to get around the IPC 180 * limit that kicks in when flags are included that bloat up the data 181 * returned. 182 */ 183 ParceledListSlice getInstalledApplications(int flags, int userId); 184 185 /** 186 * Retrieve all applications that are marked as persistent. 187 * 188 * @return A List<applicationInfo> containing one entry for each persistent 189 * application. 190 */ 191 List<ApplicationInfo> getPersistentApplications(int flags); 192 193 ProviderInfo resolveContentProvider(String name, int flags, int userId); 194 195 /** 196 * Retrieve sync information for all content providers. 197 * 198 * @param outNames Filled in with a list of the root names of the content 199 * providers that can sync. 200 * @param outInfo Filled in with a list of the ProviderInfo for each 201 * name in 'outNames'. 202 */ 203 void querySyncProviders(inout List<String> outNames, 204 inout List<ProviderInfo> outInfo); 205 206 ParceledListSlice queryContentProviders( 207 String processName, int uid, int flags); 208 209 InstrumentationInfo getInstrumentationInfo( 210 in ComponentName className, int flags); 211 212 List<InstrumentationInfo> queryInstrumentation( 213 String targetPackage, int flags); 214 215 void installPackage(in String originPath, 216 in IPackageInstallObserver2 observer, 217 int flags, 218 in String installerPackageName, 219 in VerificationParams verificationParams, 220 in String packageAbiOverride); 221 222 void installPackageAsUser(in String originPath, 223 in IPackageInstallObserver2 observer, 224 int flags, 225 in String installerPackageName, 226 in VerificationParams verificationParams, 227 in String packageAbiOverride, 228 int userId); 229 230 void finishPackageInstall(int token); 231 232 void setInstallerPackageName(in String targetPackage, in String installerPackageName); 233 234 /** @deprecated rawr, don't call AIDL methods directly! */ 235 void deletePackageAsUser(in String packageName, IPackageDeleteObserver observer, 236 int userId, int flags); 237 238 /** 239 * Delete a package for a specific user. 240 * 241 * @param packageName The fully qualified name of the package to delete. 242 * @param observer a callback to use to notify when the package deletion in finished. 243 * @param userId the id of the user for whom to delete the package 244 * @param flags - possible values: {@link #DONT_DELETE_DATA} 245 */ 246 void deletePackage(in String packageName, IPackageDeleteObserver2 observer, int userId, int flags); 247 248 String getInstallerPackageName(in String packageName); 249 250 void addPackageToPreferred(String packageName); 251 252 void removePackageFromPreferred(String packageName); 253 254 List<PackageInfo> getPreferredPackages(int flags); 255 256 void resetApplicationPreferences(int userId); 257 258 ResolveInfo getLastChosenActivity(in Intent intent, 259 String resolvedType, int flags); 260 261 void setLastChosenActivity(in Intent intent, String resolvedType, int flags, 262 in IntentFilter filter, int match, in ComponentName activity); 263 264 void addPreferredActivity(in IntentFilter filter, int match, 265 in ComponentName[] set, in ComponentName activity, int userId); 266 267 void replacePreferredActivity(in IntentFilter filter, int match, 268 in ComponentName[] set, in ComponentName activity, int userId); 269 270 void clearPackagePreferredActivities(String packageName); 271 272 int getPreferredActivities(out List<IntentFilter> outFilters, 273 out List<ComponentName> outActivities, String packageName); 274 275 void addPersistentPreferredActivity(in IntentFilter filter, in ComponentName activity, int userId); 276 277 void clearPackagePersistentPreferredActivities(String packageName, int userId); 278 279 void addCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage, 280 int sourceUserId, int targetUserId, int flags); 281 282 void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage); 283 284 /** 285 * Backup/restore support - only the system uid may use these. 286 */ 287 byte[] getPreferredActivityBackup(int userId); 288 void restorePreferredActivities(in byte[] backup, int userId); 289 byte[] getDefaultAppsBackup(int userId); 290 void restoreDefaultApps(in byte[] backup, int userId); 291 byte[] getIntentFilterVerificationBackup(int userId); 292 void restoreIntentFilterVerification(in byte[] backup, int userId); 293 294 /** 295 * Report the set of 'Home' activity candidates, plus (if any) which of them 296 * is the current "always use this one" setting. 297 */ 298 ComponentName getHomeActivities(out List<ResolveInfo> outHomeCandidates); 299 300 /** 301 * As per {@link android.content.pm.PackageManager#setComponentEnabledSetting}. 302 */ 303 void setComponentEnabledSetting(in ComponentName componentName, 304 in int newState, in int flags, int userId); 305 306 /** 307 * As per {@link android.content.pm.PackageManager#getComponentEnabledSetting}. 308 */ 309 int getComponentEnabledSetting(in ComponentName componentName, int userId); 310 311 /** 312 * As per {@link android.content.pm.PackageManager#setApplicationEnabledSetting}. 313 */ 314 void setApplicationEnabledSetting(in String packageName, in int newState, int flags, 315 int userId, String callingPackage); 316 317 /** 318 * As per {@link android.content.pm.PackageManager#getApplicationEnabledSetting}. 319 */ 320 int getApplicationEnabledSetting(in String packageName, int userId); 321 322 /** 323 * Set whether the given package should be considered stopped, making 324 * it not visible to implicit intents that filter out stopped packages. 325 */ 326 void setPackageStoppedState(String packageName, boolean stopped, int userId); 327 328 /** 329 * Free storage by deleting LRU sorted list of cache files across 330 * all applications. If the currently available free storage 331 * on the device is greater than or equal to the requested 332 * free storage, no cache files are cleared. If the currently 333 * available storage on the device is less than the requested 334 * free storage, some or all of the cache files across 335 * all applications are deleted (based on last accessed time) 336 * to increase the free storage space on the device to 337 * the requested value. There is no guarantee that clearing all 338 * the cache files from all applications will clear up 339 * enough storage to achieve the desired value. 340 * @param freeStorageSize The number of bytes of storage to be 341 * freed by the system. Say if freeStorageSize is XX, 342 * and the current free storage is YY, 343 * if XX is less than YY, just return. if not free XX-YY number 344 * of bytes if possible. 345 * @param observer call back used to notify when 346 * the operation is completed 347 */ 348 void freeStorageAndNotify(in String volumeUuid, in long freeStorageSize, 349 IPackageDataObserver observer); 350 351 /** 352 * Free storage by deleting LRU sorted list of cache files across 353 * all applications. If the currently available free storage 354 * on the device is greater than or equal to the requested 355 * free storage, no cache files are cleared. If the currently 356 * available storage on the device is less than the requested 357 * free storage, some or all of the cache files across 358 * all applications are deleted (based on last accessed time) 359 * to increase the free storage space on the device to 360 * the requested value. There is no guarantee that clearing all 361 * the cache files from all applications will clear up 362 * enough storage to achieve the desired value. 363 * @param freeStorageSize The number of bytes of storage to be 364 * freed by the system. Say if freeStorageSize is XX, 365 * and the current free storage is YY, 366 * if XX is less than YY, just return. if not free XX-YY number 367 * of bytes if possible. 368 * @param pi IntentSender call back used to 369 * notify when the operation is completed.May be null 370 * to indicate that no call back is desired. 371 */ 372 void freeStorage(in String volumeUuid, in long freeStorageSize, 373 in IntentSender pi); 374 375 /** 376 * Delete all the cache files in an applications cache directory 377 * @param packageName The package name of the application whose cache 378 * files need to be deleted 379 * @param observer a callback used to notify when the deletion is finished. 380 */ 381 void deleteApplicationCacheFiles(in String packageName, IPackageDataObserver observer); 382 383 /** 384 * Clear the user data directory of an application. 385 * @param packageName The package name of the application whose cache 386 * files need to be deleted 387 * @param observer a callback used to notify when the operation is completed. 388 */ 389 void clearApplicationUserData(in String packageName, IPackageDataObserver observer, int userId); 390 391 /** 392 * Get package statistics including the code, data and cache size for 393 * an already installed package 394 * @param packageName The package name of the application 395 * @param userHandle Which user the size should be retrieved for 396 * @param observer a callback to use to notify when the asynchronous 397 * retrieval of information is complete. 398 */ 399 void getPackageSizeInfo(in String packageName, int userHandle, IPackageStatsObserver observer); 400 401 /** 402 * Get a list of shared libraries that are available on the 403 * system. 404 */ 405 String[] getSystemSharedLibraryNames(); 406 407 /** 408 * Get a list of features that are available on the 409 * system. 410 */ 411 FeatureInfo[] getSystemAvailableFeatures(); 412 413 boolean hasSystemFeature(String name); 414 415 void enterSafeMode(); 416 boolean isSafeMode(); 417 void systemReady(); 418 boolean hasSystemUidErrors(); 419 420 /** 421 * Ask the package manager to perform boot-time dex-opt of all 422 * existing packages. 423 */ 424 void performBootDexOpt(); 425 426 /** 427 * Ask the package manager to perform dex-opt (if needed) on the given 428 * package and for the given instruction set if it already hasn't done 429 * so. 430 * 431 * If the supplied instructionSet is null, the package manager will use 432 * the packages default instruction set. 433 * 434 * In most cases, apps are dexopted in advance and this function will 435 * be a no-op. 436 */ 437 boolean performDexOptIfNeeded(String packageName, String instructionSet); 438 439 void forceDexOpt(String packageName); 440 441 /** 442 * Update status of external media on the package manager to scan and 443 * install packages installed on the external media. Like say the 444 * MountService uses this to call into the package manager to update 445 * status of sdcard. 446 */ 447 void updateExternalMediaStatus(boolean mounted, boolean reportStatus); 448 449 PackageCleanItem nextPackageToClean(in PackageCleanItem lastPackage); 450 451 int getMoveStatus(int moveId); 452 453 void registerMoveCallback(in IPackageMoveObserver callback); 454 void unregisterMoveCallback(in IPackageMoveObserver callback); 455 456 int movePackage(in String packageName, in String volumeUuid); 457 int movePrimaryStorage(in String volumeUuid); 458 459 boolean addPermissionAsync(in PermissionInfo info); 460 461 boolean setInstallLocation(int loc); 462 int getInstallLocation(); 463 464 int installExistingPackageAsUser(String packageName, int userId); 465 466 void verifyPendingInstall(int id, int verificationCode); 467 void extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay); 468 469 void verifyIntentFilter(int id, int verificationCode, in List<String> failedDomains); 470 int getIntentVerificationStatus(String packageName, int userId); 471 boolean updateIntentVerificationStatus(String packageName, int status, int userId); 472 List<IntentFilterVerificationInfo> getIntentFilterVerifications(String packageName); 473 List<IntentFilter> getAllIntentFilters(String packageName); 474 475 boolean setDefaultBrowserPackageName(String packageName, int userId); 476 String getDefaultBrowserPackageName(int userId); 477 478 VerifierDeviceIdentity getVerifierDeviceIdentity(); 479 480 boolean isFirstBoot(); 481 boolean isOnlyCoreApps(); 482 boolean isUpgrade(); 483 484 void setPermissionEnforced(String permission, boolean enforced); 485 boolean isPermissionEnforced(String permission); 486 487 /** Reflects current DeviceStorageMonitorService state */ 488 boolean isStorageLow(); 489 490 boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, int userId); 491 boolean getApplicationHiddenSettingAsUser(String packageName, int userId); 492 493 IPackageInstaller getPackageInstaller(); 494 495 boolean setBlockUninstallForUser(String packageName, boolean blockUninstall, int userId); 496 boolean getBlockUninstallForUser(String packageName, int userId); 497 498 KeySet getKeySetByAlias(String packageName, String alias); 499 KeySet getSigningKeySet(String packageName); 500 boolean isPackageSignedByKeySet(String packageName, in KeySet ks); 501 boolean isPackageSignedByKeySetExactly(String packageName, in KeySet ks); 502 503 void addOnPermissionsChangeListener(in IOnPermissionsChangeListener listener); 504 void removeOnPermissionsChangeListener(in IOnPermissionsChangeListener listener); 505 void grantDefaultPermissionsToEnabledCarrierApps(in String[] packageNames, int userId); 506 507 boolean isPermissionRevokedByPolicy(String permission, String packageName, int userId); 508 509 String getPermissionControllerPackageName(); 510} 511