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