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