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 | |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 19 | import android.annotation.IntDef; |
| 20 | import android.annotation.NonNull; |
| 21 | import android.annotation.Nullable; |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 22 | import android.content.ComponentName; |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 23 | import android.content.Intent; |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 24 | import android.content.pm.PackageManager.ApplicationInfoFlags; |
| 25 | import android.content.pm.PackageManager.ComponentInfoFlags; |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 26 | import android.content.pm.PackageManager.PackageInfoFlags; |
| 27 | import android.content.pm.PackageManager.ResolveInfoFlags; |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 28 | import android.os.Bundle; |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 29 | import android.util.SparseArray; |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 30 | |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 31 | import java.lang.annotation.Retention; |
| 32 | import java.lang.annotation.RetentionPolicy; |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 33 | import java.util.List; |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Package manager local system service interface. |
| 37 | * |
| 38 | * @hide Only for use within the system server. |
| 39 | */ |
| 40 | public abstract class PackageManagerInternal { |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 41 | public static final int PACKAGE_SYSTEM = 0; |
| 42 | public static final int PACKAGE_SETUP_WIZARD = 1; |
| 43 | public static final int PACKAGE_INSTALLER = 2; |
| 44 | public static final int PACKAGE_VERIFIER = 3; |
| 45 | public static final int PACKAGE_BROWSER = 4; |
| 46 | @IntDef(value = { |
| 47 | PACKAGE_SYSTEM, |
| 48 | PACKAGE_SETUP_WIZARD, |
| 49 | PACKAGE_INSTALLER, |
| 50 | PACKAGE_VERIFIER, |
| 51 | PACKAGE_BROWSER, |
| 52 | }) |
| 53 | @Retention(RetentionPolicy.SOURCE) |
| 54 | public @interface KnownPackage {} |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 55 | |
Todd Kennedy | 42d6160 | 2017-12-12 14:44:19 -0800 | [diff] [blame] | 56 | /** Observer called whenever the list of packages changes */ |
| 57 | public interface PackageListObserver { |
| 58 | /** A package was added to the system. */ |
| 59 | void onPackageAdded(@NonNull String packageName); |
| 60 | /** A package was removed from the system. */ |
| 61 | void onPackageRemoved(@NonNull String packageName); |
| 62 | } |
| 63 | |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 64 | /** |
| 65 | * Provider for package names. |
| 66 | */ |
| 67 | public interface PackagesProvider { |
| 68 | |
| 69 | /** |
| 70 | * Gets the packages for a given user. |
| 71 | * @param userId The user id. |
| 72 | * @return The package names. |
| 73 | */ |
| 74 | public String[] getPackages(int userId); |
| 75 | } |
| 76 | |
| 77 | /** |
Svetoslav | 0010b70 | 2015-06-30 18:05:26 -0700 | [diff] [blame] | 78 | * Provider for package names. |
| 79 | */ |
| 80 | public interface SyncAdapterPackagesProvider { |
| 81 | |
| 82 | /** |
| 83 | * Gets the sync adapter packages for given authority and user. |
| 84 | * @param authority The authority. |
| 85 | * @param userId The user id. |
| 86 | * @return The package names. |
| 87 | */ |
| 88 | public String[] getPackages(String authority, int userId); |
| 89 | } |
| 90 | |
| 91 | /** |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 92 | * Sets the location provider packages provider. |
| 93 | * @param provider The packages provider. |
| 94 | */ |
| 95 | public abstract void setLocationPackagesProvider(PackagesProvider provider); |
| 96 | |
| 97 | /** |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 98 | * Sets the voice interaction packages provider. |
| 99 | * @param provider The packages provider. |
| 100 | */ |
| 101 | public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider); |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 102 | |
| 103 | /** |
| 104 | * Sets the SMS packages provider. |
| 105 | * @param provider The packages provider. |
| 106 | */ |
| 107 | public abstract void setSmsAppPackagesProvider(PackagesProvider provider); |
| 108 | |
| 109 | /** |
| 110 | * Sets the dialer packages provider. |
| 111 | * @param provider The packages provider. |
| 112 | */ |
| 113 | public abstract void setDialerAppPackagesProvider(PackagesProvider provider); |
| 114 | |
| 115 | /** |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 116 | * Sets the sim call manager packages provider. |
| 117 | * @param provider The packages provider. |
| 118 | */ |
| 119 | public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider); |
| 120 | |
| 121 | /** |
Eric Enslen | 1e423b9 | 2017-12-18 11:30:21 -0800 | [diff] [blame^] | 122 | * Sets the Use Open Wifi packages provider. |
| 123 | * @param provider The packages provider. |
| 124 | */ |
| 125 | public abstract void setUseOpenWifiAppPackagesProvider(PackagesProvider provider); |
| 126 | |
| 127 | /** |
Svetoslav | 0010b70 | 2015-06-30 18:05:26 -0700 | [diff] [blame] | 128 | * Sets the sync adapter packages provider. |
| 129 | * @param provider The provider. |
| 130 | */ |
| 131 | public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider); |
| 132 | |
| 133 | /** |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 134 | * Requests granting of the default permissions to the current default SMS app. |
| 135 | * @param packageName The default SMS package name. |
| 136 | * @param userId The user for which to grant the permissions. |
| 137 | */ |
| 138 | public abstract void grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId); |
| 139 | |
| 140 | /** |
| 141 | * Requests granting of the default permissions to the current default dialer app. |
| 142 | * @param packageName The default dialer package name. |
| 143 | * @param userId The user for which to grant the permissions. |
| 144 | */ |
| 145 | public abstract void grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId); |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 146 | |
| 147 | /** |
| 148 | * Requests granting of the default permissions to the current default sim call manager. |
| 149 | * @param packageName The default sim call manager package name. |
| 150 | * @param userId The user for which to grant the permissions. |
| 151 | */ |
| 152 | public abstract void grantDefaultPermissionsToDefaultSimCallManager(String packageName, |
| 153 | int userId); |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 154 | |
| 155 | /** |
Eric Enslen | 1e423b9 | 2017-12-18 11:30:21 -0800 | [diff] [blame^] | 156 | * Requests granting of the default permissions to the current default Use Open Wifi app. |
| 157 | * @param packageName The default use open wifi package name. |
| 158 | * @param userId The user for which to grant the permissions. |
| 159 | */ |
| 160 | public abstract void grantDefaultPermissionsToDefaultUseOpenWifiApp(String packageName, |
| 161 | int userId); |
| 162 | |
| 163 | /** |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 164 | * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has |
| 165 | * currently installed it. The apps are not preloaded. |
| 166 | * @param packageList List of package names to keep cached. |
| 167 | */ |
| 168 | public abstract void setKeepUninstalledPackages(List<String> packageList); |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 169 | |
| 170 | /** |
| 171 | * Gets whether some of the permissions used by this package require a user |
| 172 | * review before any of the app components can run. |
| 173 | * @param packageName The package name for which to check. |
| 174 | * @param userId The user under which to check. |
| 175 | * @return True a permissions review is required. |
| 176 | */ |
| 177 | public abstract boolean isPermissionsReviewRequired(String packageName, int userId); |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 178 | |
| 179 | /** |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 180 | * Retrieve all of the information we know about a particular package/application. |
| 181 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 182 | * of the calling UID. |
| 183 | * @see PackageManager#getPackageInfo(String, int) |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 184 | */ |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 185 | public abstract PackageInfo getPackageInfo(String packageName, |
| 186 | @PackageInfoFlags int flags, int filterCallingUid, int userId); |
| 187 | |
| 188 | /** |
Christopher Tate | a732f01 | 2017-10-26 17:26:53 -0700 | [diff] [blame] | 189 | * Do a straight uid lookup for the given package/application in the given user. |
| 190 | * @see PackageManager#getPackageUidAsUser(String, int, int) |
| 191 | * @return The app's uid, or < 0 if the package was not found in that user |
| 192 | */ |
| 193 | public abstract int getPackageUid(String packageName, |
| 194 | @PackageInfoFlags int flags, int userId); |
| 195 | |
| 196 | /** |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 197 | * Retrieve all of the information we know about a particular package/application. |
| 198 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 199 | * of the calling UID. |
| 200 | * @see PackageManager#getApplicationInfo(String, int) |
| 201 | */ |
| 202 | public abstract ApplicationInfo getApplicationInfo(String packageName, |
| 203 | @ApplicationInfoFlags int flags, int filterCallingUid, int userId); |
| 204 | |
| 205 | /** |
| 206 | * Retrieve all of the information we know about a particular activity class. |
| 207 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 208 | * of the calling UID. |
| 209 | * @see PackageManager#getActivityInfo(ComponentName, int) |
| 210 | */ |
| 211 | public abstract ActivityInfo getActivityInfo(ComponentName component, |
| 212 | @ComponentInfoFlags int flags, int filterCallingUid, int userId); |
| 213 | |
| 214 | /** |
| 215 | * Retrieve all activities that can be performed for the given intent. |
| 216 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 217 | * of the calling UID. |
| 218 | * @see PackageManager#queryIntentActivities(Intent, int) |
| 219 | */ |
| 220 | public abstract List<ResolveInfo> queryIntentActivities(Intent intent, |
| 221 | @ResolveInfoFlags int flags, int filterCallingUid, int userId); |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 222 | |
| 223 | /** |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 224 | * Retrieve all services that can be performed for the given intent. |
| 225 | * @see PackageManager#queryIntentServices(Intent, int) |
| 226 | */ |
| 227 | public abstract List<ResolveInfo> queryIntentServices( |
| 228 | Intent intent, int flags, int callingUid, int userId); |
| 229 | |
| 230 | /** |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 231 | * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}. |
| 232 | */ |
| 233 | public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates, |
| 234 | int userId); |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 235 | |
| 236 | /** |
| 237 | * Called by DeviceOwnerManagerService to set the package names of device owner and profile |
| 238 | * owners. |
| 239 | */ |
| 240 | public abstract void setDeviceAndProfileOwnerPackages( |
| 241 | int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners); |
| 242 | |
| 243 | /** |
Steven Ng | 9d48a73 | 2016-06-24 19:04:14 +0100 | [diff] [blame] | 244 | * 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] | 245 | */ |
Steven Ng | 9d48a73 | 2016-06-24 19:04:14 +0100 | [diff] [blame] | 246 | public abstract boolean isPackageDataProtected(int userId, String packageName); |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 247 | |
| 248 | /** |
Dianne Hackborn | e07641d | 2016-11-09 15:07:23 -0800 | [diff] [blame] | 249 | * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns |
| 250 | * {@code false}. |
| 251 | */ |
| 252 | public abstract boolean isPackageEphemeral(int userId, String packageName); |
| 253 | |
| 254 | /** |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 255 | * Gets whether the package was ever launched. |
| 256 | * @param packageName The package name. |
| 257 | * @param userId The user for which to check. |
| 258 | * @return Whether was launched. |
Amith Yamasani | 2cbfa1e | 2017-03-28 10:34:01 -0700 | [diff] [blame] | 259 | * @throws IllegalArgumentException if the package is not found |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 260 | */ |
| 261 | public abstract boolean wasPackageEverLaunched(String packageName, int userId); |
Nicolas Prevot | 700e1e7 | 2016-09-28 15:17:18 +0100 | [diff] [blame] | 262 | |
| 263 | /** |
| 264 | * Grants a runtime permission |
| 265 | * @param packageName The package name. |
| 266 | * @param name The name of the permission. |
| 267 | * @param userId The userId for which to grant the permission. |
| 268 | * @param overridePolicy If true, grant this permission even if it is fixed by policy. |
| 269 | */ |
| 270 | public abstract void grantRuntimePermission(String packageName, String name, int userId, |
| 271 | boolean overridePolicy); |
| 272 | |
| 273 | /** |
| 274 | * Revokes a runtime permission |
| 275 | * @param packageName The package name. |
| 276 | * @param name The name of the permission. |
| 277 | * @param userId The userId for which to revoke the permission. |
| 278 | * @param overridePolicy If true, revoke this permission even if it is fixed by policy. |
| 279 | */ |
| 280 | public abstract void revokeRuntimePermission(String packageName, String name, int userId, |
| 281 | boolean overridePolicy); |
| 282 | |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 283 | /** |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 284 | * Retrieve the official name associated with a uid. This name is |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 285 | * guaranteed to never change, though it is possible for the underlying |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 286 | * uid to be changed. That is, if you are storing information about |
| 287 | * uids in persistent storage, you should use the string returned |
| 288 | * by this function instead of the raw uid. |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 289 | * |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 290 | * @param uid The uid for which you would like to retrieve a name. |
| 291 | * @return Returns a unique name for the given uid, or null if the |
| 292 | * uid is not currently assigned. |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 293 | */ |
| 294 | public abstract String getNameForUid(int uid); |
| 295 | |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 296 | /** |
| 297 | * Request to perform the second phase of ephemeral resolution. |
| 298 | * @param responseObj The response of the first phase of ephemeral resolution |
| 299 | * @param origIntent The original intent that triggered ephemeral resolution |
| 300 | * @param resolvedType The resolved type of the intent |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 301 | * @param callingPackage The name of the package requesting the ephemeral application |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 302 | * @param verificationBundle Optional bundle to pass to the installer for additional |
| 303 | * verification |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 304 | * @param userId The ID of the user that triggered ephemeral resolution |
| 305 | */ |
Todd Kennedy | e991022 | 2017-02-21 16:00:11 -0800 | [diff] [blame] | 306 | public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj, |
| 307 | Intent origIntent, String resolvedType, String callingPackage, |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 308 | Bundle verificationBundle, int userId); |
Svetoslav Ganov | e080da9 | 2016-12-21 17:10:35 -0800 | [diff] [blame] | 309 | |
| 310 | /** |
Todd Kennedy | 0e989d0 | 2017-01-13 14:15:36 -0800 | [diff] [blame] | 311 | * Grants access to the package metadata for an ephemeral application. |
| 312 | * <p> |
| 313 | * When an ephemeral application explicitly tries to interact with a full |
| 314 | * install application [via an activity, service or provider that has been |
| 315 | * exposed using the {@code visibleToInstantApp} attribute], the normal |
| 316 | * application must be able to see metadata about the connecting ephemeral |
| 317 | * app. If the ephemeral application uses an implicit intent [ie action VIEW, |
| 318 | * category BROWSABLE], it remains hidden from the launched activity. |
| 319 | * <p> |
| 320 | * If the {@code sourceUid} is not for an ephemeral app or {@code targetUid} |
| 321 | * is not for a fully installed app, this method will be a no-op. |
| 322 | * |
| 323 | * @param userId the user |
| 324 | * @param intent the intent that triggered the grant |
| 325 | * @param targetAppId The app ID of the fully installed application |
| 326 | * @param ephemeralAppId The app ID of the ephemeral application |
| 327 | */ |
| 328 | public abstract void grantEphemeralAccess(int userId, Intent intent, |
| 329 | int targetAppId, int ephemeralAppId); |
| 330 | |
Todd Kennedy | b21be12 | 2017-03-24 14:10:01 -0700 | [diff] [blame] | 331 | public abstract boolean isInstantAppInstallerComponent(ComponentName component); |
Todd Kennedy | 0e989d0 | 2017-01-13 14:15:36 -0800 | [diff] [blame] | 332 | /** |
Svetoslav Ganov | 096d304 | 2017-01-30 16:34:13 -0800 | [diff] [blame] | 333 | * Prunes instant apps and state associated with uninstalled |
| 334 | * instant apps according to the current platform policy. |
| 335 | */ |
| 336 | public abstract void pruneInstantApps(); |
| 337 | |
| 338 | /** |
Svetoslav Ganov | e080da9 | 2016-12-21 17:10:35 -0800 | [diff] [blame] | 339 | * @return The SetupWizard package name. |
| 340 | */ |
| 341 | public abstract String getSetupWizardPackageName(); |
Suprabh Shukla | aef2513 | 2017-01-23 18:09:03 -0800 | [diff] [blame] | 342 | |
| 343 | public interface ExternalSourcesPolicy { |
| 344 | |
| 345 | int USER_TRUSTED = 0; // User has trusted the package to install apps |
| 346 | int USER_BLOCKED = 1; // User has blocked the package to install apps |
| 347 | int USER_DEFAULT = 2; // Default code to use when user response is unavailable |
| 348 | |
| 349 | /** |
| 350 | * Checks the user preference for whether a package is trusted to request installs through |
| 351 | * package installer |
| 352 | * |
| 353 | * @param packageName The package to check for |
| 354 | * @param uid the uid in which the package is running |
| 355 | * @return {@link USER_TRUSTED} if the user has trusted the package, {@link USER_BLOCKED} |
| 356 | * if user has blocked requests from the package, {@link USER_DEFAULT} if the user response |
| 357 | * is not yet available |
| 358 | */ |
| 359 | int getPackageTrustedToInstallApps(String packageName, int uid); |
| 360 | } |
| 361 | |
| 362 | public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy); |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 363 | |
| 364 | /** |
Dianne Hackborn | b1e7776 | 2017-02-13 11:42:18 -0800 | [diff] [blame] | 365 | * Return true if the given package is a persistent app process. |
| 366 | */ |
| 367 | public abstract boolean isPackagePersistent(String packageName); |
| 368 | |
| 369 | /** |
Todd Kennedy | c29b11a | 2017-10-23 15:55:59 -0700 | [diff] [blame] | 370 | * Returns whether or not the given package represents a legacy system application released |
| 371 | * prior to runtime permissions. |
| 372 | */ |
| 373 | public abstract boolean isLegacySystemApp(PackageParser.Package pkg); |
| 374 | |
| 375 | /** |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 376 | * Get all overlay packages for a user. |
| 377 | * @param userId The user for which to get the overlays. |
| 378 | * @return A list of overlay packages. An empty list is returned if the |
| 379 | * user has no installed overlay packages. |
| 380 | */ |
| 381 | public abstract List<PackageInfo> getOverlayPackages(int userId); |
| 382 | |
| 383 | /** |
| 384 | * Get the names of all target packages for a user. |
| 385 | * @param userId The user for which to get the package names. |
| 386 | * @return A list of target package names. This list includes the "android" package. |
| 387 | */ |
| 388 | public abstract List<String> getTargetPackageNames(int userId); |
| 389 | |
| 390 | /** |
| 391 | * Set which overlay to use for a package. |
| 392 | * @param userId The user for which to update the overlays. |
| 393 | * @param targetPackageName The package name of the package for which to update the overlays. |
| 394 | * @param overlayPackageNames The complete list of overlay packages that should be enabled for |
| 395 | * the target. Previously enabled overlays not specified in the list |
| 396 | * will be disabled. Pass in null or an empty list to disable |
| 397 | * all overlays. The order of the items is significant if several |
| 398 | * overlays modify the same resource. |
| 399 | * @return true if all packages names were known by the package manager, false otherwise |
| 400 | */ |
| 401 | public abstract boolean setEnabledOverlayPackages(int userId, String targetPackageName, |
| 402 | List<String> overlayPackageNames); |
Todd Kennedy | 4d1de7d | 2017-02-23 10:32:18 -0800 | [diff] [blame] | 403 | |
| 404 | /** |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 405 | * Resolves an activity intent, allowing instant apps to be resolved. |
Todd Kennedy | 4d1de7d | 2017-02-23 10:32:18 -0800 | [diff] [blame] | 406 | */ |
| 407 | public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType, |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 408 | int flags, int userId, boolean resolveForStart); |
Chad Brubaker | 0f28a80 | 2017-03-29 14:05:52 -0700 | [diff] [blame] | 409 | |
| 410 | /** |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 411 | * Resolves a service intent, allowing instant apps to be resolved. |
| 412 | */ |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 413 | public abstract ResolveInfo resolveService(Intent intent, String resolvedType, |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 414 | int flags, int userId, int callingUid); |
| 415 | |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 416 | /** |
| 417 | * Resolves a content provider intent. |
| 418 | */ |
| 419 | public abstract ProviderInfo resolveContentProvider(String name, int flags, int userId); |
| 420 | |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 421 | /** |
Chad Brubaker | 0f28a80 | 2017-03-29 14:05:52 -0700 | [diff] [blame] | 422 | * Track the creator of a new isolated uid. |
| 423 | * @param isolatedUid The newly created isolated uid. |
| 424 | * @param ownerUid The uid of the app that created the isolated process. |
| 425 | */ |
| 426 | public abstract void addIsolatedUid(int isolatedUid, int ownerUid); |
| 427 | |
| 428 | /** |
| 429 | * Track removal of an isolated uid. |
| 430 | * @param isolatedUid isolated uid that is no longer being used. |
| 431 | */ |
| 432 | public abstract void removeIsolatedUid(int isolatedUid); |
Makoto Onuki | e92f794 | 2017-04-26 14:38:18 -0700 | [diff] [blame] | 433 | |
| 434 | /** |
| 435 | * Return the taget SDK version for the app with the given UID. |
| 436 | */ |
| 437 | public abstract int getUidTargetSdkVersion(int uid); |
Makoto Onuki | ad62301 | 2017-05-15 09:29:34 -0700 | [diff] [blame] | 438 | |
| 439 | /** Whether the binder caller can access instant apps. */ |
Todd Kennedy | 3051caa | 2017-05-23 15:54:18 -0700 | [diff] [blame] | 440 | public abstract boolean canAccessInstantApps(int callingUid, int userId); |
Svet Ganov | f935a70 | 2017-08-22 12:15:58 -0700 | [diff] [blame] | 441 | |
| 442 | /** |
| 443 | * Returns {@code true} if a given package has instant application meta-data. |
| 444 | * Otherwise, returns {@code false}. Meta-data is state (eg. cookie, app icon, etc) |
| 445 | * associated with an instant app. It may be kept after the instant app has been uninstalled. |
| 446 | */ |
| 447 | public abstract boolean hasInstantApplicationMetadata(String packageName, int userId); |
Todd Kennedy | df113c3 | 2017-08-31 16:10:29 -0700 | [diff] [blame] | 448 | |
| 449 | /** |
| 450 | * Updates a package last used time. |
| 451 | */ |
| 452 | public abstract void notifyPackageUse(String packageName, int reason); |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 453 | |
| 454 | /** |
| 455 | * Returns a package object for the given package name. |
| 456 | */ |
| 457 | public abstract @Nullable PackageParser.Package getPackage(@NonNull String packageName); |
| 458 | |
| 459 | /** |
Todd Kennedy | 42d6160 | 2017-12-12 14:44:19 -0800 | [diff] [blame] | 460 | * Returns a list without a change observer. |
| 461 | * |
| 462 | * {@see #getPackageList(PackageListObserver)} |
| 463 | */ |
| 464 | public @NonNull PackageList getPackageList() { |
| 465 | return getPackageList(null); |
| 466 | } |
| 467 | |
| 468 | /** |
| 469 | * Returns the list of packages installed at the time of the method call. |
| 470 | * <p>The given observer is notified when the list of installed packages |
| 471 | * changes [eg. a package was installed or uninstalled]. It will not be |
| 472 | * notified if a package is updated. |
| 473 | * <p>The package list will not be updated automatically as packages are |
| 474 | * installed / uninstalled. Any changes must be handled within the observer. |
| 475 | */ |
| 476 | public abstract @NonNull PackageList getPackageList(@Nullable PackageListObserver observer); |
| 477 | |
| 478 | /** |
| 479 | * Removes the observer. |
| 480 | * <p>Generally not needed. {@link #getPackageList(PackageListObserver)} will automatically |
| 481 | * remove the observer. |
| 482 | * <p>Does nothing if the observer isn't currently registered. |
| 483 | * <p>Observers are notified asynchronously and it's possible for an observer to be |
| 484 | * invoked after its been removed. |
| 485 | */ |
| 486 | public abstract void removePackageListObserver(@NonNull PackageListObserver observer); |
| 487 | |
| 488 | /** |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 489 | * Returns a package object for the disabled system package name. |
| 490 | */ |
| 491 | public abstract @Nullable PackageParser.Package getDisabledPackage(@NonNull String packageName); |
| 492 | |
| 493 | /** |
| 494 | * Returns whether or not the component is the resolver activity. |
| 495 | */ |
| 496 | public abstract boolean isResolveActivityComponent(@NonNull ComponentInfo component); |
| 497 | |
| 498 | /** |
| 499 | * Returns the package name for a known package. |
| 500 | */ |
| 501 | public abstract @Nullable String getKnownPackageName( |
| 502 | @KnownPackage int knownPackage, int userId); |
| 503 | |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 504 | /** |
| 505 | * Returns whether the package is an instant app. |
| 506 | */ |
| 507 | public abstract boolean isInstantApp(String packageName, int userId); |
| 508 | |
| 509 | /** |
| 510 | * Returns whether the package is an instant app. |
| 511 | */ |
| 512 | public abstract @Nullable String getInstantAppPackageName(int uid); |
| 513 | |
| 514 | /** |
| 515 | * Returns whether or not access to the application should be filtered. |
| 516 | * <p> |
| 517 | * Access may be limited based upon whether the calling or target applications |
| 518 | * are instant applications. |
| 519 | * |
| 520 | * @see #canAccessInstantApps(int) |
| 521 | */ |
| 522 | public abstract boolean filterAppAccess( |
| 523 | @Nullable PackageParser.Package pkg, int callingUid, int userId); |
| 524 | |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 525 | /* |
| 526 | * NOTE: The following methods are temporary until permissions are extracted from |
| 527 | * the package manager into a component specifically for handling permissions. |
| 528 | */ |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 529 | /** Returns the flags for the given permission. */ |
| 530 | public abstract @Nullable int getPermissionFlagsTEMP(@NonNull String permName, |
| 531 | @NonNull String packageName, int userId); |
| 532 | /** Updates the flags for the given permission. */ |
| 533 | public abstract void updatePermissionFlagsTEMP(@NonNull String permName, |
| 534 | @NonNull String packageName, int flagMask, int flagValues, int userId); |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 535 | } |