blob: b3e25d1d71b3e50bec2ea17c78cb7a47129735aa [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 Kennedy39bfee52016-02-24 10:28:21 -080021import android.content.pm.PackageManager.NameNotFoundException;
Makoto Onukic29f62c2016-06-07 12:19:46 -070022import android.util.SparseArray;
Todd Kennedy39bfee52016-02-24 10:28:21 -080023
Fyodor Kupolovcb6fd802015-11-05 14:27:06 -080024import java.util.List;
Svet Ganovadc1cf42015-06-15 16:36:24 -070025
26/**
27 * Package manager local system service interface.
28 *
29 * @hide Only for use within the system server.
30 */
31public abstract class PackageManagerInternal {
32
33 /**
34 * Provider for package names.
35 */
36 public interface PackagesProvider {
37
38 /**
39 * Gets the packages for a given user.
40 * @param userId The user id.
41 * @return The package names.
42 */
43 public String[] getPackages(int userId);
44 }
45
46 /**
Svetoslav0010b702015-06-30 18:05:26 -070047 * Provider for package names.
48 */
49 public interface SyncAdapterPackagesProvider {
50
51 /**
52 * Gets the sync adapter packages for given authority and user.
53 * @param authority The authority.
54 * @param userId The user id.
55 * @return The package names.
56 */
57 public String[] getPackages(String authority, int userId);
58 }
59
60 /**
Svet Ganovadc1cf42015-06-15 16:36:24 -070061 * Sets the location provider packages provider.
62 * @param provider The packages provider.
63 */
64 public abstract void setLocationPackagesProvider(PackagesProvider provider);
65
66 /**
Svet Ganovadc1cf42015-06-15 16:36:24 -070067 * Sets the voice interaction packages provider.
68 * @param provider The packages provider.
69 */
70 public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider);
Svetoslavcdfd2302015-06-25 19:07:31 -070071
72 /**
73 * Sets the SMS packages provider.
74 * @param provider The packages provider.
75 */
76 public abstract void setSmsAppPackagesProvider(PackagesProvider provider);
77
78 /**
79 * Sets the dialer packages provider.
80 * @param provider The packages provider.
81 */
82 public abstract void setDialerAppPackagesProvider(PackagesProvider provider);
83
84 /**
Sailesh Nepalcf855622015-07-28 19:22:14 -070085 * Sets the sim call manager packages provider.
86 * @param provider The packages provider.
87 */
88 public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider);
89
90 /**
Svetoslav0010b702015-06-30 18:05:26 -070091 * Sets the sync adapter packages provider.
92 * @param provider The provider.
93 */
94 public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider);
95
96 /**
Svetoslavcdfd2302015-06-25 19:07:31 -070097 * Requests granting of the default permissions to the current default SMS app.
98 * @param packageName The default SMS package name.
99 * @param userId The user for which to grant the permissions.
100 */
101 public abstract void grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId);
102
103 /**
104 * Requests granting of the default permissions to the current default dialer app.
105 * @param packageName The default dialer package name.
106 * @param userId The user for which to grant the permissions.
107 */
108 public abstract void grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId);
Sailesh Nepalcf855622015-07-28 19:22:14 -0700109
110 /**
111 * Requests granting of the default permissions to the current default sim call manager.
112 * @param packageName The default sim call manager package name.
113 * @param userId The user for which to grant the permissions.
114 */
115 public abstract void grantDefaultPermissionsToDefaultSimCallManager(String packageName,
116 int userId);
Fyodor Kupolovcb6fd802015-11-05 14:27:06 -0800117
118 /**
119 * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has
120 * currently installed it. The apps are not preloaded.
121 * @param packageList List of package names to keep cached.
122 */
123 public abstract void setKeepUninstalledPackages(List<String> packageList);
Svet Ganov9c165d72015-12-01 19:52:26 -0800124
125 /**
126 * Gets whether some of the permissions used by this package require a user
127 * review before any of the app components can run.
128 * @param packageName The package name for which to check.
129 * @param userId The user under which to check.
130 * @return True a permissions review is required.
131 */
132 public abstract boolean isPermissionsReviewRequired(String packageName, int userId);
Todd Kennedy39bfee52016-02-24 10:28:21 -0800133
134 /**
135 * Gets all of the information we know about a particular package.
136 *
137 * @param packageName The package name to find.
138 * @param userId The user under which to check.
139 *
140 * @return An {@link ApplicationInfo} containing information about the
Christopher Tate42a386b2016-11-07 12:21:21 -0800141 * package, or {@code null} if no application exists with that
142 * package name.
Todd Kennedy39bfee52016-02-24 10:28:21 -0800143 */
144 public abstract ApplicationInfo getApplicationInfo(String packageName, int userId);
Makoto Onuki2d5b4652016-03-11 16:09:54 -0800145
146 /**
147 * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}.
148 */
149 public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates,
150 int userId);
Makoto Onukic29f62c2016-06-07 12:19:46 -0700151
152 /**
153 * Called by DeviceOwnerManagerService to set the package names of device owner and profile
154 * owners.
155 */
156 public abstract void setDeviceAndProfileOwnerPackages(
157 int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners);
158
159 /**
Steven Ng9d48a732016-06-24 19:04:14 +0100160 * Returns {@code true} if a given package can't be wiped. Otherwise, returns {@code false}.
Makoto Onukic29f62c2016-06-07 12:19:46 -0700161 */
Steven Ng9d48a732016-06-24 19:04:14 +0100162 public abstract boolean isPackageDataProtected(int userId, String packageName);
Svet Ganov973edd192016-09-08 20:15:55 -0700163
164 /**
Dianne Hackborne07641d2016-11-09 15:07:23 -0800165 * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns
166 * {@code false}.
167 */
168 public abstract boolean isPackageEphemeral(int userId, String packageName);
169
170 /**
Svet Ganov973edd192016-09-08 20:15:55 -0700171 * Gets whether the package was ever launched.
172 * @param packageName The package name.
173 * @param userId The user for which to check.
174 * @return Whether was launched.
Amith Yamasani2cbfa1e2017-03-28 10:34:01 -0700175 * @throws IllegalArgumentException if the package is not found
Svet Ganov973edd192016-09-08 20:15:55 -0700176 */
177 public abstract boolean wasPackageEverLaunched(String packageName, int userId);
Nicolas Prevot700e1e72016-09-28 15:17:18 +0100178
179 /**
180 * Grants a runtime permission
181 * @param packageName The package name.
182 * @param name The name of the permission.
183 * @param userId The userId for which to grant the permission.
184 * @param overridePolicy If true, grant this permission even if it is fixed by policy.
185 */
186 public abstract void grantRuntimePermission(String packageName, String name, int userId,
187 boolean overridePolicy);
188
189 /**
190 * Revokes a runtime permission
191 * @param packageName The package name.
192 * @param name The name of the permission.
193 * @param userId The userId for which to revoke the permission.
194 * @param overridePolicy If true, revoke this permission even if it is fixed by policy.
195 */
196 public abstract void revokeRuntimePermission(String packageName, String name, int userId,
197 boolean overridePolicy);
198
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100199 /**
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000200 * Retrieve the official name associated with a uid. This name is
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100201 * guaranteed to never change, though it is possible for the underlying
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000202 * uid to be changed. That is, if you are storing information about
203 * uids in persistent storage, you should use the string returned
204 * by this function instead of the raw uid.
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100205 *
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000206 * @param uid The uid for which you would like to retrieve a name.
207 * @return Returns a unique name for the given uid, or null if the
208 * uid is not currently assigned.
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100209 */
210 public abstract String getNameForUid(int uid);
211
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800212 /**
213 * Request to perform the second phase of ephemeral resolution.
214 * @param responseObj The response of the first phase of ephemeral resolution
215 * @param origIntent The original intent that triggered ephemeral resolution
216 * @param resolvedType The resolved type of the intent
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800217 * @param callingPackage The name of the package requesting the ephemeral application
218 * @param userId The ID of the user that triggered ephemeral resolution
219 */
Todd Kennedye9910222017-02-21 16:00:11 -0800220 public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj,
221 Intent origIntent, String resolvedType, String callingPackage,
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800222 int userId);
Svetoslav Ganove080da92016-12-21 17:10:35 -0800223
224 /**
Todd Kennedy0e989d02017-01-13 14:15:36 -0800225 * Grants access to the package metadata for an ephemeral application.
226 * <p>
227 * When an ephemeral application explicitly tries to interact with a full
228 * install application [via an activity, service or provider that has been
229 * exposed using the {@code visibleToInstantApp} attribute], the normal
230 * application must be able to see metadata about the connecting ephemeral
231 * app. If the ephemeral application uses an implicit intent [ie action VIEW,
232 * category BROWSABLE], it remains hidden from the launched activity.
233 * <p>
234 * If the {@code sourceUid} is not for an ephemeral app or {@code targetUid}
235 * is not for a fully installed app, this method will be a no-op.
236 *
237 * @param userId the user
238 * @param intent the intent that triggered the grant
239 * @param targetAppId The app ID of the fully installed application
240 * @param ephemeralAppId The app ID of the ephemeral application
241 */
242 public abstract void grantEphemeralAccess(int userId, Intent intent,
243 int targetAppId, int ephemeralAppId);
244
245 /**
Svetoslav Ganov096d3042017-01-30 16:34:13 -0800246 * Prunes instant apps and state associated with uninstalled
247 * instant apps according to the current platform policy.
248 */
249 public abstract void pruneInstantApps();
250
251 /**
Svetoslav Ganove080da92016-12-21 17:10:35 -0800252 * @return The SetupWizard package name.
253 */
254 public abstract String getSetupWizardPackageName();
Suprabh Shuklaaef25132017-01-23 18:09:03 -0800255
256 public interface ExternalSourcesPolicy {
257
258 int USER_TRUSTED = 0; // User has trusted the package to install apps
259 int USER_BLOCKED = 1; // User has blocked the package to install apps
260 int USER_DEFAULT = 2; // Default code to use when user response is unavailable
261
262 /**
263 * Checks the user preference for whether a package is trusted to request installs through
264 * package installer
265 *
266 * @param packageName The package to check for
267 * @param uid the uid in which the package is running
268 * @return {@link USER_TRUSTED} if the user has trusted the package, {@link USER_BLOCKED}
269 * if user has blocked requests from the package, {@link USER_DEFAULT} if the user response
270 * is not yet available
271 */
272 int getPackageTrustedToInstallApps(String packageName, int uid);
273 }
274
275 public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy);
Mårten Kongstadeabc9e92015-12-15 16:40:23 +0100276
277 /**
Dianne Hackbornb1e77762017-02-13 11:42:18 -0800278 * Return true if the given package is a persistent app process.
279 */
280 public abstract boolean isPackagePersistent(String packageName);
281
282 /**
Mårten Kongstadeabc9e92015-12-15 16:40:23 +0100283 * Get all overlay packages for a user.
284 * @param userId The user for which to get the overlays.
285 * @return A list of overlay packages. An empty list is returned if the
286 * user has no installed overlay packages.
287 */
288 public abstract List<PackageInfo> getOverlayPackages(int userId);
289
290 /**
291 * Get the names of all target packages for a user.
292 * @param userId The user for which to get the package names.
293 * @return A list of target package names. This list includes the "android" package.
294 */
295 public abstract List<String> getTargetPackageNames(int userId);
296
297 /**
298 * Set which overlay to use for a package.
299 * @param userId The user for which to update the overlays.
300 * @param targetPackageName The package name of the package for which to update the overlays.
301 * @param overlayPackageNames The complete list of overlay packages that should be enabled for
302 * the target. Previously enabled overlays not specified in the list
303 * will be disabled. Pass in null or an empty list to disable
304 * all overlays. The order of the items is significant if several
305 * overlays modify the same resource.
306 * @return true if all packages names were known by the package manager, false otherwise
307 */
308 public abstract boolean setEnabledOverlayPackages(int userId, String targetPackageName,
309 List<String> overlayPackageNames);
Todd Kennedy4d1de7d2017-02-23 10:32:18 -0800310
311 /**
312 * Resolves an intent, allowing instant apps to be resolved.
313 */
314 public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType,
315 int flags, int userId);
Svet Ganovadc1cf42015-06-15 16:36:24 -0700316}