/**@class android.content.pm.PackageInstaller @extends java.lang.Object Offers the ability to install, upgrade, and remove applications on the device. This includes support for apps packaged either as a single "monolithic" APK, or apps packaged as multiple "split" APKs. <p> An app is delivered for installation through a {@link android.content.pm.PackageParser.PackageInstaller.Session}, which any app can create. Once the session is created, the installer can stream one or more APKs into place until it decides to either commit or destroy the session. Committing may require user intervention to complete the installation, unless the caller falls into one of the following categories, in which case the installation will complete automatically. <ul> <li>the device owner <li>the affiliated profile owner </ul> <p> Sessions can install brand new apps, upgrade existing apps, or add new splits into an existing app. <p> Apps packaged as multiple split APKs always consist of a single "base" APK (with a {@code null} split name) and zero or more "split" APKs (with unique split names). Any subset of these APKs can be installed together, as long as the following constraints are met: <ul> <li>All APKs must have the exact same package name, version code, and signing certificates. <li>All APKs must have unique split names. <li>All installations must contain a single base APK. </ul> <p> The ApiDemos project contains examples of using this API: <code>ApiDemos/src/com/example/android/apis/content/InstallApk*.java</code>. <p> On Android Q or above, an app installed notification will be posted by system after a new app is installed. To customize installer's notification icon, you should declare the following in the manifest <application> as follows: </p> <pre> <meta-data android:name="com.android.packageinstaller.notification.smallIcon" android:resource="@drawable/installer_notification_icon"/> </pre> <pre> <meta-data android:name="com.android.packageinstaller.notification.color" android:resource="@color/installer_notification_color"/> </pre> */ var PackageInstaller = { /**{@hide} */ ENABLE_REVOCABLE_FD : "null", /** Activity Action: Show details about a particular install session. This may surface actions such as pause, resume, or cancel. <p> This should always be scoped to the installer package that owns the session. Clients should use {@link android.content.pm.PackageInstaller.SessionInfo#createDetailsIntent()} to build this intent correctly. <p> In some cases, a matching Activity may not exist, so ensure you safeguard against this. <p> The session to show details for is defined in {@link #EXTRA_SESSION_ID}. */ ACTION_SESSION_DETAILS : "android.content.pm.action.SESSION_DETAILS", /** Broadcast Action: Explicit broadcast sent to the last known default launcher when a session for a new install is committed. For managed profile, this is sent to the default launcher of the primary profile. <p> The associated session is defined in {@link #EXTRA_SESSION} and the user for which this session was created in {@link Intent#EXTRA_USER}. */ ACTION_SESSION_COMMITTED : "android.content.pm.action.SESSION_COMMITTED", /** Broadcast Action: Send information about a staged install session when its state is updated. <p> The associated session information is defined in {@link #EXTRA_SESSION}. */ ACTION_SESSION_UPDATED : "android.content.pm.action.SESSION_UPDATED", /**{@hide} */ ACTION_CONFIRM_INSTALL : "android.content.pm.action.CONFIRM_INSTALL", /** An integer session ID that an operation is working with. @see Intent#getIntExtra(String, int) */ EXTRA_SESSION_ID : "android.content.pm.extra.SESSION_ID", /** {@link android.content.pm.PackageInstaller.SessionInfo} that an operation is working with. @see Intent#getParcelableExtra(String) */ EXTRA_SESSION : "android.content.pm.extra.SESSION", /** Package name that an operation is working with. @see Intent#getStringExtra(String) */ EXTRA_PACKAGE_NAME : "android.content.pm.extra.PACKAGE_NAME", /** Current status of an operation. Will be one of {@link #STATUS_PENDING_USER_ACTION}, {@link #STATUS_SUCCESS}, {@link #STATUS_FAILURE}, {@link #STATUS_FAILURE_ABORTED}, {@link #STATUS_FAILURE_BLOCKED}, {@link #STATUS_FAILURE_CONFLICT}, {@link #STATUS_FAILURE_INCOMPATIBLE}, {@link #STATUS_FAILURE_INVALID}, or {@link #STATUS_FAILURE_STORAGE}. <p> More information about a status may be available through additional extras; see the individual status documentation for details. @see Intent#getIntExtra(String, int) */ EXTRA_STATUS : "android.content.pm.extra.STATUS", /** Detailed string representation of the status, including raw details that are useful for debugging. @see Intent#getStringExtra(String) */ EXTRA_STATUS_MESSAGE : "android.content.pm.extra.STATUS_MESSAGE", /** Another package name relevant to a status. This is typically the package responsible for causing an operation failure. @see Intent#getStringExtra(String) */ EXTRA_OTHER_PACKAGE_NAME : "android.content.pm.extra.OTHER_PACKAGE_NAME", /** Storage path relevant to a status. @see Intent#getStringExtra(String) */ EXTRA_STORAGE_PATH : "android.content.pm.extra.STORAGE_PATH", /**{@hide} */ EXTRA_PACKAGE_NAMES : "android.content.pm.extra.PACKAGE_NAMES", /**{@hide} */ EXTRA_LEGACY_STATUS : "android.content.pm.extra.LEGACY_STATUS", /**{@hide} */ EXTRA_LEGACY_BUNDLE : "android.content.pm.extra.LEGACY_BUNDLE", /**{@hide} */ EXTRA_CALLBACK : "android.content.pm.extra.CALLBACK", /** User action is currently required to proceed. You can launch the intent activity described by {@link Intent#EXTRA_INTENT} to involve the user and continue. <p> You may choose to immediately launch the intent if the user is actively using your app. Otherwise, you should use a notification to guide the user back into your app before launching. @see Intent#getParcelableExtra(String) */ STATUS_PENDING_USER_ACTION : "-1", /** The operation succeeded. */ STATUS_SUCCESS : "0", /** The operation failed in a generic way. The system will always try to provide a more specific failure reason, but in some rare cases this may be delivered. @see #EXTRA_STATUS_MESSAGE */ STATUS_FAILURE : "1", /** The operation failed because it was blocked. For example, a device policy may be blocking the operation, a package verifier may have blocked the operation, or the app may be required for core system operation. <p> The result may also contain {@link #EXTRA_OTHER_PACKAGE_NAME} with the specific package blocking the install. @see #EXTRA_STATUS_MESSAGE @see #EXTRA_OTHER_PACKAGE_NAME */ STATUS_FAILURE_BLOCKED : "2", /** The operation failed because it was actively aborted. For example, the user actively declined requested permissions, or the session was abandoned. @see #EXTRA_STATUS_MESSAGE */ STATUS_FAILURE_ABORTED : "3", /** The operation failed because one or more of the APKs was invalid. For example, they might be malformed, corrupt, incorrectly signed, mismatched, etc. @see #EXTRA_STATUS_MESSAGE */ STATUS_FAILURE_INVALID : "4", /** The operation failed because it conflicts (or is inconsistent with) with another package already installed on the device. For example, an existing permission, incompatible certificates, etc. The user may be able to uninstall another app to fix the issue. <p> The result may also contain {@link #EXTRA_OTHER_PACKAGE_NAME} with the specific package identified as the cause of the conflict. @see #EXTRA_STATUS_MESSAGE @see #EXTRA_OTHER_PACKAGE_NAME */ STATUS_FAILURE_CONFLICT : "5", /** The operation failed because of storage issues. For example, the device may be running low on space, or external media may be unavailable. The user may be able to help free space or insert different external media. <p> The result may also contain {@link #EXTRA_STORAGE_PATH} with the path to the storage device that caused the failure. @see #EXTRA_STATUS_MESSAGE @see #EXTRA_STORAGE_PATH */ STATUS_FAILURE_STORAGE : "6", /** The operation failed because it is fundamentally incompatible with this device. For example, the app may require a hardware feature that doesn't exist, it may be missing native code for the ABIs supported by the device, or it requires a newer SDK version, etc. @see #EXTRA_STATUS_MESSAGE */ STATUS_FAILURE_INCOMPATIBLE : "7", /**Create a new session using the given parameters, returning a unique ID that represents the session. Once created, the session can be opened multiple times across multiple device boots. <p> The system may automatically destroy sessions that have not been finalized (either committed or abandoned) within a reasonable period of time, typically on the order of a day. @throws IOException if parameters were unsatisfiable, such as lack of disk space or unavailable media. @throws SecurityException when installation services are unavailable, such as when called from a restricted user. @throws IllegalArgumentException when {@link SessionParams} is invalid. @return {Number} positive, non-zero unique ID that represents the created session. This ID remains consistent across device reboots until the session is finalized. IDs are not reused during a given boot. */ createSession : function( ) {}, /**Open an existing session to actively perform work. To succeed, the caller must be the owner of the install session. @throws IOException if parameters were unsatisfiable, such as lack of disk space or unavailable media. @throws SecurityException when the caller does not own the session, or the session is invalid. */ openSession : function( ) {}, /**Update the icon representing the app being installed in a specific session. This should be roughly {@link android.content.pm.PackageParser.ActivityManager#getLauncherLargeIconSize()} in both dimensions. @throws SecurityException when the caller does not own the session, or the session is invalid. */ updateSessionAppIcon : function( ) {}, /**Update the label representing the app being installed in a specific session. @throws SecurityException when the caller does not own the session, or the session is invalid. */ updateSessionAppLabel : function( ) {}, /**Completely abandon the given session, destroying all staged data and rendering it invalid. Abandoned sessions will be reported to {@link android.content.pm.PackageInstaller.SessionCallback} listeners as failures. This is equivalent to opening the session and calling {@link android.content.pm.PackageInstaller.Session#abandon()}. @throws SecurityException when the caller does not own the session, or the session is invalid. */ abandonSession : function( ) {}, /**Return details for a specific session. No special permissions are required to retrieve these details. @return {Object {android.content.pm.PackageInstaller.SessionInfo}} details for the requested session, or {@code null} if the session does not exist. */ getSessionInfo : function( ) {}, /**Return list of all known install sessions, regardless of the installer. */ getAllSessions : function( ) {}, /**Return list of all known install sessions owned by the calling app. */ getMySessions : function( ) {}, /**Return list of all staged install sessions. */ getStagedSessions : function( ) {}, /**Returns an active staged session, or {@code null} if there is none. <p>Staged session is active iff: <ul> <li>It is committed, i.e. {@link android.content.pm.PackageInstaller.SessionInfo#isCommitted()} is {@code true}, and <li>it is not applied, i.e. {@link android.content.pm.PackageInstaller.SessionInfo#isStagedSessionApplied()} is {@code false}, and <li>it is not failed, i.e. {@link android.content.pm.PackageInstaller.SessionInfo#isStagedSessionFailed()} is {@code false}. </ul> <p>In case of a multi-apk session, reasoning above is applied to the parent session, since that is the one that should been {@link android.content.pm.PackageInstaller.Session#commit committed}. */ getActiveStagedSession : function( ) {}, /**Uninstall the given package, removing it completely from the device. This method is available to: <ul> <li>the current "installer of record" for the package <li>the device owner <li>the affiliated profile owner </ul> @param {String} packageName The package to uninstall. @param {Object {IntentSender}} statusReceiver Where to deliver the result. @see android.app.admin.DevicePolicyManager */ uninstall : function( ) {}, /**Uninstall the given package, removing it completely from the device. This method is only available to the current "installer of record" for the package. @param {String} packageName The package to uninstall. @param {Number} flags Flags for uninstall. @param {Object {IntentSender}} statusReceiver Where to deliver the result. @hide */ uninstall : function( ) {}, /**Uninstall the given package with a specific version code, removing it completely from the device. If the version code of the package does not match the one passed in the versioned package argument this method is a no-op. Use {@link android.content.pm.PackageParser.PackageManager#VERSION_CODE_HIGHEST} to uninstall the latest version of the package. <p> This method is available to: <ul> <li>the current "installer of record" for the package <li>the device owner <li>the affiliated profile owner </ul> @param {Object {VersionedPackage}} versionedPackage The versioned package to uninstall. @param {Object {IntentSender}} statusReceiver Where to deliver the result. @see android.app.admin.DevicePolicyManager */ uninstall : function( ) {}, /**Uninstall the given package with a specific version code, removing it completely from the device. This method is only available to the current "installer of record" for the package. If the version code of the package does not match the one passed in the versioned package argument this method is a no-op. Use {@link android.content.pm.PackageParser.PackageManager#VERSION_CODE_HIGHEST} to uninstall the latest version of the package. @param {Object {VersionedPackage}} versionedPackage The versioned package to uninstall. @param {Number} flags Flags for uninstall. @param {Object {IntentSender}} statusReceiver Where to deliver the result. @hide */ uninstall : function( ) {}, /**Install the given package, which already exists on the device, for the user for which this installer was created. <p>This will {@link android.content.pm.PackageParser.PackageInstaller.SessionParams#setWhitelistedRestrictedPermissions(Set) whitelist all restricted permissions}. @param {String} packageName The package to install. @param {Number} installReason Reason for install. @param {Object {IntentSender}} statusReceiver Where to deliver the result. */ installExistingPackage : function( ) {}, /**{@hide} */ setPermissionsResult : function( ) {}, /**{@hide} */ addSessionCallback : function( ) {}, /**Register to watch for session lifecycle events. No special permissions are required to watch for these events. */ registerSessionCallback : function( ) {}, /**{@hide} */ addSessionCallback : function( ) {}, /**Register to watch for session lifecycle events. No special permissions are required to watch for these events. @param {Object {PackageInstaller.SessionCallback}} handler to dispatch callback events through, otherwise uses calling thread. */ registerSessionCallback : function( ) {}, /**{@hide} */ removeSessionCallback : function( ) {}, /**Unregister a previously registered callback. */ unregisterSessionCallback : function( ) {}, };