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 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.content.ComponentName; 23 import android.content.Intent; 24 import android.content.pm.PackageManager.ApplicationInfoFlags; 25 import android.content.pm.PackageManager.ComponentInfoFlags; 26 import android.content.pm.PackageManager.PackageInfoFlags; 27 import android.content.pm.PackageManager.ResolveInfoFlags; 28 import android.os.Bundle; 29 import android.os.PersistableBundle; 30 import android.util.SparseArray; 31 32 import java.lang.annotation.Retention; 33 import java.lang.annotation.RetentionPolicy; 34 import java.util.List; 35 36 /** 37 * Package manager local system service interface. 38 * 39 * @hide Only for use within the system server. 40 */ 41 public abstract class PackageManagerInternal { 42 public static final int PACKAGE_SYSTEM = 0; 43 public static final int PACKAGE_SETUP_WIZARD = 1; 44 public static final int PACKAGE_INSTALLER = 2; 45 public static final int PACKAGE_VERIFIER = 3; 46 public static final int PACKAGE_BROWSER = 4; 47 public static final int PACKAGE_SYSTEM_TEXT_CLASSIFIER = 5; 48 @IntDef(value = { 49 PACKAGE_SYSTEM, 50 PACKAGE_SETUP_WIZARD, 51 PACKAGE_INSTALLER, 52 PACKAGE_VERIFIER, 53 PACKAGE_BROWSER, 54 PACKAGE_SYSTEM_TEXT_CLASSIFIER, 55 }) 56 @Retention(RetentionPolicy.SOURCE) 57 public @interface KnownPackage {} 58 59 /** Observer called whenever the list of packages changes */ 60 public interface PackageListObserver { 61 /** A package was added to the system. */ onPackageAdded(@onNull String packageName)62 void onPackageAdded(@NonNull String packageName); 63 /** A package was removed from the system. */ onPackageRemoved(@onNull String packageName)64 void onPackageRemoved(@NonNull String packageName); 65 } 66 67 /** 68 * Provider for package names. 69 */ 70 public interface PackagesProvider { 71 72 /** 73 * Gets the packages for a given user. 74 * @param userId The user id. 75 * @return The package names. 76 */ getPackages(int userId)77 public String[] getPackages(int userId); 78 } 79 80 /** 81 * Provider for package names. 82 */ 83 public interface SyncAdapterPackagesProvider { 84 85 /** 86 * Gets the sync adapter packages for given authority and user. 87 * @param authority The authority. 88 * @param userId The user id. 89 * @return The package names. 90 */ getPackages(String authority, int userId)91 public String[] getPackages(String authority, int userId); 92 } 93 94 /** 95 * Sets the location provider packages provider. 96 * @param provider The packages provider. 97 */ setLocationPackagesProvider(PackagesProvider provider)98 public abstract void setLocationPackagesProvider(PackagesProvider provider); 99 100 /** 101 * Sets the voice interaction packages provider. 102 * @param provider The packages provider. 103 */ setVoiceInteractionPackagesProvider(PackagesProvider provider)104 public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider); 105 106 /** 107 * Sets the SMS packages provider. 108 * @param provider The packages provider. 109 */ setSmsAppPackagesProvider(PackagesProvider provider)110 public abstract void setSmsAppPackagesProvider(PackagesProvider provider); 111 112 /** 113 * Sets the dialer packages provider. 114 * @param provider The packages provider. 115 */ setDialerAppPackagesProvider(PackagesProvider provider)116 public abstract void setDialerAppPackagesProvider(PackagesProvider provider); 117 118 /** 119 * Sets the sim call manager packages provider. 120 * @param provider The packages provider. 121 */ setSimCallManagerPackagesProvider(PackagesProvider provider)122 public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider); 123 124 /** 125 * Sets the Use Open Wifi packages provider. 126 * @param provider The packages provider. 127 */ setUseOpenWifiAppPackagesProvider(PackagesProvider provider)128 public abstract void setUseOpenWifiAppPackagesProvider(PackagesProvider provider); 129 130 /** 131 * Sets the sync adapter packages provider. 132 * @param provider The provider. 133 */ setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider)134 public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider); 135 136 /** 137 * Requests granting of the default permissions to the current default SMS app. 138 * @param packageName The default SMS package name. 139 * @param userId The user for which to grant the permissions. 140 */ grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId)141 public abstract void grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId); 142 143 /** 144 * Requests granting of the default permissions to the current default dialer app. 145 * @param packageName The default dialer package name. 146 * @param userId The user for which to grant the permissions. 147 */ grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId)148 public abstract void grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId); 149 150 /** 151 * Requests granting of the default permissions to the current default sim call manager. 152 * @param packageName The default sim call manager package name. 153 * @param userId The user for which to grant the permissions. 154 */ grantDefaultPermissionsToDefaultSimCallManager(String packageName, int userId)155 public abstract void grantDefaultPermissionsToDefaultSimCallManager(String packageName, 156 int userId); 157 158 /** 159 * Requests granting of the default permissions to the current default Use Open Wifi app. 160 * @param packageName The default use open wifi package name. 161 * @param userId The user for which to grant the permissions. 162 */ grantDefaultPermissionsToDefaultUseOpenWifiApp(String packageName, int userId)163 public abstract void grantDefaultPermissionsToDefaultUseOpenWifiApp(String packageName, 164 int userId); 165 166 /** 167 * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has 168 * currently installed it. The apps are not preloaded. 169 * @param packageList List of package names to keep cached. 170 */ setKeepUninstalledPackages(List<String> packageList)171 public abstract void setKeepUninstalledPackages(List<String> packageList); 172 173 /** 174 * Gets whether some of the permissions used by this package require a user 175 * review before any of the app components can run. 176 * @param packageName The package name for which to check. 177 * @param userId The user under which to check. 178 * @return True a permissions review is required. 179 */ isPermissionsReviewRequired(String packageName, int userId)180 public abstract boolean isPermissionsReviewRequired(String packageName, int userId); 181 182 /** 183 * Retrieve all of the information we know about a particular package/application. 184 * @param filterCallingUid The results will be filtered in the context of this UID instead 185 * of the calling UID. 186 * @see PackageManager#getPackageInfo(String, int) 187 */ getPackageInfo(String packageName, @PackageInfoFlags int flags, int filterCallingUid, int userId)188 public abstract PackageInfo getPackageInfo(String packageName, 189 @PackageInfoFlags int flags, int filterCallingUid, int userId); 190 191 /** 192 * Retrieve launcher extras for a suspended package provided to the system in 193 * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 194 * PersistableBundle, String)}. 195 * 196 * @param packageName The package for which to return launcher extras. 197 * @param userId The user for which to check. 198 * @return The launcher extras. 199 * 200 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 201 * PersistableBundle, String) 202 * @see PackageManager#isPackageSuspended() 203 */ getSuspendedPackageLauncherExtras(String packageName, int userId)204 public abstract Bundle getSuspendedPackageLauncherExtras(String packageName, 205 int userId); 206 207 /** 208 * Internal api to query the suspended state of a package. 209 * @param packageName The package to check. 210 * @param userId The user id to check for. 211 * @return {@code true} if the package is suspended, {@code false} otherwise. 212 * @see PackageManager#isPackageSuspended(String) 213 */ isPackageSuspended(String packageName, int userId)214 public abstract boolean isPackageSuspended(String packageName, int userId); 215 216 /** 217 * Get the name of the package that suspended the given package. Packages can be suspended by 218 * device administrators or apps holding {@link android.Manifest.permission#MANAGE_USERS} or 219 * {@link android.Manifest.permission#SUSPEND_APPS}. 220 * 221 * @param suspendedPackage The package that has been suspended. 222 * @param userId The user for which to check. 223 * @return Name of the package that suspended the given package. Returns {@code null} if the 224 * given package is not currently suspended and the platform package name - i.e. 225 * {@code "android"} - if the package was suspended by a device admin. 226 */ getSuspendingPackage(String suspendedPackage, int userId)227 public abstract String getSuspendingPackage(String suspendedPackage, int userId); 228 229 /** 230 * Get the dialog message to be shown to the user when they try to launch a suspended 231 * application. 232 * 233 * @param suspendedPackage The package that has been suspended. 234 * @param userId The user for which to check. 235 * @return The dialog message to be shown to the user. 236 */ getSuspendedDialogMessage(String suspendedPackage, int userId)237 public abstract String getSuspendedDialogMessage(String suspendedPackage, int userId); 238 239 /** 240 * Do a straight uid lookup for the given package/application in the given user. 241 * @see PackageManager#getPackageUidAsUser(String, int, int) 242 * @return The app's uid, or < 0 if the package was not found in that user 243 */ getPackageUid(String packageName, @PackageInfoFlags int flags, int userId)244 public abstract int getPackageUid(String packageName, 245 @PackageInfoFlags int flags, int userId); 246 247 /** 248 * Retrieve all of the information we know about a particular package/application. 249 * @param filterCallingUid The results will be filtered in the context of this UID instead 250 * of the calling UID. 251 * @see PackageManager#getApplicationInfo(String, int) 252 */ getApplicationInfo(String packageName, @ApplicationInfoFlags int flags, int filterCallingUid, int userId)253 public abstract ApplicationInfo getApplicationInfo(String packageName, 254 @ApplicationInfoFlags int flags, int filterCallingUid, int userId); 255 256 /** 257 * Retrieve all of the information we know about a particular activity class. 258 * @param filterCallingUid The results will be filtered in the context of this UID instead 259 * of the calling UID. 260 * @see PackageManager#getActivityInfo(ComponentName, int) 261 */ getActivityInfo(ComponentName component, @ComponentInfoFlags int flags, int filterCallingUid, int userId)262 public abstract ActivityInfo getActivityInfo(ComponentName component, 263 @ComponentInfoFlags int flags, int filterCallingUid, int userId); 264 265 /** 266 * Retrieve all activities that can be performed for the given intent. 267 * @param filterCallingUid The results will be filtered in the context of this UID instead 268 * of the calling UID. 269 * @see PackageManager#queryIntentActivities(Intent, int) 270 */ queryIntentActivities(Intent intent, @ResolveInfoFlags int flags, int filterCallingUid, int userId)271 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 272 @ResolveInfoFlags int flags, int filterCallingUid, int userId); 273 274 /** 275 * Retrieve all services that can be performed for the given intent. 276 * @see PackageManager#queryIntentServices(Intent, int) 277 */ queryIntentServices( Intent intent, int flags, int callingUid, int userId)278 public abstract List<ResolveInfo> queryIntentServices( 279 Intent intent, int flags, int callingUid, int userId); 280 281 /** 282 * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}. 283 */ getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates, int userId)284 public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates, 285 int userId); 286 287 /** 288 * @return The default home activity component name. 289 */ getDefaultHomeActivity(int userId)290 public abstract ComponentName getDefaultHomeActivity(int userId); 291 292 /** 293 * Called by DeviceOwnerManagerService to set the package names of device owner and profile 294 * owners. 295 */ setDeviceAndProfileOwnerPackages( int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners)296 public abstract void setDeviceAndProfileOwnerPackages( 297 int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners); 298 299 /** 300 * Returns {@code true} if a given package can't be wiped. Otherwise, returns {@code false}. 301 */ isPackageDataProtected(int userId, String packageName)302 public abstract boolean isPackageDataProtected(int userId, String packageName); 303 304 /** 305 * Returns {@code true} if a given package's state is protected, e.g. it cannot be force 306 * stopped, suspended, disabled or hidden. Otherwise, returns {@code false}. 307 */ isPackageStateProtected(String packageName, int userId)308 public abstract boolean isPackageStateProtected(String packageName, int userId); 309 310 /** 311 * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns 312 * {@code false}. 313 */ isPackageEphemeral(int userId, String packageName)314 public abstract boolean isPackageEphemeral(int userId, String packageName); 315 316 /** 317 * Gets whether the package was ever launched. 318 * @param packageName The package name. 319 * @param userId The user for which to check. 320 * @return Whether was launched. 321 * @throws IllegalArgumentException if the package is not found 322 */ wasPackageEverLaunched(String packageName, int userId)323 public abstract boolean wasPackageEverLaunched(String packageName, int userId); 324 325 /** 326 * Grants a runtime permission 327 * @param packageName The package name. 328 * @param name The name of the permission. 329 * @param userId The userId for which to grant the permission. 330 * @param overridePolicy If true, grant this permission even if it is fixed by policy. 331 */ grantRuntimePermission(String packageName, String name, int userId, boolean overridePolicy)332 public abstract void grantRuntimePermission(String packageName, String name, int userId, 333 boolean overridePolicy); 334 335 /** 336 * Revokes a runtime permission 337 * @param packageName The package name. 338 * @param name The name of the permission. 339 * @param userId The userId for which to revoke the permission. 340 * @param overridePolicy If true, revoke this permission even if it is fixed by policy. 341 */ revokeRuntimePermission(String packageName, String name, int userId, boolean overridePolicy)342 public abstract void revokeRuntimePermission(String packageName, String name, int userId, 343 boolean overridePolicy); 344 345 /** 346 * Retrieve the official name associated with a uid. This name is 347 * guaranteed to never change, though it is possible for the underlying 348 * uid to be changed. That is, if you are storing information about 349 * uids in persistent storage, you should use the string returned 350 * by this function instead of the raw uid. 351 * 352 * @param uid The uid for which you would like to retrieve a name. 353 * @return Returns a unique name for the given uid, or null if the 354 * uid is not currently assigned. 355 */ getNameForUid(int uid)356 public abstract String getNameForUid(int uid); 357 358 /** 359 * Request to perform the second phase of ephemeral resolution. 360 * @param responseObj The response of the first phase of ephemeral resolution 361 * @param origIntent The original intent that triggered ephemeral resolution 362 * @param resolvedType The resolved type of the intent 363 * @param callingPackage The name of the package requesting the ephemeral application 364 * @param verificationBundle Optional bundle to pass to the installer for additional 365 * verification 366 * @param userId The ID of the user that triggered ephemeral resolution 367 */ requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj, Intent origIntent, String resolvedType, String callingPackage, Bundle verificationBundle, int userId)368 public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj, 369 Intent origIntent, String resolvedType, String callingPackage, 370 Bundle verificationBundle, int userId); 371 372 /** 373 * Grants access to the package metadata for an ephemeral application. 374 * <p> 375 * When an ephemeral application explicitly tries to interact with a full 376 * install application [via an activity, service or provider that has been 377 * exposed using the {@code visibleToInstantApp} attribute], the normal 378 * application must be able to see metadata about the connecting ephemeral 379 * app. If the ephemeral application uses an implicit intent [ie action VIEW, 380 * category BROWSABLE], it remains hidden from the launched activity. 381 * <p> 382 * If the {@code sourceUid} is not for an ephemeral app or {@code targetUid} 383 * is not for a fully installed app, this method will be a no-op. 384 * 385 * @param userId the user 386 * @param intent the intent that triggered the grant 387 * @param targetAppId The app ID of the fully installed application 388 * @param ephemeralAppId The app ID of the ephemeral application 389 */ grantEphemeralAccess(int userId, Intent intent, int targetAppId, int ephemeralAppId)390 public abstract void grantEphemeralAccess(int userId, Intent intent, 391 int targetAppId, int ephemeralAppId); 392 isInstantAppInstallerComponent(ComponentName component)393 public abstract boolean isInstantAppInstallerComponent(ComponentName component); 394 /** 395 * Prunes instant apps and state associated with uninstalled 396 * instant apps according to the current platform policy. 397 */ pruneInstantApps()398 public abstract void pruneInstantApps(); 399 400 /** 401 * @return The SetupWizard package name. 402 */ getSetupWizardPackageName()403 public abstract String getSetupWizardPackageName(); 404 405 public interface ExternalSourcesPolicy { 406 407 int USER_TRUSTED = 0; // User has trusted the package to install apps 408 int USER_BLOCKED = 1; // User has blocked the package to install apps 409 int USER_DEFAULT = 2; // Default code to use when user response is unavailable 410 411 /** 412 * Checks the user preference for whether a package is trusted to request installs through 413 * package installer 414 * 415 * @param packageName The package to check for 416 * @param uid the uid in which the package is running 417 * @return {@link USER_TRUSTED} if the user has trusted the package, {@link USER_BLOCKED} 418 * if user has blocked requests from the package, {@link USER_DEFAULT} if the user response 419 * is not yet available 420 */ getPackageTrustedToInstallApps(String packageName, int uid)421 int getPackageTrustedToInstallApps(String packageName, int uid); 422 } 423 setExternalSourcesPolicy(ExternalSourcesPolicy policy)424 public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy); 425 426 /** 427 * Return true if the given package is a persistent app process. 428 */ isPackagePersistent(String packageName)429 public abstract boolean isPackagePersistent(String packageName); 430 431 /** 432 * Returns whether or not the given package represents a legacy system application released 433 * prior to runtime permissions. 434 */ isLegacySystemApp(PackageParser.Package pkg)435 public abstract boolean isLegacySystemApp(PackageParser.Package pkg); 436 437 /** 438 * Get all overlay packages for a user. 439 * @param userId The user for which to get the overlays. 440 * @return A list of overlay packages. An empty list is returned if the 441 * user has no installed overlay packages. 442 */ getOverlayPackages(int userId)443 public abstract List<PackageInfo> getOverlayPackages(int userId); 444 445 /** 446 * Get the names of all target packages for a user. 447 * @param userId The user for which to get the package names. 448 * @return A list of target package names. This list includes the "android" package. 449 */ getTargetPackageNames(int userId)450 public abstract List<String> getTargetPackageNames(int userId); 451 452 /** 453 * Set which overlay to use for a package. 454 * @param userId The user for which to update the overlays. 455 * @param targetPackageName The package name of the package for which to update the overlays. 456 * @param overlayPackageNames The complete list of overlay packages that should be enabled for 457 * the target. Previously enabled overlays not specified in the list 458 * will be disabled. Pass in null or an empty list to disable 459 * all overlays. The order of the items is significant if several 460 * overlays modify the same resource. 461 * @return true if all packages names were known by the package manager, false otherwise 462 */ setEnabledOverlayPackages(int userId, String targetPackageName, List<String> overlayPackageNames)463 public abstract boolean setEnabledOverlayPackages(int userId, String targetPackageName, 464 List<String> overlayPackageNames); 465 466 /** 467 * Resolves an activity intent, allowing instant apps to be resolved. 468 */ resolveIntent(Intent intent, String resolvedType, int flags, int userId, boolean resolveForStart, int filterCallingUid)469 public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType, 470 int flags, int userId, boolean resolveForStart, int filterCallingUid); 471 472 /** 473 * Resolves a service intent, allowing instant apps to be resolved. 474 */ resolveService(Intent intent, String resolvedType, int flags, int userId, int callingUid)475 public abstract ResolveInfo resolveService(Intent intent, String resolvedType, 476 int flags, int userId, int callingUid); 477 478 /** 479 * Resolves a content provider intent. 480 */ resolveContentProvider(String name, int flags, int userId)481 public abstract ProviderInfo resolveContentProvider(String name, int flags, int userId); 482 483 /** 484 * Track the creator of a new isolated uid. 485 * @param isolatedUid The newly created isolated uid. 486 * @param ownerUid The uid of the app that created the isolated process. 487 */ addIsolatedUid(int isolatedUid, int ownerUid)488 public abstract void addIsolatedUid(int isolatedUid, int ownerUid); 489 490 /** 491 * Track removal of an isolated uid. 492 * @param isolatedUid isolated uid that is no longer being used. 493 */ removeIsolatedUid(int isolatedUid)494 public abstract void removeIsolatedUid(int isolatedUid); 495 496 /** 497 * Return the taget SDK version for the app with the given UID. 498 */ getUidTargetSdkVersion(int uid)499 public abstract int getUidTargetSdkVersion(int uid); 500 501 /** 502 * Return the taget SDK version for the app with the given package name. 503 */ getPackageTargetSdkVersion(String packageName)504 public abstract int getPackageTargetSdkVersion(String packageName); 505 506 /** Whether the binder caller can access instant apps. */ canAccessInstantApps(int callingUid, int userId)507 public abstract boolean canAccessInstantApps(int callingUid, int userId); 508 509 /** Whether the binder caller can access the given component. */ canAccessComponent(int callingUid, ComponentName component, int userId)510 public abstract boolean canAccessComponent(int callingUid, ComponentName component, int userId); 511 512 /** 513 * Returns {@code true} if a given package has instant application meta-data. 514 * Otherwise, returns {@code false}. Meta-data is state (eg. cookie, app icon, etc) 515 * associated with an instant app. It may be kept after the instant app has been uninstalled. 516 */ hasInstantApplicationMetadata(String packageName, int userId)517 public abstract boolean hasInstantApplicationMetadata(String packageName, int userId); 518 519 /** 520 * Updates a package last used time. 521 */ notifyPackageUse(String packageName, int reason)522 public abstract void notifyPackageUse(String packageName, int reason); 523 524 /** 525 * Returns a package object for the given package name. 526 */ getPackage(@onNull String packageName)527 public abstract @Nullable PackageParser.Package getPackage(@NonNull String packageName); 528 529 /** 530 * Returns a list without a change observer. 531 * 532 * {@see #getPackageList(PackageListObserver)} 533 */ getPackageList()534 public @NonNull PackageList getPackageList() { 535 return getPackageList(null); 536 } 537 538 /** 539 * Returns the list of packages installed at the time of the method call. 540 * <p>The given observer is notified when the list of installed packages 541 * changes [eg. a package was installed or uninstalled]. It will not be 542 * notified if a package is updated. 543 * <p>The package list will not be updated automatically as packages are 544 * installed / uninstalled. Any changes must be handled within the observer. 545 */ getPackageList(@ullable PackageListObserver observer)546 public abstract @NonNull PackageList getPackageList(@Nullable PackageListObserver observer); 547 548 /** 549 * Removes the observer. 550 * <p>Generally not needed. {@link #getPackageList(PackageListObserver)} will automatically 551 * remove the observer. 552 * <p>Does nothing if the observer isn't currently registered. 553 * <p>Observers are notified asynchronously and it's possible for an observer to be 554 * invoked after its been removed. 555 */ removePackageListObserver(@onNull PackageListObserver observer)556 public abstract void removePackageListObserver(@NonNull PackageListObserver observer); 557 558 /** 559 * Returns a package object for the disabled system package name. 560 */ getDisabledPackage(@onNull String packageName)561 public abstract @Nullable PackageParser.Package getDisabledPackage(@NonNull String packageName); 562 563 /** 564 * Returns whether or not the component is the resolver activity. 565 */ isResolveActivityComponent(@onNull ComponentInfo component)566 public abstract boolean isResolveActivityComponent(@NonNull ComponentInfo component); 567 568 /** 569 * Returns the package name for a known package. 570 */ getKnownPackageName( @nownPackage int knownPackage, int userId)571 public abstract @Nullable String getKnownPackageName( 572 @KnownPackage int knownPackage, int userId); 573 574 /** 575 * Returns whether the package is an instant app. 576 */ isInstantApp(String packageName, int userId)577 public abstract boolean isInstantApp(String packageName, int userId); 578 579 /** 580 * Returns whether the package is an instant app. 581 */ getInstantAppPackageName(int uid)582 public abstract @Nullable String getInstantAppPackageName(int uid); 583 584 /** 585 * Returns whether or not access to the application should be filtered. 586 * <p> 587 * Access may be limited based upon whether the calling or target applications 588 * are instant applications. 589 * 590 * @see #canAccessInstantApps(int) 591 */ filterAppAccess( @ullable PackageParser.Package pkg, int callingUid, int userId)592 public abstract boolean filterAppAccess( 593 @Nullable PackageParser.Package pkg, int callingUid, int userId); 594 595 /* 596 * NOTE: The following methods are temporary until permissions are extracted from 597 * the package manager into a component specifically for handling permissions. 598 */ 599 /** Returns the flags for the given permission. */ getPermissionFlagsTEMP(@onNull String permName, @NonNull String packageName, int userId)600 public abstract @Nullable int getPermissionFlagsTEMP(@NonNull String permName, 601 @NonNull String packageName, int userId); 602 /** Updates the flags for the given permission. */ updatePermissionFlagsTEMP(@onNull String permName, @NonNull String packageName, int flagMask, int flagValues, int userId)603 public abstract void updatePermissionFlagsTEMP(@NonNull String permName, 604 @NonNull String packageName, int flagMask, int flagValues, int userId); 605 606 /** 607 * Returns true if it's still safe to restore data backed up from this app's version 608 * that was signed with restoringFromSigHash. 609 */ isDataRestoreSafe(@onNull byte[] restoringFromSigHash, @NonNull String packageName)610 public abstract boolean isDataRestoreSafe(@NonNull byte[] restoringFromSigHash, 611 @NonNull String packageName); 612 613 /** 614 * Returns true if it's still safe to restore data backed up from this app's version 615 * that was signed with restoringFromSig. 616 */ isDataRestoreSafe(@onNull Signature restoringFromSig, @NonNull String packageName)617 public abstract boolean isDataRestoreSafe(@NonNull Signature restoringFromSig, 618 @NonNull String packageName); 619 620 621 /** 622 * Returns true if the the signing information for {@code clientUid} is sufficient to gain 623 * access gated by {@code capability}. This can happen if the two UIDs have the same signing 624 * information, if the signing information {@code clientUid} indicates that it has the signing 625 * certificate for {@code serverUid} in its signing history (if it was previously signed by it), 626 * or if the signing certificate for {@code clientUid} is in ths signing history for {@code 627 * serverUid} and with the {@code capability} specified. 628 */ hasSignatureCapability(int serverUid, int clientUid, @PackageParser.SigningDetails.CertCapabilities int capability)629 public abstract boolean hasSignatureCapability(int serverUid, int clientUid, 630 @PackageParser.SigningDetails.CertCapabilities int capability); 631 } 632