PackageManager.java revision e06b4d1d9f718b9fe02980fea794a36831a16db2
1/* 2 * Copyright (C) 2006 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 19import android.Manifest; 20import android.annotation.CheckResult; 21import android.annotation.DrawableRes; 22import android.annotation.IntDef; 23import android.annotation.NonNull; 24import android.annotation.Nullable; 25import android.annotation.RequiresPermission; 26import android.annotation.SdkConstant; 27import android.annotation.SdkConstant.SdkConstantType; 28import android.annotation.StringRes; 29import android.annotation.SystemApi; 30import android.annotation.XmlRes; 31import android.app.PackageDeleteObserver; 32import android.app.PackageInstallObserver; 33import android.app.admin.DevicePolicyManager; 34import android.content.ComponentName; 35import android.content.Context; 36import android.content.Intent; 37import android.content.IntentFilter; 38import android.content.IntentSender; 39import android.content.pm.PackageParser.PackageParserException; 40import android.content.res.Resources; 41import android.content.res.XmlResourceParser; 42import android.graphics.Rect; 43import android.graphics.drawable.Drawable; 44import android.net.Uri; 45import android.os.Bundle; 46import android.os.Handler; 47import android.os.RemoteException; 48import android.os.UserHandle; 49import android.os.storage.VolumeInfo; 50import android.util.AndroidException; 51 52import com.android.internal.util.ArrayUtils; 53 54import java.io.File; 55import java.lang.annotation.Retention; 56import java.lang.annotation.RetentionPolicy; 57import java.util.List; 58 59/** 60 * Class for retrieving various kinds of information related to the application 61 * packages that are currently installed on the device. 62 * 63 * You can find this class through {@link Context#getPackageManager}. 64 */ 65public abstract class PackageManager { 66 67 /** 68 * This exception is thrown when a given package, application, or component 69 * name cannot be found. 70 */ 71 public static class NameNotFoundException extends AndroidException { 72 public NameNotFoundException() { 73 } 74 75 public NameNotFoundException(String name) { 76 super(name); 77 } 78 } 79 80 /** 81 * Listener for changes in permissions granted to a UID. 82 * 83 * @hide 84 */ 85 @SystemApi 86 public interface OnPermissionsChangedListener { 87 88 /** 89 * Called when the permissions for a UID change. 90 * @param uid The UID with a change. 91 */ 92 public void onPermissionsChanged(int uid); 93 } 94 95 /** 96 * As a guiding principle: 97 * <p> 98 * {@code GET_} flags are used to request additional data that may have been 99 * elided to save wire space. 100 * <p> 101 * {@code MATCH_} flags are used to include components or packages that 102 * would have otherwise been omitted from a result set by current system 103 * state. 104 */ 105 106 /** @hide */ 107 @IntDef(flag = true, value = { 108 GET_ACTIVITIES, 109 GET_RECEIVERS, 110 GET_SERVICES, 111 GET_PROVIDERS, 112 GET_INSTRUMENTATION, 113 GET_INTENT_FILTERS, 114 GET_SIGNATURES, 115 GET_META_DATA, 116 GET_GIDS, 117 GET_SHARED_LIBRARY_FILES, 118 GET_URI_PERMISSION_PATTERNS, 119 GET_PERMISSIONS, 120 GET_CONFIGURATIONS, 121 MATCH_UNINSTALLED_PACKAGES, 122 MATCH_DISABLED_COMPONENTS, 123 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 124 MATCH_DEBUG_TRIAGED_MISSING, 125 }) 126 @Retention(RetentionPolicy.SOURCE) 127 public @interface PackageInfoFlags {} 128 129 /** @hide */ 130 @IntDef(flag = true, value = { 131 GET_META_DATA, 132 GET_SHARED_LIBRARY_FILES, 133 MATCH_UNINSTALLED_PACKAGES, 134 MATCH_SYSTEM_ONLY, 135 MATCH_DEBUG_TRIAGED_MISSING, 136 }) 137 @Retention(RetentionPolicy.SOURCE) 138 public @interface ApplicationInfoFlags {} 139 140 /** @hide */ 141 @IntDef(flag = true, value = { 142 GET_META_DATA, 143 GET_SHARED_LIBRARY_FILES, 144 MATCH_UNINSTALLED_PACKAGES, 145 MATCH_DISABLED_COMPONENTS, 146 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 147 MATCH_ALL, 148 MATCH_DEFAULT_ONLY, 149 MATCH_ENCRYPTION_AWARE, 150 MATCH_ENCRYPTION_AWARE_AND_UNAWARE, 151 MATCH_ENCRYPTION_UNAWARE, 152 MATCH_SYSTEM_ONLY, 153 MATCH_DEBUG_TRIAGED_MISSING, 154 }) 155 @Retention(RetentionPolicy.SOURCE) 156 public @interface ComponentInfoFlags {} 157 158 /** @hide */ 159 @IntDef(flag = true, value = { 160 GET_META_DATA, 161 GET_SHARED_LIBRARY_FILES, 162 GET_RESOLVED_FILTER, 163 MATCH_UNINSTALLED_PACKAGES, 164 MATCH_DISABLED_COMPONENTS, 165 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 166 MATCH_ALL, 167 MATCH_DEFAULT_ONLY, 168 MATCH_ENCRYPTION_AWARE, 169 MATCH_ENCRYPTION_AWARE_AND_UNAWARE, 170 MATCH_ENCRYPTION_UNAWARE, 171 MATCH_SYSTEM_ONLY, 172 MATCH_DEBUG_TRIAGED_MISSING, 173 }) 174 @Retention(RetentionPolicy.SOURCE) 175 public @interface ResolveInfoFlags {} 176 177 /** @hide */ 178 @IntDef(flag = true, value = { 179 GET_META_DATA, 180 }) 181 @Retention(RetentionPolicy.SOURCE) 182 public @interface PermissionInfoFlags {} 183 184 /** @hide */ 185 @IntDef(flag = true, value = { 186 GET_META_DATA, 187 }) 188 @Retention(RetentionPolicy.SOURCE) 189 public @interface PermissionGroupInfoFlags {} 190 191 /** @hide */ 192 @IntDef(flag = true, value = { 193 GET_META_DATA, 194 }) 195 @Retention(RetentionPolicy.SOURCE) 196 public @interface InstrumentationInfoFlags {} 197 198 /** 199 * {@link PackageInfo} flag: return information about 200 * activities in the package in {@link PackageInfo#activities}. 201 */ 202 public static final int GET_ACTIVITIES = 0x00000001; 203 204 /** 205 * {@link PackageInfo} flag: return information about 206 * intent receivers in the package in 207 * {@link PackageInfo#receivers}. 208 */ 209 public static final int GET_RECEIVERS = 0x00000002; 210 211 /** 212 * {@link PackageInfo} flag: return information about 213 * services in the package in {@link PackageInfo#services}. 214 */ 215 public static final int GET_SERVICES = 0x00000004; 216 217 /** 218 * {@link PackageInfo} flag: return information about 219 * content providers in the package in 220 * {@link PackageInfo#providers}. 221 */ 222 public static final int GET_PROVIDERS = 0x00000008; 223 224 /** 225 * {@link PackageInfo} flag: return information about 226 * instrumentation in the package in 227 * {@link PackageInfo#instrumentation}. 228 */ 229 public static final int GET_INSTRUMENTATION = 0x00000010; 230 231 /** 232 * {@link PackageInfo} flag: return information about the 233 * intent filters supported by the activity. 234 */ 235 public static final int GET_INTENT_FILTERS = 0x00000020; 236 237 /** 238 * {@link PackageInfo} flag: return information about the 239 * signatures included in the package. 240 */ 241 public static final int GET_SIGNATURES = 0x00000040; 242 243 /** 244 * {@link ResolveInfo} flag: return the IntentFilter that 245 * was matched for a particular ResolveInfo in 246 * {@link ResolveInfo#filter}. 247 */ 248 public static final int GET_RESOLVED_FILTER = 0x00000040; 249 250 /** 251 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData} 252 * data {@link android.os.Bundle}s that are associated with a component. 253 * This applies for any API returning a ComponentInfo subclass. 254 */ 255 public static final int GET_META_DATA = 0x00000080; 256 257 /** 258 * {@link PackageInfo} flag: return the 259 * {@link PackageInfo#gids group ids} that are associated with an 260 * application. 261 * This applies for any API returning a PackageInfo class, either 262 * directly or nested inside of another. 263 */ 264 public static final int GET_GIDS = 0x00000100; 265 266 /** 267 * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS} 268 */ 269 @Deprecated 270 public static final int GET_DISABLED_COMPONENTS = 0x00000200; 271 272 /** 273 * {@link PackageInfo} flag: include disabled components in the returned info. 274 */ 275 public static final int MATCH_DISABLED_COMPONENTS = 0x00000200; 276 277 /** 278 * {@link ApplicationInfo} flag: return the 279 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries} 280 * that are associated with an application. 281 * This applies for any API returning an ApplicationInfo class, either 282 * directly or nested inside of another. 283 */ 284 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400; 285 286 /** 287 * {@link ProviderInfo} flag: return the 288 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns} 289 * that are associated with a content provider. 290 * This applies for any API returning a ProviderInfo class, either 291 * directly or nested inside of another. 292 */ 293 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800; 294 /** 295 * {@link PackageInfo} flag: return information about 296 * permissions in the package in 297 * {@link PackageInfo#permissions}. 298 */ 299 public static final int GET_PERMISSIONS = 0x00001000; 300 301 /** 302 * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES} 303 */ 304 @Deprecated 305 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000; 306 307 /** 308 * Flag parameter to retrieve some information about all applications (even 309 * uninstalled ones) which have data directories. This state could have 310 * resulted if applications have been deleted with flag 311 * {@code DONT_DELETE_DATA} with a possibility of being replaced or 312 * reinstalled in future. 313 * <p> 314 * Note: this flag may cause less information about currently installed 315 * applications to be returned. 316 */ 317 public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000; 318 319 /** 320 * {@link PackageInfo} flag: return information about 321 * hardware preferences in 322 * {@link PackageInfo#configPreferences PackageInfo.configPreferences}, 323 * and requested features in {@link PackageInfo#reqFeatures} and 324 * {@link PackageInfo#featureGroups}. 325 */ 326 public static final int GET_CONFIGURATIONS = 0x00004000; 327 328 /** 329 * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}. 330 */ 331 @Deprecated 332 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000; 333 334 /** 335 * {@link PackageInfo} flag: include disabled components which are in 336 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED} 337 * in the returned info. Note that if you set this flag, applications 338 * that are in this disabled state will be reported as enabled. 339 */ 340 public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000; 341 342 /** 343 * Resolution and querying flag: if set, only filters that support the 344 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for 345 * matching. This is a synonym for including the CATEGORY_DEFAULT in your 346 * supplied Intent. 347 */ 348 public static final int MATCH_DEFAULT_ONLY = 0x00010000; 349 350 /** 351 * Querying flag: if set and if the platform is doing any filtering of the 352 * results, then the filtering will not happen. This is a synonym for saying 353 * that all results should be returned. 354 * <p> 355 * <em>This flag should be used with extreme care.</em> 356 */ 357 public static final int MATCH_ALL = 0x00020000; 358 359 /** 360 * Querying flag: include only components which are encryption unaware in 361 * the returned info, regardless of the current user state. 362 */ 363 public static final int MATCH_ENCRYPTION_UNAWARE = 0x00040000; 364 365 /** 366 * Querying flag: include only components which are encryption aware in the 367 * returned info, regardless of the current user state. 368 */ 369 public static final int MATCH_ENCRYPTION_AWARE = 0x00080000; 370 371 /** 372 * Querying flag: include both encryption aware and unaware components in 373 * the returned info, regardless of the current user state. 374 */ 375 public static final int MATCH_ENCRYPTION_AWARE_AND_UNAWARE = MATCH_ENCRYPTION_AWARE 376 | MATCH_ENCRYPTION_UNAWARE; 377 378 /** 379 * Querying flag: include only components from applications that are marked 380 * with {@link ApplicationInfo#FLAG_SYSTEM}. 381 */ 382 public static final int MATCH_SYSTEM_ONLY = 0x00100000; 383 384 /** 385 * Internal flag used to indicate that a system component has done their 386 * homework and verified that they correctly handle packages and components 387 * that come and go over time. In particular: 388 * <ul> 389 * <li>Apps installed on external storage, which will appear to be 390 * uninstalled while the the device is ejected. 391 * <li>Apps with encryption unaware components, which will appear to not 392 * exist while the device is locked. 393 * </ul> 394 * 395 * @see #MATCH_UNINSTALLED_PACKAGES 396 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 397 * @hide 398 */ 399 public static final int MATCH_DEBUG_TRIAGED_MISSING = 0x10000000; 400 401 /** 402 * Flag for {@link addCrossProfileIntentFilter}: if this flag is set: 403 * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current 404 * profile will be skipped. 405 * Only activities in the target user can respond to the intent. 406 * @hide 407 */ 408 public static final int SKIP_CURRENT_PROFILE = 0x00000002; 409 410 /** 411 * Flag for {@link addCrossProfileIntentFilter}: if this flag is set: 412 * activities in the other profiles can respond to the intent only if no activity with 413 * non-negative priority in current profile can respond to the intent. 414 * @hide 415 */ 416 public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004; 417 418 /** @hide */ 419 @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED}) 420 @Retention(RetentionPolicy.SOURCE) 421 public @interface PermissionResult {} 422 423 /** 424 * Permission check result: this is returned by {@link #checkPermission} 425 * if the permission has been granted to the given package. 426 */ 427 public static final int PERMISSION_GRANTED = 0; 428 429 /** 430 * Permission check result: this is returned by {@link #checkPermission} 431 * if the permission has not been granted to the given package. 432 */ 433 public static final int PERMISSION_DENIED = -1; 434 435 /** 436 * Signature check result: this is returned by {@link #checkSignatures} 437 * if all signatures on the two packages match. 438 */ 439 public static final int SIGNATURE_MATCH = 0; 440 441 /** 442 * Signature check result: this is returned by {@link #checkSignatures} 443 * if neither of the two packages is signed. 444 */ 445 public static final int SIGNATURE_NEITHER_SIGNED = 1; 446 447 /** 448 * Signature check result: this is returned by {@link #checkSignatures} 449 * if the first package is not signed but the second is. 450 */ 451 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1; 452 453 /** 454 * Signature check result: this is returned by {@link #checkSignatures} 455 * if the second package is not signed but the first is. 456 */ 457 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2; 458 459 /** 460 * Signature check result: this is returned by {@link #checkSignatures} 461 * if not all signatures on both packages match. 462 */ 463 public static final int SIGNATURE_NO_MATCH = -3; 464 465 /** 466 * Signature check result: this is returned by {@link #checkSignatures} 467 * if either of the packages are not valid. 468 */ 469 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4; 470 471 /** 472 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 473 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 474 * component or application is in its default enabled state (as specified 475 * in its manifest). 476 */ 477 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; 478 479 /** 480 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 481 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 482 * component or application has been explictily enabled, regardless of 483 * what it has specified in its manifest. 484 */ 485 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1; 486 487 /** 488 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 489 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 490 * component or application has been explicitly disabled, regardless of 491 * what it has specified in its manifest. 492 */ 493 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; 494 495 /** 496 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The 497 * user has explicitly disabled the application, regardless of what it has 498 * specified in its manifest. Because this is due to the user's request, 499 * they may re-enable it if desired through the appropriate system UI. This 500 * option currently <strong>cannot</strong> be used with 501 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 502 */ 503 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3; 504 505 /** 506 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This 507 * application should be considered, until the point where the user actually 508 * wants to use it. This means that it will not normally show up to the user 509 * (such as in the launcher), but various parts of the user interface can 510 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow 511 * the user to select it (as for example an IME, device admin, etc). Such code, 512 * once the user has selected the app, should at that point also make it enabled. 513 * This option currently <strong>can not</strong> be used with 514 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 515 */ 516 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4; 517 518 /** 519 * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to 520 * indicate that this package should be installed as forward locked, i.e. only the app itself 521 * should have access to its code and non-resource assets. 522 * @hide 523 */ 524 public static final int INSTALL_FORWARD_LOCK = 0x00000001; 525 526 /** 527 * Flag parameter for {@link #installPackage} to indicate that you want to replace an already 528 * installed package, if one exists. 529 * @hide 530 */ 531 public static final int INSTALL_REPLACE_EXISTING = 0x00000002; 532 533 /** 534 * Flag parameter for {@link #installPackage} to indicate that you want to 535 * allow test packages (those that have set android:testOnly in their 536 * manifest) to be installed. 537 * @hide 538 */ 539 public static final int INSTALL_ALLOW_TEST = 0x00000004; 540 541 /** 542 * Flag parameter for {@link #installPackage} to indicate that this package 543 * must be installed to an ASEC on a {@link VolumeInfo#TYPE_PUBLIC}. 544 * 545 * @hide 546 */ 547 public static final int INSTALL_EXTERNAL = 0x00000008; 548 549 /** 550 * Flag parameter for {@link #installPackage} to indicate that this package 551 * must be installed to internal storage. 552 * 553 * @hide 554 */ 555 public static final int INSTALL_INTERNAL = 0x00000010; 556 557 /** 558 * Flag parameter for {@link #installPackage} to indicate that this install 559 * was initiated via ADB. 560 * 561 * @hide 562 */ 563 public static final int INSTALL_FROM_ADB = 0x00000020; 564 565 /** 566 * Flag parameter for {@link #installPackage} to indicate that this install 567 * should immediately be visible to all users. 568 * 569 * @hide 570 */ 571 public static final int INSTALL_ALL_USERS = 0x00000040; 572 573 /** 574 * Flag parameter for {@link #installPackage} to indicate that it is okay 575 * to install an update to an app where the newly installed app has a lower 576 * version code than the currently installed app. 577 * 578 * @hide 579 */ 580 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080; 581 582 /** 583 * Flag parameter for {@link #installPackage} to indicate that all runtime 584 * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS} 585 * is set the runtime permissions will be granted to all users, otherwise 586 * only to the owner. 587 * 588 * @hide 589 */ 590 public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100; 591 592 /** {@hide} */ 593 public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200; 594 595 /** 596 * Flag parameter for {@link #installPackage} to indicate that we always want to force 597 * the prompt for permission approval. This overrides any special behaviour for internal 598 * components. 599 * 600 * @hide 601 */ 602 public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400; 603 604 /** 605 * Flag parameter for {@link #installPackage} to indicate that this package is 606 * to be installed as a lightweight "ephemeral" app. 607 * 608 * @hide 609 */ 610 public static final int INSTALL_EPHEMERAL = 0x00000800; 611 612 /** 613 * Flag parameter for 614 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate 615 * that you don't want to kill the app containing the component. Be careful when you set this 616 * since changing component states can make the containing application's behavior unpredictable. 617 */ 618 public static final int DONT_KILL_APP = 0x00000001; 619 620 /** 621 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 622 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success. 623 * @hide 624 */ 625 @SystemApi 626 public static final int INSTALL_SUCCEEDED = 1; 627 628 /** 629 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 630 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is 631 * already installed. 632 * @hide 633 */ 634 @SystemApi 635 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1; 636 637 /** 638 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 639 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive 640 * file is invalid. 641 * @hide 642 */ 643 @SystemApi 644 public static final int INSTALL_FAILED_INVALID_APK = -2; 645 646 /** 647 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 648 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in 649 * is invalid. 650 * @hide 651 */ 652 @SystemApi 653 public static final int INSTALL_FAILED_INVALID_URI = -3; 654 655 /** 656 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 657 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager 658 * service found that the device didn't have enough storage space to install the app. 659 * @hide 660 */ 661 @SystemApi 662 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; 663 664 /** 665 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 666 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a 667 * package is already installed with the same name. 668 * @hide 669 */ 670 @SystemApi 671 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; 672 673 /** 674 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 675 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 676 * the requested shared user does not exist. 677 * @hide 678 */ 679 @SystemApi 680 public static final int INSTALL_FAILED_NO_SHARED_USER = -6; 681 682 /** 683 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 684 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 685 * a previously installed package of the same name has a different signature 686 * than the new package (and the old package's data was not removed). 687 * @hide 688 */ 689 @SystemApi 690 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; 691 692 /** 693 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 694 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 695 * the new package is requested a shared user which is already installed on the 696 * device and does not have matching signature. 697 * @hide 698 */ 699 @SystemApi 700 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; 701 702 /** 703 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 704 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 705 * the new package uses a shared library that is not available. 706 * @hide 707 */ 708 @SystemApi 709 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; 710 711 /** 712 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 713 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 714 * the new package uses a shared library that is not available. 715 * @hide 716 */ 717 @SystemApi 718 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; 719 720 /** 721 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 722 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 723 * the new package failed while optimizing and validating its dex files, 724 * either because there was not enough storage or the validation failed. 725 * @hide 726 */ 727 @SystemApi 728 public static final int INSTALL_FAILED_DEXOPT = -11; 729 730 /** 731 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 732 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 733 * the new package failed because the current SDK version is older than 734 * that required by the package. 735 * @hide 736 */ 737 @SystemApi 738 public static final int INSTALL_FAILED_OLDER_SDK = -12; 739 740 /** 741 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 742 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 743 * the new package failed because it contains a content provider with the 744 * same authority as a provider already installed in the system. 745 * @hide 746 */ 747 @SystemApi 748 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; 749 750 /** 751 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 752 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 753 * the new package failed because the current SDK version is newer than 754 * that required by the package. 755 * @hide 756 */ 757 @SystemApi 758 public static final int INSTALL_FAILED_NEWER_SDK = -14; 759 760 /** 761 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 762 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 763 * the new package failed because it has specified that it is a test-only 764 * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST} 765 * flag. 766 * @hide 767 */ 768 @SystemApi 769 public static final int INSTALL_FAILED_TEST_ONLY = -15; 770 771 /** 772 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 773 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 774 * the package being installed contains native code, but none that is 775 * compatible with the device's CPU_ABI. 776 * @hide 777 */ 778 @SystemApi 779 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; 780 781 /** 782 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 783 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 784 * the new package uses a feature that is not available. 785 * @hide 786 */ 787 @SystemApi 788 public static final int INSTALL_FAILED_MISSING_FEATURE = -17; 789 790 // ------ Errors related to sdcard 791 /** 792 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 793 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 794 * a secure container mount point couldn't be accessed on external media. 795 * @hide 796 */ 797 @SystemApi 798 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18; 799 800 /** 801 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 802 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 803 * the new package couldn't be installed in the specified install 804 * location. 805 * @hide 806 */ 807 @SystemApi 808 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; 809 810 /** 811 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 812 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 813 * the new package couldn't be installed in the specified install 814 * location because the media is not available. 815 * @hide 816 */ 817 @SystemApi 818 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; 819 820 /** 821 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 822 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 823 * the new package couldn't be installed because the verification timed out. 824 * @hide 825 */ 826 @SystemApi 827 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21; 828 829 /** 830 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 831 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 832 * the new package couldn't be installed because the verification did not succeed. 833 * @hide 834 */ 835 @SystemApi 836 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22; 837 838 /** 839 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 840 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 841 * the package changed from what the calling program expected. 842 * @hide 843 */ 844 @SystemApi 845 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; 846 847 /** 848 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 849 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 850 * the new package is assigned a different UID than it previously held. 851 * @hide 852 */ 853 public static final int INSTALL_FAILED_UID_CHANGED = -24; 854 855 /** 856 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 857 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 858 * the new package has an older version code than the currently installed package. 859 * @hide 860 */ 861 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25; 862 863 /** 864 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 865 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 866 * the old package has target SDK high enough to support runtime permission and 867 * the new package has target SDK low enough to not support runtime permissions. 868 * @hide 869 */ 870 @SystemApi 871 public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26; 872 873 /** 874 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 875 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 876 * if the parser was given a path that is not a file, or does not end with the expected 877 * '.apk' extension. 878 * @hide 879 */ 880 @SystemApi 881 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100; 882 883 /** 884 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 885 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 886 * if the parser was unable to retrieve the AndroidManifest.xml file. 887 * @hide 888 */ 889 @SystemApi 890 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; 891 892 /** 893 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 894 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 895 * if the parser encountered an unexpected exception. 896 * @hide 897 */ 898 @SystemApi 899 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; 900 901 /** 902 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 903 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 904 * if the parser did not find any certificates in the .apk. 905 * @hide 906 */ 907 @SystemApi 908 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; 909 910 /** 911 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 912 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 913 * if the parser found inconsistent certificates on the files in the .apk. 914 * @hide 915 */ 916 @SystemApi 917 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; 918 919 /** 920 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 921 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 922 * if the parser encountered a CertificateEncodingException in one of the 923 * files in the .apk. 924 * @hide 925 */ 926 @SystemApi 927 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; 928 929 /** 930 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 931 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 932 * if the parser encountered a bad or missing package name in the manifest. 933 * @hide 934 */ 935 @SystemApi 936 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; 937 938 /** 939 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 940 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 941 * if the parser encountered a bad shared user id name in the manifest. 942 * @hide 943 */ 944 @SystemApi 945 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; 946 947 /** 948 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 949 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 950 * if the parser encountered some structural problem in the manifest. 951 * @hide 952 */ 953 @SystemApi 954 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; 955 956 /** 957 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 958 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 959 * if the parser did not find any actionable tags (instrumentation or application) 960 * in the manifest. 961 * @hide 962 */ 963 @SystemApi 964 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; 965 966 /** 967 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 968 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 969 * if the system failed to install the package because of system issues. 970 * @hide 971 */ 972 @SystemApi 973 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110; 974 975 /** 976 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 977 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 978 * if the system failed to install the package because the user is restricted from installing 979 * apps. 980 * @hide 981 */ 982 public static final int INSTALL_FAILED_USER_RESTRICTED = -111; 983 984 /** 985 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 986 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 987 * if the system failed to install the package because it is attempting to define a 988 * permission that is already defined by some existing package. 989 * 990 * <p>The package name of the app which has already defined the permission is passed to 991 * a {@link PackageInstallObserver}, if any, as the {@link #EXTRA_EXISTING_PACKAGE} 992 * string extra; and the name of the permission being redefined is passed in the 993 * {@link #EXTRA_EXISTING_PERMISSION} string extra. 994 * @hide 995 */ 996 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112; 997 998 /** 999 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 1000 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 1001 * if the system failed to install the package because its packaged native code did not 1002 * match any of the ABIs supported by the system. 1003 * 1004 * @hide 1005 */ 1006 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113; 1007 1008 /** 1009 * Internal return code for NativeLibraryHelper methods to indicate that the package 1010 * being processed did not contain any native code. This is placed here only so that 1011 * it can belong to the same value space as the other install failure codes. 1012 * 1013 * @hide 1014 */ 1015 public static final int NO_NATIVE_LIBRARIES = -114; 1016 1017 /** {@hide} */ 1018 public static final int INSTALL_FAILED_ABORTED = -115; 1019 1020 /** 1021 * Installation failed return code: ephemeral app installs are incompatible with some 1022 * other installation flags supplied for the operation; or other circumstances such 1023 * as trying to upgrade a system app via an ephemeral install. 1024 * @hide 1025 */ 1026 public static final int INSTALL_FAILED_EPHEMERAL_INVALID = -116; 1027 1028 /** 1029 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the 1030 * package's data directory. 1031 * 1032 * @hide 1033 */ 1034 public static final int DELETE_KEEP_DATA = 0x00000001; 1035 1036 /** 1037 * Flag parameter for {@link #deletePackage} to indicate that you want the 1038 * package deleted for all users. 1039 * 1040 * @hide 1041 */ 1042 public static final int DELETE_ALL_USERS = 0x00000002; 1043 1044 /** 1045 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling 1046 * uninstall on a system that has been updated, then don't do the normal process 1047 * of uninstalling the update and rolling back to the older system version (which 1048 * needs to happen for all users); instead, just mark the app as uninstalled for 1049 * the current user. 1050 * 1051 * @hide 1052 */ 1053 public static final int DELETE_SYSTEM_APP = 0x00000004; 1054 1055 /** 1056 * Return code for when package deletion succeeds. This is passed to the 1057 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 1058 * succeeded in deleting the package. 1059 * 1060 * @hide 1061 */ 1062 public static final int DELETE_SUCCEEDED = 1; 1063 1064 /** 1065 * Deletion failed return code: this is passed to the 1066 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 1067 * failed to delete the package for an unspecified reason. 1068 * 1069 * @hide 1070 */ 1071 public static final int DELETE_FAILED_INTERNAL_ERROR = -1; 1072 1073 /** 1074 * Deletion failed return code: this is passed to the 1075 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 1076 * failed to delete the package because it is the active DevicePolicy 1077 * manager. 1078 * 1079 * @hide 1080 */ 1081 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; 1082 1083 /** 1084 * Deletion failed return code: this is passed to the 1085 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 1086 * failed to delete the package since the user is restricted. 1087 * 1088 * @hide 1089 */ 1090 public static final int DELETE_FAILED_USER_RESTRICTED = -3; 1091 1092 /** 1093 * Deletion failed return code: this is passed to the 1094 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 1095 * failed to delete the package because a profile 1096 * or device owner has marked the package as uninstallable. 1097 * 1098 * @hide 1099 */ 1100 public static final int DELETE_FAILED_OWNER_BLOCKED = -4; 1101 1102 /** {@hide} */ 1103 public static final int DELETE_FAILED_ABORTED = -5; 1104 1105 /** 1106 * Return code that is passed to the {@link IPackageMoveObserver} by 1107 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the 1108 * package has been successfully moved by the system. 1109 * 1110 * @hide 1111 */ 1112 public static final int MOVE_SUCCEEDED = -100; 1113 1114 /** 1115 * Error code that is passed to the {@link IPackageMoveObserver} by 1116 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1117 * when the package hasn't been successfully moved by the system 1118 * because of insufficient memory on specified media. 1119 * @hide 1120 */ 1121 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1; 1122 1123 /** 1124 * Error code that is passed to the {@link IPackageMoveObserver} by 1125 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1126 * if the specified package doesn't exist. 1127 * @hide 1128 */ 1129 public static final int MOVE_FAILED_DOESNT_EXIST = -2; 1130 1131 /** 1132 * Error code that is passed to the {@link IPackageMoveObserver} by 1133 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1134 * if the specified package cannot be moved since its a system package. 1135 * @hide 1136 */ 1137 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3; 1138 1139 /** 1140 * Error code that is passed to the {@link IPackageMoveObserver} by 1141 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1142 * if the specified package cannot be moved since its forward locked. 1143 * @hide 1144 */ 1145 public static final int MOVE_FAILED_FORWARD_LOCKED = -4; 1146 1147 /** 1148 * Error code that is passed to the {@link IPackageMoveObserver} by 1149 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1150 * if the specified package cannot be moved to the specified location. 1151 * @hide 1152 */ 1153 public static final int MOVE_FAILED_INVALID_LOCATION = -5; 1154 1155 /** 1156 * Error code that is passed to the {@link IPackageMoveObserver} by 1157 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1158 * if the specified package cannot be moved to the specified location. 1159 * @hide 1160 */ 1161 public static final int MOVE_FAILED_INTERNAL_ERROR = -6; 1162 1163 /** 1164 * Error code that is passed to the {@link IPackageMoveObserver} by 1165 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the 1166 * specified package already has an operation pending in the 1167 * {@link PackageHandler} queue. 1168 * 1169 * @hide 1170 */ 1171 public static final int MOVE_FAILED_OPERATION_PENDING = -7; 1172 1173 /** 1174 * Flag parameter for {@link #movePackage} to indicate that 1175 * the package should be moved to internal storage if its 1176 * been installed on external media. 1177 * @hide 1178 */ 1179 @Deprecated 1180 public static final int MOVE_INTERNAL = 0x00000001; 1181 1182 /** 1183 * Flag parameter for {@link #movePackage} to indicate that 1184 * the package should be moved to external media. 1185 * @hide 1186 */ 1187 @Deprecated 1188 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; 1189 1190 /** {@hide} */ 1191 public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID"; 1192 1193 /** 1194 * Usable by the required verifier as the {@code verificationCode} argument 1195 * for {@link PackageManager#verifyPendingInstall} to indicate that it will 1196 * allow the installation to proceed without any of the optional verifiers 1197 * needing to vote. 1198 * 1199 * @hide 1200 */ 1201 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2; 1202 1203 /** 1204 * Used as the {@code verificationCode} argument for 1205 * {@link PackageManager#verifyPendingInstall} to indicate that the calling 1206 * package verifier allows the installation to proceed. 1207 */ 1208 public static final int VERIFICATION_ALLOW = 1; 1209 1210 /** 1211 * Used as the {@code verificationCode} argument for 1212 * {@link PackageManager#verifyPendingInstall} to indicate the calling 1213 * package verifier does not vote to allow the installation to proceed. 1214 */ 1215 public static final int VERIFICATION_REJECT = -1; 1216 1217 /** 1218 * Used as the {@code verificationCode} argument for 1219 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 1220 * IntentFilter Verifier confirms that the IntentFilter is verified. 1221 * 1222 * @hide 1223 */ 1224 public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1; 1225 1226 /** 1227 * Used as the {@code verificationCode} argument for 1228 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 1229 * IntentFilter Verifier confirms that the IntentFilter is NOT verified. 1230 * 1231 * @hide 1232 */ 1233 public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1; 1234 1235 /** 1236 * Internal status code to indicate that an IntentFilter verification result is not specified. 1237 * 1238 * @hide 1239 */ 1240 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0; 1241 1242 /** 1243 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1244 * to indicate that the User will always be prompted the Intent Disambiguation Dialog if there 1245 * are two or more Intent resolved for the IntentFilter's domain(s). 1246 * 1247 * @hide 1248 */ 1249 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1; 1250 1251 /** 1252 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1253 * to indicate that the User will never be prompted the Intent Disambiguation Dialog if there 1254 * are two or more resolution of the Intent. The default App for the domain(s) specified in the 1255 * IntentFilter will also ALWAYS be used. 1256 * 1257 * @hide 1258 */ 1259 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2; 1260 1261 /** 1262 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1263 * to indicate that the User may be prompted the Intent Disambiguation Dialog if there 1264 * are two or more Intent resolved. The default App for the domain(s) specified in the 1265 * IntentFilter will also NEVER be presented to the User. 1266 * 1267 * @hide 1268 */ 1269 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3; 1270 1271 /** 1272 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1273 * to indicate that this app should always be considered as an ambiguous candidate for 1274 * handling the matching Intent even if there are other candidate apps in the "always" 1275 * state. Put another way: if there are any 'always ask' apps in a set of more than 1276 * one candidate app, then a disambiguation is *always* presented even if there is 1277 * another candidate app with the 'always' state. 1278 * 1279 * @hide 1280 */ 1281 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4; 1282 1283 /** 1284 * Can be used as the {@code millisecondsToDelay} argument for 1285 * {@link PackageManager#extendVerificationTimeout}. This is the 1286 * maximum time {@code PackageManager} waits for the verification 1287 * agent to return (in milliseconds). 1288 */ 1289 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000; 1290 1291 /** 1292 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's 1293 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or 1294 * lag in sound input or output. 1295 */ 1296 @SdkConstant(SdkConstantType.FEATURE) 1297 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency"; 1298 1299 /** 1300 * Feature for {@link #getSystemAvailableFeatures} and 1301 * {@link #hasSystemFeature}: The device includes at least one form of audio 1302 * output, such as speakers, audio jack or streaming over bluetooth 1303 */ 1304 @SdkConstant(SdkConstantType.FEATURE) 1305 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output"; 1306 1307 /** 1308 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1309 * The device has professional audio level of functionality and performance. 1310 */ 1311 @SdkConstant(SdkConstantType.FEATURE) 1312 public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro"; 1313 1314 /** 1315 * Feature for {@link #getSystemAvailableFeatures} and 1316 * {@link #hasSystemFeature}: The device is capable of communicating with 1317 * other devices via Bluetooth. 1318 */ 1319 @SdkConstant(SdkConstantType.FEATURE) 1320 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 1321 1322 /** 1323 * Feature for {@link #getSystemAvailableFeatures} and 1324 * {@link #hasSystemFeature}: The device is capable of communicating with 1325 * other devices via Bluetooth Low Energy radio. 1326 */ 1327 @SdkConstant(SdkConstantType.FEATURE) 1328 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le"; 1329 1330 /** 1331 * Feature for {@link #getSystemAvailableFeatures} and 1332 * {@link #hasSystemFeature}: The device has a camera facing away 1333 * from the screen. 1334 */ 1335 @SdkConstant(SdkConstantType.FEATURE) 1336 public static final String FEATURE_CAMERA = "android.hardware.camera"; 1337 1338 /** 1339 * Feature for {@link #getSystemAvailableFeatures} and 1340 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 1341 */ 1342 @SdkConstant(SdkConstantType.FEATURE) 1343 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 1344 1345 /** 1346 * Feature for {@link #getSystemAvailableFeatures} and 1347 * {@link #hasSystemFeature}: The device has at least one camera pointing in 1348 * some direction, or can support an external camera being connected to it. 1349 */ 1350 @SdkConstant(SdkConstantType.FEATURE) 1351 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any"; 1352 1353 /** 1354 * Feature for {@link #getSystemAvailableFeatures} and 1355 * {@link #hasSystemFeature}: The device can support having an external camera connected to it. 1356 * The external camera may not always be connected or available to applications to use. 1357 */ 1358 @SdkConstant(SdkConstantType.FEATURE) 1359 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external"; 1360 1361 /** 1362 * Feature for {@link #getSystemAvailableFeatures} and 1363 * {@link #hasSystemFeature}: The device's camera supports flash. 1364 */ 1365 @SdkConstant(SdkConstantType.FEATURE) 1366 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 1367 1368 /** 1369 * Feature for {@link #getSystemAvailableFeatures} and 1370 * {@link #hasSystemFeature}: The device has a front facing camera. 1371 */ 1372 @SdkConstant(SdkConstantType.FEATURE) 1373 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 1374 1375 /** 1376 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1377 * of the cameras on the device supports the 1378 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware} 1379 * capability level. 1380 */ 1381 @SdkConstant(SdkConstantType.FEATURE) 1382 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full"; 1383 1384 /** 1385 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1386 * of the cameras on the device supports the 1387 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor} 1388 * capability level. 1389 */ 1390 @SdkConstant(SdkConstantType.FEATURE) 1391 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR = 1392 "android.hardware.camera.capability.manual_sensor"; 1393 1394 /** 1395 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1396 * of the cameras on the device supports the 1397 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing} 1398 * capability level. 1399 */ 1400 @SdkConstant(SdkConstantType.FEATURE) 1401 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING = 1402 "android.hardware.camera.capability.manual_post_processing"; 1403 1404 /** 1405 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1406 * of the cameras on the device supports the 1407 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW} 1408 * capability level. 1409 */ 1410 @SdkConstant(SdkConstantType.FEATURE) 1411 public static final String FEATURE_CAMERA_CAPABILITY_RAW = 1412 "android.hardware.camera.capability.raw"; 1413 1414 /** 1415 * Feature for {@link #getSystemAvailableFeatures} and 1416 * {@link #hasSystemFeature}: The device is capable of communicating with 1417 * consumer IR devices. 1418 */ 1419 @SdkConstant(SdkConstantType.FEATURE) 1420 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir"; 1421 1422 /** 1423 * Feature for {@link #getSystemAvailableFeatures} and 1424 * {@link #hasSystemFeature}: The device supports one or more methods of 1425 * reporting current location. 1426 */ 1427 @SdkConstant(SdkConstantType.FEATURE) 1428 public static final String FEATURE_LOCATION = "android.hardware.location"; 1429 1430 /** 1431 * Feature for {@link #getSystemAvailableFeatures} and 1432 * {@link #hasSystemFeature}: The device has a Global Positioning System 1433 * receiver and can report precise location. 1434 */ 1435 @SdkConstant(SdkConstantType.FEATURE) 1436 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 1437 1438 /** 1439 * Feature for {@link #getSystemAvailableFeatures} and 1440 * {@link #hasSystemFeature}: The device can report location with coarse 1441 * accuracy using a network-based geolocation system. 1442 */ 1443 @SdkConstant(SdkConstantType.FEATURE) 1444 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 1445 1446 /** 1447 * Feature for {@link #getSystemAvailableFeatures} and 1448 * {@link #hasSystemFeature}: The device can record audio via a 1449 * microphone. 1450 */ 1451 @SdkConstant(SdkConstantType.FEATURE) 1452 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 1453 1454 /** 1455 * Feature for {@link #getSystemAvailableFeatures} and 1456 * {@link #hasSystemFeature}: The device can communicate using Near-Field 1457 * Communications (NFC). 1458 */ 1459 @SdkConstant(SdkConstantType.FEATURE) 1460 public static final String FEATURE_NFC = "android.hardware.nfc"; 1461 1462 /** 1463 * Feature for {@link #getSystemAvailableFeatures} and 1464 * {@link #hasSystemFeature}: The device supports host- 1465 * based NFC card emulation. 1466 * 1467 * TODO remove when depending apps have moved to new constant. 1468 * @hide 1469 * @deprecated 1470 */ 1471 @Deprecated 1472 @SdkConstant(SdkConstantType.FEATURE) 1473 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce"; 1474 1475 /** 1476 * Feature for {@link #getSystemAvailableFeatures} and 1477 * {@link #hasSystemFeature}: The device supports host- 1478 * based NFC card emulation. 1479 */ 1480 @SdkConstant(SdkConstantType.FEATURE) 1481 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; 1482 1483 /** 1484 * Feature for {@link #getSystemAvailableFeatures} and 1485 * {@link #hasSystemFeature}: The device supports the OpenGL ES 1486 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 1487 * Android Extension Pack</a>. 1488 */ 1489 @SdkConstant(SdkConstantType.FEATURE) 1490 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 1491 1492 /** 1493 * Feature for {@link #getSystemAvailableFeatures} and 1494 * {@link #hasSystemFeature}: The device includes an accelerometer. 1495 */ 1496 @SdkConstant(SdkConstantType.FEATURE) 1497 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 1498 1499 /** 1500 * Feature for {@link #getSystemAvailableFeatures} and 1501 * {@link #hasSystemFeature}: The device includes a barometer (air 1502 * pressure sensor.) 1503 */ 1504 @SdkConstant(SdkConstantType.FEATURE) 1505 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 1506 1507 /** 1508 * Feature for {@link #getSystemAvailableFeatures} and 1509 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 1510 */ 1511 @SdkConstant(SdkConstantType.FEATURE) 1512 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 1513 1514 /** 1515 * Feature for {@link #getSystemAvailableFeatures} and 1516 * {@link #hasSystemFeature}: The device includes a gyroscope. 1517 */ 1518 @SdkConstant(SdkConstantType.FEATURE) 1519 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 1520 1521 /** 1522 * Feature for {@link #getSystemAvailableFeatures} and 1523 * {@link #hasSystemFeature}: The device includes a light sensor. 1524 */ 1525 @SdkConstant(SdkConstantType.FEATURE) 1526 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 1527 1528 /** 1529 * Feature for {@link #getSystemAvailableFeatures} and 1530 * {@link #hasSystemFeature}: The device includes a proximity sensor. 1531 */ 1532 @SdkConstant(SdkConstantType.FEATURE) 1533 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 1534 1535 /** 1536 * Feature for {@link #getSystemAvailableFeatures} and 1537 * {@link #hasSystemFeature}: The device includes a hardware step counter. 1538 */ 1539 @SdkConstant(SdkConstantType.FEATURE) 1540 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 1541 1542 /** 1543 * Feature for {@link #getSystemAvailableFeatures} and 1544 * {@link #hasSystemFeature}: The device includes a hardware step detector. 1545 */ 1546 @SdkConstant(SdkConstantType.FEATURE) 1547 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 1548 1549 /** 1550 * Feature for {@link #getSystemAvailableFeatures} and 1551 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 1552 */ 1553 @SdkConstant(SdkConstantType.FEATURE) 1554 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 1555 1556 /** 1557 * Feature for {@link #getSystemAvailableFeatures} and 1558 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocargiogram. 1559 */ 1560 @SdkConstant(SdkConstantType.FEATURE) 1561 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 1562 "android.hardware.sensor.heartrate.ecg"; 1563 1564 /** 1565 * Feature for {@link #getSystemAvailableFeatures} and 1566 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 1567 */ 1568 @SdkConstant(SdkConstantType.FEATURE) 1569 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 1570 "android.hardware.sensor.relative_humidity"; 1571 1572 /** 1573 * Feature for {@link #getSystemAvailableFeatures} and 1574 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 1575 */ 1576 @SdkConstant(SdkConstantType.FEATURE) 1577 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 1578 "android.hardware.sensor.ambient_temperature"; 1579 1580 /** 1581 * Feature for {@link #getSystemAvailableFeatures} and 1582 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing 1583 * capabilities. 1584 */ 1585 @SdkConstant(SdkConstantType.FEATURE) 1586 public static final String FEATURE_HIFI_SENSORS = 1587 "android.hardware.sensor.hifi_sensors"; 1588 1589 /** 1590 * Feature for {@link #getSystemAvailableFeatures} and 1591 * {@link #hasSystemFeature}: The device has a telephony radio with data 1592 * communication support. 1593 */ 1594 @SdkConstant(SdkConstantType.FEATURE) 1595 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 1596 1597 /** 1598 * Feature for {@link #getSystemAvailableFeatures} and 1599 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 1600 */ 1601 @SdkConstant(SdkConstantType.FEATURE) 1602 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 1603 1604 /** 1605 * Feature for {@link #getSystemAvailableFeatures} and 1606 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 1607 */ 1608 @SdkConstant(SdkConstantType.FEATURE) 1609 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 1610 1611 /** 1612 * Feature for {@link #getSystemAvailableFeatures} and 1613 * {@link #hasSystemFeature}: The device supports connecting to USB devices 1614 * as the USB host. 1615 */ 1616 @SdkConstant(SdkConstantType.FEATURE) 1617 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 1618 1619 /** 1620 * Feature for {@link #getSystemAvailableFeatures} and 1621 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 1622 */ 1623 @SdkConstant(SdkConstantType.FEATURE) 1624 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 1625 1626 /** 1627 * Feature for {@link #getSystemAvailableFeatures} and 1628 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 1629 */ 1630 @SdkConstant(SdkConstantType.FEATURE) 1631 public static final String FEATURE_SIP = "android.software.sip"; 1632 1633 /** 1634 * Feature for {@link #getSystemAvailableFeatures} and 1635 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 1636 */ 1637 @SdkConstant(SdkConstantType.FEATURE) 1638 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 1639 1640 /** 1641 * Feature for {@link #getSystemAvailableFeatures} and 1642 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device. 1643 */ 1644 @SdkConstant(SdkConstantType.FEATURE) 1645 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice"; 1646 1647 /** 1648 * Feature for {@link #getSystemAvailableFeatures} and 1649 * {@link #hasSystemFeature}: The device's display has a touch screen. 1650 */ 1651 @SdkConstant(SdkConstantType.FEATURE) 1652 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 1653 1654 /** 1655 * Feature for {@link #getSystemAvailableFeatures} and 1656 * {@link #hasSystemFeature}: The device's touch screen supports 1657 * multitouch sufficient for basic two-finger gesture detection. 1658 */ 1659 @SdkConstant(SdkConstantType.FEATURE) 1660 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 1661 1662 /** 1663 * Feature for {@link #getSystemAvailableFeatures} and 1664 * {@link #hasSystemFeature}: The device's touch screen is capable of 1665 * tracking two or more fingers fully independently. 1666 */ 1667 @SdkConstant(SdkConstantType.FEATURE) 1668 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 1669 1670 /** 1671 * Feature for {@link #getSystemAvailableFeatures} and 1672 * {@link #hasSystemFeature}: The device's touch screen is capable of 1673 * tracking a full hand of fingers fully independently -- that is, 5 or 1674 * more simultaneous independent pointers. 1675 */ 1676 @SdkConstant(SdkConstantType.FEATURE) 1677 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 1678 1679 /** 1680 * Feature for {@link #getSystemAvailableFeatures} and 1681 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1682 * does support touch emulation for basic events. For instance, the 1683 * device might use a mouse or remote control to drive a cursor, and 1684 * emulate basic touch pointer events like down, up, drag, etc. All 1685 * devices that support android.hardware.touchscreen or a sub-feature are 1686 * presumed to also support faketouch. 1687 */ 1688 @SdkConstant(SdkConstantType.FEATURE) 1689 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 1690 1691 /** 1692 * Feature for {@link #getSystemAvailableFeatures} and 1693 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1694 * does support touch emulation for basic events that supports distinct 1695 * tracking of two or more fingers. This is an extension of 1696 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1697 * that unlike a distinct multitouch screen as defined by 1698 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 1699 * devices will not actually provide full two-finger gestures since the 1700 * input is being transformed to cursor movement on the screen. That is, 1701 * single finger gestures will move a cursor; two-finger swipes will 1702 * result in single-finger touch events; other two-finger gestures will 1703 * result in the corresponding two-finger touch event. 1704 */ 1705 @SdkConstant(SdkConstantType.FEATURE) 1706 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 1707 1708 /** 1709 * Feature for {@link #getSystemAvailableFeatures} and 1710 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1711 * does support touch emulation for basic events that supports tracking 1712 * a hand of fingers (5 or more fingers) fully independently. 1713 * This is an extension of 1714 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1715 * that unlike a multitouch screen as defined by 1716 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 1717 * gestures can be detected due to the limitations described for 1718 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 1719 */ 1720 @SdkConstant(SdkConstantType.FEATURE) 1721 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 1722 1723 /** 1724 * Feature for {@link #getSystemAvailableFeatures} and 1725 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint. 1726 */ 1727 @SdkConstant(SdkConstantType.FEATURE) 1728 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; 1729 1730 /** 1731 * Feature for {@link #getSystemAvailableFeatures} and 1732 * {@link #hasSystemFeature}: The device supports portrait orientation 1733 * screens. For backwards compatibility, you can assume that if neither 1734 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 1735 * both portrait and landscape. 1736 */ 1737 @SdkConstant(SdkConstantType.FEATURE) 1738 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 1739 1740 /** 1741 * Feature for {@link #getSystemAvailableFeatures} and 1742 * {@link #hasSystemFeature}: The device supports landscape orientation 1743 * screens. For backwards compatibility, you can assume that if neither 1744 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 1745 * both portrait and landscape. 1746 */ 1747 @SdkConstant(SdkConstantType.FEATURE) 1748 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 1749 1750 /** 1751 * Feature for {@link #getSystemAvailableFeatures} and 1752 * {@link #hasSystemFeature}: The device supports live wallpapers. 1753 */ 1754 @SdkConstant(SdkConstantType.FEATURE) 1755 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 1756 /** 1757 * Feature for {@link #getSystemAvailableFeatures} and 1758 * {@link #hasSystemFeature}: The device supports app widgets. 1759 */ 1760 @SdkConstant(SdkConstantType.FEATURE) 1761 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 1762 1763 /** 1764 * @hide 1765 * Feature for {@link #getSystemAvailableFeatures} and 1766 * {@link #hasSystemFeature}: The device supports 1767 * {@link android.service.voice.VoiceInteractionService} and 1768 * {@link android.app.VoiceInteractor}. 1769 */ 1770 @SdkConstant(SdkConstantType.FEATURE) 1771 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 1772 1773 1774 /** 1775 * Feature for {@link #getSystemAvailableFeatures} and 1776 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 1777 * by third party applications. 1778 */ 1779 @SdkConstant(SdkConstantType.FEATURE) 1780 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 1781 1782 /** 1783 * Feature for {@link #getSystemAvailableFeatures} and 1784 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 1785 * with the {@link android.inputmethodservice.InputMethodService} API. 1786 */ 1787 @SdkConstant(SdkConstantType.FEATURE) 1788 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 1789 1790 /** 1791 * Feature for {@link #getSystemAvailableFeatures} and 1792 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 1793 */ 1794 @SdkConstant(SdkConstantType.FEATURE) 1795 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 1796 1797 /** 1798 * Feature for {@link #getSystemAvailableFeatures} and 1799 * {@link #hasSystemFeature}: The device supports leanback UI. This is 1800 * typically used in a living room television experience, but is a software 1801 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 1802 * feature will use resources associated with the "television" UI mode. 1803 */ 1804 @SdkConstant(SdkConstantType.FEATURE) 1805 public static final String FEATURE_LEANBACK = "android.software.leanback"; 1806 1807 /** 1808 * Feature for {@link #getSystemAvailableFeatures} and 1809 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 1810 * applications designed for this experience should be run, though this is 1811 * not enforced by the system. 1812 * @hide 1813 */ 1814 @SdkConstant(SdkConstantType.FEATURE) 1815 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 1816 1817 /** 1818 * Feature for {@link #getSystemAvailableFeatures} and 1819 * {@link #hasSystemFeature}: The device supports live TV and can display 1820 * contents from TV inputs implemented with the 1821 * {@link android.media.tv.TvInputService} API. 1822 */ 1823 @SdkConstant(SdkConstantType.FEATURE) 1824 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 1825 1826 /** 1827 * Feature for {@link #getSystemAvailableFeatures} and 1828 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 1829 */ 1830 @SdkConstant(SdkConstantType.FEATURE) 1831 public static final String FEATURE_WIFI = "android.hardware.wifi"; 1832 1833 /** 1834 * Feature for {@link #getSystemAvailableFeatures} and 1835 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 1836 */ 1837 @SdkConstant(SdkConstantType.FEATURE) 1838 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 1839 1840 /** 1841 * Feature for {@link #getSystemAvailableFeatures} and 1842 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1843 * on a vehicle headunit. A headunit here is defined to be inside a 1844 * vehicle that may or may not be moving. A headunit uses either a 1845 * primary display in the center console and/or additional displays in 1846 * the instrument cluster or elsewhere in the vehicle. Headunit display(s) 1847 * have limited size and resolution. The user will likely be focused on 1848 * driving so limiting driver distraction is a primary concern. User input 1849 * can be a variety of hard buttons, touch, rotary controllers and even mouse- 1850 * like interfaces. 1851 */ 1852 @SdkConstant(SdkConstantType.FEATURE) 1853 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive"; 1854 1855 /** 1856 * Feature for {@link #getSystemAvailableFeatures} and 1857 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1858 * on a television. Television here is defined to be a typical living 1859 * room television experience: displayed on a big screen, where the user 1860 * is sitting far away from it, and the dominant form of input will be 1861 * something like a DPAD, not through touch or mouse. 1862 * @deprecated use {@link #FEATURE_LEANBACK} instead. 1863 */ 1864 @Deprecated 1865 @SdkConstant(SdkConstantType.FEATURE) 1866 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 1867 1868 /** 1869 * Feature for {@link #getSystemAvailableFeatures} and 1870 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1871 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 1872 * the wrist. The user is very close when interacting with the device. 1873 */ 1874 @SdkConstant(SdkConstantType.FEATURE) 1875 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 1876 1877 /** 1878 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1879 * The device supports printing. 1880 */ 1881 @SdkConstant(SdkConstantType.FEATURE) 1882 public static final String FEATURE_PRINTING = "android.software.print"; 1883 1884 /** 1885 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1886 * The device can perform backup and restore operations on installed applications. 1887 */ 1888 @SdkConstant(SdkConstantType.FEATURE) 1889 public static final String FEATURE_BACKUP = "android.software.backup"; 1890 1891 /** 1892 * Feature for {@link #getSystemAvailableFeatures} and 1893 * {@link #hasSystemFeature}: The device supports freeform window management. 1894 * Windows have title bars and can be moved and resized. 1895 */ 1896 // If this feature is present, you also need to set 1897 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay. 1898 @SdkConstant(SdkConstantType.FEATURE) 1899 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT 1900 = "android.software.freeform_window_management"; 1901 1902 /** 1903 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1904 * The device supports picture-in-picture multi-window mode. 1905 */ 1906 @SdkConstant(SdkConstantType.FEATURE) 1907 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; 1908 1909 /** 1910 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1911 * The device supports creating secondary users and managed profiles via 1912 * {@link DevicePolicyManager}. 1913 */ 1914 @SdkConstant(SdkConstantType.FEATURE) 1915 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 1916 1917 /** 1918 * @hide 1919 * TODO: Remove after dependencies updated b/17392243 1920 */ 1921 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 1922 1923 /** 1924 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1925 * The device supports verified boot. 1926 */ 1927 @SdkConstant(SdkConstantType.FEATURE) 1928 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 1929 1930 /** 1931 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1932 * The device supports secure removal of users. When a user is deleted the data associated 1933 * with that user is securely deleted and no longer available. 1934 */ 1935 @SdkConstant(SdkConstantType.FEATURE) 1936 public static final String FEATURE_SECURELY_REMOVES_USERS 1937 = "android.software.securely_removes_users"; 1938 1939 /** 1940 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1941 * The device has a full implementation of the android.webkit.* APIs. Devices 1942 * lacking this feature will not have a functioning WebView implementation. 1943 */ 1944 @SdkConstant(SdkConstantType.FEATURE) 1945 public static final String FEATURE_WEBVIEW = "android.software.webview"; 1946 1947 /** 1948 * Feature for {@link #getSystemAvailableFeatures} and 1949 * {@link #hasSystemFeature}: This device supports ethernet. 1950 */ 1951 @SdkConstant(SdkConstantType.FEATURE) 1952 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 1953 1954 /** 1955 * Feature for {@link #getSystemAvailableFeatures} and 1956 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 1957 * @hide 1958 */ 1959 @SdkConstant(SdkConstantType.FEATURE) 1960 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 1961 1962 /** 1963 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1964 * The device has all of the inputs necessary to be considered a compatible game controller, or 1965 * includes a compatible game controller in the box. 1966 */ 1967 @SdkConstant(SdkConstantType.FEATURE) 1968 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 1969 1970 /** 1971 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1972 * The device has a full implementation of the android.media.midi.* APIs. 1973 */ 1974 @SdkConstant(SdkConstantType.FEATURE) 1975 public static final String FEATURE_MIDI = "android.software.midi"; 1976 1977 /** 1978 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1979 * The device implements a an optimized mode for virtual reality (VR) applications that handles 1980 * stereoscopic rendering of notifications, and may potentially also include optimizations to 1981 * reduce latency in the graphics, display, and sensor stacks. Presence of this feature 1982 * also indicates that the VrCore library is included on this device. 1983 */ 1984 @SdkConstant(SdkConstantType.FEATURE) 1985 public static final String FEATURE_VR_MODE = "android.software.vr.mode"; 1986 1987 /** 1988 * Action to external storage service to clean out removed apps. 1989 * @hide 1990 */ 1991 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 1992 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 1993 1994 /** 1995 * Extra field name for the URI to a verification file. Passed to a package 1996 * verifier. 1997 * 1998 * @hide 1999 */ 2000 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 2001 2002 /** 2003 * Extra field name for the ID of a package pending verification. Passed to 2004 * a package verifier and is used to call back to 2005 * {@link PackageManager#verifyPendingInstall(int, int)} 2006 */ 2007 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 2008 2009 /** 2010 * Extra field name for the package identifier which is trying to install 2011 * the package. 2012 * 2013 * @hide 2014 */ 2015 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 2016 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 2017 2018 /** 2019 * Extra field name for the requested install flags for a package pending 2020 * verification. Passed to a package verifier. 2021 * 2022 * @hide 2023 */ 2024 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 2025 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 2026 2027 /** 2028 * Extra field name for the uid of who is requesting to install 2029 * the package. 2030 * 2031 * @hide 2032 */ 2033 public static final String EXTRA_VERIFICATION_INSTALLER_UID 2034 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 2035 2036 /** 2037 * Extra field name for the package name of a package pending verification. 2038 * 2039 * @hide 2040 */ 2041 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 2042 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 2043 /** 2044 * Extra field name for the result of a verification, either 2045 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 2046 * Passed to package verifiers after a package is verified. 2047 */ 2048 public static final String EXTRA_VERIFICATION_RESULT 2049 = "android.content.pm.extra.VERIFICATION_RESULT"; 2050 2051 /** 2052 * Extra field name for the version code of a package pending verification. 2053 * 2054 * @hide 2055 */ 2056 public static final String EXTRA_VERIFICATION_VERSION_CODE 2057 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 2058 2059 /** 2060 * Extra field name for the ID of a intent filter pending verification. Passed to 2061 * an intent filter verifier and is used to call back to 2062 * {@link PackageManager#verifyIntentFilter(int, int)} 2063 * 2064 * @hide 2065 */ 2066 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 2067 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 2068 2069 /** 2070 * Extra field name for the scheme used for an intent filter pending verification. Passed to 2071 * an intent filter verifier and is used to construct the URI to verify against. 2072 * 2073 * Usually this is "https" 2074 * 2075 * @hide 2076 */ 2077 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 2078 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 2079 2080 /** 2081 * Extra field name for the host names to be used for an intent filter pending verification. 2082 * Passed to an intent filter verifier and is used to construct the URI to verify the 2083 * intent filter. 2084 * 2085 * This is a space delimited list of hosts. 2086 * 2087 * @hide 2088 */ 2089 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 2090 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 2091 2092 /** 2093 * Extra field name for the package name to be used for an intent filter pending verification. 2094 * Passed to an intent filter verifier and is used to check the verification responses coming 2095 * from the hosts. Each host response will need to include the package name of APK containing 2096 * the intent filter. 2097 * 2098 * @hide 2099 */ 2100 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 2101 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 2102 2103 /** 2104 * The action used to request that the user approve a permission request 2105 * from the application. 2106 * 2107 * @hide 2108 */ 2109 @SystemApi 2110 public static final String ACTION_REQUEST_PERMISSIONS = 2111 "android.content.pm.action.REQUEST_PERMISSIONS"; 2112 2113 /** 2114 * The names of the requested permissions. 2115 * <p> 2116 * <strong>Type:</strong> String[] 2117 * </p> 2118 * 2119 * @hide 2120 */ 2121 @SystemApi 2122 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 2123 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 2124 2125 /** 2126 * The results from the permissions request. 2127 * <p> 2128 * <strong>Type:</strong> int[] of #PermissionResult 2129 * </p> 2130 * 2131 * @hide 2132 */ 2133 @SystemApi 2134 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 2135 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 2136 2137 /** 2138 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2139 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 2140 * the existing definition for the permission. 2141 * @hide 2142 */ 2143 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 2144 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 2145 2146 /** 2147 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2148 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 2149 * being redundantly defined by the package being installed. 2150 * @hide 2151 */ 2152 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 2153 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 2154 2155 /** 2156 * Permission flag: The permission is set in its current state 2157 * by the user and apps can still request it at runtime. 2158 * 2159 * @hide 2160 */ 2161 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 2162 2163 /** 2164 * Permission flag: The permission is set in its current state 2165 * by the user and it is fixed, i.e. apps can no longer request 2166 * this permission. 2167 * 2168 * @hide 2169 */ 2170 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 2171 2172 /** 2173 * Permission flag: The permission is set in its current state 2174 * by device policy and neither apps nor the user can change 2175 * its state. 2176 * 2177 * @hide 2178 */ 2179 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 2180 2181 /** 2182 * Permission flag: The permission is set in a granted state but 2183 * access to resources it guards is restricted by other means to 2184 * enable revoking a permission on legacy apps that do not support 2185 * runtime permissions. If this permission is upgraded to runtime 2186 * because the app was updated to support runtime permissions, the 2187 * the permission will be revoked in the upgrade process. 2188 * 2189 * @hide 2190 */ 2191 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 2192 2193 /** 2194 * Permission flag: The permission is set in its current state 2195 * because the app is a component that is a part of the system. 2196 * 2197 * @hide 2198 */ 2199 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 2200 2201 /** 2202 * Permission flag: The permission is granted by default because it 2203 * enables app functionality that is expected to work out-of-the-box 2204 * for providing a smooth user experience. For example, the phone app 2205 * is expected to have the phone permission. 2206 * 2207 * @hide 2208 */ 2209 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 2210 2211 /** 2212 * Permission flag: The permission has to be reviewed before any of 2213 * the app components can run. 2214 * 2215 * @hide 2216 */ 2217 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 2218 2219 /** 2220 * Mask for all permission flags. 2221 * 2222 * @hide 2223 */ 2224 @SystemApi 2225 public static final int MASK_PERMISSION_FLAGS = 0xFF; 2226 2227 /** 2228 * Retrieve overall information about an application package that is 2229 * installed on the system. 2230 * <p> 2231 * Throws {@link NameNotFoundException} if a package with the given name can 2232 * not be found on the system. 2233 * 2234 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2235 * desired package. 2236 * @param flags Additional option flags. Use any combination of 2237 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS}, 2238 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION}, 2239 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2240 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2241 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to 2242 * modify the data returned. 2243 * @return A PackageInfo object containing information about the 2244 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the 2245 * package is not found in the list of installed applications, the 2246 * package information is retrieved from the list of uninstalled 2247 * applications (which includes installed applications as well as 2248 * applications with data directory i.e. applications which had been 2249 * deleted with {@code DONT_DELETE_DATA} flag set). 2250 * @see #GET_ACTIVITIES 2251 * @see #GET_GIDS 2252 * @see #GET_CONFIGURATIONS 2253 * @see #GET_INSTRUMENTATION 2254 * @see #GET_PERMISSIONS 2255 * @see #GET_PROVIDERS 2256 * @see #GET_RECEIVERS 2257 * @see #GET_SERVICES 2258 * @see #GET_SIGNATURES 2259 * @see #GET_UNINSTALLED_PACKAGES 2260 */ 2261 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) 2262 throws NameNotFoundException; 2263 2264 /** 2265 * @hide 2266 * Retrieve overall information about an application package that is 2267 * installed on the system. 2268 * <p> 2269 * Throws {@link NameNotFoundException} if a package with the given name can 2270 * not be found on the system. 2271 * 2272 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2273 * desired package. 2274 * @param flags Additional option flags. Use any combination of 2275 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS}, 2276 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION}, 2277 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2278 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2279 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to 2280 * modify the data returned. 2281 * @param userId The user id. 2282 * @return A PackageInfo object containing information about the 2283 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the 2284 * package is not found in the list of installed applications, the 2285 * package information is retrieved from the list of uninstalled 2286 * applications (which includes installed applications as well as 2287 * applications with data directory i.e. applications which had been 2288 * deleted with {@code DONT_DELETE_DATA} flag set). 2289 * @see #GET_ACTIVITIES 2290 * @see #GET_GIDS 2291 * @see #GET_CONFIGURATIONS 2292 * @see #GET_INSTRUMENTATION 2293 * @see #GET_PERMISSIONS 2294 * @see #GET_PROVIDERS 2295 * @see #GET_RECEIVERS 2296 * @see #GET_SERVICES 2297 * @see #GET_SIGNATURES 2298 * @see #GET_UNINSTALLED_PACKAGES 2299 */ 2300 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 2301 public abstract PackageInfo getPackageInfoAsUser(String packageName, 2302 @PackageInfoFlags int flags, int userId) throws NameNotFoundException; 2303 2304 /** 2305 * Map from the current package names in use on the device to whatever 2306 * the current canonical name of that package is. 2307 * @param names Array of current names to be mapped. 2308 * @return Returns an array of the same size as the original, containing 2309 * the canonical name for each package. 2310 */ 2311 public abstract String[] currentToCanonicalPackageNames(String[] names); 2312 2313 /** 2314 * Map from a packages canonical name to the current name in use on the device. 2315 * @param names Array of new names to be mapped. 2316 * @return Returns an array of the same size as the original, containing 2317 * the current name for each package. 2318 */ 2319 public abstract String[] canonicalToCurrentPackageNames(String[] names); 2320 2321 /** 2322 * Returns a "good" intent to launch a front-door activity in a package. 2323 * This is used, for example, to implement an "open" button when browsing 2324 * through packages. The current implementation looks first for a main 2325 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 2326 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 2327 * <code>null</code> if neither are found. 2328 * 2329 * @param packageName The name of the package to inspect. 2330 * 2331 * @return A fully-qualified {@link Intent} that can be used to launch the 2332 * main activity in the package. Returns <code>null</code> if the package 2333 * does not contain such an activity, or if <em>packageName</em> is not 2334 * recognized. 2335 */ 2336 public abstract Intent getLaunchIntentForPackage(String packageName); 2337 2338 /** 2339 * Return a "good" intent to launch a front-door Leanback activity in a 2340 * package, for use for example to implement an "open" button when browsing 2341 * through packages. The current implementation will look for a main 2342 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 2343 * return null if no main leanback activities are found. 2344 * <p> 2345 * Throws {@link NameNotFoundException} if a package with the given name 2346 * cannot be found on the system. 2347 * 2348 * @param packageName The name of the package to inspect. 2349 * @return Returns either a fully-qualified Intent that can be used to launch 2350 * the main Leanback activity in the package, or null if the package 2351 * does not contain such an activity. 2352 */ 2353 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName); 2354 2355 /** 2356 * Return an array of all of the secondary group-ids that have been assigned 2357 * to a package. 2358 * <p> 2359 * Throws {@link NameNotFoundException} if a package with the given name 2360 * cannot be found on the system. 2361 * 2362 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2363 * desired package. 2364 * @return Returns an int array of the assigned gids, or null if there are 2365 * none. 2366 */ 2367 public abstract int[] getPackageGids(String packageName) 2368 throws NameNotFoundException; 2369 2370 /** 2371 * @hide Return the uid associated with the given package name for the 2372 * given user. 2373 * 2374 * <p>Throws {@link NameNotFoundException} if a package with the given 2375 * name can not be found on the system. 2376 * 2377 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2378 * desired package. 2379 * @param userHandle The user handle identifier to look up the package under. 2380 * 2381 * @return Returns an integer uid who owns the given package name. 2382 */ 2383 public abstract int getPackageUidAsUser(String packageName, int userId) 2384 throws NameNotFoundException; 2385 2386 /** 2387 * Retrieve all of the information we know about a particular permission. 2388 * 2389 * <p>Throws {@link NameNotFoundException} if a permission with the given 2390 * name cannot be found on the system. 2391 * 2392 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 2393 * of the permission you are interested in. 2394 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2395 * retrieve any meta-data associated with the permission. 2396 * 2397 * @return Returns a {@link PermissionInfo} containing information about the 2398 * permission. 2399 */ 2400 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags) 2401 throws NameNotFoundException; 2402 2403 /** 2404 * Query for all of the permissions associated with a particular group. 2405 * 2406 * <p>Throws {@link NameNotFoundException} if the given group does not 2407 * exist. 2408 * 2409 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 2410 * of the permission group you are interested in. Use null to 2411 * find all of the permissions not associated with a group. 2412 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2413 * retrieve any meta-data associated with the permissions. 2414 * 2415 * @return Returns a list of {@link PermissionInfo} containing information 2416 * about all of the permissions in the given group. 2417 */ 2418 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 2419 @PermissionInfoFlags int flags) throws NameNotFoundException; 2420 2421 /** 2422 * Retrieve all of the information we know about a particular group of 2423 * permissions. 2424 * 2425 * <p>Throws {@link NameNotFoundException} if a permission group with the given 2426 * name cannot be found on the system. 2427 * 2428 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 2429 * of the permission you are interested in. 2430 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2431 * retrieve any meta-data associated with the permission group. 2432 * 2433 * @return Returns a {@link PermissionGroupInfo} containing information 2434 * about the permission. 2435 */ 2436 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 2437 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 2438 2439 /** 2440 * Retrieve all of the known permission groups in the system. 2441 * 2442 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2443 * retrieve any meta-data associated with the permission group. 2444 * 2445 * @return Returns a list of {@link PermissionGroupInfo} containing 2446 * information about all of the known permission groups. 2447 */ 2448 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 2449 @PermissionGroupInfoFlags int flags); 2450 2451 /** 2452 * Retrieve all of the information we know about a particular 2453 * package/application. 2454 * 2455 * <p>Throws {@link NameNotFoundException} if an application with the given 2456 * package name cannot be found on the system. 2457 * 2458 * @param packageName The full name (i.e. com.google.apps.contacts) of an 2459 * application. 2460 * @param flags Additional option flags. Use any combination of 2461 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2462 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2463 * 2464 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing 2465 * information about the package. 2466 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 2467 * found in the list of installed applications, 2468 * the application information is retrieved from the 2469 * list of uninstalled applications(which includes 2470 * installed applications as well as applications 2471 * with data directory ie applications which had been 2472 * deleted with {@code DONT_DELETE_DATA} flag set). 2473 * 2474 * @see #GET_META_DATA 2475 * @see #GET_SHARED_LIBRARY_FILES 2476 * @see #GET_UNINSTALLED_PACKAGES 2477 */ 2478 public abstract ApplicationInfo getApplicationInfo(String packageName, 2479 @ApplicationInfoFlags int flags) throws NameNotFoundException; 2480 2481 /** 2482 * Retrieve all of the information we know about a particular activity 2483 * class. 2484 * 2485 * <p>Throws {@link NameNotFoundException} if an activity with the given 2486 * class name cannot be found on the system. 2487 * 2488 * @param component The full component name (i.e. 2489 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity 2490 * class. 2491 * @param flags Additional option flags. Use any combination of 2492 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2493 * to modify the data (in ApplicationInfo) returned. 2494 * 2495 * @return {@link ActivityInfo} containing information about the activity. 2496 * 2497 * @see #GET_INTENT_FILTERS 2498 * @see #GET_META_DATA 2499 * @see #GET_SHARED_LIBRARY_FILES 2500 */ 2501 public abstract ActivityInfo getActivityInfo(ComponentName component, 2502 @ComponentInfoFlags int flags) throws NameNotFoundException; 2503 2504 /** 2505 * Retrieve all of the information we know about a particular receiver 2506 * class. 2507 * 2508 * <p>Throws {@link NameNotFoundException} if a receiver with the given 2509 * class name cannot be found on the system. 2510 * 2511 * @param component The full component name (i.e. 2512 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver 2513 * class. 2514 * @param flags Additional option flags. Use any combination of 2515 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2516 * to modify the data returned. 2517 * 2518 * @return {@link ActivityInfo} containing information about the receiver. 2519 * 2520 * @see #GET_INTENT_FILTERS 2521 * @see #GET_META_DATA 2522 * @see #GET_SHARED_LIBRARY_FILES 2523 */ 2524 public abstract ActivityInfo getReceiverInfo(ComponentName component, 2525 @ComponentInfoFlags int flags) throws NameNotFoundException; 2526 2527 /** 2528 * Retrieve all of the information we know about a particular service 2529 * class. 2530 * 2531 * <p>Throws {@link NameNotFoundException} if a service with the given 2532 * class name cannot be found on the system. 2533 * 2534 * @param component The full component name (i.e. 2535 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service 2536 * class. 2537 * @param flags Additional option flags. Use any combination of 2538 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2539 * to modify the data returned. 2540 * 2541 * @return ServiceInfo containing information about the service. 2542 * 2543 * @see #GET_META_DATA 2544 * @see #GET_SHARED_LIBRARY_FILES 2545 */ 2546 public abstract ServiceInfo getServiceInfo(ComponentName component, 2547 @ComponentInfoFlags int flags) throws NameNotFoundException; 2548 2549 /** 2550 * Retrieve all of the information we know about a particular content 2551 * provider class. 2552 * 2553 * <p>Throws {@link NameNotFoundException} if a provider with the given 2554 * class name cannot be found on the system. 2555 * 2556 * @param component The full component name (i.e. 2557 * com.google.providers.media/com.google.providers.media.MediaProvider) of a 2558 * ContentProvider class. 2559 * @param flags Additional option flags. Use any combination of 2560 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2561 * to modify the data returned. 2562 * 2563 * @return ProviderInfo containing information about the service. 2564 * 2565 * @see #GET_META_DATA 2566 * @see #GET_SHARED_LIBRARY_FILES 2567 */ 2568 public abstract ProviderInfo getProviderInfo(ComponentName component, 2569 @ComponentInfoFlags int flags) throws NameNotFoundException; 2570 2571 /** 2572 * Return a List of all packages that are installed 2573 * on the device. 2574 * 2575 * @param flags Additional option flags. Use any combination of 2576 * {@link #GET_ACTIVITIES}, 2577 * {@link #GET_GIDS}, 2578 * {@link #GET_CONFIGURATIONS}, 2579 * {@link #GET_INSTRUMENTATION}, 2580 * {@link #GET_PERMISSIONS}, 2581 * {@link #GET_PROVIDERS}, 2582 * {@link #GET_RECEIVERS}, 2583 * {@link #GET_SERVICES}, 2584 * {@link #GET_SIGNATURES}, 2585 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2586 * 2587 * @return A List of PackageInfo objects, one for each package that is 2588 * installed on the device. In the unlikely case of there being no 2589 * installed packages, an empty list is returned. 2590 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2591 * applications including those deleted with {@code DONT_DELETE_DATA} 2592 * (partially installed apps with data directory) will be returned. 2593 * 2594 * @see #GET_ACTIVITIES 2595 * @see #GET_GIDS 2596 * @see #GET_CONFIGURATIONS 2597 * @see #GET_INSTRUMENTATION 2598 * @see #GET_PERMISSIONS 2599 * @see #GET_PROVIDERS 2600 * @see #GET_RECEIVERS 2601 * @see #GET_SERVICES 2602 * @see #GET_SIGNATURES 2603 * @see #GET_UNINSTALLED_PACKAGES 2604 */ 2605 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags); 2606 2607 /** 2608 * Return a List of all installed packages that are currently 2609 * holding any of the given permissions. 2610 * 2611 * @param flags Additional option flags. Use any combination of 2612 * {@link #GET_ACTIVITIES}, 2613 * {@link #GET_GIDS}, 2614 * {@link #GET_CONFIGURATIONS}, 2615 * {@link #GET_INSTRUMENTATION}, 2616 * {@link #GET_PERMISSIONS}, 2617 * {@link #GET_PROVIDERS}, 2618 * {@link #GET_RECEIVERS}, 2619 * {@link #GET_SERVICES}, 2620 * {@link #GET_SIGNATURES}, 2621 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2622 * 2623 * @return Returns a List of PackageInfo objects, one for each installed 2624 * application that is holding any of the permissions that were provided. 2625 * 2626 * @see #GET_ACTIVITIES 2627 * @see #GET_GIDS 2628 * @see #GET_CONFIGURATIONS 2629 * @see #GET_INSTRUMENTATION 2630 * @see #GET_PERMISSIONS 2631 * @see #GET_PROVIDERS 2632 * @see #GET_RECEIVERS 2633 * @see #GET_SERVICES 2634 * @see #GET_SIGNATURES 2635 * @see #GET_UNINSTALLED_PACKAGES 2636 */ 2637 public abstract List<PackageInfo> getPackagesHoldingPermissions( 2638 String[] permissions, @PackageInfoFlags int flags); 2639 2640 /** 2641 * Return a List of all packages that are installed on the device, for a specific user. 2642 * Requesting a list of installed packages for another user 2643 * will require the permission INTERACT_ACROSS_USERS_FULL. 2644 * @param flags Additional option flags. Use any combination of 2645 * {@link #GET_ACTIVITIES}, 2646 * {@link #GET_GIDS}, 2647 * {@link #GET_CONFIGURATIONS}, 2648 * {@link #GET_INSTRUMENTATION}, 2649 * {@link #GET_PERMISSIONS}, 2650 * {@link #GET_PROVIDERS}, 2651 * {@link #GET_RECEIVERS}, 2652 * {@link #GET_SERVICES}, 2653 * {@link #GET_SIGNATURES}, 2654 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2655 * @param userId The user for whom the installed packages are to be listed 2656 * 2657 * @return A List of PackageInfo objects, one for each package that is 2658 * installed on the device. In the unlikely case of there being no 2659 * installed packages, an empty list is returned. 2660 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2661 * applications including those deleted with {@code DONT_DELETE_DATA} 2662 * (partially installed apps with data directory) will be returned. 2663 * 2664 * @see #GET_ACTIVITIES 2665 * @see #GET_GIDS 2666 * @see #GET_CONFIGURATIONS 2667 * @see #GET_INSTRUMENTATION 2668 * @see #GET_PERMISSIONS 2669 * @see #GET_PROVIDERS 2670 * @see #GET_RECEIVERS 2671 * @see #GET_SERVICES 2672 * @see #GET_SIGNATURES 2673 * @see #GET_UNINSTALLED_PACKAGES 2674 * 2675 * @hide 2676 */ 2677 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags, 2678 int userId); 2679 2680 /** 2681 * Check whether a particular package has been granted a particular 2682 * permission. 2683 * 2684 * @param permName The name of the permission you are checking for. 2685 * @param pkgName The name of the package you are checking against. 2686 * 2687 * @return If the package has the permission, PERMISSION_GRANTED is 2688 * returned. If it does not have the permission, PERMISSION_DENIED 2689 * is returned. 2690 * 2691 * @see #PERMISSION_GRANTED 2692 * @see #PERMISSION_DENIED 2693 */ 2694 @CheckResult 2695 public abstract int checkPermission(String permName, String pkgName); 2696 2697 /** 2698 * Checks whether a particular permissions has been revoked for a 2699 * package by policy. Typically the device owner or the profile owner 2700 * may apply such a policy. The user cannot grant policy revoked 2701 * permissions, hence the only way for an app to get such a permission 2702 * is by a policy change. 2703 * 2704 * @param permName The name of the permission you are checking for. 2705 * @param pkgName The name of the package you are checking against. 2706 * 2707 * @return Whether the permission is restricted by policy. 2708 */ 2709 @CheckResult 2710 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 2711 @NonNull String pkgName); 2712 2713 /** 2714 * Gets the package name of the component controlling runtime permissions. 2715 * 2716 * @return The package name. 2717 * 2718 * @hide 2719 */ 2720 public abstract String getPermissionControllerPackageName(); 2721 2722 /** 2723 * Add a new dynamic permission to the system. For this to work, your 2724 * package must have defined a permission tree through the 2725 * {@link android.R.styleable#AndroidManifestPermissionTree 2726 * <permission-tree>} tag in its manifest. A package can only add 2727 * permissions to trees that were defined by either its own package or 2728 * another with the same user id; a permission is in a tree if it 2729 * matches the name of the permission tree + ".": for example, 2730 * "com.foo.bar" is a member of the permission tree "com.foo". 2731 * 2732 * <p>It is good to make your permission tree name descriptive, because you 2733 * are taking possession of that entire set of permission names. Thus, it 2734 * must be under a domain you control, with a suffix that will not match 2735 * any normal permissions that may be declared in any applications that 2736 * are part of that domain. 2737 * 2738 * <p>New permissions must be added before 2739 * any .apks are installed that use those permissions. Permissions you 2740 * add through this method are remembered across reboots of the device. 2741 * If the given permission already exists, the info you supply here 2742 * will be used to update it. 2743 * 2744 * @param info Description of the permission to be added. 2745 * 2746 * @return Returns true if a new permission was created, false if an 2747 * existing one was updated. 2748 * 2749 * @throws SecurityException if you are not allowed to add the 2750 * given permission name. 2751 * 2752 * @see #removePermission(String) 2753 */ 2754 public abstract boolean addPermission(PermissionInfo info); 2755 2756 /** 2757 * Like {@link #addPermission(PermissionInfo)} but asynchronously 2758 * persists the package manager state after returning from the call, 2759 * allowing it to return quicker and batch a series of adds at the 2760 * expense of no guarantee the added permission will be retained if 2761 * the device is rebooted before it is written. 2762 */ 2763 public abstract boolean addPermissionAsync(PermissionInfo info); 2764 2765 /** 2766 * Removes a permission that was previously added with 2767 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 2768 * -- you are only allowed to remove permissions that you are allowed 2769 * to add. 2770 * 2771 * @param name The name of the permission to remove. 2772 * 2773 * @throws SecurityException if you are not allowed to remove the 2774 * given permission name. 2775 * 2776 * @see #addPermission(PermissionInfo) 2777 */ 2778 public abstract void removePermission(String name); 2779 2780 2781 /** 2782 * Permission flags set when granting or revoking a permission. 2783 * 2784 * @hide 2785 */ 2786 @SystemApi 2787 @IntDef({FLAG_PERMISSION_USER_SET, 2788 FLAG_PERMISSION_USER_FIXED, 2789 FLAG_PERMISSION_POLICY_FIXED, 2790 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 2791 FLAG_PERMISSION_SYSTEM_FIXED, 2792 FLAG_PERMISSION_GRANTED_BY_DEFAULT}) 2793 @Retention(RetentionPolicy.SOURCE) 2794 public @interface PermissionFlags {} 2795 2796 /** 2797 * Grant a runtime permission to an application which the application does not 2798 * already have. The permission must have been requested by the application. 2799 * If the application is not allowed to hold the permission, a {@link 2800 * java.lang.SecurityException} is thrown. 2801 * <p> 2802 * <strong>Note: </strong>Using this API requires holding 2803 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is 2804 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 2805 * </p> 2806 * 2807 * @param packageName The package to which to grant the permission. 2808 * @param permissionName The permission name to grant. 2809 * @param user The user for which to grant the permission. 2810 * 2811 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 2812 * @see android.content.pm.PackageManager.PermissionFlags 2813 * 2814 * @hide 2815 */ 2816 @SystemApi 2817 public abstract void grantRuntimePermission(@NonNull String packageName, 2818 @NonNull String permissionName, @NonNull UserHandle user); 2819 2820 /** 2821 * Revoke a runtime permission that was previously granted by {@link 2822 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 2823 * permission must have been requested by and granted to the application. 2824 * If the application is not allowed to hold the permission, a {@link 2825 * java.lang.SecurityException} is thrown. 2826 * <p> 2827 * <strong>Note: </strong>Using this API requires holding 2828 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is 2829 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 2830 * </p> 2831 * 2832 * @param packageName The package from which to revoke the permission. 2833 * @param permissionName The permission name to revoke. 2834 * @param user The user for which to revoke the permission. 2835 * 2836 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 2837 * @see android.content.pm.PackageManager.PermissionFlags 2838 * 2839 * @hide 2840 */ 2841 @SystemApi 2842 public abstract void revokeRuntimePermission(@NonNull String packageName, 2843 @NonNull String permissionName, @NonNull UserHandle user); 2844 2845 /** 2846 * Gets the state flags associated with a permission. 2847 * 2848 * @param permissionName The permission for which to get the flags. 2849 * @param packageName The package name for which to get the flags. 2850 * @param user The user for which to get permission flags. 2851 * @return The permission flags. 2852 * 2853 * @hide 2854 */ 2855 @SystemApi 2856 public abstract @PermissionFlags int getPermissionFlags(String permissionName, 2857 String packageName, @NonNull UserHandle user); 2858 2859 /** 2860 * Updates the flags associated with a permission by replacing the flags in 2861 * the specified mask with the provided flag values. 2862 * 2863 * @param permissionName The permission for which to update the flags. 2864 * @param packageName The package name for which to update the flags. 2865 * @param flagMask The flags which to replace. 2866 * @param flagValues The flags with which to replace. 2867 * @param user The user for which to update the permission flags. 2868 * 2869 * @hide 2870 */ 2871 @SystemApi 2872 public abstract void updatePermissionFlags(String permissionName, 2873 String packageName, @PermissionFlags int flagMask, int flagValues, 2874 @NonNull UserHandle user); 2875 2876 /** 2877 * Gets whether you should show UI with rationale for requesting a permission. 2878 * You should do this only if you do not have the permission and the context in 2879 * which the permission is requested does not clearly communicate to the user 2880 * what would be the benefit from grating this permission. 2881 * 2882 * @param permission A permission your app wants to request. 2883 * @return Whether you can show permission rationale UI. 2884 * 2885 * @hide 2886 */ 2887 public abstract boolean shouldShowRequestPermissionRationale(String permission); 2888 2889 /** 2890 * Returns an {@link android.content.Intent} suitable for passing to 2891 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 2892 * which prompts the user to grant permissions to this application. 2893 * 2894 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 2895 * 2896 * @hide 2897 */ 2898 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 2899 if (ArrayUtils.isEmpty(permissions)) { 2900 throw new NullPointerException("permission cannot be null or empty"); 2901 } 2902 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 2903 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 2904 intent.setPackage(getPermissionControllerPackageName()); 2905 return intent; 2906 } 2907 2908 /** 2909 * Compare the signatures of two packages to determine if the same 2910 * signature appears in both of them. If they do contain the same 2911 * signature, then they are allowed special privileges when working 2912 * with each other: they can share the same user-id, run instrumentation 2913 * against each other, etc. 2914 * 2915 * @param pkg1 First package name whose signature will be compared. 2916 * @param pkg2 Second package name whose signature will be compared. 2917 * 2918 * @return Returns an integer indicating whether all signatures on the 2919 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2920 * all signatures match or < 0 if there is not a match ({@link 2921 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2922 * 2923 * @see #checkSignatures(int, int) 2924 * @see #SIGNATURE_MATCH 2925 * @see #SIGNATURE_NO_MATCH 2926 * @see #SIGNATURE_UNKNOWN_PACKAGE 2927 */ 2928 @CheckResult 2929 public abstract int checkSignatures(String pkg1, String pkg2); 2930 2931 /** 2932 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 2933 * the two packages to be checked. This can be useful, for example, 2934 * when doing the check in an IPC, where the UID is the only identity 2935 * available. It is functionally identical to determining the package 2936 * associated with the UIDs and checking their signatures. 2937 * 2938 * @param uid1 First UID whose signature will be compared. 2939 * @param uid2 Second UID whose signature will be compared. 2940 * 2941 * @return Returns an integer indicating whether all signatures on the 2942 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2943 * all signatures match or < 0 if there is not a match ({@link 2944 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2945 * 2946 * @see #checkSignatures(String, String) 2947 * @see #SIGNATURE_MATCH 2948 * @see #SIGNATURE_NO_MATCH 2949 * @see #SIGNATURE_UNKNOWN_PACKAGE 2950 */ 2951 @CheckResult 2952 public abstract int checkSignatures(int uid1, int uid2); 2953 2954 /** 2955 * Retrieve the names of all packages that are associated with a particular 2956 * user id. In most cases, this will be a single package name, the package 2957 * that has been assigned that user id. Where there are multiple packages 2958 * sharing the same user id through the "sharedUserId" mechanism, all 2959 * packages with that id will be returned. 2960 * 2961 * @param uid The user id for which you would like to retrieve the 2962 * associated packages. 2963 * 2964 * @return Returns an array of one or more packages assigned to the user 2965 * id, or null if there are no known packages with the given id. 2966 */ 2967 public abstract String[] getPackagesForUid(int uid); 2968 2969 /** 2970 * Retrieve the official name associated with a user id. This name is 2971 * guaranteed to never change, though it is possible for the underlying 2972 * user id to be changed. That is, if you are storing information about 2973 * user ids in persistent storage, you should use the string returned 2974 * by this function instead of the raw user-id. 2975 * 2976 * @param uid The user id for which you would like to retrieve a name. 2977 * @return Returns a unique name for the given user id, or null if the 2978 * user id is not currently assigned. 2979 */ 2980 public abstract String getNameForUid(int uid); 2981 2982 /** 2983 * Return the user id associated with a shared user name. Multiple 2984 * applications can specify a shared user name in their manifest and thus 2985 * end up using a common uid. This might be used for new applications 2986 * that use an existing shared user name and need to know the uid of the 2987 * shared user. 2988 * 2989 * @param sharedUserName The shared user name whose uid is to be retrieved. 2990 * @return Returns the uid associated with the shared user, or NameNotFoundException 2991 * if the shared user name is not being used by any installed packages 2992 * @hide 2993 */ 2994 public abstract int getUidForSharedUser(String sharedUserName) 2995 throws NameNotFoundException; 2996 2997 /** 2998 * Return a List of all application packages that are installed on the 2999 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 3000 * applications including those deleted with {@code DONT_DELETE_DATA} (partially 3001 * installed apps with data directory) will be returned. 3002 * 3003 * @param flags Additional option flags. Use any combination of 3004 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3005 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 3006 * 3007 * @return Returns a List of ApplicationInfo objects, one for each application that 3008 * is installed on the device. In the unlikely case of there being 3009 * no installed applications, an empty list is returned. 3010 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 3011 * applications including those deleted with {@code DONT_DELETE_DATA} 3012 * (partially installed apps with data directory) will be returned. 3013 * 3014 * @see #GET_META_DATA 3015 * @see #GET_SHARED_LIBRARY_FILES 3016 * @see #GET_UNINSTALLED_PACKAGES 3017 */ 3018 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags); 3019 3020 /** 3021 * Gets the ephemeral applications the user recently used. Requires 3022 * holding "android.permission.ACCESS_EPHEMERAL_APPS". 3023 * 3024 * @return The ephemeral app list. 3025 * 3026 * @hide 3027 */ 3028 @RequiresPermission(Manifest.permission.ACCESS_EPHEMERAL_APPS) 3029 public abstract List<EphemeralApplicationInfo> getEphemeralApplications(); 3030 3031 /** 3032 * Gets the icon for an ephemeral application. 3033 * 3034 * @param packageName The app package name. 3035 * 3036 * @hide 3037 */ 3038 public abstract Drawable getEphemeralApplicationIcon(String packageName); 3039 3040 /** 3041 * Gets whether the caller is an ephemeral app. 3042 * 3043 * @return Whether caller is an ephemeral app. 3044 * 3045 * @see #setEphemeralCookie(byte[]) 3046 * @see #getEphemeralCookie() 3047 * @see #getEphemeralCookieMaxSizeBytes() 3048 */ 3049 public abstract boolean isEphemeralApplication(); 3050 3051 /** 3052 * Gets the maximum size in bytes of the cookie data an ephemeral app 3053 * can store on the device. 3054 * 3055 * @return The max cookie size in bytes. 3056 * 3057 * @see #isEphemeralApplication() 3058 * @see #setEphemeralCookie(byte[]) 3059 * @see #getEphemeralCookie() 3060 */ 3061 public abstract int getEphemeralCookieMaxSizeBytes(); 3062 3063 /** 3064 * Gets the ephemeral application cookie for this app. Non 3065 * ephemeral apps and apps that were ephemeral but were upgraded 3066 * to non-ephemeral can still access this API. For ephemeral apps 3067 * this cooke is cached for some time after uninstall while for 3068 * normal apps the cookie is deleted after the app is uninstalled. 3069 * The cookie is always present while the app is installed. 3070 * 3071 * @return The cookie. 3072 * 3073 * @see #isEphemeralApplication() 3074 * @see #setEphemeralCookie(byte[]) 3075 * @see #getEphemeralCookieMaxSizeBytes() 3076 */ 3077 public abstract @NonNull byte[] getEphemeralCookie(); 3078 3079 /** 3080 * Sets the ephemeral application cookie for the calling app. Non 3081 * ephemeral apps and apps that were ephemeral but were upgraded 3082 * to non-ephemeral can still access this API. For ephemeral apps 3083 * this cooke is cached for some time after uninstall while for 3084 * normal apps the cookie is deleted after the app is uninstalled. 3085 * The cookie is always present while the app is installed. The 3086 * cookie size is limited by {@link #getEphemeralCookieMaxSizeBytes()}. 3087 * 3088 * @param cookie The cookie data. 3089 * @return True if the cookie was set. 3090 * 3091 * @see #isEphemeralApplication() 3092 * @see #getEphemeralCookieMaxSizeBytes() 3093 * @see #getEphemeralCookie(); 3094 */ 3095 public abstract boolean setEphemeralCookie(@NonNull byte[] cookie); 3096 3097 /** 3098 * Get a list of shared libraries that are available on the 3099 * system. 3100 * 3101 * @return An array of shared library names that are 3102 * available on the system, or null if none are installed. 3103 * 3104 */ 3105 public abstract String[] getSystemSharedLibraryNames(); 3106 3107 /** 3108 * Get a list of features that are available on the 3109 * system. 3110 * 3111 * @return An array of FeatureInfo classes describing the features 3112 * that are available on the system, or null if there are none(!!). 3113 */ 3114 public abstract FeatureInfo[] getSystemAvailableFeatures(); 3115 3116 /** 3117 * Check whether the given feature name is one of the available 3118 * features as returned by {@link #getSystemAvailableFeatures()}. 3119 * 3120 * @return Returns true if the devices supports the feature, else 3121 * false. 3122 */ 3123 public abstract boolean hasSystemFeature(String name); 3124 3125 /** 3126 * Determine the best action to perform for a given Intent. This is how 3127 * {@link Intent#resolveActivity} finds an activity if a class has not 3128 * been explicitly specified. 3129 * 3130 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 3131 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 3132 * only flag. You need to do so to resolve the activity in the same way 3133 * that {@link android.content.Context#startActivity(Intent)} and 3134 * {@link android.content.Intent#resolveActivity(PackageManager) 3135 * Intent.resolveActivity(PackageManager)} do.</p> 3136 * 3137 * @param intent An intent containing all of the desired specification 3138 * (action, data, type, category, and/or component). 3139 * @param flags Additional option flags. The most important is 3140 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3141 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3142 * 3143 * @return Returns a ResolveInfo containing the final activity intent that 3144 * was determined to be the best action. Returns null if no 3145 * matching activity was found. If multiple matching activities are 3146 * found and there is no default set, returns a ResolveInfo 3147 * containing something else, such as the activity resolver. 3148 * 3149 * @see #MATCH_DEFAULT_ONLY 3150 * @see #GET_INTENT_FILTERS 3151 * @see #GET_RESOLVED_FILTER 3152 */ 3153 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags); 3154 3155 /** 3156 * Determine the best action to perform for a given Intent for a given user. This 3157 * is how {@link Intent#resolveActivity} finds an activity if a class has not 3158 * been explicitly specified. 3159 * 3160 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 3161 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 3162 * only flag. You need to do so to resolve the activity in the same way 3163 * that {@link android.content.Context#startActivity(Intent)} and 3164 * {@link android.content.Intent#resolveActivity(PackageManager) 3165 * Intent.resolveActivity(PackageManager)} do.</p> 3166 * 3167 * @param intent An intent containing all of the desired specification 3168 * (action, data, type, category, and/or component). 3169 * @param flags Additional option flags. The most important is 3170 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3171 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3172 * @param userId The user id. 3173 * 3174 * @return Returns a ResolveInfo containing the final activity intent that 3175 * was determined to be the best action. Returns null if no 3176 * matching activity was found. If multiple matching activities are 3177 * found and there is no default set, returns a ResolveInfo 3178 * containing something else, such as the activity resolver. 3179 * 3180 * @see #MATCH_DEFAULT_ONLY 3181 * @see #GET_INTENT_FILTERS 3182 * @see #GET_RESOLVED_FILTER 3183 * 3184 * @hide 3185 */ 3186 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags, 3187 int userId); 3188 3189 /** 3190 * Retrieve all activities that can be performed for the given intent. 3191 * 3192 * @param intent The desired intent as per resolveActivity(). 3193 * @param flags Additional option flags. The most important is 3194 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3195 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3196 * 3197 * You can also set {@link #MATCH_ALL} for preventing the filtering of the results. 3198 * 3199 * @return A List<ResolveInfo> containing one entry for each matching 3200 * Activity. These are ordered from best to worst match -- that 3201 * is, the first item in the list is what is returned by 3202 * {@link #resolveActivity}. If there are no matching activities, an empty 3203 * list is returned. 3204 * 3205 * @see #MATCH_DEFAULT_ONLY 3206 * @see #GET_INTENT_FILTERS 3207 * @see #GET_RESOLVED_FILTER 3208 */ 3209 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 3210 @ResolveInfoFlags int flags); 3211 3212 /** 3213 * Retrieve all activities that can be performed for the given intent, for a specific user. 3214 * 3215 * @param intent The desired intent as per resolveActivity(). 3216 * @param flags Additional option flags. The most important is 3217 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3218 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3219 * 3220 * You can also set {@link #MATCH_ALL} for preventing the filtering of the results. 3221 * 3222 * @return A List<ResolveInfo> containing one entry for each matching 3223 * Activity. These are ordered from best to worst match -- that 3224 * is, the first item in the list is what is returned by 3225 * {@link #resolveActivity}. If there are no matching activities, an empty 3226 * list is returned. 3227 * 3228 * @see #MATCH_DEFAULT_ONLY 3229 * @see #GET_INTENT_FILTERS 3230 * @see #GET_RESOLVED_FILTER 3231 * @hide 3232 */ 3233 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 3234 @ResolveInfoFlags int flags, int userId); 3235 3236 /** 3237 * Retrieve a set of activities that should be presented to the user as 3238 * similar options. This is like {@link #queryIntentActivities}, except it 3239 * also allows you to supply a list of more explicit Intents that you would 3240 * like to resolve to particular options, and takes care of returning the 3241 * final ResolveInfo list in a reasonable order, with no duplicates, based 3242 * on those inputs. 3243 * 3244 * @param caller The class name of the activity that is making the 3245 * request. This activity will never appear in the output 3246 * list. Can be null. 3247 * @param specifics An array of Intents that should be resolved to the 3248 * first specific results. Can be null. 3249 * @param intent The desired intent as per resolveActivity(). 3250 * @param flags Additional option flags. The most important is 3251 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3252 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3253 * 3254 * @return A List<ResolveInfo> containing one entry for each matching 3255 * Activity. These are ordered first by all of the intents resolved 3256 * in <var>specifics</var> and then any additional activities that 3257 * can handle <var>intent</var> but did not get included by one of 3258 * the <var>specifics</var> intents. If there are no matching 3259 * activities, an empty list is returned. 3260 * 3261 * @see #MATCH_DEFAULT_ONLY 3262 * @see #GET_INTENT_FILTERS 3263 * @see #GET_RESOLVED_FILTER 3264 */ 3265 public abstract List<ResolveInfo> queryIntentActivityOptions( 3266 ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags); 3267 3268 /** 3269 * Retrieve all receivers that can handle a broadcast of the given intent. 3270 * 3271 * @param intent The desired intent as per resolveActivity(). 3272 * @param flags Additional option flags. 3273 * 3274 * @return A List<ResolveInfo> containing one entry for each matching 3275 * Receiver. These are ordered from first to last in priority. If 3276 * there are no matching receivers, an empty list is returned. 3277 * 3278 * @see #MATCH_DEFAULT_ONLY 3279 * @see #GET_INTENT_FILTERS 3280 * @see #GET_RESOLVED_FILTER 3281 */ 3282 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 3283 @ResolveInfoFlags int flags); 3284 3285 /** 3286 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific 3287 * user. 3288 * 3289 * @param intent The desired intent as per resolveActivity(). 3290 * @param flags Additional option flags. 3291 * @param userId The userId of the user being queried. 3292 * 3293 * @return A List<ResolveInfo> containing one entry for each matching 3294 * Receiver. These are ordered from first to last in priority. If 3295 * there are no matching receivers, an empty list or {@code null} is returned. 3296 * 3297 * @see #MATCH_DEFAULT_ONLY 3298 * @see #GET_INTENT_FILTERS 3299 * @see #GET_RESOLVED_FILTER 3300 * @hide 3301 */ 3302 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 3303 @ResolveInfoFlags int flags, int userId); 3304 3305 /** 3306 * Determine the best service to handle for a given Intent. 3307 * 3308 * @param intent An intent containing all of the desired specification 3309 * (action, data, type, category, and/or component). 3310 * @param flags Additional option flags. 3311 * 3312 * @return Returns a ResolveInfo containing the final service intent that 3313 * was determined to be the best action. Returns null if no 3314 * matching service was found. 3315 * 3316 * @see #GET_INTENT_FILTERS 3317 * @see #GET_RESOLVED_FILTER 3318 */ 3319 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags); 3320 3321 /** 3322 * Retrieve all services that can match the given intent. 3323 * 3324 * @param intent The desired intent as per resolveService(). 3325 * @param flags Additional option flags. 3326 * 3327 * @return A List<ResolveInfo> containing one entry for each matching 3328 * ServiceInfo. These are ordered from best to worst match -- that 3329 * is, the first item in the list is what is returned by 3330 * resolveService(). If there are no matching services, an empty 3331 * list or {@code null} is returned. 3332 * 3333 * @see #GET_INTENT_FILTERS 3334 * @see #GET_RESOLVED_FILTER 3335 */ 3336 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 3337 @ResolveInfoFlags int flags); 3338 3339 /** 3340 * Retrieve all services that can match the given intent for a given user. 3341 * 3342 * @param intent The desired intent as per resolveService(). 3343 * @param flags Additional option flags. 3344 * @param userId The user id. 3345 * 3346 * @return A List<ResolveInfo> containing one entry for each matching 3347 * ServiceInfo. These are ordered from best to worst match -- that 3348 * is, the first item in the list is what is returned by 3349 * resolveService(). If there are no matching services, an empty 3350 * list or {@code null} is returned. 3351 * 3352 * @see #GET_INTENT_FILTERS 3353 * @see #GET_RESOLVED_FILTER 3354 * 3355 * @hide 3356 */ 3357 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 3358 @ResolveInfoFlags int flags, int userId); 3359 3360 /** {@hide} */ 3361 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 3362 Intent intent, @ResolveInfoFlags int flags, int userId); 3363 3364 /** 3365 * Retrieve all providers that can match the given intent. 3366 * 3367 * @param intent An intent containing all of the desired specification 3368 * (action, data, type, category, and/or component). 3369 * @param flags Additional option flags. 3370 * @return A List<ResolveInfo> containing one entry for each matching 3371 * ProviderInfo. These are ordered from best to worst match. If 3372 * there are no matching providers, an empty list or {@code null} is returned. 3373 * @see #GET_INTENT_FILTERS 3374 * @see #GET_RESOLVED_FILTER 3375 */ 3376 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, 3377 @ResolveInfoFlags int flags); 3378 3379 /** 3380 * Find a single content provider by its base path name. 3381 * 3382 * @param name The name of the provider to find. 3383 * @param flags Additional option flags. Currently should always be 0. 3384 * 3385 * @return ContentProviderInfo Information about the provider, if found, 3386 * else null. 3387 */ 3388 public abstract ProviderInfo resolveContentProvider(String name, 3389 @ComponentInfoFlags int flags); 3390 3391 /** 3392 * Find a single content provider by its base path name. 3393 * 3394 * @param name The name of the provider to find. 3395 * @param flags Additional option flags. Currently should always be 0. 3396 * @param userId The user id. 3397 * 3398 * @return ContentProviderInfo Information about the provider, if found, 3399 * else null. 3400 * @hide 3401 */ 3402 public abstract ProviderInfo resolveContentProviderAsUser(String name, 3403 @ComponentInfoFlags int flags, int userId); 3404 3405 /** 3406 * Retrieve content provider information. 3407 * 3408 * <p><em>Note: unlike most other methods, an empty result set is indicated 3409 * by a null return instead of an empty list.</em> 3410 * 3411 * @param processName If non-null, limits the returned providers to only 3412 * those that are hosted by the given process. If null, 3413 * all content providers are returned. 3414 * @param uid If <var>processName</var> is non-null, this is the required 3415 * uid owning the requested content providers. 3416 * @param flags Additional option flags. Currently should always be 0. 3417 * 3418 * @return A List<ContentProviderInfo> containing one entry for each 3419 * content provider either patching <var>processName</var> or, if 3420 * <var>processName</var> is null, all known content providers. 3421 * <em>If there are no matching providers, null is returned.</em> 3422 */ 3423 public abstract List<ProviderInfo> queryContentProviders( 3424 String processName, int uid, @ComponentInfoFlags int flags); 3425 3426 /** 3427 * Retrieve all of the information we know about a particular 3428 * instrumentation class. 3429 * 3430 * <p>Throws {@link NameNotFoundException} if instrumentation with the 3431 * given class name cannot be found on the system. 3432 * 3433 * @param className The full name (i.e. 3434 * com.google.apps.contacts.InstrumentList) of an 3435 * Instrumentation class. 3436 * @param flags Additional option flags. Currently should always be 0. 3437 * 3438 * @return InstrumentationInfo containing information about the 3439 * instrumentation. 3440 */ 3441 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className, 3442 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 3443 3444 /** 3445 * Retrieve information about available instrumentation code. May be used 3446 * to retrieve either all instrumentation code, or only the code targeting 3447 * a particular package. 3448 * 3449 * @param targetPackage If null, all instrumentation is returned; only the 3450 * instrumentation targeting this package name is 3451 * returned. 3452 * @param flags Additional option flags. Currently should always be 0. 3453 * 3454 * @return A List<InstrumentationInfo> containing one entry for each 3455 * matching available Instrumentation. Returns an empty list if 3456 * there is no instrumentation available for the given package. 3457 */ 3458 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage, 3459 @InstrumentationInfoFlags int flags); 3460 3461 /** 3462 * Retrieve an image from a package. This is a low-level API used by 3463 * the various package manager info structures (such as 3464 * {@link ComponentInfo} to implement retrieval of their associated 3465 * icon. 3466 * 3467 * @param packageName The name of the package that this icon is coming from. 3468 * Cannot be null. 3469 * @param resid The resource identifier of the desired image. Cannot be 0. 3470 * @param appInfo Overall information about <var>packageName</var>. This 3471 * may be null, in which case the application information will be retrieved 3472 * for you if needed; if you already have this information around, it can 3473 * be much more efficient to supply it here. 3474 * 3475 * @return Returns a Drawable holding the requested image. Returns null if 3476 * an image could not be found for any reason. 3477 */ 3478 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid, 3479 ApplicationInfo appInfo); 3480 3481 /** 3482 * Retrieve the icon associated with an activity. Given the full name of 3483 * an activity, retrieves the information about it and calls 3484 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 3485 * If the activity cannot be found, NameNotFoundException is thrown. 3486 * 3487 * @param activityName Name of the activity whose icon is to be retrieved. 3488 * 3489 * @return Returns the image of the icon, or the default activity icon if 3490 * it could not be found. Does not return null. 3491 * @throws NameNotFoundException Thrown if the resources for the given 3492 * activity could not be loaded. 3493 * 3494 * @see #getActivityIcon(Intent) 3495 */ 3496 public abstract Drawable getActivityIcon(ComponentName activityName) 3497 throws NameNotFoundException; 3498 3499 /** 3500 * Retrieve the icon associated with an Intent. If intent.getClassName() is 3501 * set, this simply returns the result of 3502 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 3503 * component and returns the icon associated with the resolved component. 3504 * If intent.getClassName() cannot be found or the Intent cannot be resolved 3505 * to a component, NameNotFoundException is thrown. 3506 * 3507 * @param intent The intent for which you would like to retrieve an icon. 3508 * 3509 * @return Returns the image of the icon, or the default activity icon if 3510 * it could not be found. Does not return null. 3511 * @throws NameNotFoundException Thrown if the resources for application 3512 * matching the given intent could not be loaded. 3513 * 3514 * @see #getActivityIcon(ComponentName) 3515 */ 3516 public abstract Drawable getActivityIcon(Intent intent) 3517 throws NameNotFoundException; 3518 3519 /** 3520 * Retrieve the banner associated with an activity. Given the full name of 3521 * an activity, retrieves the information about it and calls 3522 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 3523 * banner. If the activity cannot be found, NameNotFoundException is thrown. 3524 * 3525 * @param activityName Name of the activity whose banner is to be retrieved. 3526 * @return Returns the image of the banner, or null if the activity has no 3527 * banner specified. 3528 * @throws NameNotFoundException Thrown if the resources for the given 3529 * activity could not be loaded. 3530 * @see #getActivityBanner(Intent) 3531 */ 3532 public abstract Drawable getActivityBanner(ComponentName activityName) 3533 throws NameNotFoundException; 3534 3535 /** 3536 * Retrieve the banner associated with an Intent. If intent.getClassName() 3537 * is set, this simply returns the result of 3538 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 3539 * intent's component and returns the banner associated with the resolved 3540 * component. If intent.getClassName() cannot be found or the Intent cannot 3541 * be resolved to a component, NameNotFoundException is thrown. 3542 * 3543 * @param intent The intent for which you would like to retrieve a banner. 3544 * @return Returns the image of the banner, or null if the activity has no 3545 * banner specified. 3546 * @throws NameNotFoundException Thrown if the resources for application 3547 * matching the given intent could not be loaded. 3548 * @see #getActivityBanner(ComponentName) 3549 */ 3550 public abstract Drawable getActivityBanner(Intent intent) 3551 throws NameNotFoundException; 3552 3553 /** 3554 * Return the generic icon for an activity that is used when no specific 3555 * icon is defined. 3556 * 3557 * @return Drawable Image of the icon. 3558 */ 3559 public abstract Drawable getDefaultActivityIcon(); 3560 3561 /** 3562 * Retrieve the icon associated with an application. If it has not defined 3563 * an icon, the default app icon is returned. Does not return null. 3564 * 3565 * @param info Information about application being queried. 3566 * 3567 * @return Returns the image of the icon, or the default application icon 3568 * if it could not be found. 3569 * 3570 * @see #getApplicationIcon(String) 3571 */ 3572 public abstract Drawable getApplicationIcon(ApplicationInfo info); 3573 3574 /** 3575 * Retrieve the icon associated with an application. Given the name of the 3576 * application's package, retrieves the information about it and calls 3577 * getApplicationIcon() to return its icon. If the application cannot be 3578 * found, NameNotFoundException is thrown. 3579 * 3580 * @param packageName Name of the package whose application icon is to be 3581 * retrieved. 3582 * 3583 * @return Returns the image of the icon, or the default application icon 3584 * if it could not be found. Does not return null. 3585 * @throws NameNotFoundException Thrown if the resources for the given 3586 * application could not be loaded. 3587 * 3588 * @see #getApplicationIcon(ApplicationInfo) 3589 */ 3590 public abstract Drawable getApplicationIcon(String packageName) 3591 throws NameNotFoundException; 3592 3593 /** 3594 * Retrieve the banner associated with an application. 3595 * 3596 * @param info Information about application being queried. 3597 * @return Returns the image of the banner or null if the application has no 3598 * banner specified. 3599 * @see #getApplicationBanner(String) 3600 */ 3601 public abstract Drawable getApplicationBanner(ApplicationInfo info); 3602 3603 /** 3604 * Retrieve the banner associated with an application. Given the name of the 3605 * application's package, retrieves the information about it and calls 3606 * getApplicationIcon() to return its banner. If the application cannot be 3607 * found, NameNotFoundException is thrown. 3608 * 3609 * @param packageName Name of the package whose application banner is to be 3610 * retrieved. 3611 * @return Returns the image of the banner or null if the application has no 3612 * banner specified. 3613 * @throws NameNotFoundException Thrown if the resources for the given 3614 * application could not be loaded. 3615 * @see #getApplicationBanner(ApplicationInfo) 3616 */ 3617 public abstract Drawable getApplicationBanner(String packageName) 3618 throws NameNotFoundException; 3619 3620 /** 3621 * Retrieve the logo associated with an activity. Given the full name of an 3622 * activity, retrieves the information about it and calls 3623 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 3624 * logo. If the activity cannot be found, NameNotFoundException is thrown. 3625 * 3626 * @param activityName Name of the activity whose logo is to be retrieved. 3627 * @return Returns the image of the logo or null if the activity has no logo 3628 * specified. 3629 * @throws NameNotFoundException Thrown if the resources for the given 3630 * activity could not be loaded. 3631 * @see #getActivityLogo(Intent) 3632 */ 3633 public abstract Drawable getActivityLogo(ComponentName activityName) 3634 throws NameNotFoundException; 3635 3636 /** 3637 * Retrieve the logo associated with an Intent. If intent.getClassName() is 3638 * set, this simply returns the result of 3639 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 3640 * component and returns the logo associated with the resolved component. 3641 * If intent.getClassName() cannot be found or the Intent cannot be resolved 3642 * to a component, NameNotFoundException is thrown. 3643 * 3644 * @param intent The intent for which you would like to retrieve a logo. 3645 * 3646 * @return Returns the image of the logo, or null if the activity has no 3647 * logo specified. 3648 * 3649 * @throws NameNotFoundException Thrown if the resources for application 3650 * matching the given intent could not be loaded. 3651 * 3652 * @see #getActivityLogo(ComponentName) 3653 */ 3654 public abstract Drawable getActivityLogo(Intent intent) 3655 throws NameNotFoundException; 3656 3657 /** 3658 * Retrieve the logo associated with an application. If it has not specified 3659 * a logo, this method returns null. 3660 * 3661 * @param info Information about application being queried. 3662 * 3663 * @return Returns the image of the logo, or null if no logo is specified 3664 * by the application. 3665 * 3666 * @see #getApplicationLogo(String) 3667 */ 3668 public abstract Drawable getApplicationLogo(ApplicationInfo info); 3669 3670 /** 3671 * Retrieve the logo associated with an application. Given the name of the 3672 * application's package, retrieves the information about it and calls 3673 * getApplicationLogo() to return its logo. If the application cannot be 3674 * found, NameNotFoundException is thrown. 3675 * 3676 * @param packageName Name of the package whose application logo is to be 3677 * retrieved. 3678 * 3679 * @return Returns the image of the logo, or null if no application logo 3680 * has been specified. 3681 * 3682 * @throws NameNotFoundException Thrown if the resources for the given 3683 * application could not be loaded. 3684 * 3685 * @see #getApplicationLogo(ApplicationInfo) 3686 */ 3687 public abstract Drawable getApplicationLogo(String packageName) 3688 throws NameNotFoundException; 3689 3690 /** 3691 * If the target user is a managed profile of the calling user or if the 3692 * target user is the caller and is itself a managed profile, then this 3693 * returns a badged copy of the given icon to be able to distinguish it from 3694 * the original icon. For badging an arbitrary drawable use 3695 * {@link #getUserBadgedDrawableForDensity( 3696 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 3697 * <p> 3698 * If the original drawable is a BitmapDrawable and the backing bitmap is 3699 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 3700 * is performed in place and the original drawable is returned. 3701 * </p> 3702 * 3703 * @param icon The icon to badge. 3704 * @param user The target user. 3705 * @return A drawable that combines the original icon and a badge as 3706 * determined by the system. 3707 */ 3708 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 3709 3710 /** 3711 * If the target user is a managed profile of the calling user or the caller 3712 * is itself a managed profile, then this returns a badged copy of the given 3713 * drawable allowing the user to distinguish it from the original drawable. 3714 * The caller can specify the location in the bounds of the drawable to be 3715 * badged where the badge should be applied as well as the density of the 3716 * badge to be used. 3717 * <p> 3718 * If the original drawable is a BitmapDrawable and the backing bitmap is 3719 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading 3720 * is performed in place and the original drawable is returned. 3721 * </p> 3722 * 3723 * @param drawable The drawable to badge. 3724 * @param user The target user. 3725 * @param badgeLocation Where in the bounds of the badged drawable to place 3726 * the badge. If not provided, the badge is applied on top of the entire 3727 * drawable being badged. 3728 * @param badgeDensity The optional desired density for the badge as per 3729 * {@link android.util.DisplayMetrics#densityDpi}. If not provided, 3730 * the density of the display is used. 3731 * @return A drawable that combines the original drawable and a badge as 3732 * determined by the system. 3733 */ 3734 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 3735 UserHandle user, Rect badgeLocation, int badgeDensity); 3736 3737 /** 3738 * If the target user is a managed profile of the calling user or the caller 3739 * is itself a managed profile, then this returns a drawable to use as a small 3740 * icon to include in a view to distinguish it from the original icon. 3741 * 3742 * @param user The target user. 3743 * @param density The optional desired density for the badge as per 3744 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 3745 * the density of the current display is used. 3746 * @return the drawable or null if no drawable is required. 3747 * @hide 3748 */ 3749 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 3750 3751 /** 3752 * If the target user is a managed profile of the calling user or the caller 3753 * is itself a managed profile, then this returns a copy of the label with 3754 * badging for accessibility services like talkback. E.g. passing in "Email" 3755 * and it might return "Work Email" for Email in the work profile. 3756 * 3757 * @param label The label to change. 3758 * @param user The target user. 3759 * @return A label that combines the original label and a badge as 3760 * determined by the system. 3761 */ 3762 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 3763 3764 /** 3765 * Retrieve text from a package. This is a low-level API used by 3766 * the various package manager info structures (such as 3767 * {@link ComponentInfo} to implement retrieval of their associated 3768 * labels and other text. 3769 * 3770 * @param packageName The name of the package that this text is coming from. 3771 * Cannot be null. 3772 * @param resid The resource identifier of the desired text. Cannot be 0. 3773 * @param appInfo Overall information about <var>packageName</var>. This 3774 * may be null, in which case the application information will be retrieved 3775 * for you if needed; if you already have this information around, it can 3776 * be much more efficient to supply it here. 3777 * 3778 * @return Returns a CharSequence holding the requested text. Returns null 3779 * if the text could not be found for any reason. 3780 */ 3781 public abstract CharSequence getText(String packageName, @StringRes int resid, 3782 ApplicationInfo appInfo); 3783 3784 /** 3785 * Retrieve an XML file from a package. This is a low-level API used to 3786 * retrieve XML meta data. 3787 * 3788 * @param packageName The name of the package that this xml is coming from. 3789 * Cannot be null. 3790 * @param resid The resource identifier of the desired xml. Cannot be 0. 3791 * @param appInfo Overall information about <var>packageName</var>. This 3792 * may be null, in which case the application information will be retrieved 3793 * for you if needed; if you already have this information around, it can 3794 * be much more efficient to supply it here. 3795 * 3796 * @return Returns an XmlPullParser allowing you to parse out the XML 3797 * data. Returns null if the xml resource could not be found for any 3798 * reason. 3799 */ 3800 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid, 3801 ApplicationInfo appInfo); 3802 3803 /** 3804 * Return the label to use for this application. 3805 * 3806 * @return Returns the label associated with this application, or null if 3807 * it could not be found for any reason. 3808 * @param info The application to get the label of. 3809 */ 3810 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 3811 3812 /** 3813 * Retrieve the resources associated with an activity. Given the full 3814 * name of an activity, retrieves the information about it and calls 3815 * getResources() to return its application's resources. If the activity 3816 * cannot be found, NameNotFoundException is thrown. 3817 * 3818 * @param activityName Name of the activity whose resources are to be 3819 * retrieved. 3820 * 3821 * @return Returns the application's Resources. 3822 * @throws NameNotFoundException Thrown if the resources for the given 3823 * application could not be loaded. 3824 * 3825 * @see #getResourcesForApplication(ApplicationInfo) 3826 */ 3827 public abstract Resources getResourcesForActivity(ComponentName activityName) 3828 throws NameNotFoundException; 3829 3830 /** 3831 * Retrieve the resources for an application. Throws NameNotFoundException 3832 * if the package is no longer installed. 3833 * 3834 * @param app Information about the desired application. 3835 * 3836 * @return Returns the application's Resources. 3837 * @throws NameNotFoundException Thrown if the resources for the given 3838 * application could not be loaded (most likely because it was uninstalled). 3839 */ 3840 public abstract Resources getResourcesForApplication(ApplicationInfo app) 3841 throws NameNotFoundException; 3842 3843 /** 3844 * Retrieve the resources associated with an application. Given the full 3845 * package name of an application, retrieves the information about it and 3846 * calls getResources() to return its application's resources. If the 3847 * appPackageName cannot be found, NameNotFoundException is thrown. 3848 * 3849 * @param appPackageName Package name of the application whose resources 3850 * are to be retrieved. 3851 * 3852 * @return Returns the application's Resources. 3853 * @throws NameNotFoundException Thrown if the resources for the given 3854 * application could not be loaded. 3855 * 3856 * @see #getResourcesForApplication(ApplicationInfo) 3857 */ 3858 public abstract Resources getResourcesForApplication(String appPackageName) 3859 throws NameNotFoundException; 3860 3861 /** @hide */ 3862 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId) 3863 throws NameNotFoundException; 3864 3865 /** 3866 * Retrieve overall information about an application package defined 3867 * in a package archive file 3868 * 3869 * @param archiveFilePath The path to the archive file 3870 * @param flags Additional option flags. Use any combination of 3871 * {@link #GET_ACTIVITIES}, 3872 * {@link #GET_GIDS}, 3873 * {@link #GET_CONFIGURATIONS}, 3874 * {@link #GET_INSTRUMENTATION}, 3875 * {@link #GET_PERMISSIONS}, 3876 * {@link #GET_PROVIDERS}, 3877 * {@link #GET_RECEIVERS}, 3878 * {@link #GET_SERVICES}, 3879 * {@link #GET_SIGNATURES}, to modify the data returned. 3880 * 3881 * @return Returns the information about the package. Returns 3882 * null if the package could not be successfully parsed. 3883 * 3884 * @see #GET_ACTIVITIES 3885 * @see #GET_GIDS 3886 * @see #GET_CONFIGURATIONS 3887 * @see #GET_INSTRUMENTATION 3888 * @see #GET_PERMISSIONS 3889 * @see #GET_PROVIDERS 3890 * @see #GET_RECEIVERS 3891 * @see #GET_SERVICES 3892 * @see #GET_SIGNATURES 3893 * 3894 */ 3895 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) { 3896 final PackageParser parser = new PackageParser(); 3897 final File apkFile = new File(archiveFilePath); 3898 try { 3899 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 3900 if ((flags & GET_SIGNATURES) != 0) { 3901 parser.collectCertificates(pkg, 0); 3902 } 3903 PackageUserState state = new PackageUserState(); 3904 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 3905 } catch (PackageParserException e) { 3906 return null; 3907 } 3908 } 3909 3910 /** 3911 * @hide Install a package. Since this may take a little while, the result 3912 * will be posted back to the given observer. An installation will 3913 * fail if the calling context lacks the 3914 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if 3915 * the package named in the package file's manifest is already 3916 * installed, or if there's no space available on the device. 3917 * @param packageURI The location of the package file to install. This can 3918 * be a 'file:' or a 'content:' URI. 3919 * @param observer An observer callback to get notified when the package 3920 * installation is complete. 3921 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3922 * will be called when that happens. This parameter must not be 3923 * null. 3924 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3925 * {@link #INSTALL_REPLACE_EXISTING}, 3926 * {@link #INSTALL_ALLOW_TEST}. 3927 * @param installerPackageName Optional package name of the application that 3928 * is performing the installation. This identifies which market 3929 * the package came from. 3930 * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int, 3931 * String)} instead. This method will continue to be supported 3932 * but the older observer interface will not get additional 3933 * failure details. 3934 */ 3935 // @SystemApi 3936 public abstract void installPackage( 3937 Uri packageURI, IPackageInstallObserver observer, int flags, 3938 String installerPackageName); 3939 3940 /** 3941 * Similar to 3942 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3943 * with an extra verification file provided. 3944 * 3945 * @param packageURI The location of the package file to install. This can 3946 * be a 'file:' or a 'content:' URI. 3947 * @param observer An observer callback to get notified when the package 3948 * installation is complete. 3949 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3950 * will be called when that happens. This parameter must not be 3951 * null. 3952 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3953 * {@link #INSTALL_REPLACE_EXISTING}, 3954 * {@link #INSTALL_ALLOW_TEST}. 3955 * @param installerPackageName Optional package name of the application that 3956 * is performing the installation. This identifies which market 3957 * the package came from. 3958 * @param verificationURI The location of the supplementary verification 3959 * file. This can be a 'file:' or a 'content:' URI. May be 3960 * {@code null}. 3961 * @param encryptionParams if the package to be installed is encrypted, 3962 * these parameters describing the encryption and authentication 3963 * used. May be {@code null}. 3964 * @hide 3965 * @deprecated Use {@link #installPackageWithVerification(Uri, 3966 * PackageInstallObserver, int, String, Uri, 3967 * ContainerEncryptionParams)} instead. This method will 3968 * continue to be supported but the older observer interface 3969 * will not get additional failure details. 3970 */ 3971 // @SystemApi 3972 public abstract void installPackageWithVerification(Uri packageURI, 3973 IPackageInstallObserver observer, int flags, String installerPackageName, 3974 Uri verificationURI, 3975 ContainerEncryptionParams encryptionParams); 3976 3977 /** 3978 * Similar to 3979 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3980 * with an extra verification information provided. 3981 * 3982 * @param packageURI The location of the package file to install. This can 3983 * be a 'file:' or a 'content:' URI. 3984 * @param observer An observer callback to get notified when the package 3985 * installation is complete. 3986 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3987 * will be called when that happens. This parameter must not be 3988 * null. 3989 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3990 * {@link #INSTALL_REPLACE_EXISTING}, 3991 * {@link #INSTALL_ALLOW_TEST}. 3992 * @param installerPackageName Optional package name of the application that 3993 * is performing the installation. This identifies which market 3994 * the package came from. 3995 * @param verificationParams an object that holds signal information to 3996 * assist verification. May be {@code null}. 3997 * @param encryptionParams if the package to be installed is encrypted, 3998 * these parameters describing the encryption and authentication 3999 * used. May be {@code null}. 4000 * @hide 4001 * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri, 4002 * PackageInstallObserver, int, String, VerificationParams, 4003 * ContainerEncryptionParams)} instead. This method will 4004 * continue to be supported but the older observer interface 4005 * will not get additional failure details. 4006 */ 4007 @Deprecated 4008 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 4009 IPackageInstallObserver observer, int flags, String installerPackageName, 4010 VerificationParams verificationParams, 4011 ContainerEncryptionParams encryptionParams); 4012 4013 // Package-install variants that take the new, expanded form of observer interface. 4014 // Note that these *also* take the original observer type and will redundantly 4015 // report the same information to that observer if supplied; but it is not required. 4016 4017 /** 4018 * @hide 4019 * 4020 * Install a package. Since this may take a little while, the result will 4021 * be posted back to the given observer. An installation will fail if the calling context 4022 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the 4023 * package named in the package file's manifest is already installed, or if there's no space 4024 * available on the device. 4025 * 4026 * @param packageURI The location of the package file to install. This can be a 'file:' or a 4027 * 'content:' URI. 4028 * @param observer An observer callback to get notified when the package installation is 4029 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 4030 * called when that happens. This parameter must not be null. 4031 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 4032 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 4033 * @param installerPackageName Optional package name of the application that is performing the 4034 * installation. This identifies which market the package came from. 4035 */ 4036 public abstract void installPackage( 4037 Uri packageURI, PackageInstallObserver observer, 4038 int flags, String installerPackageName); 4039 4040 4041 /** 4042 * @hide 4043 * Install a package. Since this may take a little while, the result will be 4044 * posted back to the given observer. An installation will fail if the package named 4045 * in the package file's manifest is already installed, or if there's no space 4046 * available on the device. 4047 * @param packageURI The location of the package file to install. This can be a 'file:' or a 4048 * 'content:' URI. 4049 * @param observer An observer callback to get notified when the package installation is 4050 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 4051 * called when that happens. This parameter must not be null. 4052 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 4053 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 4054 * @param installerPackageName Optional package name of the application that is performing the 4055 * installation. This identifies which market the package came from. 4056 * @param userId The user id. 4057 */ 4058 @RequiresPermission(anyOf = { 4059 Manifest.permission.INSTALL_PACKAGES, 4060 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4061 public abstract void installPackageAsUser( 4062 Uri packageURI, PackageInstallObserver observer, int flags, 4063 String installerPackageName, int userId); 4064 4065 /** 4066 * Similar to 4067 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 4068 * with an extra verification file provided. 4069 * 4070 * @param packageURI The location of the package file to install. This can 4071 * be a 'file:' or a 'content:' URI. 4072 * @param observer An observer callback to get notified when the package installation is 4073 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 4074 * called when that happens. This parameter must not be null. 4075 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 4076 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 4077 * @param installerPackageName Optional package name of the application that 4078 * is performing the installation. This identifies which market 4079 * the package came from. 4080 * @param verificationURI The location of the supplementary verification 4081 * file. This can be a 'file:' or a 'content:' URI. May be 4082 * {@code null}. 4083 * @param encryptionParams if the package to be installed is encrypted, 4084 * these parameters describing the encryption and authentication 4085 * used. May be {@code null}. 4086 * @hide 4087 */ 4088 public abstract void installPackageWithVerification(Uri packageURI, 4089 PackageInstallObserver observer, int flags, String installerPackageName, 4090 Uri verificationURI, 4091 ContainerEncryptionParams encryptionParams); 4092 4093 /** 4094 * Similar to 4095 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 4096 * with an extra verification information provided. 4097 * 4098 * @param packageURI The location of the package file to install. This can 4099 * be a 'file:' or a 'content:' URI. 4100 * @param observer An observer callback to get notified when the package installation is 4101 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 4102 * called when that happens. This parameter must not be null. 4103 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 4104 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 4105 * @param installerPackageName Optional package name of the application that 4106 * is performing the installation. This identifies which market 4107 * the package came from. 4108 * @param verificationParams an object that holds signal information to 4109 * assist verification. May be {@code null}. 4110 * @param encryptionParams if the package to be installed is encrypted, 4111 * these parameters describing the encryption and authentication 4112 * used. May be {@code null}. 4113 * 4114 * @hide 4115 */ 4116 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 4117 PackageInstallObserver observer, int flags, String installerPackageName, 4118 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams); 4119 4120 /** 4121 * If there is already an application with the given package name installed 4122 * on the system for other users, also install it for the calling user. 4123 * @hide 4124 */ 4125 // @SystemApi 4126 public abstract int installExistingPackage(String packageName) throws NameNotFoundException; 4127 4128 /** 4129 * If there is already an application with the given package name installed 4130 * on the system for other users, also install it for the specified user. 4131 * @hide 4132 */ 4133 @RequiresPermission(anyOf = { 4134 Manifest.permission.INSTALL_PACKAGES, 4135 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4136 public abstract int installExistingPackageAsUser(String packageName, int userId) 4137 throws NameNotFoundException; 4138 4139 /** 4140 * Allows a package listening to the 4141 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4142 * broadcast} to respond to the package manager. The response must include 4143 * the {@code verificationCode} which is one of 4144 * {@link PackageManager#VERIFICATION_ALLOW} or 4145 * {@link PackageManager#VERIFICATION_REJECT}. 4146 * 4147 * @param id pending package identifier as passed via the 4148 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4149 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 4150 * or {@link PackageManager#VERIFICATION_REJECT}. 4151 * @throws SecurityException if the caller does not have the 4152 * PACKAGE_VERIFICATION_AGENT permission. 4153 */ 4154 public abstract void verifyPendingInstall(int id, int verificationCode); 4155 4156 /** 4157 * Allows a package listening to the 4158 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4159 * broadcast} to extend the default timeout for a response and declare what 4160 * action to perform after the timeout occurs. The response must include 4161 * the {@code verificationCodeAtTimeout} which is one of 4162 * {@link PackageManager#VERIFICATION_ALLOW} or 4163 * {@link PackageManager#VERIFICATION_REJECT}. 4164 * 4165 * This method may only be called once per package id. Additional calls 4166 * will have no effect. 4167 * 4168 * @param id pending package identifier as passed via the 4169 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4170 * @param verificationCodeAtTimeout either 4171 * {@link PackageManager#VERIFICATION_ALLOW} or 4172 * {@link PackageManager#VERIFICATION_REJECT}. If 4173 * {@code verificationCodeAtTimeout} is neither 4174 * {@link PackageManager#VERIFICATION_ALLOW} or 4175 * {@link PackageManager#VERIFICATION_REJECT}, then 4176 * {@code verificationCodeAtTimeout} will default to 4177 * {@link PackageManager#VERIFICATION_REJECT}. 4178 * @param millisecondsToDelay the amount of time requested for the timeout. 4179 * Must be positive and less than 4180 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 4181 * {@code millisecondsToDelay} is out of bounds, 4182 * {@code millisecondsToDelay} will be set to the closest in 4183 * bounds value; namely, 0 or 4184 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 4185 * @throws SecurityException if the caller does not have the 4186 * PACKAGE_VERIFICATION_AGENT permission. 4187 */ 4188 public abstract void extendVerificationTimeout(int id, 4189 int verificationCodeAtTimeout, long millisecondsToDelay); 4190 4191 /** 4192 * Allows a package listening to the 4193 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification 4194 * broadcast} to respond to the package manager. The response must include 4195 * the {@code verificationCode} which is one of 4196 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 4197 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4198 * 4199 * @param verificationId pending package identifier as passed via the 4200 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4201 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 4202 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4203 * @param outFailedDomains a list of failed domains if the verificationCode is 4204 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 4205 * @throws SecurityException if the caller does not have the 4206 * INTENT_FILTER_VERIFICATION_AGENT permission. 4207 * 4208 * @hide 4209 */ 4210 @SystemApi 4211 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 4212 List<String> outFailedDomains); 4213 4214 /** 4215 * Get the status of a Domain Verification Result for an IntentFilter. This is 4216 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4217 * {@link android.content.IntentFilter#getAutoVerify()} 4218 * 4219 * This is used by the ResolverActivity to change the status depending on what the User select 4220 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4221 * for a domain. 4222 * 4223 * @param packageName The package name of the Activity associated with the IntentFilter. 4224 * @param userId The user id. 4225 * 4226 * @return The status to set to. This can be 4227 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4228 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4229 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 4230 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 4231 * 4232 * @hide 4233 */ 4234 public abstract int getIntentVerificationStatusAsUser(String packageName, int userId); 4235 4236 /** 4237 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 4238 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4239 * {@link android.content.IntentFilter#getAutoVerify()} 4240 * 4241 * This is used by the ResolverActivity to change the status depending on what the User select 4242 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4243 * for a domain. 4244 * 4245 * @param packageName The package name of the Activity associated with the IntentFilter. 4246 * @param status The status to set to. This can be 4247 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4248 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4249 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 4250 * @param userId The user id. 4251 * 4252 * @return true if the status has been set. False otherwise. 4253 * 4254 * @hide 4255 */ 4256 public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status, 4257 int userId); 4258 4259 /** 4260 * Get the list of IntentFilterVerificationInfo for a specific package and User. 4261 * 4262 * @param packageName the package name. When this parameter is set to a non null value, 4263 * the results will be filtered by the package name provided. 4264 * Otherwise, there will be no filtering and it will return a list 4265 * corresponding for all packages 4266 * 4267 * @return a list of IntentFilterVerificationInfo for a specific package. 4268 * 4269 * @hide 4270 */ 4271 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 4272 String packageName); 4273 4274 /** 4275 * Get the list of IntentFilter for a specific package. 4276 * 4277 * @param packageName the package name. This parameter is set to a non null value, 4278 * the list will contain all the IntentFilter for that package. 4279 * Otherwise, the list will be empty. 4280 * 4281 * @return a list of IntentFilter for a specific package. 4282 * 4283 * @hide 4284 */ 4285 public abstract List<IntentFilter> getAllIntentFilters(String packageName); 4286 4287 /** 4288 * Get the default Browser package name for a specific user. 4289 * 4290 * @param userId The user id. 4291 * 4292 * @return the package name of the default Browser for the specified user. If the user id passed 4293 * is -1 (all users) it will return a null value. 4294 * 4295 * @hide 4296 */ 4297 public abstract String getDefaultBrowserPackageNameAsUser(int userId); 4298 4299 /** 4300 * Set the default Browser package name for a specific user. 4301 * 4302 * @param packageName The package name of the default Browser. 4303 * @param userId The user id. 4304 * 4305 * @return true if the default Browser for the specified user has been set, 4306 * otherwise return false. If the user id passed is -1 (all users) this call will not 4307 * do anything and just return false. 4308 * 4309 * @hide 4310 */ 4311 public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName, int userId); 4312 4313 /** 4314 * Change the installer associated with a given package. There are limitations 4315 * on how the installer package can be changed; in particular: 4316 * <ul> 4317 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 4318 * is not signed with the same certificate as the calling application. 4319 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 4320 * has an installer package, and that installer package is not signed with 4321 * the same certificate as the calling application. 4322 * </ul> 4323 * 4324 * @param targetPackage The installed package whose installer will be changed. 4325 * @param installerPackageName The package name of the new installer. May be 4326 * null to clear the association. 4327 */ 4328 public abstract void setInstallerPackageName(String targetPackage, 4329 String installerPackageName); 4330 4331 /** 4332 * Attempts to delete a package. Since this may take a little while, the result will 4333 * be posted back to the given observer. A deletion will fail if the calling context 4334 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 4335 * named package cannot be found, or if the named package is a "system package". 4336 * (TODO: include pointer to documentation on "system packages") 4337 * 4338 * @param packageName The name of the package to delete 4339 * @param observer An observer callback to get notified when the package deletion is 4340 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 4341 * called when that happens. observer may be null to indicate that no callback is desired. 4342 * @param flags Possible values: {@link #DELETE_KEEP_DATA}, 4343 * {@link #DELETE_ALL_USERS}. 4344 * 4345 * @hide 4346 */ 4347 // @SystemApi 4348 public abstract void deletePackage( 4349 String packageName, IPackageDeleteObserver observer, int flags); 4350 4351 /** 4352 * Attempts to delete a package. Since this may take a little while, the result will 4353 * be posted back to the given observer. A deletion will fail if the named package cannot be 4354 * found, or if the named package is a "system package". 4355 * (TODO: include pointer to documentation on "system packages") 4356 * 4357 * @param packageName The name of the package to delete 4358 * @param observer An observer callback to get notified when the package deletion is 4359 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 4360 * called when that happens. observer may be null to indicate that no callback is desired. 4361 * @param flags Possible values: {@link #DELETE_KEEP_DATA}, {@link #DELETE_ALL_USERS}. 4362 * @param userId The user Id 4363 * 4364 * @hide 4365 */ 4366 @RequiresPermission(anyOf = { 4367 Manifest.permission.DELETE_PACKAGES, 4368 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4369 public abstract void deletePackageAsUser( 4370 String packageName, IPackageDeleteObserver observer, int flags, int userId); 4371 4372 /** 4373 * Retrieve the package name of the application that installed a package. This identifies 4374 * which market the package came from. 4375 * 4376 * @param packageName The name of the package to query 4377 */ 4378 public abstract String getInstallerPackageName(String packageName); 4379 4380 /** 4381 * Attempts to clear the user data directory of an application. 4382 * Since this may take a little while, the result will 4383 * be posted back to the given observer. A deletion will fail if the 4384 * named package cannot be found, or if the named package is a "system package". 4385 * 4386 * @param packageName The name of the package 4387 * @param observer An observer callback to get notified when the operation is finished 4388 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 4389 * will be called when that happens. observer may be null to indicate that 4390 * no callback is desired. 4391 * 4392 * @hide 4393 */ 4394 public abstract void clearApplicationUserData(String packageName, 4395 IPackageDataObserver observer); 4396 /** 4397 * Attempts to delete the cache files associated with an application. 4398 * Since this may take a little while, the result will 4399 * be posted back to the given observer. A deletion will fail if the calling context 4400 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 4401 * named package cannot be found, or if the named package is a "system package". 4402 * 4403 * @param packageName The name of the package to delete 4404 * @param observer An observer callback to get notified when the cache file deletion 4405 * is complete. 4406 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 4407 * will be called when that happens. observer may be null to indicate that 4408 * no callback is desired. 4409 * 4410 * @hide 4411 */ 4412 public abstract void deleteApplicationCacheFiles(String packageName, 4413 IPackageDataObserver observer); 4414 4415 /** 4416 * Free storage by deleting LRU sorted list of cache files across 4417 * all applications. If the currently available free storage 4418 * on the device is greater than or equal to the requested 4419 * free storage, no cache files are cleared. If the currently 4420 * available storage on the device is less than the requested 4421 * free storage, some or all of the cache files across 4422 * all applications are deleted (based on last accessed time) 4423 * to increase the free storage space on the device to 4424 * the requested value. There is no guarantee that clearing all 4425 * the cache files from all applications will clear up 4426 * enough storage to achieve the desired value. 4427 * @param freeStorageSize The number of bytes of storage to be 4428 * freed by the system. Say if freeStorageSize is XX, 4429 * and the current free storage is YY, 4430 * if XX is less than YY, just return. if not free XX-YY number 4431 * of bytes if possible. 4432 * @param observer call back used to notify when 4433 * the operation is completed 4434 * 4435 * @hide 4436 */ 4437 // @SystemApi 4438 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) { 4439 freeStorageAndNotify(null, freeStorageSize, observer); 4440 } 4441 4442 /** {@hide} */ 4443 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize, 4444 IPackageDataObserver observer); 4445 4446 /** 4447 * Free storage by deleting LRU sorted list of cache files across 4448 * all applications. If the currently available free storage 4449 * on the device is greater than or equal to the requested 4450 * free storage, no cache files are cleared. If the currently 4451 * available storage on the device is less than the requested 4452 * free storage, some or all of the cache files across 4453 * all applications are deleted (based on last accessed time) 4454 * to increase the free storage space on the device to 4455 * the requested value. There is no guarantee that clearing all 4456 * the cache files from all applications will clear up 4457 * enough storage to achieve the desired value. 4458 * @param freeStorageSize The number of bytes of storage to be 4459 * freed by the system. Say if freeStorageSize is XX, 4460 * and the current free storage is YY, 4461 * if XX is less than YY, just return. if not free XX-YY number 4462 * of bytes if possible. 4463 * @param pi IntentSender call back used to 4464 * notify when the operation is completed.May be null 4465 * to indicate that no call back is desired. 4466 * 4467 * @hide 4468 */ 4469 public void freeStorage(long freeStorageSize, IntentSender pi) { 4470 freeStorage(null, freeStorageSize, pi); 4471 } 4472 4473 /** {@hide} */ 4474 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi); 4475 4476 /** 4477 * Retrieve the size information for a package. 4478 * Since this may take a little while, the result will 4479 * be posted back to the given observer. The calling context 4480 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 4481 * 4482 * @param packageName The name of the package whose size information is to be retrieved 4483 * @param userId The user whose size information should be retrieved. 4484 * @param observer An observer callback to get notified when the operation 4485 * is complete. 4486 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 4487 * The observer's callback is invoked with a PackageStats object(containing the 4488 * code, data and cache sizes of the package) and a boolean value representing 4489 * the status of the operation. observer may be null to indicate that 4490 * no callback is desired. 4491 * 4492 * @hide 4493 */ 4494 public abstract void getPackageSizeInfoAsUser(String packageName, int userId, 4495 IPackageStatsObserver observer); 4496 4497 /** 4498 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but 4499 * returns the size for the calling user. 4500 * 4501 * @hide 4502 */ 4503 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 4504 getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer); 4505 } 4506 4507 /** 4508 * @deprecated This function no longer does anything; it was an old 4509 * approach to managing preferred activities, which has been superseded 4510 * by (and conflicts with) the modern activity-based preferences. 4511 */ 4512 @Deprecated 4513 public abstract void addPackageToPreferred(String packageName); 4514 4515 /** 4516 * @deprecated This function no longer does anything; it was an old 4517 * approach to managing preferred activities, which has been superseded 4518 * by (and conflicts with) the modern activity-based preferences. 4519 */ 4520 @Deprecated 4521 public abstract void removePackageFromPreferred(String packageName); 4522 4523 /** 4524 * Retrieve the list of all currently configured preferred packages. The 4525 * first package on the list is the most preferred, the last is the 4526 * least preferred. 4527 * 4528 * @param flags Additional option flags. Use any combination of 4529 * {@link #GET_ACTIVITIES}, 4530 * {@link #GET_GIDS}, 4531 * {@link #GET_CONFIGURATIONS}, 4532 * {@link #GET_INSTRUMENTATION}, 4533 * {@link #GET_PERMISSIONS}, 4534 * {@link #GET_PROVIDERS}, 4535 * {@link #GET_RECEIVERS}, 4536 * {@link #GET_SERVICES}, 4537 * {@link #GET_SIGNATURES}, to modify the data returned. 4538 * 4539 * @return Returns a list of PackageInfo objects describing each 4540 * preferred application, in order of preference. 4541 * 4542 * @see #GET_ACTIVITIES 4543 * @see #GET_GIDS 4544 * @see #GET_CONFIGURATIONS 4545 * @see #GET_INSTRUMENTATION 4546 * @see #GET_PERMISSIONS 4547 * @see #GET_PROVIDERS 4548 * @see #GET_RECEIVERS 4549 * @see #GET_SERVICES 4550 * @see #GET_SIGNATURES 4551 */ 4552 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags); 4553 4554 /** 4555 * @deprecated This is a protected API that should not have been available 4556 * to third party applications. It is the platform's responsibility for 4557 * assigning preferred activities and this cannot be directly modified. 4558 * 4559 * Add a new preferred activity mapping to the system. This will be used 4560 * to automatically select the given activity component when 4561 * {@link Context#startActivity(Intent) Context.startActivity()} finds 4562 * multiple matching activities and also matches the given filter. 4563 * 4564 * @param filter The set of intents under which this activity will be 4565 * made preferred. 4566 * @param match The IntentFilter match category that this preference 4567 * applies to. 4568 * @param set The set of activities that the user was picking from when 4569 * this preference was made. 4570 * @param activity The component name of the activity that is to be 4571 * preferred. 4572 */ 4573 @Deprecated 4574 public abstract void addPreferredActivity(IntentFilter filter, int match, 4575 ComponentName[] set, ComponentName activity); 4576 4577 /** 4578 * Same as {@link #addPreferredActivity(IntentFilter, int, 4579 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 4580 to. 4581 * @hide 4582 */ 4583 public void addPreferredActivityAsUser(IntentFilter filter, int match, 4584 ComponentName[] set, ComponentName activity, int userId) { 4585 throw new RuntimeException("Not implemented. Must override in a subclass."); 4586 } 4587 4588 /** 4589 * @deprecated This is a protected API that should not have been available 4590 * to third party applications. It is the platform's responsibility for 4591 * assigning preferred activities and this cannot be directly modified. 4592 * 4593 * Replaces an existing preferred activity mapping to the system, and if that were not present 4594 * adds a new preferred activity. This will be used 4595 * to automatically select the given activity component when 4596 * {@link Context#startActivity(Intent) Context.startActivity()} finds 4597 * multiple matching activities and also matches the given filter. 4598 * 4599 * @param filter The set of intents under which this activity will be 4600 * made preferred. 4601 * @param match The IntentFilter match category that this preference 4602 * applies to. 4603 * @param set The set of activities that the user was picking from when 4604 * this preference was made. 4605 * @param activity The component name of the activity that is to be 4606 * preferred. 4607 * @hide 4608 */ 4609 @Deprecated 4610 public abstract void replacePreferredActivity(IntentFilter filter, int match, 4611 ComponentName[] set, ComponentName activity); 4612 4613 /** 4614 * @hide 4615 */ 4616 @Deprecated 4617 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 4618 ComponentName[] set, ComponentName activity, int userId) { 4619 throw new RuntimeException("Not implemented. Must override in a subclass."); 4620 } 4621 4622 /** 4623 * Remove all preferred activity mappings, previously added with 4624 * {@link #addPreferredActivity}, from the 4625 * system whose activities are implemented in the given package name. 4626 * An application can only clear its own package(s). 4627 * 4628 * @param packageName The name of the package whose preferred activity 4629 * mappings are to be removed. 4630 */ 4631 public abstract void clearPackagePreferredActivities(String packageName); 4632 4633 /** 4634 * Retrieve all preferred activities, previously added with 4635 * {@link #addPreferredActivity}, that are 4636 * currently registered with the system. 4637 * 4638 * @param outFilters A required list in which to place the filters of all of the 4639 * preferred activities. 4640 * @param outActivities A required list in which to place the component names of 4641 * all of the preferred activities. 4642 * @param packageName An optional package in which you would like to limit 4643 * the list. If null, all activities will be returned; if non-null, only 4644 * those activities in the given package are returned. 4645 * 4646 * @return Returns the total number of registered preferred activities 4647 * (the number of distinct IntentFilter records, not the number of unique 4648 * activity components) that were found. 4649 */ 4650 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 4651 @NonNull List<ComponentName> outActivities, String packageName); 4652 4653 /** 4654 * Ask for the set of available 'home' activities and the current explicit 4655 * default, if any. 4656 * @hide 4657 */ 4658 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 4659 4660 /** 4661 * Set the enabled setting for a package component (activity, receiver, service, provider). 4662 * This setting will override any enabled state which may have been set by the component in its 4663 * manifest. 4664 * 4665 * @param componentName The component to enable 4666 * @param newState The new enabled state for the component. The legal values for this state 4667 * are: 4668 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4669 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 4670 * and 4671 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 4672 * The last one removes the setting, thereby restoring the component's state to 4673 * whatever was set in it's manifest (or enabled, by default). 4674 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 4675 */ 4676 public abstract void setComponentEnabledSetting(ComponentName componentName, 4677 int newState, int flags); 4678 4679 4680 /** 4681 * Return the enabled setting for a package component (activity, 4682 * receiver, service, provider). This returns the last value set by 4683 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 4684 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 4685 * the value originally specified in the manifest has not been modified. 4686 * 4687 * @param componentName The component to retrieve. 4688 * @return Returns the current enabled state for the component. May 4689 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4690 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 4691 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 4692 * component's enabled state is based on the original information in 4693 * the manifest as found in {@link ComponentInfo}. 4694 */ 4695 public abstract int getComponentEnabledSetting(ComponentName componentName); 4696 4697 /** 4698 * Set the enabled setting for an application 4699 * This setting will override any enabled state which may have been set by the application in 4700 * its manifest. It also overrides the enabled state set in the manifest for any of the 4701 * application's components. It does not override any enabled state set by 4702 * {@link #setComponentEnabledSetting} for any of the application's components. 4703 * 4704 * @param packageName The package name of the application to enable 4705 * @param newState The new enabled state for the component. The legal values for this state 4706 * are: 4707 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4708 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 4709 * and 4710 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 4711 * The last one removes the setting, thereby restoring the applications's state to 4712 * whatever was set in its manifest (or enabled, by default). 4713 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 4714 */ 4715 public abstract void setApplicationEnabledSetting(String packageName, 4716 int newState, int flags); 4717 4718 /** 4719 * Return the enabled setting for an application. This returns 4720 * the last value set by 4721 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 4722 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 4723 * the value originally specified in the manifest has not been modified. 4724 * 4725 * @param packageName The package name of the application to retrieve. 4726 * @return Returns the current enabled state for the application. May 4727 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4728 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 4729 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 4730 * application's enabled state is based on the original information in 4731 * the manifest as found in {@link ComponentInfo}. 4732 * @throws IllegalArgumentException if the named package does not exist. 4733 */ 4734 public abstract int getApplicationEnabledSetting(String packageName); 4735 4736 /** 4737 * Puts the package in a hidden state, which is almost like an uninstalled state, 4738 * making the package unavailable, but it doesn't remove the data or the actual 4739 * package file. Application can be unhidden by either resetting the hidden state 4740 * or by installing it, such as with {@link #installExistingPackage(String)} 4741 * @hide 4742 */ 4743 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 4744 UserHandle userHandle); 4745 4746 /** 4747 * Returns the hidden state of a package. 4748 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 4749 * @hide 4750 */ 4751 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 4752 UserHandle userHandle); 4753 4754 /** 4755 * Return whether the device has been booted into safe mode. 4756 */ 4757 public abstract boolean isSafeMode(); 4758 4759 /** 4760 * Adds a listener for permission changes for installed packages. 4761 * 4762 * @param listener The listener to add. 4763 * 4764 * @hide 4765 */ 4766 @SystemApi 4767 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 4768 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener); 4769 4770 /** 4771 * Remvoes a listener for permission changes for installed packages. 4772 * 4773 * @param listener The listener to remove. 4774 * 4775 * @hide 4776 */ 4777 @SystemApi 4778 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener); 4779 4780 /** 4781 * Return the {@link KeySet} associated with the String alias for this 4782 * application. 4783 * 4784 * @param alias The alias for a given {@link KeySet} as defined in the 4785 * application's AndroidManifest.xml. 4786 * @hide 4787 */ 4788 public abstract KeySet getKeySetByAlias(String packageName, String alias); 4789 4790 /** Return the signing {@link KeySet} for this application. 4791 * @hide 4792 */ 4793 public abstract KeySet getSigningKeySet(String packageName); 4794 4795 /** 4796 * Return whether the package denoted by packageName has been signed by all 4797 * of the keys specified by the {@link KeySet} ks. This will return true if 4798 * the package has been signed by additional keys (a superset) as well. 4799 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 4800 * @hide 4801 */ 4802 public abstract boolean isSignedBy(String packageName, KeySet ks); 4803 4804 /** 4805 * Return whether the package denoted by packageName has been signed by all 4806 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 4807 * {@link #isSignedBy(String packageName, KeySet ks)}. 4808 * @hide 4809 */ 4810 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 4811 4812 /** 4813 * Attempts to move package resources from internal to external media or vice versa. 4814 * Since this may take a little while, the result will 4815 * be posted back to the given observer. This call may fail if the calling context 4816 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the 4817 * named package cannot be found, or if the named package is a "system package". 4818 * 4819 * @param packageName The name of the package to delete 4820 * @param observer An observer callback to get notified when the package move is 4821 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be 4822 * called when that happens. observer may be null to indicate that no callback is desired. 4823 * @param flags To indicate install location {@link #MOVE_INTERNAL} or 4824 * {@link #MOVE_EXTERNAL_MEDIA} 4825 * 4826 * @hide 4827 */ 4828 @Deprecated 4829 public void movePackage(String packageName, IPackageMoveObserver observer, int flags) { 4830 throw new UnsupportedOperationException(); 4831 } 4832 4833 /** 4834 * Puts the package in a suspended state, making the package un-runnable, 4835 * but it doesn't remove the data or the actual package file. The application notifications 4836 * will be hidden and also the application will not show up in recents. 4837 * 4838 * @param packageName The name of the package to set the suspended status. 4839 * @param suspended If set to {@code true} than the package will be suspended, if set to 4840 * {@code false} the package will be unsuspended. 4841 * @param userId The user id. 4842 * 4843 * @hide 4844 */ 4845 public abstract boolean setPackageSuspendedAsUser( 4846 String packageName, boolean suspended, int userId); 4847 4848 /** {@hide} */ 4849 public static boolean isMoveStatusFinished(int status) { 4850 return (status < 0 || status > 100); 4851 } 4852 4853 /** {@hide} */ 4854 public static abstract class MoveCallback { 4855 public void onCreated(int moveId, Bundle extras) {} 4856 public abstract void onStatusChanged(int moveId, int status, long estMillis); 4857 } 4858 4859 /** {@hide} */ 4860 public abstract int getMoveStatus(int moveId); 4861 4862 /** {@hide} */ 4863 public abstract void registerMoveCallback(MoveCallback callback, Handler handler); 4864 /** {@hide} */ 4865 public abstract void unregisterMoveCallback(MoveCallback callback); 4866 4867 /** {@hide} */ 4868 public abstract int movePackage(String packageName, VolumeInfo vol); 4869 /** {@hide} */ 4870 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app); 4871 /** {@hide} */ 4872 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app); 4873 4874 /** {@hide} */ 4875 public abstract int movePrimaryStorage(VolumeInfo vol); 4876 /** {@hide} */ 4877 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 4878 /** {@hide} */ 4879 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 4880 4881 /** 4882 * Returns the device identity that verifiers can use to associate their scheme to a particular 4883 * device. This should not be used by anything other than a package verifier. 4884 * 4885 * @return identity that uniquely identifies current device 4886 * @hide 4887 */ 4888 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 4889 4890 /** 4891 * Returns true if the device is upgrading, such as first boot after OTA. 4892 * 4893 * @hide 4894 */ 4895 public abstract boolean isUpgrade(); 4896 4897 /** 4898 * Return interface that offers the ability to install, upgrade, and remove 4899 * applications on the device. 4900 */ 4901 public abstract @NonNull PackageInstaller getPackageInstaller(); 4902 4903 /** 4904 * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the 4905 * user with id sourceUserId can also be be resolved by activities in the user with id 4906 * targetUserId if they match the specified intent filter. 4907 * @param filter The {@link IntentFilter} the intent has to match 4908 * @param sourceUserId The source user id. 4909 * @param targetUserId The target user id. 4910 * @param flags The possible values are {@link SKIP_CURRENT_PROFILE} and 4911 * {@link ONLY_IF_NO_MATCH_FOUND}. 4912 * @hide 4913 */ 4914 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 4915 int targetUserId, int flags); 4916 4917 /** 4918 * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their 4919 * source, and have been set by the app calling this method. 4920 * @param sourceUserId The source user id. 4921 * @hide 4922 */ 4923 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 4924 4925 /** 4926 * @hide 4927 */ 4928 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 4929 4930 /** 4931 * @hide 4932 */ 4933 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 4934 4935 /** {@hide} */ 4936 public abstract boolean isPackageAvailable(String packageName); 4937 4938 /** {@hide} */ 4939 public static String installStatusToString(int status, String msg) { 4940 final String str = installStatusToString(status); 4941 if (msg != null) { 4942 return str + ": " + msg; 4943 } else { 4944 return str; 4945 } 4946 } 4947 4948 /** {@hide} */ 4949 public static String installStatusToString(int status) { 4950 switch (status) { 4951 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 4952 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 4953 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 4954 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 4955 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 4956 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 4957 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 4958 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 4959 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 4960 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 4961 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 4962 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 4963 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 4964 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 4965 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 4966 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 4967 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 4968 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 4969 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 4970 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 4971 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 4972 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 4973 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 4974 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 4975 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 4976 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 4977 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 4978 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 4979 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 4980 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 4981 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 4982 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 4983 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 4984 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 4985 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 4986 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 4987 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 4988 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 4989 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 4990 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 4991 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 4992 default: return Integer.toString(status); 4993 } 4994 } 4995 4996 /** {@hide} */ 4997 public static int installStatusToPublicStatus(int status) { 4998 switch (status) { 4999 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5000 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5001 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5002 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 5003 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5004 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5005 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5006 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5007 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5008 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5009 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5010 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 5011 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5012 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5013 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5014 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 5015 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5016 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5017 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 5018 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 5019 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5020 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 5021 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 5022 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5023 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5024 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5025 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5026 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5027 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 5028 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 5029 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5030 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5031 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 5032 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 5033 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 5034 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 5035 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 5036 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5037 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5038 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5039 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5040 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5041 default: return PackageInstaller.STATUS_FAILURE; 5042 } 5043 } 5044 5045 /** {@hide} */ 5046 public static String deleteStatusToString(int status, String msg) { 5047 final String str = deleteStatusToString(status); 5048 if (msg != null) { 5049 return str + ": " + msg; 5050 } else { 5051 return str; 5052 } 5053 } 5054 5055 /** {@hide} */ 5056 public static String deleteStatusToString(int status) { 5057 switch (status) { 5058 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 5059 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 5060 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 5061 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 5062 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 5063 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 5064 default: return Integer.toString(status); 5065 } 5066 } 5067 5068 /** {@hide} */ 5069 public static int deleteStatusToPublicStatus(int status) { 5070 switch (status) { 5071 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5072 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5073 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5074 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5075 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5076 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5077 default: return PackageInstaller.STATUS_FAILURE; 5078 } 5079 } 5080 5081 /** {@hide} */ 5082 public static String permissionFlagToString(int flag) { 5083 switch (flag) { 5084 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 5085 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 5086 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 5087 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 5088 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE"; 5089 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 5090 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 5091 default: return Integer.toString(flag); 5092 } 5093 } 5094 5095 /** {@hide} */ 5096 public static class LegacyPackageInstallObserver extends PackageInstallObserver { 5097 private final IPackageInstallObserver mLegacy; 5098 5099 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { 5100 mLegacy = legacy; 5101 } 5102 5103 @Override 5104 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 5105 Bundle extras) { 5106 if (mLegacy == null) return; 5107 try { 5108 mLegacy.packageInstalled(basePackageName, returnCode); 5109 } catch (RemoteException ignored) { 5110 } 5111 } 5112 } 5113 5114 /** {@hide} */ 5115 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 5116 private final IPackageDeleteObserver mLegacy; 5117 5118 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 5119 mLegacy = legacy; 5120 } 5121 5122 @Override 5123 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 5124 if (mLegacy == null) return; 5125 try { 5126 mLegacy.packageDeleted(basePackageName, returnCode); 5127 } catch (RemoteException ignored) { 5128 } 5129 } 5130 } 5131} 5132