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