blob: 4c981cdb251141385195468e1e0c53420f685ed4 [file] [log] [blame]
Svet Ganovadc1cf42015-06-15 16:36:24 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content.pm;
18
Makoto Onuki2d5b4652016-03-11 16:09:54 -080019import android.content.ComponentName;
Todd Kennedy01ad0c72016-11-11 15:33:12 -080020import android.content.Intent;
Todd Kennedy18211fd2017-06-06 09:15:46 -070021import android.content.pm.PackageManager.ApplicationInfoFlags;
22import android.content.pm.PackageManager.ComponentInfoFlags;
Todd Kennedy18211fd2017-06-06 09:15:46 -070023import android.content.pm.PackageManager.PackageInfoFlags;
24import android.content.pm.PackageManager.ResolveInfoFlags;
Chad Brubaker06068612017-04-06 09:43:47 -070025import android.os.Bundle;
Makoto Onukic29f62c2016-06-07 12:19:46 -070026import android.util.SparseArray;
Todd Kennedy39bfee52016-02-24 10:28:21 -080027
Fyodor Kupolovcb6fd802015-11-05 14:27:06 -080028import java.util.List;
Svet Ganovadc1cf42015-06-15 16:36:24 -070029
30/**
31 * Package manager local system service interface.
32 *
33 * @hide Only for use within the system server.
34 */
35public abstract class PackageManagerInternal {
36
37 /**
38 * Provider for package names.
39 */
40 public interface PackagesProvider {
41
42 /**
43 * Gets the packages for a given user.
44 * @param userId The user id.
45 * @return The package names.
46 */
47 public String[] getPackages(int userId);
48 }
49
50 /**
Svetoslav0010b702015-06-30 18:05:26 -070051 * Provider for package names.
52 */
53 public interface SyncAdapterPackagesProvider {
54
55 /**
56 * Gets the sync adapter packages for given authority and user.
57 * @param authority The authority.
58 * @param userId The user id.
59 * @return The package names.
60 */
61 public String[] getPackages(String authority, int userId);
62 }
63
64 /**
Svet Ganovadc1cf42015-06-15 16:36:24 -070065 * Sets the location provider packages provider.
66 * @param provider The packages provider.
67 */
68 public abstract void setLocationPackagesProvider(PackagesProvider provider);
69
70 /**
Svet Ganovadc1cf42015-06-15 16:36:24 -070071 * Sets the voice interaction packages provider.
72 * @param provider The packages provider.
73 */
74 public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider);
Svetoslavcdfd2302015-06-25 19:07:31 -070075
76 /**
77 * Sets the SMS packages provider.
78 * @param provider The packages provider.
79 */
80 public abstract void setSmsAppPackagesProvider(PackagesProvider provider);
81
82 /**
83 * Sets the dialer packages provider.
84 * @param provider The packages provider.
85 */
86 public abstract void setDialerAppPackagesProvider(PackagesProvider provider);
87
88 /**
Sailesh Nepalcf855622015-07-28 19:22:14 -070089 * Sets the sim call manager packages provider.
90 * @param provider The packages provider.
91 */
92 public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider);
93
94 /**
Svetoslav0010b702015-06-30 18:05:26 -070095 * Sets the sync adapter packages provider.
96 * @param provider The provider.
97 */
98 public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider);
99
100 /**
Svetoslavcdfd2302015-06-25 19:07:31 -0700101 * Requests granting of the default permissions to the current default SMS app.
102 * @param packageName The default SMS package name.
103 * @param userId The user for which to grant the permissions.
104 */
105 public abstract void grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId);
106
107 /**
108 * Requests granting of the default permissions to the current default dialer app.
109 * @param packageName The default dialer package name.
110 * @param userId The user for which to grant the permissions.
111 */
112 public abstract void grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId);
Sailesh Nepalcf855622015-07-28 19:22:14 -0700113
114 /**
115 * Requests granting of the default permissions to the current default sim call manager.
116 * @param packageName The default sim call manager package name.
117 * @param userId The user for which to grant the permissions.
118 */
119 public abstract void grantDefaultPermissionsToDefaultSimCallManager(String packageName,
120 int userId);
Fyodor Kupolovcb6fd802015-11-05 14:27:06 -0800121
122 /**
123 * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has
124 * currently installed it. The apps are not preloaded.
125 * @param packageList List of package names to keep cached.
126 */
127 public abstract void setKeepUninstalledPackages(List<String> packageList);
Svet Ganov9c165d72015-12-01 19:52:26 -0800128
129 /**
130 * Gets whether some of the permissions used by this package require a user
131 * review before any of the app components can run.
132 * @param packageName The package name for which to check.
133 * @param userId The user under which to check.
134 * @return True a permissions review is required.
135 */
136 public abstract boolean isPermissionsReviewRequired(String packageName, int userId);
Todd Kennedy39bfee52016-02-24 10:28:21 -0800137
138 /**
Todd Kennedy18211fd2017-06-06 09:15:46 -0700139 * Retrieve all of the information we know about a particular package/application.
140 * @param filterCallingUid The results will be filtered in the context of this UID instead
141 * of the calling UID.
142 * @see PackageManager#getPackageInfo(String, int)
Todd Kennedy39bfee52016-02-24 10:28:21 -0800143 */
Todd Kennedy18211fd2017-06-06 09:15:46 -0700144 public abstract PackageInfo getPackageInfo(String packageName,
145 @PackageInfoFlags int flags, int filterCallingUid, int userId);
146
147 /**
148 * Retrieve all of the information we know about a particular package/application.
149 * @param filterCallingUid The results will be filtered in the context of this UID instead
150 * of the calling UID.
151 * @see PackageManager#getApplicationInfo(String, int)
152 */
153 public abstract ApplicationInfo getApplicationInfo(String packageName,
154 @ApplicationInfoFlags int flags, int filterCallingUid, int userId);
155
156 /**
157 * Retrieve all of the information we know about a particular activity class.
158 * @param filterCallingUid The results will be filtered in the context of this UID instead
159 * of the calling UID.
160 * @see PackageManager#getActivityInfo(ComponentName, int)
161 */
162 public abstract ActivityInfo getActivityInfo(ComponentName component,
163 @ComponentInfoFlags int flags, int filterCallingUid, int userId);
164
165 /**
166 * Retrieve all activities that can be performed for the given intent.
167 * @param filterCallingUid The results will be filtered in the context of this UID instead
168 * of the calling UID.
169 * @see PackageManager#queryIntentActivities(Intent, int)
170 */
171 public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
172 @ResolveInfoFlags int flags, int filterCallingUid, int userId);
Makoto Onuki2d5b4652016-03-11 16:09:54 -0800173
174 /**
175 * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}.
176 */
177 public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates,
178 int userId);
Makoto Onukic29f62c2016-06-07 12:19:46 -0700179
180 /**
181 * Called by DeviceOwnerManagerService to set the package names of device owner and profile
182 * owners.
183 */
184 public abstract void setDeviceAndProfileOwnerPackages(
185 int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners);
186
187 /**
Steven Ng9d48a732016-06-24 19:04:14 +0100188 * Returns {@code true} if a given package can't be wiped. Otherwise, returns {@code false}.
Makoto Onukic29f62c2016-06-07 12:19:46 -0700189 */
Steven Ng9d48a732016-06-24 19:04:14 +0100190 public abstract boolean isPackageDataProtected(int userId, String packageName);
Svet Ganov973edd192016-09-08 20:15:55 -0700191
192 /**
Dianne Hackborne07641d2016-11-09 15:07:23 -0800193 * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns
194 * {@code false}.
195 */
196 public abstract boolean isPackageEphemeral(int userId, String packageName);
197
198 /**
Svet Ganov973edd192016-09-08 20:15:55 -0700199 * Gets whether the package was ever launched.
200 * @param packageName The package name.
201 * @param userId The user for which to check.
202 * @return Whether was launched.
Amith Yamasani2cbfa1e2017-03-28 10:34:01 -0700203 * @throws IllegalArgumentException if the package is not found
Svet Ganov973edd192016-09-08 20:15:55 -0700204 */
205 public abstract boolean wasPackageEverLaunched(String packageName, int userId);
Nicolas Prevot700e1e72016-09-28 15:17:18 +0100206
207 /**
208 * Grants a runtime permission
209 * @param packageName The package name.
210 * @param name The name of the permission.
211 * @param userId The userId for which to grant the permission.
212 * @param overridePolicy If true, grant this permission even if it is fixed by policy.
213 */
214 public abstract void grantRuntimePermission(String packageName, String name, int userId,
215 boolean overridePolicy);
216
217 /**
218 * Revokes a runtime permission
219 * @param packageName The package name.
220 * @param name The name of the permission.
221 * @param userId The userId for which to revoke the permission.
222 * @param overridePolicy If true, revoke this permission even if it is fixed by policy.
223 */
224 public abstract void revokeRuntimePermission(String packageName, String name, int userId,
225 boolean overridePolicy);
226
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100227 /**
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000228 * Retrieve the official name associated with a uid. This name is
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100229 * guaranteed to never change, though it is possible for the underlying
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000230 * uid to be changed. That is, if you are storing information about
231 * uids in persistent storage, you should use the string returned
232 * by this function instead of the raw uid.
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100233 *
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000234 * @param uid The uid for which you would like to retrieve a name.
235 * @return Returns a unique name for the given uid, or null if the
236 * uid is not currently assigned.
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100237 */
238 public abstract String getNameForUid(int uid);
239
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800240 /**
241 * Request to perform the second phase of ephemeral resolution.
242 * @param responseObj The response of the first phase of ephemeral resolution
243 * @param origIntent The original intent that triggered ephemeral resolution
244 * @param resolvedType The resolved type of the intent
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800245 * @param callingPackage The name of the package requesting the ephemeral application
Chad Brubaker06068612017-04-06 09:43:47 -0700246 * @param verificationBundle Optional bundle to pass to the installer for additional
247 * verification
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800248 * @param userId The ID of the user that triggered ephemeral resolution
249 */
Todd Kennedye9910222017-02-21 16:00:11 -0800250 public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj,
251 Intent origIntent, String resolvedType, String callingPackage,
Chad Brubaker06068612017-04-06 09:43:47 -0700252 Bundle verificationBundle, int userId);
Svetoslav Ganove080da92016-12-21 17:10:35 -0800253
254 /**
Todd Kennedy0e989d02017-01-13 14:15:36 -0800255 * Grants access to the package metadata for an ephemeral application.
256 * <p>
257 * When an ephemeral application explicitly tries to interact with a full
258 * install application [via an activity, service or provider that has been
259 * exposed using the {@code visibleToInstantApp} attribute], the normal
260 * application must be able to see metadata about the connecting ephemeral
261 * app. If the ephemeral application uses an implicit intent [ie action VIEW,
262 * category BROWSABLE], it remains hidden from the launched activity.
263 * <p>
264 * If the {@code sourceUid} is not for an ephemeral app or {@code targetUid}
265 * is not for a fully installed app, this method will be a no-op.
266 *
267 * @param userId the user
268 * @param intent the intent that triggered the grant
269 * @param targetAppId The app ID of the fully installed application
270 * @param ephemeralAppId The app ID of the ephemeral application
271 */
272 public abstract void grantEphemeralAccess(int userId, Intent intent,
273 int targetAppId, int ephemeralAppId);
274
Todd Kennedyb21be122017-03-24 14:10:01 -0700275 public abstract boolean isInstantAppInstallerComponent(ComponentName component);
Todd Kennedy0e989d02017-01-13 14:15:36 -0800276 /**
Svetoslav Ganov096d3042017-01-30 16:34:13 -0800277 * Prunes instant apps and state associated with uninstalled
278 * instant apps according to the current platform policy.
279 */
280 public abstract void pruneInstantApps();
281
282 /**
Svetoslav Ganove080da92016-12-21 17:10:35 -0800283 * @return The SetupWizard package name.
284 */
285 public abstract String getSetupWizardPackageName();
Suprabh Shuklaaef25132017-01-23 18:09:03 -0800286
287 public interface ExternalSourcesPolicy {
288
289 int USER_TRUSTED = 0; // User has trusted the package to install apps
290 int USER_BLOCKED = 1; // User has blocked the package to install apps
291 int USER_DEFAULT = 2; // Default code to use when user response is unavailable
292
293 /**
294 * Checks the user preference for whether a package is trusted to request installs through
295 * package installer
296 *
297 * @param packageName The package to check for
298 * @param uid the uid in which the package is running
299 * @return {@link USER_TRUSTED} if the user has trusted the package, {@link USER_BLOCKED}
300 * if user has blocked requests from the package, {@link USER_DEFAULT} if the user response
301 * is not yet available
302 */
303 int getPackageTrustedToInstallApps(String packageName, int uid);
304 }
305
306 public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy);
Mårten Kongstadeabc9e92015-12-15 16:40:23 +0100307
308 /**
Dianne Hackbornb1e77762017-02-13 11:42:18 -0800309 * Return true if the given package is a persistent app process.
310 */
311 public abstract boolean isPackagePersistent(String packageName);
312
313 /**
Mårten Kongstadeabc9e92015-12-15 16:40:23 +0100314 * Get all overlay packages for a user.
315 * @param userId The user for which to get the overlays.
316 * @return A list of overlay packages. An empty list is returned if the
317 * user has no installed overlay packages.
318 */
319 public abstract List<PackageInfo> getOverlayPackages(int userId);
320
321 /**
322 * Get the names of all target packages for a user.
323 * @param userId The user for which to get the package names.
324 * @return A list of target package names. This list includes the "android" package.
325 */
326 public abstract List<String> getTargetPackageNames(int userId);
327
328 /**
329 * Set which overlay to use for a package.
330 * @param userId The user for which to update the overlays.
331 * @param targetPackageName The package name of the package for which to update the overlays.
332 * @param overlayPackageNames The complete list of overlay packages that should be enabled for
333 * the target. Previously enabled overlays not specified in the list
334 * will be disabled. Pass in null or an empty list to disable
335 * all overlays. The order of the items is significant if several
336 * overlays modify the same resource.
337 * @return true if all packages names were known by the package manager, false otherwise
338 */
339 public abstract boolean setEnabledOverlayPackages(int userId, String targetPackageName,
340 List<String> overlayPackageNames);
Todd Kennedy4d1de7d2017-02-23 10:32:18 -0800341
342 /**
Todd Kennedy51b3aac2017-03-30 17:50:42 -0700343 * Resolves an activity intent, allowing instant apps to be resolved.
Todd Kennedy4d1de7d2017-02-23 10:32:18 -0800344 */
345 public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType,
346 int flags, int userId);
Chad Brubaker0f28a802017-03-29 14:05:52 -0700347
348 /**
Todd Kennedy51b3aac2017-03-30 17:50:42 -0700349 * Resolves a service intent, allowing instant apps to be resolved.
350 */
351 public abstract ResolveInfo resolveService(Intent intent, String resolvedType,
352 int flags, int userId, int callingUid);
353
354 /**
Chad Brubaker0f28a802017-03-29 14:05:52 -0700355 * Track the creator of a new isolated uid.
356 * @param isolatedUid The newly created isolated uid.
357 * @param ownerUid The uid of the app that created the isolated process.
358 */
359 public abstract void addIsolatedUid(int isolatedUid, int ownerUid);
360
361 /**
362 * Track removal of an isolated uid.
363 * @param isolatedUid isolated uid that is no longer being used.
364 */
365 public abstract void removeIsolatedUid(int isolatedUid);
Makoto Onukie92f7942017-04-26 14:38:18 -0700366
367 /**
368 * Return the taget SDK version for the app with the given UID.
369 */
370 public abstract int getUidTargetSdkVersion(int uid);
Makoto Onukiad623012017-05-15 09:29:34 -0700371
372 /** Whether the binder caller can access instant apps. */
Todd Kennedy3051caa2017-05-23 15:54:18 -0700373 public abstract boolean canAccessInstantApps(int callingUid, int userId);
Svet Ganovf935a702017-08-22 12:15:58 -0700374
375 /**
376 * Returns {@code true} if a given package has instant application meta-data.
377 * Otherwise, returns {@code false}. Meta-data is state (eg. cookie, app icon, etc)
378 * associated with an instant app. It may be kept after the instant app has been uninstalled.
379 */
380 public abstract boolean hasInstantApplicationMetadata(String packageName, int userId);
Todd Kennedydf113c32017-08-31 16:10:29 -0700381
382 /**
383 * Updates a package last used time.
384 */
385 public abstract void notifyPackageUse(String packageName, int reason);
Svet Ganovadc1cf42015-06-15 16:36:24 -0700386}