blob: 63d092456a26823b0ee110344d76582e282cf24e [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
Patrick Baumannde37e432019-08-28 09:51:29 -070019import android.annotation.AppIdInt;
Todd Kennedy82b08422017-09-28 13:32:05 -070020import android.annotation.IntDef;
21import android.annotation.NonNull;
22import android.annotation.Nullable;
Ricky Waicf134eb2018-10-10 09:26:32 +010023import android.annotation.UserIdInt;
Makoto Onuki2d5b4652016-03-11 16:09:54 -080024import android.content.ComponentName;
Patrick Baumann182ea1c2019-11-18 13:43:11 -080025import android.content.ContentResolver;
Todd Kennedy01ad0c72016-11-11 15:33:12 -080026import android.content.Intent;
Nikita Ioffef012a222019-03-05 22:37:55 +000027import android.content.IntentSender;
Todd Kennedy18211fd2017-06-06 09:15:46 -070028import android.content.pm.PackageManager.ApplicationInfoFlags;
29import android.content.pm.PackageManager.ComponentInfoFlags;
Todd Kennedy18211fd2017-06-06 09:15:46 -070030import android.content.pm.PackageManager.PackageInfoFlags;
31import android.content.pm.PackageManager.ResolveInfoFlags;
Winson14ff7172019-10-23 10:42:27 -070032import android.content.pm.parsing.AndroidPackage;
33import android.content.pm.parsing.ComponentParseUtils;
Chad Brubaker06068612017-04-06 09:43:47 -070034import android.os.Bundle;
Suprabh Shukla19b41f32018-03-26 22:35:13 -070035import android.os.PersistableBundle;
Dianne Hackbornf6729fa2020-01-06 13:12:36 -080036import android.util.ArrayMap;
Eugene Suslaabdefba2018-11-09 18:06:43 -080037import android.util.ArraySet;
Makoto Onukic29f62c2016-06-07 12:19:46 -070038import android.util.SparseArray;
Todd Kennedy39bfee52016-02-24 10:28:21 -080039
Christopher Tatee4f5f2d2019-10-08 15:49:43 -070040import com.android.server.pm.PackageList;
41
Jeff Sharkey5790af02018-08-13 17:42:54 -060042import java.io.IOException;
Todd Kennedy82b08422017-09-28 13:32:05 -070043import java.lang.annotation.Retention;
44import java.lang.annotation.RetentionPolicy;
Ryan Mitchellee4a5642019-10-16 08:32:55 -070045import java.util.Collection;
Fyodor Kupolovcb6fd802015-11-05 14:27:06 -080046import java.util.List;
Eugene Suslaabdefba2018-11-09 18:06:43 -080047import java.util.function.Consumer;
Svet Ganovadc1cf42015-06-15 16:36:24 -070048
49/**
50 * Package manager local system service interface.
51 *
52 * @hide Only for use within the system server.
53 */
54public abstract class PackageManagerInternal {
Todd Kennedy82b08422017-09-28 13:32:05 -070055 public static final int PACKAGE_SYSTEM = 0;
56 public static final int PACKAGE_SETUP_WIZARD = 1;
57 public static final int PACKAGE_INSTALLER = 2;
58 public static final int PACKAGE_VERIFIER = 3;
59 public static final int PACKAGE_BROWSER = 4;
Makoto Onuki700feef2018-02-15 10:59:41 -080060 public static final int PACKAGE_SYSTEM_TEXT_CLASSIFIER = 5;
Philip P. Moltmann8943ad62018-07-25 12:12:30 -070061 public static final int PACKAGE_PERMISSION_CONTROLLER = 6;
Varun Shah5f303652018-11-16 18:11:19 -080062 public static final int PACKAGE_WELLBEING = 7;
Jeff Sharkey15707b32018-12-10 12:08:41 -070063 public static final int PACKAGE_DOCUMENTER = 8;
Stanislav Zholnin596437f2018-12-28 15:34:23 +000064 public static final int PACKAGE_CONFIGURATOR = 9;
Joe Onorato5a15b552018-12-18 10:40:04 -080065 public static final int PACKAGE_INCIDENT_REPORT_APPROVER = 10;
George Hodulikcd7695d2019-01-29 18:17:05 -080066 public static final int PACKAGE_APP_PREDICTOR = 11;
Chen Xu45c183d2019-10-07 00:24:41 -070067 public static final int PACKAGE_TELEPHONY = 12;
Eugene Susla1fa23ed02019-07-24 16:30:16 -070068 public static final int PACKAGE_WIFI = 13;
69 public static final int PACKAGE_COMPANION = 14;
wayneyang8126b1f2020-01-09 14:10:31 +080070 public static final int PACKAGE_RETAIL_DEMO = 15;
Eugene Susla1fa23ed02019-07-24 16:30:16 -070071
Todd Kennedy82b08422017-09-28 13:32:05 -070072 @IntDef(value = {
Song Pan26dee802019-10-17 17:56:21 +010073 INTEGRITY_VERIFICATION_ALLOW,
74 INTEGRITY_VERIFICATION_REJECT,
75 })
76 @Retention(RetentionPolicy.SOURCE)
77 public @interface IntegrityVerificationResult {}
78
79 /**
80 * Used as the {@code verificationCode} argument for
81 * {@link PackageManagerInternal#setIntegrityVerificationResult(int, int)} to indicate that the
82 * integrity component allows the install to proceed.
83 */
84 public static final int INTEGRITY_VERIFICATION_ALLOW = 1;
85
86 /**
87 * Used as the {@code verificationCode} argument for
88 * {@link PackageManagerInternal#setIntegrityVerificationResult(int, int)} to indicate that the
89 * integrity component does not allow install to proceed.
90 */
91 public static final int INTEGRITY_VERIFICATION_REJECT = 0;
92
93 @IntDef(value = {
Todd Kennedy82b08422017-09-28 13:32:05 -070094 PACKAGE_SYSTEM,
95 PACKAGE_SETUP_WIZARD,
96 PACKAGE_INSTALLER,
97 PACKAGE_VERIFIER,
98 PACKAGE_BROWSER,
Makoto Onuki700feef2018-02-15 10:59:41 -080099 PACKAGE_SYSTEM_TEXT_CLASSIFIER,
Philip P. Moltmann8943ad62018-07-25 12:12:30 -0700100 PACKAGE_PERMISSION_CONTROLLER,
Varun Shah5f303652018-11-16 18:11:19 -0800101 PACKAGE_WELLBEING,
Jeff Sharkey15707b32018-12-10 12:08:41 -0700102 PACKAGE_DOCUMENTER,
Stanislav Zholnin596437f2018-12-28 15:34:23 +0000103 PACKAGE_CONFIGURATOR,
Joe Onorato5a15b552018-12-18 10:40:04 -0800104 PACKAGE_INCIDENT_REPORT_APPROVER,
George Hodulikcd7695d2019-01-29 18:17:05 -0800105 PACKAGE_APP_PREDICTOR,
Chen Xu45c183d2019-10-07 00:24:41 -0700106 PACKAGE_TELEPHONY,
Eugene Susla1fa23ed02019-07-24 16:30:16 -0700107 PACKAGE_WIFI,
108 PACKAGE_COMPANION,
wayneyang8126b1f2020-01-09 14:10:31 +0800109 PACKAGE_RETAIL_DEMO,
Todd Kennedy82b08422017-09-28 13:32:05 -0700110 })
111 @Retention(RetentionPolicy.SOURCE)
112 public @interface KnownPackage {}
Svet Ganovadc1cf42015-06-15 16:36:24 -0700113
Todd Kennedy42d61602017-12-12 14:44:19 -0800114 /** Observer called whenever the list of packages changes */
115 public interface PackageListObserver {
116 /** A package was added to the system. */
Chenbo Fengde8e3b72019-02-21 14:24:24 -0800117 void onPackageAdded(@NonNull String packageName, int uid);
Svet Ganovd8eb8b22019-04-05 18:52:08 -0700118 /** A package was changed - either installed for a specific user or updated. */
119 default void onPackageChanged(@NonNull String packageName, int uid) {}
Todd Kennedy42d61602017-12-12 14:44:19 -0800120 /** A package was removed from the system. */
Chenbo Fengde8e3b72019-02-21 14:24:24 -0800121 void onPackageRemoved(@NonNull String packageName, int uid);
Todd Kennedy42d61602017-12-12 14:44:19 -0800122 }
123
Svet Ganovadc1cf42015-06-15 16:36:24 -0700124 /**
Philip P. Moltmannb0be05c2018-09-19 02:46:56 +0000125 * Called when the package for the default SMS handler changed
126 *
127 * @param packageName the new sms package
128 * @param userId user for which the change was made
Svetoslavcdfd2302015-06-25 19:07:31 -0700129 */
Philip P. Moltmannb0be05c2018-09-19 02:46:56 +0000130 public void onDefaultSmsAppChanged(String packageName, int userId) {}
Sailesh Nepalcf855622015-07-28 19:22:14 -0700131
132 /**
Philip P. Moltmannb0be05c2018-09-19 02:46:56 +0000133 * Called when the package for the default sim call manager changed
134 *
135 * @param packageName the new sms package
136 * @param userId user for which the change was made
Sailesh Nepalcf855622015-07-28 19:22:14 -0700137 */
Philip P. Moltmannb0be05c2018-09-19 02:46:56 +0000138 public void onDefaultSimCallManagerAppChanged(String packageName, int userId) {}
Fyodor Kupolovcb6fd802015-11-05 14:27:06 -0800139
140 /**
141 * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has
142 * currently installed it. The apps are not preloaded.
143 * @param packageList List of package names to keep cached.
144 */
145 public abstract void setKeepUninstalledPackages(List<String> packageList);
Svet Ganov9c165d72015-12-01 19:52:26 -0800146
147 /**
148 * Gets whether some of the permissions used by this package require a user
149 * review before any of the app components can run.
150 * @param packageName The package name for which to check.
151 * @param userId The user under which to check.
152 * @return True a permissions review is required.
153 */
154 public abstract boolean isPermissionsReviewRequired(String packageName, int userId);
Todd Kennedy39bfee52016-02-24 10:28:21 -0800155
156 /**
Todd Kennedy18211fd2017-06-06 09:15:46 -0700157 * Retrieve all of the information we know about a particular package/application.
158 * @param filterCallingUid The results will be filtered in the context of this UID instead
159 * of the calling UID.
160 * @see PackageManager#getPackageInfo(String, int)
Todd Kennedy39bfee52016-02-24 10:28:21 -0800161 */
Todd Kennedy18211fd2017-06-06 09:15:46 -0700162 public abstract PackageInfo getPackageInfo(String packageName,
163 @PackageInfoFlags int flags, int filterCallingUid, int userId);
164
165 /**
Ricky Wai5a8fe7a2019-12-13 15:20:47 +0000166 * Retrieve CE data directory inode number of an application.
167 * Return 0 if there's error.
168 */
169 public abstract long getCeDataInode(String packageName, int userId);
170
171 /**
Ricky Waicf134eb2018-10-10 09:26:32 +0100172 * Return a List of all application packages that are installed on the
173 * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been
174 * set, a list of all applications including those deleted with
Sudheer Shanka31961ce2020-01-22 20:41:27 -0800175 * {@code DELETE_KEEP_DATA} (partially installed apps with data directory)
Ricky Waicf134eb2018-10-10 09:26:32 +0100176 * will be returned.
177 *
178 * @param flags Additional option flags to modify the data returned.
179 * @param userId The user for whom the installed applications are to be
180 * listed
181 * @param callingUid The uid of the original caller app
182 * @return A List of ApplicationInfo objects, one for each installed
183 * application. In the unlikely case there are no installed
184 * packages, an empty list is returned. If flag
185 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
186 * information is retrieved from the list of uninstalled
187 * applications (which includes installed applications as well as
188 * applications with data directory i.e. applications which had been
Sudheer Shanka31961ce2020-01-22 20:41:27 -0800189 * deleted with {@code DELETE_KEEP_DATA} flag set).
Ricky Waicf134eb2018-10-10 09:26:32 +0100190 */
191 public abstract List<ApplicationInfo> getInstalledApplications(
192 @ApplicationInfoFlags int flags, @UserIdInt int userId, int callingUid);
193
194 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -0700195 * Retrieve launcher extras for a suspended package provided to the system in
196 * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
Suprabh Shukla3c3af142018-03-30 00:28:37 -0700197 * PersistableBundle, String)}.
Suprabh Shukla19b41f32018-03-26 22:35:13 -0700198 *
199 * @param packageName The package for which to return launcher extras.
Suprabh Shukla3c3af142018-03-30 00:28:37 -0700200 * @param userId The user for which to check.
Suprabh Shukla19b41f32018-03-26 22:35:13 -0700201 * @return The launcher extras.
202 *
203 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
204 * PersistableBundle, String)
205 * @see PackageManager#isPackageSuspended()
206 */
207 public abstract Bundle getSuspendedPackageLauncherExtras(String packageName,
208 int userId);
209
210 /**
Suprabh Shukla69c71422018-04-02 18:39:01 -0700211 * Internal api to query the suspended state of a package.
212 * @param packageName The package to check.
213 * @param userId The user id to check for.
214 * @return {@code true} if the package is suspended, {@code false} otherwise.
215 * @see PackageManager#isPackageSuspended(String)
216 */
217 public abstract boolean isPackageSuspended(String packageName, int userId);
218
219 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -0700220 * Get the name of the package that suspended the given package. Packages can be suspended by
221 * device administrators or apps holding {@link android.Manifest.permission#MANAGE_USERS} or
222 * {@link android.Manifest.permission#SUSPEND_APPS}.
223 *
224 * @param suspendedPackage The package that has been suspended.
225 * @param userId The user for which to check.
226 * @return Name of the package that suspended the given package. Returns {@code null} if the
227 * given package is not currently suspended and the platform package name - i.e.
228 * {@code "android"} - if the package was suspended by a device admin.
229 */
230 public abstract String getSuspendingPackage(String suspendedPackage, int userId);
231
232 /**
Suprabh Shukla389cb6f2018-10-01 18:20:39 -0700233 * Get the information describing the dialog to be shown to the user when they try to launch a
234 * suspended application.
Suprabh Shukla3c3af142018-03-30 00:28:37 -0700235 *
236 * @param suspendedPackage The package that has been suspended.
Suprabh Shuklad3278442019-08-27 15:58:03 -0700237 * @param suspendingPackage
Suprabh Shukla3c3af142018-03-30 00:28:37 -0700238 * @param userId The user for which to check.
Suprabh Shukla389cb6f2018-10-01 18:20:39 -0700239 * @return A {@link SuspendDialogInfo} object describing the dialog to be shown.
Suprabh Shukla3c3af142018-03-30 00:28:37 -0700240 */
Suprabh Shukla389cb6f2018-10-01 18:20:39 -0700241 @Nullable
Suprabh Shuklad3278442019-08-27 15:58:03 -0700242 public abstract SuspendDialogInfo getSuspendedDialogInfo(String suspendedPackage,
243 String suspendingPackage, int userId);
Suprabh Shukla3c3af142018-03-30 00:28:37 -0700244
245 /**
Suprabh Shukla79000492018-12-24 17:03:02 -0800246 * Gets any distraction flags set via
247 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)}
248 *
249 * @param packageName
250 * @param userId
251 * @return A bitwise OR of any of the {@link PackageManager.DistractionRestriction}
252 */
253 public abstract @PackageManager.DistractionRestriction int getDistractingPackageRestrictions(
254 String packageName, int userId);
255
256 /**
Patrick Baumann26050db2020-01-23 10:12:22 -0800257 * Do a straight uid lookup for the given package/application in the given user. This enforces
258 * app visibility rules and permissions. Call {@link #getPackageUidInternal} for the internal
259 * implementation.
260 * @deprecated Use {@link PackageManager#getPackageUid(String, int)}
261 * @return The app's uid, or < 0 if the package was not found in that user
262 */
263 @Deprecated
264 public abstract int getPackageUid(String packageName,
265 @PackageInfoFlags int flags, int userId);
266
267 /**
Christopher Tatea732f012017-10-26 17:26:53 -0700268 * Do a straight uid lookup for the given package/application in the given user.
269 * @see PackageManager#getPackageUidAsUser(String, int, int)
270 * @return The app's uid, or < 0 if the package was not found in that user
Patrick Baumann26050db2020-01-23 10:12:22 -0800271 * TODO(b/148235092): rename this to getPackageUid
Christopher Tatea732f012017-10-26 17:26:53 -0700272 */
Patrick Baumann26050db2020-01-23 10:12:22 -0800273 public abstract int getPackageUidInternal(String packageName,
Christopher Tatea732f012017-10-26 17:26:53 -0700274 @PackageInfoFlags int flags, int userId);
275
276 /**
Todd Kennedy18211fd2017-06-06 09:15:46 -0700277 * Retrieve all of the information we know about a particular package/application.
278 * @param filterCallingUid The results will be filtered in the context of this UID instead
279 * of the calling UID.
280 * @see PackageManager#getApplicationInfo(String, int)
281 */
282 public abstract ApplicationInfo getApplicationInfo(String packageName,
283 @ApplicationInfoFlags int flags, int filterCallingUid, int userId);
284
285 /**
286 * Retrieve all of the information we know about a particular activity class.
287 * @param filterCallingUid The results will be filtered in the context of this UID instead
288 * of the calling UID.
289 * @see PackageManager#getActivityInfo(ComponentName, int)
290 */
291 public abstract ActivityInfo getActivityInfo(ComponentName component,
292 @ComponentInfoFlags int flags, int filterCallingUid, int userId);
293
294 /**
295 * Retrieve all activities that can be performed for the given intent.
Patrick Baumann182ea1c2019-11-18 13:43:11 -0800296 * @param resolvedType the resolved type of the intent, which should be resolved via
297 * {@link Intent#resolveTypeIfNeeded(ContentResolver)} before passing to {@link PackageManager}
Todd Kennedy18211fd2017-06-06 09:15:46 -0700298 * @param filterCallingUid The results will be filtered in the context of this UID instead
299 * of the calling UID.
300 * @see PackageManager#queryIntentActivities(Intent, int)
301 */
Patrick Baumann182ea1c2019-11-18 13:43:11 -0800302 public abstract List<ResolveInfo> queryIntentActivities(
303 Intent intent, @Nullable String resolvedType, @ResolveInfoFlags int flags,
304 int filterCallingUid, int userId);
305
Makoto Onuki2d5b4652016-03-11 16:09:54 -0800306
307 /**
Todd Kennedy82b08422017-09-28 13:32:05 -0700308 * Retrieve all services that can be performed for the given intent.
309 * @see PackageManager#queryIntentServices(Intent, int)
310 */
311 public abstract List<ResolveInfo> queryIntentServices(
312 Intent intent, int flags, int callingUid, int userId);
313
314 /**
Makoto Onuki2d5b4652016-03-11 16:09:54 -0800315 * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}.
316 */
317 public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates,
318 int userId);
Makoto Onukic29f62c2016-06-07 12:19:46 -0700319
320 /**
Winson Chungc1674272018-02-21 10:15:17 -0800321 * @return The default home activity component name.
322 */
323 public abstract ComponentName getDefaultHomeActivity(int userId);
324
325 /**
Winson Chungf2b41772019-11-06 15:00:48 -0800326 * @return The SystemUI service component name.
327 */
328 public abstract ComponentName getSystemUiServiceComponent();
329
330 /**
Makoto Onukic29f62c2016-06-07 12:19:46 -0700331 * Called by DeviceOwnerManagerService to set the package names of device owner and profile
332 * owners.
333 */
334 public abstract void setDeviceAndProfileOwnerPackages(
335 int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners);
336
337 /**
Srinivas Paladugu0bb962c2019-10-25 10:03:14 -0700338 * Called by DevicePolicyManagerService to set the package names protected by the device
339 * owner.
340 */
341 public abstract void setDeviceOwnerProtectedPackages(List<String> packageNames);
342
343 /**
Steven Ng9d48a732016-06-24 19:04:14 +0100344 * Returns {@code true} if a given package can't be wiped. Otherwise, returns {@code false}.
Makoto Onukic29f62c2016-06-07 12:19:46 -0700345 */
Steven Ng9d48a732016-06-24 19:04:14 +0100346 public abstract boolean isPackageDataProtected(int userId, String packageName);
Svet Ganov973edd192016-09-08 20:15:55 -0700347
348 /**
Benjamin Franzf81bf7f2018-03-26 16:23:04 +0100349 * Returns {@code true} if a given package's state is protected, e.g. it cannot be force
350 * stopped, suspended, disabled or hidden. Otherwise, returns {@code false}.
351 */
352 public abstract boolean isPackageStateProtected(String packageName, int userId);
353
354 /**
Dianne Hackborne07641d2016-11-09 15:07:23 -0800355 * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns
356 * {@code false}.
357 */
358 public abstract boolean isPackageEphemeral(int userId, String packageName);
359
360 /**
Svet Ganov973edd192016-09-08 20:15:55 -0700361 * Gets whether the package was ever launched.
362 * @param packageName The package name.
363 * @param userId The user for which to check.
364 * @return Whether was launched.
Amith Yamasani2cbfa1e2017-03-28 10:34:01 -0700365 * @throws IllegalArgumentException if the package is not found
Svet Ganov973edd192016-09-08 20:15:55 -0700366 */
367 public abstract boolean wasPackageEverLaunched(String packageName, int userId);
Nicolas Prevot700e1e72016-09-28 15:17:18 +0100368
369 /**
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000370 * Retrieve the official name associated with a uid. This name is
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100371 * guaranteed to never change, though it is possible for the underlying
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000372 * uid to be changed. That is, if you are storing information about
373 * uids in persistent storage, you should use the string returned
374 * by this function instead of the raw uid.
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100375 *
Michal Karpinskicb67dc92016-12-13 18:20:23 +0000376 * @param uid The uid for which you would like to retrieve a name.
377 * @return Returns a unique name for the given uid, or null if the
378 * uid is not currently assigned.
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100379 */
380 public abstract String getNameForUid(int uid);
381
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800382 /**
Bookatz04d7ae52019-08-05 14:07:12 -0700383 * Marks a package as installed (or not installed) for a given user.
384 *
385 * @param pkg the package whose installation is to be set
386 * @param userId the user for whom to set it
387 * @param installed the new installed state
388 * @return true if the installed state changed as a result
389 */
Winson14ff7172019-10-23 10:42:27 -0700390 public abstract boolean setInstalled(AndroidPackage pkg,
Bookatz04d7ae52019-08-05 14:07:12 -0700391 @UserIdInt int userId, boolean installed);
392
393 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800394 * Request to perform the second phase of ephemeral resolution.
395 * @param responseObj The response of the first phase of ephemeral resolution
396 * @param origIntent The original intent that triggered ephemeral resolution
397 * @param resolvedType The resolved type of the intent
Winson81fef842019-08-28 12:19:08 -0700398 * @param callingPkg The app requesting the ephemeral application
Philip P. Moltmann9c5226f2020-01-10 08:53:43 -0800399 * @param callingFeatureId The feature in the package
Winson81fef842019-08-28 12:19:08 -0700400 * @param isRequesterInstantApp Whether or not the app requesting the ephemeral application
401 * is an instant app
Chad Brubaker06068612017-04-06 09:43:47 -0700402 * @param verificationBundle Optional bundle to pass to the installer for additional
403 * verification
Todd Kennedy01ad0c72016-11-11 15:33:12 -0800404 * @param userId The ID of the user that triggered ephemeral resolution
405 */
Todd Kennedye9910222017-02-21 16:00:11 -0800406 public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj,
Winson81fef842019-08-28 12:19:08 -0700407 Intent origIntent, String resolvedType, String callingPkg,
Philip P. Moltmann9c5226f2020-01-10 08:53:43 -0800408 @Nullable String callingFeatureId, boolean isRequesterInstantApp,
409 Bundle verificationBundle, int userId);
Svetoslav Ganove080da92016-12-21 17:10:35 -0800410
411 /**
Patrick Baumannde37e432019-08-28 09:51:29 -0700412 * Grants implicit access based on an interaction between two apps. This grants the target app
413 * access to the calling application's package metadata.
Todd Kennedy0e989d02017-01-13 14:15:36 -0800414 * <p>
Patrick Baumannde37e432019-08-28 09:51:29 -0700415 * When an application explicitly tries to interact with another application [via an
416 * activity, service or provider that is either declared in the caller's
417 * manifest via the {@code <queries>} tag or has been exposed via the target apps manifest using
418 * the {@code visibleToInstantApp} attribute], the target application must be able to see
419 * metadata about the calling app. If the calling application uses an implicit intent [ie
420 * action VIEW, category BROWSABLE], it remains hidden from the launched app.
Todd Kennedy0e989d02017-01-13 14:15:36 -0800421 * <p>
Todd Kennedy0e989d02017-01-13 14:15:36 -0800422 * @param userId the user
423 * @param intent the intent that triggered the grant
Patrick Baumannb6e72972019-09-20 07:54:47 -0700424 * @param callingUid The uid of the calling application
Patrick Baumannde37e432019-08-28 09:51:29 -0700425 * @param targetAppId The app ID of the target application
Todd Kennedy0e989d02017-01-13 14:15:36 -0800426 */
Patrick Baumannde37e432019-08-28 09:51:29 -0700427 public abstract void grantImplicitAccess(
Patrick Baumannb6e72972019-09-20 07:54:47 -0700428 @UserIdInt int userId, Intent intent, int callingUid,
Patrick Baumannde37e432019-08-28 09:51:29 -0700429 @AppIdInt int targetAppId);
Todd Kennedy0e989d02017-01-13 14:15:36 -0800430
Todd Kennedyb21be122017-03-24 14:10:01 -0700431 public abstract boolean isInstantAppInstallerComponent(ComponentName component);
Todd Kennedy0e989d02017-01-13 14:15:36 -0800432 /**
Svetoslav Ganov096d3042017-01-30 16:34:13 -0800433 * Prunes instant apps and state associated with uninstalled
434 * instant apps according to the current platform policy.
435 */
436 public abstract void pruneInstantApps();
437
438 /**
Svetoslav Ganove080da92016-12-21 17:10:35 -0800439 * @return The SetupWizard package name.
440 */
441 public abstract String getSetupWizardPackageName();
Suprabh Shuklaaef25132017-01-23 18:09:03 -0800442
443 public interface ExternalSourcesPolicy {
444
445 int USER_TRUSTED = 0; // User has trusted the package to install apps
446 int USER_BLOCKED = 1; // User has blocked the package to install apps
447 int USER_DEFAULT = 2; // Default code to use when user response is unavailable
448
449 /**
450 * Checks the user preference for whether a package is trusted to request installs through
451 * package installer
452 *
453 * @param packageName The package to check for
454 * @param uid the uid in which the package is running
Philip P. Moltmannb0be05c2018-09-19 02:46:56 +0000455 * @return {@link #USER_TRUSTED} if the user has trusted the package, {@link #USER_BLOCKED}
456 * if user has blocked requests from the package, {@link #USER_DEFAULT} if the user response
Suprabh Shuklaaef25132017-01-23 18:09:03 -0800457 * is not yet available
458 */
459 int getPackageTrustedToInstallApps(String packageName, int uid);
460 }
461
462 public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy);
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +0100463
464 /**
Dianne Hackbornb1e77762017-02-13 11:42:18 -0800465 * Return true if the given package is a persistent app process.
466 */
467 public abstract boolean isPackagePersistent(String packageName);
468
469 /**
Todd Kennedyc29b11a2017-10-23 15:55:59 -0700470 * Returns whether or not the given package represents a legacy system application released
471 * prior to runtime permissions.
472 */
Winson14ff7172019-10-23 10:42:27 -0700473 public abstract boolean isLegacySystemApp(AndroidPackage pkg);
Todd Kennedyc29b11a2017-10-23 15:55:59 -0700474
475 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +0100476 * Get all overlay packages for a user.
477 * @param userId The user for which to get the overlays.
478 * @return A list of overlay packages. An empty list is returned if the
479 * user has no installed overlay packages.
480 */
481 public abstract List<PackageInfo> getOverlayPackages(int userId);
482
483 /**
484 * Get the names of all target packages for a user.
485 * @param userId The user for which to get the package names.
486 * @return A list of target package names. This list includes the "android" package.
487 */
488 public abstract List<String> getTargetPackageNames(int userId);
489
490 /**
491 * Set which overlay to use for a package.
492 * @param userId The user for which to update the overlays.
493 * @param targetPackageName The package name of the package for which to update the overlays.
494 * @param overlayPackageNames The complete list of overlay packages that should be enabled for
495 * the target. Previously enabled overlays not specified in the list
496 * will be disabled. Pass in null or an empty list to disable
497 * all overlays. The order of the items is significant if several
498 * overlays modify the same resource.
Ryan Mitchellee4a5642019-10-16 08:32:55 -0700499 * @param outUpdatedPackageNames An output list that contains the package names of packages
500 * affected by the update of enabled overlays.
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +0100501 * @return true if all packages names were known by the package manager, false otherwise
502 */
503 public abstract boolean setEnabledOverlayPackages(int userId, String targetPackageName,
Ryan Mitchellee4a5642019-10-16 08:32:55 -0700504 List<String> overlayPackageNames, Collection<String> outUpdatedPackageNames);
Todd Kennedy4d1de7d2017-02-23 10:32:18 -0800505
506 /**
Todd Kennedy51b3aac2017-03-30 17:50:42 -0700507 * Resolves an activity intent, allowing instant apps to be resolved.
Todd Kennedy4d1de7d2017-02-23 10:32:18 -0800508 */
509 public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType,
Patrick Baumann78380272018-04-04 10:41:01 -0700510 int flags, int userId, boolean resolveForStart, int filterCallingUid);
Chad Brubaker0f28a802017-03-29 14:05:52 -0700511
512 /**
Todd Kennedy51b3aac2017-03-30 17:50:42 -0700513 * Resolves a service intent, allowing instant apps to be resolved.
514 */
Todd Kennedy82b08422017-09-28 13:32:05 -0700515 public abstract ResolveInfo resolveService(Intent intent, String resolvedType,
Todd Kennedy51b3aac2017-03-30 17:50:42 -0700516 int flags, int userId, int callingUid);
517
Todd Kennedy82b08422017-09-28 13:32:05 -0700518 /**
519 * Resolves a content provider intent.
520 */
521 public abstract ProviderInfo resolveContentProvider(String name, int flags, int userId);
522
Todd Kennedy51b3aac2017-03-30 17:50:42 -0700523 /**
Chad Brubaker0f28a802017-03-29 14:05:52 -0700524 * Track the creator of a new isolated uid.
525 * @param isolatedUid The newly created isolated uid.
526 * @param ownerUid The uid of the app that created the isolated process.
527 */
528 public abstract void addIsolatedUid(int isolatedUid, int ownerUid);
529
530 /**
531 * Track removal of an isolated uid.
532 * @param isolatedUid isolated uid that is no longer being used.
533 */
534 public abstract void removeIsolatedUid(int isolatedUid);
Makoto Onukie92f7942017-04-26 14:38:18 -0700535
536 /**
537 * Return the taget SDK version for the app with the given UID.
538 */
539 public abstract int getUidTargetSdkVersion(int uid);
Makoto Onukiad623012017-05-15 09:29:34 -0700540
Jeff Sharkey9252b342018-01-19 07:58:35 +0900541 /**
542 * Return the taget SDK version for the app with the given package name.
543 */
544 public abstract int getPackageTargetSdkVersion(String packageName);
545
Makoto Onukiad623012017-05-15 09:29:34 -0700546 /** Whether the binder caller can access instant apps. */
Todd Kennedy3051caa2017-05-23 15:54:18 -0700547 public abstract boolean canAccessInstantApps(int callingUid, int userId);
Svet Ganovf935a702017-08-22 12:15:58 -0700548
Todd Kennedy662504f2018-03-14 08:09:00 -0700549 /** Whether the binder caller can access the given component. */
550 public abstract boolean canAccessComponent(int callingUid, ComponentName component, int userId);
551
Svet Ganovf935a702017-08-22 12:15:58 -0700552 /**
553 * Returns {@code true} if a given package has instant application meta-data.
554 * Otherwise, returns {@code false}. Meta-data is state (eg. cookie, app icon, etc)
555 * associated with an instant app. It may be kept after the instant app has been uninstalled.
556 */
557 public abstract boolean hasInstantApplicationMetadata(String packageName, int userId);
Todd Kennedydf113c32017-08-31 16:10:29 -0700558
559 /**
560 * Updates a package last used time.
561 */
562 public abstract void notifyPackageUse(String packageName, int reason);
Todd Kennedy82b08422017-09-28 13:32:05 -0700563
564 /**
565 * Returns a package object for the given package name.
566 */
Winson14ff7172019-10-23 10:42:27 -0700567 public abstract @Nullable AndroidPackage getPackage(@NonNull String packageName);
568
569 // TODO(b/135203078): PackageSetting can't be referenced directly. Should move to a server side
570 // internal PM which is aware of PS.
571 public abstract @Nullable Object getPackageSetting(String packageName);
Todd Kennedy82b08422017-09-28 13:32:05 -0700572
573 /**
Todd Kennedyca1ea172019-07-03 15:02:28 -0700574 * Returns a package for the given UID. If the UID is part of a shared user ID, one
575 * of the packages will be chosen to be returned.
576 */
Winson14ff7172019-10-23 10:42:27 -0700577 public abstract @Nullable AndroidPackage getPackage(int uid);
Todd Kennedyca1ea172019-07-03 15:02:28 -0700578
579 /**
Todd Kennedy42d61602017-12-12 14:44:19 -0800580 * Returns a list without a change observer.
581 *
Philip P. Moltmannb0be05c2018-09-19 02:46:56 +0000582 * @see #getPackageList(PackageListObserver)
Todd Kennedy42d61602017-12-12 14:44:19 -0800583 */
584 public @NonNull PackageList getPackageList() {
585 return getPackageList(null);
586 }
587
588 /**
589 * Returns the list of packages installed at the time of the method call.
590 * <p>The given observer is notified when the list of installed packages
591 * changes [eg. a package was installed or uninstalled]. It will not be
592 * notified if a package is updated.
593 * <p>The package list will not be updated automatically as packages are
594 * installed / uninstalled. Any changes must be handled within the observer.
595 */
596 public abstract @NonNull PackageList getPackageList(@Nullable PackageListObserver observer);
597
598 /**
599 * Removes the observer.
600 * <p>Generally not needed. {@link #getPackageList(PackageListObserver)} will automatically
601 * remove the observer.
602 * <p>Does nothing if the observer isn't currently registered.
603 * <p>Observers are notified asynchronously and it's possible for an observer to be
604 * invoked after its been removed.
605 */
606 public abstract void removePackageListObserver(@NonNull PackageListObserver observer);
607
Winson14ff7172019-10-23 10:42:27 -0700608 // TODO(b/135203078): PackageSetting can't be referenced directly
Todd Kennedy42d61602017-12-12 14:44:19 -0800609 /**
Todd Kennedy82b08422017-09-28 13:32:05 -0700610 * Returns a package object for the disabled system package name.
611 */
Winson14ff7172019-10-23 10:42:27 -0700612 public abstract @Nullable Object getDisabledSystemPackage(@NonNull String packageName);
Philip P. Moltmannb0be05c2018-09-19 02:46:56 +0000613
614 /**
615 * Returns the package name for the disabled system package.
616 *
617 * This is equivalent to
Winson14ff7172019-10-23 10:42:27 -0700618 * {@link #getDisabledSystemPackage(String)}
619 * .{@link com.android.server.pm.PackageSetting#pkg}
620 * .{@link AndroidPackage#getPackageName()}
Philip P. Moltmannb0be05c2018-09-19 02:46:56 +0000621 */
622 public abstract @Nullable String getDisabledSystemPackageName(@NonNull String packageName);
Todd Kennedy82b08422017-09-28 13:32:05 -0700623
624 /**
625 * Returns whether or not the component is the resolver activity.
626 */
627 public abstract boolean isResolveActivityComponent(@NonNull ComponentInfo component);
628
Chen Xu45c183d2019-10-07 00:24:41 -0700629
Todd Kennedy82b08422017-09-28 13:32:05 -0700630 /**
Chen Xu45c183d2019-10-07 00:24:41 -0700631 * Returns a list of package names for a known package
Todd Kennedy82b08422017-09-28 13:32:05 -0700632 */
Chen Xu45c183d2019-10-07 00:24:41 -0700633 public abstract @NonNull String[] getKnownPackageNames(
Todd Kennedy82b08422017-09-28 13:32:05 -0700634 @KnownPackage int knownPackage, int userId);
635
Todd Kennedy0eb97382017-10-03 16:57:22 -0700636 /**
637 * Returns whether the package is an instant app.
638 */
639 public abstract boolean isInstantApp(String packageName, int userId);
640
641 /**
642 * Returns whether the package is an instant app.
643 */
644 public abstract @Nullable String getInstantAppPackageName(int uid);
645
646 /**
647 * Returns whether or not access to the application should be filtered.
648 * <p>
649 * Access may be limited based upon whether the calling or target applications
650 * are instant applications.
651 *
Philip P. Moltmannb0be05c2018-09-19 02:46:56 +0000652 * @see #canAccessInstantApps
Todd Kennedy0eb97382017-10-03 16:57:22 -0700653 */
654 public abstract boolean filterAppAccess(
Winson14ff7172019-10-23 10:42:27 -0700655 @NonNull AndroidPackage pkg, int callingUid, int userId);
Todd Kennedyc5b0e862019-07-16 09:47:58 -0700656
657 /**
658 * Returns whether or not access to the application should be filtered.
659 *
660 * @see #filterAppAccess(android.content.pm.PackageParser.Package, int, int)
661 */
662 public abstract boolean filterAppAccess(
663 @NonNull String packageName, int callingUid, int userId);
Todd Kennedy0eb97382017-10-03 16:57:22 -0700664
Philip P. Moltmannb0be05c2018-09-19 02:46:56 +0000665 /** Returns whether the given package was signed by the platform */
666 public abstract boolean isPlatformSigned(String pkg);
667
Michal Karpinski528c3e52018-02-07 17:47:10 +0000668 /**
669 * Returns true if it's still safe to restore data backed up from this app's version
670 * that was signed with restoringFromSigHash.
671 */
672 public abstract boolean isDataRestoreSafe(@NonNull byte[] restoringFromSigHash,
673 @NonNull String packageName);
674
675 /**
676 * Returns true if it's still safe to restore data backed up from this app's version
677 * that was signed with restoringFromSig.
678 */
679 public abstract boolean isDataRestoreSafe(@NonNull Signature restoringFromSig,
680 @NonNull String packageName);
Dan Cashman303c4bb2018-04-10 07:41:16 -0700681
Dan Cashman303c4bb2018-04-10 07:41:16 -0700682 /**
Todd Kennedycf827032018-07-03 13:17:22 -0700683 * Returns {@code true} if the the signing information for {@code clientUid} is sufficient
684 * to gain access gated by {@code capability}. This can happen if the two UIDs have the
685 * same signing information, if the signing information {@code clientUid} indicates that
686 * it has the signing certificate for {@code serverUid} in its signing history (if it was
687 * previously signed by it), or if the signing certificate for {@code clientUid} is in the
688 * signing history for {@code serverUid} and with the {@code capability} specified.
Dan Cashman303c4bb2018-04-10 07:41:16 -0700689 */
690 public abstract boolean hasSignatureCapability(int serverUid, int clientUid,
691 @PackageParser.SigningDetails.CertCapabilities int capability);
Svet Ganovd873ae62018-06-25 16:39:23 -0700692
693 /**
Sudheer Shanka0a541a52018-07-31 13:21:11 -0700694 * Get appIds of all available apps which specified android:sharedUserId in the manifest.
695 *
696 * @return a SparseArray mapping from appId to it's sharedUserId.
697 */
698 public abstract SparseArray<String> getAppsWithSharedUserIds();
Jeff Sharkey5790af02018-08-13 17:42:54 -0600699
700 /**
Alan Stokes20fbef22019-12-17 15:33:12 +0000701 * Get all packages which share the same userId as the specified package, or an empty array
702 * if the package does not have a shared userId.
Sudheer Shanka2ac25a92018-10-25 10:59:32 -0700703 */
Alan Stokes20fbef22019-12-17 15:33:12 +0000704 @NonNull
705 public abstract String[] getSharedUserPackagesForPackage(@NonNull String packageName,
706 int userId);
Sudheer Shanka2ac25a92018-10-25 10:59:32 -0700707
708 /**
Dianne Hackbornf6729fa2020-01-06 13:12:36 -0800709 * Return the processes that have been declared for a uid.
710 *
711 * @param uid The uid to query.
712 *
713 * @return Returns null if there are no declared processes for the uid; otherwise,
714 * returns the set of processes it declared.
715 */
716 public abstract ArrayMap<String, ProcessInfo> getProcessesForUid(int uid);
717
718 /**
719 * Return the gids associated with a particular permission.
720 *
721 * @param permissionName The name of the permission to query.
722 * @param userId The user id the gids will be associated with.
723 *
724 * @return Returns null if there are no gids associated with the permission, otherwise an
725 * array if the gid ints.
726 */
727 public abstract int[] getPermissionGids(String permissionName, int userId);
728
729 /**
Jeff Sharkey5790af02018-08-13 17:42:54 -0600730 * Return if device is currently in a "core" boot environment, typically
731 * used to support full-disk encryption. Only apps marked with
732 * {@code coreApp} attribute are available.
733 */
734 public abstract boolean isOnlyCoreApps();
735
736 /**
737 * Make a best-effort attempt to provide the requested free disk space by
738 * deleting cached files.
739 *
740 * @throws IOException if the request was unable to be fulfilled.
741 */
742 public abstract void freeStorage(String volumeUuid, long bytes, int storageFlags)
743 throws IOException;
Todd Kennedycf827032018-07-03 13:17:22 -0700744
745 /** Returns {@code true} if the specified component is enabled and matches the given flags. */
Winson14ff7172019-10-23 10:42:27 -0700746 public abstract boolean isEnabledAndMatches(
747 @NonNull ComponentParseUtils.ParsedComponent component, int flags, int userId);
Todd Kennedycf827032018-07-03 13:17:22 -0700748
749 /** Returns {@code true} if the given user requires extra badging for icons. */
750 public abstract boolean userNeedsBadging(int userId);
Eugene Suslaabdefba2018-11-09 18:06:43 -0800751
752 /**
753 * Perform the given action for each package.
754 * Note that packages lock will be held while performin the actions.
755 *
756 * @param actionLocked action to be performed
757 */
Winson14ff7172019-10-23 10:42:27 -0700758 public abstract void forEachPackage(Consumer<AndroidPackage> actionLocked);
Eugene Suslaabdefba2018-11-09 18:06:43 -0800759
Hai Zhangeb8b4602019-05-22 13:04:12 -0700760 /**
761 * Perform the given action for each installed package for a user.
762 * Note that packages lock will be held while performin the actions.
763 */
764 public abstract void forEachInstalledPackage(
Winson14ff7172019-10-23 10:42:27 -0700765 @NonNull Consumer<AndroidPackage> actionLocked, @UserIdInt int userId);
Hai Zhangeb8b4602019-05-22 13:04:12 -0700766
Eugene Suslaabdefba2018-11-09 18:06:43 -0800767 /** Returns the list of enabled components */
768 public abstract ArraySet<String> getEnabledComponents(String packageName, int userId);
769
770 /** Returns the list of disabled components */
771 public abstract ArraySet<String> getDisabledComponents(String packageName, int userId);
772
773 /** Returns whether the given package is enabled for the given user */
774 public abstract @PackageManager.EnabledState int getApplicationEnabledState(
775 String packageName, int userId);
Richard Uhlerb29f1452018-09-12 16:38:15 +0100776
777 /**
778 * Extra field name for the token of a request to enable rollback for a
779 * package.
780 */
781 public static final String EXTRA_ENABLE_ROLLBACK_TOKEN =
782 "android.content.pm.extra.ENABLE_ROLLBACK_TOKEN";
783
784 /**
785 * Extra field name for the installFlags of a request to enable rollback
786 * for a package.
787 */
788 public static final String EXTRA_ENABLE_ROLLBACK_INSTALL_FLAGS =
789 "android.content.pm.extra.ENABLE_ROLLBACK_INSTALL_FLAGS";
790
791 /**
Richard Uhler82913b72019-04-01 13:02:31 +0100792 * Extra field name for the user id an install is associated with when
793 * enabling rollback.
794 */
795 public static final String EXTRA_ENABLE_ROLLBACK_USER =
796 "android.content.pm.extra.ENABLE_ROLLBACK_USER";
797
798 /**
Richard Uhlerb29f1452018-09-12 16:38:15 +0100799 * Used as the {@code enableRollbackCode} argument for
800 * {@link PackageManagerInternal#setEnableRollbackCode} to indicate that
801 * enabling rollback succeeded.
802 */
803 public static final int ENABLE_ROLLBACK_SUCCEEDED = 1;
804
805 /**
806 * Used as the {@code enableRollbackCode} argument for
807 * {@link PackageManagerInternal#setEnableRollbackCode} to indicate that
808 * enabling rollback failed.
809 */
810 public static final int ENABLE_ROLLBACK_FAILED = -1;
811
812 /**
813 * Allows the rollback manager listening to the
814 * {@link Intent#ACTION_PACKAGE_ENABLE_ROLLBACK enable rollback broadcast}
815 * to respond to the package manager. The response must include the
816 * {@code enableRollbackCode} which is one of
817 * {@link PackageManager#ENABLE_ROLLBACK_SUCCEEDED} or
818 * {@link PackageManager#ENABLE_ROLLBACK_FAILED}.
819 *
820 * @param token pending package identifier as passed via the
821 * {@link PackageManager#EXTRA_ENABLE_ROLLBACK_TOKEN} Intent extra.
822 * @param enableRollbackCode the status code result of enabling rollback
823 * @throws SecurityException if the caller does not have the
824 * PACKAGE_ROLLBACK_AGENT permission.
825 */
826 public abstract void setEnableRollbackCode(int token, int enableRollbackCode);
Eric Holka1485f62019-01-07 13:58:25 -0800827
828 /**
829 * Ask the package manager to compile layouts in the given package.
830 */
831 public abstract boolean compileLayouts(String packageName);
Narayan Kamath869f7062019-01-10 12:24:15 +0000832
833 /*
834 * Inform the package manager that the pending package install identified by
835 * {@code token} can be completed.
836 */
837 public abstract void finishPackageInstall(int token, boolean didLaunch);
Hai Zhanga22cd832019-01-30 13:38:43 -0800838
839 /**
840 * Remove the default browser stored in the legacy package settings.
841 *
842 * @param userId the user id
843 *
844 * @return the package name of the default browser, or {@code null} if none
845 */
846 @Nullable
847 public abstract String removeLegacyDefaultBrowserPackageName(int userId);
Hai Zhang85fd0622019-02-01 14:06:04 -0800848
849 /**
Nikita Ioffef012a222019-03-05 22:37:55 +0000850 * Returns {@code true} if given {@code packageName} is an apex package.
851 */
852 public abstract boolean isApexPackage(String packageName);
853
854 /**
Mohammad Samiul Islam3fcecfc2019-12-20 17:46:01 +0000855 * Returns list of {@code packageName} of apks inside the given apex.
856 * @param apexPackageName Package name of the apk container of apex
857 */
858 public abstract List<String> getApksInApex(String apexPackageName);
859
860 /**
Nikita Ioffef012a222019-03-05 22:37:55 +0000861 * Uninstalls given {@code packageName}.
862 *
863 * @param packageName apex package to uninstall.
864 * @param versionCode version of a package to uninstall.
865 * @param userId user to uninstall apex package for. Must be
866 * {@link android.os.UserHandle#USER_ALL}, otherwise failure will be reported.
867 * @param intentSender a {@link IntentSender} to send result of an uninstall to.
Gavin Corkery4fd10882019-11-28 15:37:51 +0000868 * @param flags flags about the uninstall.
Nikita Ioffef012a222019-03-05 22:37:55 +0000869 */
870 public abstract void uninstallApex(String packageName, long versionCode, int userId,
Gavin Corkery4fd10882019-11-28 15:37:51 +0000871 IntentSender intentSender, int flags);
Svet Ganovd8eb8b22019-04-05 18:52:08 -0700872
873 /**
Philip P. Moltmann5f5783e2019-05-22 14:57:18 -0700874 * Get fingerprint of build that updated the runtime permissions for a user.
875 *
876 * @param userId The user to update
877 * @param fingerPrint The fingerprint to set
878 */
879 public abstract void setRuntimePermissionsFingerPrint(@NonNull String fingerPrint,
880 @UserIdInt int userId);
Narayan Kamath157dd1d2019-06-12 13:06:30 +0100881
882 /**
883 * Migrates legacy obb data to its new location.
884 */
885 public abstract void migrateLegacyObbData();
Todd Kennedy6ffc5a62019-07-03 09:35:31 -0700886
887 /**
888 * Writes all package manager settings to disk. If {@code async} is {@code true}, the
889 * settings are written at some point in the future. Otherwise, the call blocks until
890 * the settings have been written.
891 */
892 public abstract void writeSettings(boolean async);
Todd Kennedy230c0a72019-07-03 13:06:35 -0700893
894 /**
895 * Writes all permission settings for the given set of users to disk. If {@code async}
896 * is {@code true}, the settings are written at some point in the future. Otherwise,
897 * the call blocks until the settings have been written.
898 */
899 public abstract void writePermissionSettings(@NonNull @UserIdInt int[] userIds, boolean async);
900
901 /**
Todd Kennedy7e3dd3a2019-07-08 10:34:29 -0700902 * Returns {@code true} if the caller is the installer of record for the given package.
903 * Otherwise, {@code false}.
904 */
905 public abstract boolean isCallerInstallerOfRecord(
Winson14ff7172019-10-23 10:42:27 -0700906 @NonNull AndroidPackage pkg, int callingUid);
Todd Kennedy583378d2019-07-12 06:50:30 -0700907
908 /** Returns whether or not default runtime permissions are granted for the given user */
909 public abstract boolean areDefaultRuntimePermissionsGranted(@UserIdInt int userId);
Todd Kennedyc5b0e862019-07-16 09:47:58 -0700910
911 /** Sets the enforcement of reading external storage */
912 public abstract void setReadExternalStorageEnforced(boolean enforced);
Song Panf93a39c2019-11-19 00:58:31 +0000913
914 /**
915 * Allows the integrity component to respond to the
916 * {@link Intent#ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION package verification
917 * broadcast} to respond to the package manager. The response must include
918 * the {@code verificationCode} which is one of
Song Pan26dee802019-10-17 17:56:21 +0100919 * {@link #INTEGRITY_VERIFICATION_ALLOW} and {@link #INTEGRITY_VERIFICATION_REJECT}.
Song Panf93a39c2019-11-19 00:58:31 +0000920 *
921 * @param verificationId pending package identifier as passed via the
922 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
Song Pan26dee802019-10-17 17:56:21 +0100923 * @param verificationResult either {@link #INTEGRITY_VERIFICATION_ALLOW}
924 * or {@link #INTEGRITY_VERIFICATION_REJECT}.
Song Panf93a39c2019-11-19 00:58:31 +0000925 */
Song Pan26dee802019-10-17 17:56:21 +0100926 public abstract void setIntegrityVerificationResult(int verificationId,
927 @IntegrityVerificationResult int verificationResult);
Svet Ganovadc1cf42015-06-15 16:36:24 -0700928}