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