3 ** Copyright 2007, The Android Open Source Project
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
9 ** http://www.apache.org/licenses/LICENSE-2.0
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.
18 package android.content.pm;
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;
53 * See {@link PackageManager} for documentation on most of the APIs
58 interface IPackageManager {
59 boolean isPackageAvailable(String packageName, int userId);
60 PackageInfo getPackageInfo(String packageName, int flags, int userId);
61 int getPackageUid(String packageName, int userId);
62 int[] getPackageGids(String packageName);
64 String[] currentToCanonicalPackageNames(in String[] names);
65 String[] canonicalToCurrentPackageNames(in String[] names);
67 PermissionInfo getPermissionInfo(String name, int flags);
69 List<PermissionInfo> queryPermissionsByGroup(String group, int flags);
71 PermissionGroupInfo getPermissionGroupInfo(String name, int flags);
73 List<PermissionGroupInfo> getAllPermissionGroups(int flags);
75 ApplicationInfo getApplicationInfo(String packageName, int flags ,int userId);
77 ActivityInfo getActivityInfo(in ComponentName className, int flags, int userId);
79 boolean activitySupportsIntent(in ComponentName className, in Intent intent,
82 ActivityInfo getReceiverInfo(in ComponentName className, int flags, int userId);
84 ServiceInfo getServiceInfo(in ComponentName className, int flags, int userId);
86 ProviderInfo getProviderInfo(in ComponentName className, int flags, int userId);
88 int checkPermission(String permName, String pkgName);
90 int checkUidPermission(String permName, int uid);
92 boolean addPermission(in PermissionInfo info);
94 void removePermission(String name);
96 void grantPermission(String packageName, String permissionName);
98 void revokePermission(String packageName, String permissionName);
100 boolean isProtectedBroadcast(String actionName);
102 int checkSignatures(String pkg1, String pkg2);
104 int checkUidSignatures(int uid1, int uid2);
106 String[] getPackagesForUid(int uid);
108 String getNameForUid(int uid);
110 int getUidForSharedUser(String sharedUserName);
112 int getFlagsForUid(int uid);
114 boolean isUidPrivileged(int uid);
116 String[] getAppOpPermissionPackages(String permissionName);
118 ResolveInfo resolveIntent(in Intent intent, String resolvedType, int flags, int userId);
120 boolean canForwardTo(in Intent intent, String resolvedType, int sourceUserId, int targetUserId);
122 List<ResolveInfo> queryIntentActivities(in Intent intent,
123 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);
130 List<ResolveInfo> queryIntentReceivers(in Intent intent,
131 String resolvedType, int flags, int userId);
133 ResolveInfo resolveService(in Intent intent,
134 String resolvedType, int flags, int userId);
136 List<ResolveInfo> queryIntentServices(in Intent intent,
137 String resolvedType, int flags, int userId);
139 List<ResolveInfo> queryIntentContentProviders(in Intent intent,
140 String resolvedType, int flags, int userId);
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
148 ParceledListSlice getInstalledPackages(int flags, in int userId);
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
156 ParceledListSlice getPackagesHoldingPermissions(in String[] permissions,
157 int flags, int userId);
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
165 ParceledListSlice getInstalledApplications(int flags, int userId);
168 * Retrieve all applications that are marked as persistent.
170 * @return A List<applicationInfo> containing one entry for each persistent
173 List<ApplicationInfo> getPersistentApplications(int flags);
175 ProviderInfo resolveContentProvider(String name, int flags, int userId);
178 * Retrieve sync information for all content providers.
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'.
185 void querySyncProviders(inout List<String> outNames,
186 inout List<ProviderInfo> outInfo);
188 List<ProviderInfo> queryContentProviders(
189 String processName, int uid, int flags);
191 InstrumentationInfo getInstrumentationInfo(
192 in ComponentName className, int flags);
194 List<InstrumentationInfo> queryInstrumentation(
195 String targetPackage, int flags);
197 void installPackage(in String originPath,
198 in IPackageInstallObserver2 observer,
200 in String installerPackageName,
201 in VerificationParams verificationParams,
202 in String packageAbiOverride);
204 void installPackageAsUser(in String originPath,
205 in IPackageInstallObserver2 observer,
207 in String installerPackageName,
208 in VerificationParams verificationParams,
209 in String packageAbiOverride,
212 void finishPackageInstall(int token);
214 void setInstallerPackageName(in String targetPackage, in String installerPackageName);
216 /** @deprecated rawr, don't call AIDL methods directly! */
217 void deletePackageAsUser(in String packageName, IPackageDeleteObserver observer,
218 int userId, int flags);
221 * Delete a package for a specific user.
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}
228 void deletePackage(in String packageName, IPackageDeleteObserver2 observer, int userId, int flags);
230 String getInstallerPackageName(in String packageName);
232 void addPackageToPreferred(String packageName);
234 void removePackageFromPreferred(String packageName);
236 List<PackageInfo> getPreferredPackages(int flags);
238 void resetPreferredActivities(int userId);
240 ResolveInfo getLastChosenActivity(in Intent intent,
241 String resolvedType, int flags);
243 void setLastChosenActivity(in Intent intent, String resolvedType, int flags,
244 in IntentFilter filter, int match, in ComponentName activity);
246 void addPreferredActivity(in IntentFilter filter, int match,
247 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);
252 void clearPackagePreferredActivities(String packageName);
254 int getPreferredActivities(out List<IntentFilter> outFilters,
255 out List<ComponentName> outActivities, String packageName);
257 void addPersistentPreferredActivity(in IntentFilter filter, in ComponentName activity, int userId);
259 void clearPackagePersistentPreferredActivities(String packageName, int userId);
261 void addCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage,
262 int ownerUserId, int sourceUserId, int targetUserId, int flags);
264 void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage, int ownerUserId);
267 * Report the set of 'Home' activity candidates, plus (if any) which of them
268 * is the current "always use this one" setting.
270 ComponentName getHomeActivities(out List<ResolveInfo> outHomeCandidates);
273 * As per {@link android.content.pm.PackageManager#setComponentEnabledSetting}.
275 void setComponentEnabledSetting(in ComponentName componentName,
276 in int newState, in int flags, int userId);
279 * As per {@link android.content.pm.PackageManager#getComponentEnabledSetting}.
281 int getComponentEnabledSetting(in ComponentName componentName, int userId);
284 * As per {@link android.content.pm.PackageManager#setApplicationEnabledSetting}.
286 void setApplicationEnabledSetting(in String packageName, in int newState, int flags,
287 int userId, String callingPackage);
290 * As per {@link android.content.pm.PackageManager#getApplicationEnabledSetting}.
292 int getApplicationEnabledSetting(in String packageName, int userId);
295 * Set whether the given package should be considered stopped, making
296 * it not visible to implicit intents that filter out stopped packages.
298 void setPackageStoppedState(String packageName, boolean stopped, int userId);
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
320 void freeStorageAndNotify(in long freeStorageSize,
321 IPackageDataObserver observer);
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.
344 void freeStorage(in long freeStorageSize,
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.
353 void deleteApplicationCacheFiles(in String packageName, IPackageDataObserver observer);
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.
361 void clearApplicationUserData(in String packageName, IPackageDataObserver observer, int userId);
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.
371 void getPackageSizeInfo(in String packageName, int userHandle, IPackageStatsObserver observer);
374 * Get a list of shared libraries that are available on the
377 String[] getSystemSharedLibraryNames();
380 * Get a list of features that are available on the
383 FeatureInfo[] getSystemAvailableFeatures();
385 boolean hasSystemFeature(String name);
387 void enterSafeMode();
388 boolean isSafeMode();
390 boolean hasSystemUidErrors();
393 * Ask the package manager to perform boot-time dex-opt of all
396 void performBootDexOpt();
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
403 * If the supplied instructionSet is null, the package manager will use
404 * the packages default instruction set.
406 * In most cases, apps are dexopted in advance and this function will
409 boolean performDexOptIfNeeded(String packageName, String instructionSet);
411 void forceDexOpt(String packageName);
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
419 void updateExternalMediaStatus(boolean mounted, boolean reportStatus);
421 PackageCleanItem nextPackageToClean(in PackageCleanItem lastPackage);
423 void movePackage(String packageName, IPackageMoveObserver observer, int flags);
425 boolean addPermissionAsync(in PermissionInfo info);
427 boolean setInstallLocation(int loc);
428 int getInstallLocation();
430 int installExistingPackageAsUser(String packageName, int userId);
432 void verifyPendingInstall(int id, int verificationCode);
433 void extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay);
435 VerifierDeviceIdentity getVerifierDeviceIdentity();
437 boolean isFirstBoot();
438 boolean isOnlyCoreApps();
441 void setPermissionEnforced(String permission, boolean enforced);
442 boolean isPermissionEnforced(String permission);
444 /** Reflects current DeviceStorageMonitorService state */
445 boolean isStorageLow();
447 boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, int userId);
448 boolean getApplicationHiddenSettingAsUser(String packageName, int userId);
450 IPackageInstaller getPackageInstaller();
452 boolean setBlockUninstallForUser(String packageName, boolean blockUninstall, int userId);
453 boolean getBlockUninstallForUser(String packageName, int userId);
455 KeySet getKeySetByAlias(String packageName, String alias);
456 KeySet getSigningKeySet(String packageName);
457 boolean isPackageSignedByKeySet(String packageName, in KeySet ks);
458 boolean isPackageSignedByKeySetExactly(String packageName, in KeySet ks);