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.IPackageInstallObserver; 28import android.content.pm.IPackageDeleteObserver; 29import android.content.pm.IPackageDataObserver; 30import android.content.pm.IPackageMoveObserver; 31import android.content.pm.IPackageStatsObserver; 32import android.content.pm.InstrumentationInfo; 33import android.content.pm.PackageInfo; 34import android.content.pm.ManifestDigest; 35import android.content.pm.PackageCleanItem; 36import android.content.pm.ParceledListSlice; 37import android.content.pm.ProviderInfo; 38import android.content.pm.PermissionGroupInfo; 39import android.content.pm.PermissionInfo; 40import android.content.pm.ResolveInfo; 41import android.content.pm.ServiceInfo; 42import android.content.pm.UserInfo; 43import android.content.pm.VerificationParams; 44import android.content.pm.VerifierDeviceIdentity; 45import android.net.Uri; 46import android.os.ParcelFileDescriptor; 47import android.content.IntentSender; 48 49/** 50 * See {@link PackageManager} for documentation on most of the APIs 51 * here. 52 * 53 * {@hide} 54 */ 55interface IPackageManager { 56 PackageInfo getPackageInfo(String packageName, int flags, int userId); 57 int getPackageUid(String packageName, int userId); 58 int[] getPackageGids(String packageName); 59 60 String[] currentToCanonicalPackageNames(in String[] names); 61 String[] canonicalToCurrentPackageNames(in String[] names); 62 63 PermissionInfo getPermissionInfo(String name, int flags); 64 65 List<PermissionInfo> queryPermissionsByGroup(String group, int flags); 66 67 PermissionGroupInfo getPermissionGroupInfo(String name, int flags); 68 69 List<PermissionGroupInfo> getAllPermissionGroups(int flags); 70 71 ApplicationInfo getApplicationInfo(String packageName, int flags ,int userId); 72 73 ActivityInfo getActivityInfo(in ComponentName className, int flags, int userId); 74 75 ActivityInfo getReceiverInfo(in ComponentName className, int flags, int userId); 76 77 ServiceInfo getServiceInfo(in ComponentName className, int flags, int userId); 78 79 ProviderInfo getProviderInfo(in ComponentName className, int flags, int userId); 80 81 int checkPermission(String permName, String pkgName); 82 83 int checkUidPermission(String permName, int uid); 84 85 boolean addPermission(in PermissionInfo info); 86 87 void removePermission(String name); 88 89 void grantPermission(String packageName, String permissionName); 90 91 void revokePermission(String packageName, String permissionName); 92 93 boolean isProtectedBroadcast(String actionName); 94 95 int checkSignatures(String pkg1, String pkg2); 96 97 int checkUidSignatures(int uid1, int uid2); 98 99 String[] getPackagesForUid(int uid); 100 101 String getNameForUid(int uid); 102 103 int getUidForSharedUser(String sharedUserName); 104 105 ResolveInfo resolveIntent(in Intent intent, String resolvedType, int flags, int userId); 106 107 List<ResolveInfo> queryIntentActivities(in Intent intent, 108 String resolvedType, int flags, int userId); 109 110 List<ResolveInfo> queryIntentActivityOptions( 111 in ComponentName caller, in Intent[] specifics, 112 in String[] specificTypes, in Intent intent, 113 String resolvedType, int flags, int userId); 114 115 List<ResolveInfo> queryIntentReceivers(in Intent intent, 116 String resolvedType, int flags, int userId); 117 118 ResolveInfo resolveService(in Intent intent, 119 String resolvedType, int flags, int userId); 120 121 List<ResolveInfo> queryIntentServices(in Intent intent, 122 String resolvedType, int flags, int userId); 123 124 /** 125 * This implements getInstalledPackages via a "last returned row" 126 * mechanism that is not exposed in the API. This is to get around the IPC 127 * limit that kicks in when flags are included that bloat up the data 128 * returned. 129 */ 130 ParceledListSlice getInstalledPackages(int flags, in String lastRead, in int userId); 131 132 /** 133 * This implements getInstalledApplications via a "last returned row" 134 * mechanism that is not exposed in the API. This is to get around the IPC 135 * limit that kicks in when flags are included that bloat up the data 136 * returned. 137 */ 138 ParceledListSlice getInstalledApplications(int flags, in String lastRead, int userId); 139 140 /** 141 * Retrieve all applications that are marked as persistent. 142 * 143 * @return A List<applicationInfo> containing one entry for each persistent 144 * application. 145 */ 146 List<ApplicationInfo> getPersistentApplications(int flags); 147 148 ProviderInfo resolveContentProvider(String name, int flags, int userId); 149 150 /** 151 * Retrieve sync information for all content providers. 152 * 153 * @param outNames Filled in with a list of the root names of the content 154 * providers that can sync. 155 * @param outInfo Filled in with a list of the ProviderInfo for each 156 * name in 'outNames'. 157 */ 158 void querySyncProviders(inout List<String> outNames, 159 inout List<ProviderInfo> outInfo); 160 161 List<ProviderInfo> queryContentProviders( 162 String processName, int uid, int flags); 163 164 InstrumentationInfo getInstrumentationInfo( 165 in ComponentName className, int flags); 166 167 List<InstrumentationInfo> queryInstrumentation( 168 String targetPackage, int flags); 169 170 /** 171 * Install a package. 172 * 173 * @param packageURI The location of the package file to install. 174 * @param observer a callback to use to notify when the package installation in finished. 175 * @param flags - possible values: {@link #FORWARD_LOCK_PACKAGE}, 176 * {@link #REPLACE_EXISITING_PACKAGE} 177 * @param installerPackageName Optional package name of the application that is performing the 178 * installation. This identifies which market the package came from. 179 */ 180 void installPackage(in Uri packageURI, IPackageInstallObserver observer, int flags, 181 in String installerPackageName); 182 183 void finishPackageInstall(int token); 184 185 void setInstallerPackageName(in String targetPackage, in String installerPackageName); 186 187 /** 188 * Delete a package. 189 * 190 * @param packageName The fully qualified name of the package to delete. 191 * @param observer a callback to use to notify when the package deletion in finished. 192 * @param flags - possible values: {@link #DONT_DELETE_DATA} 193 */ 194 void deletePackage(in String packageName, IPackageDeleteObserver observer, int flags); 195 196 String getInstallerPackageName(in String packageName); 197 198 void addPackageToPreferred(String packageName); 199 200 void removePackageFromPreferred(String packageName); 201 202 List<PackageInfo> getPreferredPackages(int flags); 203 204 void addPreferredActivity(in IntentFilter filter, int match, 205 in ComponentName[] set, in ComponentName activity, int userId); 206 207 void replacePreferredActivity(in IntentFilter filter, int match, 208 in ComponentName[] set, in ComponentName activity); 209 210 void clearPackagePreferredActivities(String packageName); 211 212 int getPreferredActivities(out List<IntentFilter> outFilters, 213 out List<ComponentName> outActivities, String packageName); 214 215 /** 216 * As per {@link android.content.pm.PackageManager#setComponentEnabledSetting}. 217 */ 218 void setComponentEnabledSetting(in ComponentName componentName, 219 in int newState, in int flags, int userId); 220 221 /** 222 * As per {@link android.content.pm.PackageManager#getComponentEnabledSetting}. 223 */ 224 int getComponentEnabledSetting(in ComponentName componentName, int userId); 225 226 /** 227 * As per {@link android.content.pm.PackageManager#setApplicationEnabledSetting}. 228 */ 229 void setApplicationEnabledSetting(in String packageName, in int newState, int flags, int userId); 230 231 /** 232 * As per {@link android.content.pm.PackageManager#getApplicationEnabledSetting}. 233 */ 234 int getApplicationEnabledSetting(in String packageName, int userId); 235 236 /** 237 * Set whether the given package should be considered stopped, making 238 * it not visible to implicit intents that filter out stopped packages. 239 */ 240 void setPackageStoppedState(String packageName, boolean stopped, int userId); 241 242 /** 243 * Free storage by deleting LRU sorted list of cache files across 244 * all applications. If the currently available free storage 245 * on the device is greater than or equal to the requested 246 * free storage, no cache files are cleared. If the currently 247 * available storage on the device is less than the requested 248 * free storage, some or all of the cache files across 249 * all applications are deleted (based on last accessed time) 250 * to increase the free storage space on the device to 251 * the requested value. There is no guarantee that clearing all 252 * the cache files from all applications will clear up 253 * enough storage to achieve the desired value. 254 * @param freeStorageSize The number of bytes of storage to be 255 * freed by the system. Say if freeStorageSize is XX, 256 * and the current free storage is YY, 257 * if XX is less than YY, just return. if not free XX-YY number 258 * of bytes if possible. 259 * @param observer call back used to notify when 260 * the operation is completed 261 */ 262 void freeStorageAndNotify(in long freeStorageSize, 263 IPackageDataObserver observer); 264 265 /** 266 * Free storage by deleting LRU sorted list of cache files across 267 * all applications. If the currently available free storage 268 * on the device is greater than or equal to the requested 269 * free storage, no cache files are cleared. If the currently 270 * available storage on the device is less than the requested 271 * free storage, some or all of the cache files across 272 * all applications are deleted (based on last accessed time) 273 * to increase the free storage space on the device to 274 * the requested value. There is no guarantee that clearing all 275 * the cache files from all applications will clear up 276 * enough storage to achieve the desired value. 277 * @param freeStorageSize The number of bytes of storage to be 278 * freed by the system. Say if freeStorageSize is XX, 279 * and the current free storage is YY, 280 * if XX is less than YY, just return. if not free XX-YY number 281 * of bytes if possible. 282 * @param pi IntentSender call back used to 283 * notify when the operation is completed.May be null 284 * to indicate that no call back is desired. 285 */ 286 void freeStorage(in long freeStorageSize, 287 in IntentSender pi); 288 289 /** 290 * Delete all the cache files in an applications cache directory 291 * @param packageName The package name of the application whose cache 292 * files need to be deleted 293 * @param observer a callback used to notify when the deletion is finished. 294 */ 295 void deleteApplicationCacheFiles(in String packageName, IPackageDataObserver observer); 296 297 /** 298 * Clear the user data directory of an application. 299 * @param packageName The package name of the application whose cache 300 * files need to be deleted 301 * @param observer a callback used to notify when the operation is completed. 302 */ 303 void clearApplicationUserData(in String packageName, IPackageDataObserver observer, int userId); 304 305 /** 306 * Get package statistics including the code, data and cache size for 307 * an already installed package 308 * @param packageName The package name of the application 309 * @param userHandle Which user the size should be retrieved for 310 * @param observer a callback to use to notify when the asynchronous 311 * retrieval of information is complete. 312 */ 313 void getPackageSizeInfo(in String packageName, int userHandle, IPackageStatsObserver observer); 314 315 /** 316 * Get a list of shared libraries that are available on the 317 * system. 318 */ 319 String[] getSystemSharedLibraryNames(); 320 321 /** 322 * Get a list of features that are available on the 323 * system. 324 */ 325 FeatureInfo[] getSystemAvailableFeatures(); 326 327 boolean hasSystemFeature(String name); 328 329 void enterSafeMode(); 330 boolean isSafeMode(); 331 void systemReady(); 332 boolean hasSystemUidErrors(); 333 334 /** 335 * Ask the package manager to perform boot-time dex-opt of all 336 * existing packages. 337 */ 338 void performBootDexOpt(); 339 340 /** 341 * Ask the package manager to perform dex-opt (if needed) on the given 342 * package, if it already hasn't done mode. Only does this if running 343 * in the special development "no pre-dexopt" mode. 344 */ 345 boolean performDexOpt(String packageName); 346 347 /** 348 * Update status of external media on the package manager to scan and 349 * install packages installed on the external media. Like say the 350 * MountService uses this to call into the package manager to update 351 * status of sdcard. 352 */ 353 void updateExternalMediaStatus(boolean mounted, boolean reportStatus); 354 355 PackageCleanItem nextPackageToClean(in PackageCleanItem lastPackage); 356 357 void movePackage(String packageName, IPackageMoveObserver observer, int flags); 358 359 boolean addPermissionAsync(in PermissionInfo info); 360 361 boolean setInstallLocation(int loc); 362 int getInstallLocation(); 363 364 void installPackageWithVerification(in Uri packageURI, in IPackageInstallObserver observer, 365 int flags, in String installerPackageName, in Uri verificationURI, 366 in ManifestDigest manifestDigest, in ContainerEncryptionParams encryptionParams); 367 368 void installPackageWithVerificationAndEncryption(in Uri packageURI, 369 in IPackageInstallObserver observer, int flags, in String installerPackageName, 370 in VerificationParams verificationParams, 371 in ContainerEncryptionParams encryptionParams); 372 373 int installExistingPackage(String packageName); 374 375 void verifyPendingInstall(int id, int verificationCode); 376 void extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay); 377 378 VerifierDeviceIdentity getVerifierDeviceIdentity(); 379 380 boolean isFirstBoot(); 381 382 void setPermissionEnforced(String permission, boolean enforced); 383 boolean isPermissionEnforced(String permission); 384 385 /** Reflects current DeviceStorageMonitorService state */ 386 boolean isStorageLow(); 387} 388