Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.content.pm; |
| 18 | |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 19 | import android.content.ComponentName; |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 20 | import android.content.Intent; |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 21 | import android.content.pm.PackageManager.NameNotFoundException; |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 22 | import android.os.Bundle; |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 23 | import android.util.SparseArray; |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 24 | |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 25 | import java.util.List; |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Package manager local system service interface. |
| 29 | * |
| 30 | * @hide Only for use within the system server. |
| 31 | */ |
| 32 | public abstract class PackageManagerInternal { |
| 33 | |
| 34 | /** |
| 35 | * Provider for package names. |
| 36 | */ |
| 37 | public interface PackagesProvider { |
| 38 | |
| 39 | /** |
| 40 | * Gets the packages for a given user. |
| 41 | * @param userId The user id. |
| 42 | * @return The package names. |
| 43 | */ |
| 44 | public String[] getPackages(int userId); |
| 45 | } |
| 46 | |
| 47 | /** |
Svetoslav | 0010b70 | 2015-06-30 18:05:26 -0700 | [diff] [blame] | 48 | * Provider for package names. |
| 49 | */ |
| 50 | public interface SyncAdapterPackagesProvider { |
| 51 | |
| 52 | /** |
| 53 | * Gets the sync adapter packages for given authority and user. |
| 54 | * @param authority The authority. |
| 55 | * @param userId The user id. |
| 56 | * @return The package names. |
| 57 | */ |
| 58 | public String[] getPackages(String authority, int userId); |
| 59 | } |
| 60 | |
| 61 | /** |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 62 | * Sets the location provider packages provider. |
| 63 | * @param provider The packages provider. |
| 64 | */ |
| 65 | public abstract void setLocationPackagesProvider(PackagesProvider provider); |
| 66 | |
| 67 | /** |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 68 | * Sets the voice interaction packages provider. |
| 69 | * @param provider The packages provider. |
| 70 | */ |
| 71 | public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider); |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * Sets the SMS packages provider. |
| 75 | * @param provider The packages provider. |
| 76 | */ |
| 77 | public abstract void setSmsAppPackagesProvider(PackagesProvider provider); |
| 78 | |
| 79 | /** |
| 80 | * Sets the dialer packages provider. |
| 81 | * @param provider The packages provider. |
| 82 | */ |
| 83 | public abstract void setDialerAppPackagesProvider(PackagesProvider provider); |
| 84 | |
| 85 | /** |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 86 | * Sets the sim call manager packages provider. |
| 87 | * @param provider The packages provider. |
| 88 | */ |
| 89 | public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider); |
| 90 | |
| 91 | /** |
Svetoslav | 0010b70 | 2015-06-30 18:05:26 -0700 | [diff] [blame] | 92 | * Sets the sync adapter packages provider. |
| 93 | * @param provider The provider. |
| 94 | */ |
| 95 | public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider); |
| 96 | |
| 97 | /** |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 98 | * Requests granting of the default permissions to the current default SMS app. |
| 99 | * @param packageName The default SMS package name. |
| 100 | * @param userId The user for which to grant the permissions. |
| 101 | */ |
| 102 | public abstract void grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId); |
| 103 | |
| 104 | /** |
| 105 | * Requests granting of the default permissions to the current default dialer app. |
| 106 | * @param packageName The default dialer package name. |
| 107 | * @param userId The user for which to grant the permissions. |
| 108 | */ |
| 109 | public abstract void grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId); |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * Requests granting of the default permissions to the current default sim call manager. |
| 113 | * @param packageName The default sim call manager package name. |
| 114 | * @param userId The user for which to grant the permissions. |
| 115 | */ |
| 116 | public abstract void grantDefaultPermissionsToDefaultSimCallManager(String packageName, |
| 117 | int userId); |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 118 | |
| 119 | /** |
| 120 | * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has |
| 121 | * currently installed it. The apps are not preloaded. |
| 122 | * @param packageList List of package names to keep cached. |
| 123 | */ |
| 124 | public abstract void setKeepUninstalledPackages(List<String> packageList); |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * Gets whether some of the permissions used by this package require a user |
| 128 | * review before any of the app components can run. |
| 129 | * @param packageName The package name for which to check. |
| 130 | * @param userId The user under which to check. |
| 131 | * @return True a permissions review is required. |
| 132 | */ |
| 133 | public abstract boolean isPermissionsReviewRequired(String packageName, int userId); |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 134 | |
| 135 | /** |
| 136 | * Gets all of the information we know about a particular package. |
| 137 | * |
| 138 | * @param packageName The package name to find. |
| 139 | * @param userId The user under which to check. |
| 140 | * |
| 141 | * @return An {@link ApplicationInfo} containing information about the |
Christopher Tate | 42a386b | 2016-11-07 12:21:21 -0800 | [diff] [blame] | 142 | * package, or {@code null} if no application exists with that |
| 143 | * package name. |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 144 | */ |
| 145 | public abstract ApplicationInfo getApplicationInfo(String packageName, int userId); |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 146 | |
| 147 | /** |
| 148 | * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}. |
| 149 | */ |
| 150 | public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates, |
| 151 | int userId); |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 152 | |
| 153 | /** |
| 154 | * Called by DeviceOwnerManagerService to set the package names of device owner and profile |
| 155 | * owners. |
| 156 | */ |
| 157 | public abstract void setDeviceAndProfileOwnerPackages( |
| 158 | int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners); |
| 159 | |
| 160 | /** |
Steven Ng | 9d48a73 | 2016-06-24 19:04:14 +0100 | [diff] [blame] | 161 | * Returns {@code true} if a given package can't be wiped. Otherwise, returns {@code false}. |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 162 | */ |
Steven Ng | 9d48a73 | 2016-06-24 19:04:14 +0100 | [diff] [blame] | 163 | public abstract boolean isPackageDataProtected(int userId, String packageName); |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 164 | |
| 165 | /** |
Dianne Hackborn | e07641d | 2016-11-09 15:07:23 -0800 | [diff] [blame] | 166 | * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns |
| 167 | * {@code false}. |
| 168 | */ |
| 169 | public abstract boolean isPackageEphemeral(int userId, String packageName); |
| 170 | |
| 171 | /** |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 172 | * Gets whether the package was ever launched. |
| 173 | * @param packageName The package name. |
| 174 | * @param userId The user for which to check. |
| 175 | * @return Whether was launched. |
Amith Yamasani | 2cbfa1e | 2017-03-28 10:34:01 -0700 | [diff] [blame] | 176 | * @throws IllegalArgumentException if the package is not found |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 177 | */ |
| 178 | public abstract boolean wasPackageEverLaunched(String packageName, int userId); |
Nicolas Prevot | 700e1e7 | 2016-09-28 15:17:18 +0100 | [diff] [blame] | 179 | |
| 180 | /** |
| 181 | * Grants a runtime permission |
| 182 | * @param packageName The package name. |
| 183 | * @param name The name of the permission. |
| 184 | * @param userId The userId for which to grant the permission. |
| 185 | * @param overridePolicy If true, grant this permission even if it is fixed by policy. |
| 186 | */ |
| 187 | public abstract void grantRuntimePermission(String packageName, String name, int userId, |
| 188 | boolean overridePolicy); |
| 189 | |
| 190 | /** |
| 191 | * Revokes a runtime permission |
| 192 | * @param packageName The package name. |
| 193 | * @param name The name of the permission. |
| 194 | * @param userId The userId for which to revoke the permission. |
| 195 | * @param overridePolicy If true, revoke this permission even if it is fixed by policy. |
| 196 | */ |
| 197 | public abstract void revokeRuntimePermission(String packageName, String name, int userId, |
| 198 | boolean overridePolicy); |
| 199 | |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 200 | /** |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 201 | * Retrieve the official name associated with a uid. This name is |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 202 | * guaranteed to never change, though it is possible for the underlying |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 203 | * uid to be changed. That is, if you are storing information about |
| 204 | * uids in persistent storage, you should use the string returned |
| 205 | * by this function instead of the raw uid. |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 206 | * |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 207 | * @param uid The uid for which you would like to retrieve a name. |
| 208 | * @return Returns a unique name for the given uid, or null if the |
| 209 | * uid is not currently assigned. |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 210 | */ |
| 211 | public abstract String getNameForUid(int uid); |
| 212 | |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 213 | /** |
| 214 | * Request to perform the second phase of ephemeral resolution. |
| 215 | * @param responseObj The response of the first phase of ephemeral resolution |
| 216 | * @param origIntent The original intent that triggered ephemeral resolution |
| 217 | * @param resolvedType The resolved type of the intent |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 218 | * @param callingPackage The name of the package requesting the ephemeral application |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 219 | * @param verificationBundle Optional bundle to pass to the installer for additional |
| 220 | * verification |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 221 | * @param userId The ID of the user that triggered ephemeral resolution |
| 222 | */ |
Todd Kennedy | e991022 | 2017-02-21 16:00:11 -0800 | [diff] [blame] | 223 | public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj, |
| 224 | Intent origIntent, String resolvedType, String callingPackage, |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 225 | Bundle verificationBundle, int userId); |
Svetoslav Ganov | e080da9 | 2016-12-21 17:10:35 -0800 | [diff] [blame] | 226 | |
| 227 | /** |
Todd Kennedy | 0e989d0 | 2017-01-13 14:15:36 -0800 | [diff] [blame] | 228 | * Grants access to the package metadata for an ephemeral application. |
| 229 | * <p> |
| 230 | * When an ephemeral application explicitly tries to interact with a full |
| 231 | * install application [via an activity, service or provider that has been |
| 232 | * exposed using the {@code visibleToInstantApp} attribute], the normal |
| 233 | * application must be able to see metadata about the connecting ephemeral |
| 234 | * app. If the ephemeral application uses an implicit intent [ie action VIEW, |
| 235 | * category BROWSABLE], it remains hidden from the launched activity. |
| 236 | * <p> |
| 237 | * If the {@code sourceUid} is not for an ephemeral app or {@code targetUid} |
| 238 | * is not for a fully installed app, this method will be a no-op. |
| 239 | * |
| 240 | * @param userId the user |
| 241 | * @param intent the intent that triggered the grant |
| 242 | * @param targetAppId The app ID of the fully installed application |
| 243 | * @param ephemeralAppId The app ID of the ephemeral application |
| 244 | */ |
| 245 | public abstract void grantEphemeralAccess(int userId, Intent intent, |
| 246 | int targetAppId, int ephemeralAppId); |
| 247 | |
Todd Kennedy | b21be12 | 2017-03-24 14:10:01 -0700 | [diff] [blame] | 248 | public abstract boolean isInstantAppInstallerComponent(ComponentName component); |
Todd Kennedy | 0e989d0 | 2017-01-13 14:15:36 -0800 | [diff] [blame] | 249 | /** |
Svetoslav Ganov | 096d304 | 2017-01-30 16:34:13 -0800 | [diff] [blame] | 250 | * Prunes instant apps and state associated with uninstalled |
| 251 | * instant apps according to the current platform policy. |
| 252 | */ |
| 253 | public abstract void pruneInstantApps(); |
| 254 | |
| 255 | /** |
Svetoslav Ganov | e080da9 | 2016-12-21 17:10:35 -0800 | [diff] [blame] | 256 | * @return The SetupWizard package name. |
| 257 | */ |
| 258 | public abstract String getSetupWizardPackageName(); |
Suprabh Shukla | aef2513 | 2017-01-23 18:09:03 -0800 | [diff] [blame] | 259 | |
| 260 | public interface ExternalSourcesPolicy { |
| 261 | |
| 262 | int USER_TRUSTED = 0; // User has trusted the package to install apps |
| 263 | int USER_BLOCKED = 1; // User has blocked the package to install apps |
| 264 | int USER_DEFAULT = 2; // Default code to use when user response is unavailable |
| 265 | |
| 266 | /** |
| 267 | * Checks the user preference for whether a package is trusted to request installs through |
| 268 | * package installer |
| 269 | * |
| 270 | * @param packageName The package to check for |
| 271 | * @param uid the uid in which the package is running |
| 272 | * @return {@link USER_TRUSTED} if the user has trusted the package, {@link USER_BLOCKED} |
| 273 | * if user has blocked requests from the package, {@link USER_DEFAULT} if the user response |
| 274 | * is not yet available |
| 275 | */ |
| 276 | int getPackageTrustedToInstallApps(String packageName, int uid); |
| 277 | } |
| 278 | |
| 279 | public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy); |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 280 | |
| 281 | /** |
Dianne Hackborn | b1e7776 | 2017-02-13 11:42:18 -0800 | [diff] [blame] | 282 | * Return true if the given package is a persistent app process. |
| 283 | */ |
| 284 | public abstract boolean isPackagePersistent(String packageName); |
| 285 | |
| 286 | /** |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 287 | * Get all overlay packages for a user. |
| 288 | * @param userId The user for which to get the overlays. |
| 289 | * @return A list of overlay packages. An empty list is returned if the |
| 290 | * user has no installed overlay packages. |
| 291 | */ |
| 292 | public abstract List<PackageInfo> getOverlayPackages(int userId); |
| 293 | |
| 294 | /** |
| 295 | * Get the names of all target packages for a user. |
| 296 | * @param userId The user for which to get the package names. |
| 297 | * @return A list of target package names. This list includes the "android" package. |
| 298 | */ |
| 299 | public abstract List<String> getTargetPackageNames(int userId); |
| 300 | |
| 301 | /** |
| 302 | * Set which overlay to use for a package. |
| 303 | * @param userId The user for which to update the overlays. |
| 304 | * @param targetPackageName The package name of the package for which to update the overlays. |
| 305 | * @param overlayPackageNames The complete list of overlay packages that should be enabled for |
| 306 | * the target. Previously enabled overlays not specified in the list |
| 307 | * will be disabled. Pass in null or an empty list to disable |
| 308 | * all overlays. The order of the items is significant if several |
| 309 | * overlays modify the same resource. |
| 310 | * @return true if all packages names were known by the package manager, false otherwise |
| 311 | */ |
| 312 | public abstract boolean setEnabledOverlayPackages(int userId, String targetPackageName, |
| 313 | List<String> overlayPackageNames); |
Todd Kennedy | 4d1de7d | 2017-02-23 10:32:18 -0800 | [diff] [blame] | 314 | |
| 315 | /** |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 316 | * Resolves an activity intent, allowing instant apps to be resolved. |
Todd Kennedy | 4d1de7d | 2017-02-23 10:32:18 -0800 | [diff] [blame] | 317 | */ |
| 318 | public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType, |
| 319 | int flags, int userId); |
Chad Brubaker | 0f28a80 | 2017-03-29 14:05:52 -0700 | [diff] [blame] | 320 | |
| 321 | /** |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 322 | * Resolves a service intent, allowing instant apps to be resolved. |
| 323 | */ |
| 324 | public abstract ResolveInfo resolveService(Intent intent, String resolvedType, |
| 325 | int flags, int userId, int callingUid); |
| 326 | |
| 327 | /** |
Chad Brubaker | 0f28a80 | 2017-03-29 14:05:52 -0700 | [diff] [blame] | 328 | * Track the creator of a new isolated uid. |
| 329 | * @param isolatedUid The newly created isolated uid. |
| 330 | * @param ownerUid The uid of the app that created the isolated process. |
| 331 | */ |
| 332 | public abstract void addIsolatedUid(int isolatedUid, int ownerUid); |
| 333 | |
| 334 | /** |
| 335 | * Track removal of an isolated uid. |
| 336 | * @param isolatedUid isolated uid that is no longer being used. |
| 337 | */ |
| 338 | public abstract void removeIsolatedUid(int isolatedUid); |
Makoto Onuki | e92f794 | 2017-04-26 14:38:18 -0700 | [diff] [blame] | 339 | |
| 340 | /** |
| 341 | * Return the taget SDK version for the app with the given UID. |
| 342 | */ |
| 343 | public abstract int getUidTargetSdkVersion(int uid); |
Makoto Onuki | ad62301 | 2017-05-15 09:29:34 -0700 | [diff] [blame^] | 344 | |
| 345 | /** Whether the binder caller can access instant apps. */ |
| 346 | public abstract boolean canAccessInstantApps(int callingUid); |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 347 | } |