blob: 99700df2b990a6c4318ebb293445aef9d1366809 [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 Kennedy39bfee52016-02-24 10:28:21 -080023import android.content.pm.PackageManager.NameNotFoundException;
Todd Kennedy18211fd2017-06-06 09:15:46 -070024import android.content.pm.PackageManager.PackageInfoFlags;
25import android.content.pm.PackageManager.ResolveInfoFlags;
Chad Brubaker06068612017-04-06 09:43:47 -070026import android.os.Bundle;
Makoto Onukic29f62c2016-06-07 12:19:46 -070027import android.util.SparseArray;
Todd Kennedy39bfee52016-02-24 10:28:21 -080028
Fyodor Kupolovcb6fd802015-11-05 14:27:06 -080029import java.util.List;
Svet Ganovadc1cf42015-06-15 16:36:24 -070030
31/**
32 * Package manager local system service interface.
33 *
34 * @hide Only for use within the system server.
35 */
36public abstract class PackageManagerInternal {
37
38 /**
39 * Provider for package names.
40 */
41 public interface PackagesProvider {
42
43 /**
44 * Gets the packages for a given user.
45 * @param userId The user id.
46 * @return The package names.
47 */
48 public String[] getPackages(int userId);
49 }
50
51 /**
Svetoslav0010b702015-06-30 18:05:26 -070052 * Provider for package names.
53 */
54 public interface SyncAdapterPackagesProvider {
55
56 /**
57 * Gets the sync adapter packages for given authority and user.
58 * @param authority The authority.
59 * @param userId The user id.
60 * @return The package names.
61 */
62 public String[] getPackages(String authority, int userId);
63 }
64
65 /**
Svet Ganovadc1cf42015-06-15 16:36:24 -070066 * Sets the location provider packages provider.
67 * @param provider The packages provider.
68 */
69 public abstract void setLocationPackagesProvider(PackagesProvider provider);
70
71 /**
Svet Ganovadc1cf42015-06-15 16:36:24 -070072 * Sets the voice interaction packages provider.
73 * @param provider The packages provider.
74 */
75 public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider);
Svetoslavcdfd2302015-06-25 19:07:31 -070076
77 /**
78 * Sets the SMS packages provider.
79 * @param provider The packages provider.
80 */
81 public abstract void setSmsAppPackagesProvider(PackagesProvider provider);
82
83 /**
84 * Sets the dialer packages provider.
85 * @param provider The packages provider.
86 */
87 public abstract void setDialerAppPackagesProvider(PackagesProvider provider);
88
89 /**
Sailesh Nepalcf855622015-07-28 19:22:14 -070090 * Sets the sim call manager packages provider.
91 * @param provider The packages provider.
92 */
93 public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider);
94
95 /**
Svetoslav0010b702015-06-30 18:05:26 -070096 * Sets the sync adapter packages provider.
97 * @param provider The provider.
98 */
99 public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider);
100
101 /**
Svetoslavcdfd2302015-06-25 19:07:31 -0700102 * Requests granting of the default permissions to the current default SMS app.
103 * @param packageName The default SMS package name.
104 * @param userId The user for which to grant the permissions.
105 */
106 public abstract void grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId);
107
108 /**
109 * Requests granting of the default permissions to the current default dialer app.
110 * @param packageName The default dialer package name.
111 * @param userId The user for which to grant the permissions.
112 */
113 public abstract void grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId);
Sailesh Nepalcf855622015-07-28 19:22:14 -0700114
115 /**
116 * Requests granting of the default permissions to the current default sim call manager.
117 * @param packageName The default sim call manager package name.
118 * @param userId The user for which to grant the permissions.
119 */
120 public abstract void grantDefaultPermissionsToDefaultSimCallManager(String packageName,
121 int userId);
Fyodor Kupolovcb6fd802015-11-05 14:27:06 -0800122
123 /**
124 * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has
125 * currently installed it. The apps are not preloaded.
126 * @param packageList List of package names to keep cached.
127 */
128 public abstract void setKeepUninstalledPackages(List<String> packageList);
Svet Ganov9c165d72015-12-01 19:52:26 -0800129
130 /**
131 * Gets whether some of the permissions used by this package require a user
132 * review before any of the app components can run.
133 * @param packageName The package name for which to check.
134 * @param userId The user under which to check.
135 * @return True a permissions review is required.
136 */
137 public abstract boolean isPermissionsReviewRequired(String packageName, int userId);
Todd Kennedy39bfee52016-02-24 10:28:21 -0800138
139 /**
Todd Kennedy18211fd2017-06-06 09:15:46 -0700140 * Retrieve all of the information we know about a particular package/application.
141 * @param filterCallingUid The results will be filtered in the context of this UID instead
142 * of the calling UID.
143 * @see PackageManager#getPackageInfo(String, int)
Todd Kennedy39bfee52016-02-24 10:28:21 -0800144 */
Todd Kennedy18211fd2017-06-06 09:15:46 -0700145 public abstract PackageInfo getPackageInfo(String packageName,
146 @PackageInfoFlags int flags, int filterCallingUid, int userId);
147
148 /**
149 * Retrieve all of the information we know about a particular package/application.
150 * @param filterCallingUid The results will be filtered in the context of this UID instead
151 * of the calling UID.
152 * @see PackageManager#getApplicationInfo(String, int)
153 */
154 public abstract ApplicationInfo getApplicationInfo(String packageName,
155 @ApplicationInfoFlags int flags, int filterCallingUid, int userId);
156
157 /**
158 * Retrieve all of the information we know about a particular activity class.
159 * @param filterCallingUid The results will be filtered in the context of this UID instead
160 * of the calling UID.
161 * @see PackageManager#getActivityInfo(ComponentName, int)
162 */
163 public abstract ActivityInfo getActivityInfo(ComponentName component,
164 @ComponentInfoFlags int flags, int filterCallingUid, int userId);
165
166 /**
167 * Retrieve all activities that can be performed for the given intent.
168 * @param filterCallingUid The results will be filtered in the context of this UID instead
169 * of the calling UID.
170 * @see PackageManager#queryIntentActivities(Intent, int)
171 */
172 public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
173 @ResolveInfoFlags int flags, int filterCallingUid, int userId);
Makoto Onuki2d5b4652016-03-11 16:09:54 -0800174
175 /**
176 * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}.
177 */
178 public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates,
179 int userId);
Makoto Onukic29f62c2016-06-07 12:19:46 -0700180
181 /**
182 * Called by DeviceOwnerManagerService to set the package names of device owner and profile
183 * owners.
184 */
185 public abstract void setDeviceAndProfileOwnerPackages(
186 int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners);
187
188 /**
Steven Ng9d48a732016-06-24 19:04:14 +0100189 * Returns {@code true} if a given package can't be wiped. Otherwise, returns {@code false}.
Makoto Onukic29f62c2016-06-07 12:19:46 -0700190 */
Steven Ng9d48a732016-06-24 19:04:14 +0100191 public abstract boolean isPackageDataProtected(int userId, String packageName);
Svet Ganov973edd192016-09-08 20:15:55 -0700192
193 /**
Dianne Hackborne07641d2016-11-09 15:07:23 -0800194 * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns
195 * {@code false}.
196 */
197 public abstract boolean isPackageEphemeral(int userId, String packageName);
198
199 /**
Svet Ganov973edd192016-09-08 20:15:55 -0700200 * Gets whether the package was ever launched.
201 * @param packageName The package name.
202 * @param userId The user for which to check.
203 * @return Whether was launched.
Amith Yamasani2cbfa1e2017-03-28 10:34:01 -0700204 * @throws IllegalArgumentException if the package is not found
Svet Ganov973edd192016-09-08 20:15:55 -0700205 */
206 public abstract boolean wasPackageEverLaunched(String packageName, int userId);
Nicolas Prevot700e1e72016-09-28 15:17:18 +0100207
208 /**
209 * Grants a runtime permission
210 * @param packageName The package name.
211 * @param name The name of the permission.
212 * @param userId The userId for which to grant the permission.
213 * @param overridePolicy If true, grant this permission even if it is fixed by policy.
214 */
215 public abstract void grantRuntimePermission(String packageName, String name, int userId,
216 boolean overridePolicy);
217
218 /**
219 * Revokes a runtime permission
220 * @param packageName The package name.
221 * @param name The name of the permission.
222 * @param userId The userId for which to revoke the permission.
223 * @param overridePolicy If true, revoke this permission even if it is fixed by policy.
224 */
225 public abstract void revokeRuntimePermission(String packageName, String name, int userId,
226 boolean overridePolicy);
227
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100228 /**
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000229 * Retrieve the official name associated with a uid. This name is
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100230 * guaranteed to never change, though it is possible for the underlying
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000231 * uid to be changed. That is, if you are storing information about
232 * uids in persistent storage, you should use the string returned
233 * by this function instead of the raw uid.
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100234 *
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000235 * @param uid The uid for which you would like to retrieve a name.
236 * @return Returns a unique name for the given uid, or null if the
237 * uid is not currently assigned.
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100238 */
239 public abstract String getNameForUid(int uid);
240
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800241 /**
242 * Request to perform the second phase of ephemeral resolution.
243 * @param responseObj The response of the first phase of ephemeral resolution
244 * @param origIntent The original intent that triggered ephemeral resolution
245 * @param resolvedType The resolved type of the intent
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800246 * @param callingPackage The name of the package requesting the ephemeral application
Chad Brubaker06068612017-04-06 09:43:47 -0700247 * @param verificationBundle Optional bundle to pass to the installer for additional
248 * verification
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800249 * @param userId The ID of the user that triggered ephemeral resolution
250 */
Todd Kennedye9910222017-02-21 16:00:11 -0800251 public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj,
252 Intent origIntent, String resolvedType, String callingPackage,
Chad Brubaker06068612017-04-06 09:43:47 -0700253 Bundle verificationBundle, int userId);
Svetoslav Ganove080da92016-12-21 17:10:35 -0800254
255 /**
Todd Kennedy0e989d02017-01-13 14:15:36 -0800256 * Grants access to the package metadata for an ephemeral application.
257 * <p>
258 * When an ephemeral application explicitly tries to interact with a full
259 * install application [via an activity, service or provider that has been
260 * exposed using the {@code visibleToInstantApp} attribute], the normal
261 * application must be able to see metadata about the connecting ephemeral
262 * app. If the ephemeral application uses an implicit intent [ie action VIEW,
263 * category BROWSABLE], it remains hidden from the launched activity.
264 * <p>
265 * If the {@code sourceUid} is not for an ephemeral app or {@code targetUid}
266 * is not for a fully installed app, this method will be a no-op.
267 *
268 * @param userId the user
269 * @param intent the intent that triggered the grant
270 * @param targetAppId The app ID of the fully installed application
271 * @param ephemeralAppId The app ID of the ephemeral application
272 */
273 public abstract void grantEphemeralAccess(int userId, Intent intent,
274 int targetAppId, int ephemeralAppId);
275
Todd Kennedyb21be122017-03-24 14:10:01 -0700276 public abstract boolean isInstantAppInstallerComponent(ComponentName component);
Todd Kennedy0e989d02017-01-13 14:15:36 -0800277 /**
Svetoslav Ganov096d3042017-01-30 16:34:13 -0800278 * Prunes instant apps and state associated with uninstalled
279 * instant apps according to the current platform policy.
280 */
281 public abstract void pruneInstantApps();
282
283 /**
Svetoslav Ganove080da92016-12-21 17:10:35 -0800284 * @return The SetupWizard package name.
285 */
286 public abstract String getSetupWizardPackageName();
Suprabh Shuklaaef25132017-01-23 18:09:03 -0800287
288 public interface ExternalSourcesPolicy {
289
290 int USER_TRUSTED = 0; // User has trusted the package to install apps
291 int USER_BLOCKED = 1; // User has blocked the package to install apps
292 int USER_DEFAULT = 2; // Default code to use when user response is unavailable
293
294 /**
295 * Checks the user preference for whether a package is trusted to request installs through
296 * package installer
297 *
298 * @param packageName The package to check for
299 * @param uid the uid in which the package is running
300 * @return {@link USER_TRUSTED} if the user has trusted the package, {@link USER_BLOCKED}
301 * if user has blocked requests from the package, {@link USER_DEFAULT} if the user response
302 * is not yet available
303 */
304 int getPackageTrustedToInstallApps(String packageName, int uid);
305 }
306
307 public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy);
Mårten Kongstadeabc9e92015-12-15 16:40:23 +0100308
309 /**
Dianne Hackbornb1e77762017-02-13 11:42:18 -0800310 * Return true if the given package is a persistent app process.
311 */
312 public abstract boolean isPackagePersistent(String packageName);
313
314 /**
Mårten Kongstadeabc9e92015-12-15 16:40:23 +0100315 * Get all overlay packages for a user.
316 * @param userId The user for which to get the overlays.
317 * @return A list of overlay packages. An empty list is returned if the
318 * user has no installed overlay packages.
319 */
320 public abstract List<PackageInfo> getOverlayPackages(int userId);
321
322 /**
323 * Get the names of all target packages for a user.
324 * @param userId The user for which to get the package names.
325 * @return A list of target package names. This list includes the "android" package.
326 */
327 public abstract List<String> getTargetPackageNames(int userId);
328
329 /**
330 * Set which overlay to use for a package.
331 * @param userId The user for which to update the overlays.
332 * @param targetPackageName The package name of the package for which to update the overlays.
333 * @param overlayPackageNames The complete list of overlay packages that should be enabled for
334 * the target. Previously enabled overlays not specified in the list
335 * will be disabled. Pass in null or an empty list to disable
336 * all overlays. The order of the items is significant if several
337 * overlays modify the same resource.
338 * @return true if all packages names were known by the package manager, false otherwise
339 */
340 public abstract boolean setEnabledOverlayPackages(int userId, String targetPackageName,
341 List<String> overlayPackageNames);
Todd Kennedy4d1de7d2017-02-23 10:32:18 -0800342
343 /**
Todd Kennedy51b3aac2017-03-30 17:50:42 -0700344 * Resolves an activity intent, allowing instant apps to be resolved.
Todd Kennedy4d1de7d2017-02-23 10:32:18 -0800345 */
346 public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType,
347 int flags, int userId);
Chad Brubaker0f28a802017-03-29 14:05:52 -0700348
349 /**
Todd Kennedy51b3aac2017-03-30 17:50:42 -0700350 * Resolves a service intent, allowing instant apps to be resolved.
351 */
352 public abstract ResolveInfo resolveService(Intent intent, String resolvedType,
353 int flags, int userId, int callingUid);
354
355 /**
Chad Brubaker0f28a802017-03-29 14:05:52 -0700356 * Track the creator of a new isolated uid.
357 * @param isolatedUid The newly created isolated uid.
358 * @param ownerUid The uid of the app that created the isolated process.
359 */
360 public abstract void addIsolatedUid(int isolatedUid, int ownerUid);
361
362 /**
363 * Track removal of an isolated uid.
364 * @param isolatedUid isolated uid that is no longer being used.
365 */
366 public abstract void removeIsolatedUid(int isolatedUid);
Makoto Onukie92f7942017-04-26 14:38:18 -0700367
368 /**
369 * Return the taget SDK version for the app with the given UID.
370 */
371 public abstract int getUidTargetSdkVersion(int uid);
Makoto Onukiad623012017-05-15 09:29:34 -0700372
373 /** Whether the binder caller can access instant apps. */
Todd Kennedy3051caa2017-05-23 15:54:18 -0700374 public abstract boolean canAccessInstantApps(int callingUid, int userId);
Svet Ganovadc1cf42015-06-15 16:36:24 -0700375}