PackageInstaller.SessionInfo


public static class PackageInstaller.SessionInfo
extends Object implements Parcelable

java.lang.Object
   ↳ android.content.pm.PackageInstaller.SessionInfo


Details for an active install session.

Summary

Constants

int INVALID_ID

A session ID that does not exist or is invalid.

int SESSION_ACTIVATION_FAILED

Constant indicating that an error occurred during the activation phase of this session.

int SESSION_CONFLICT

Constant indicating that the session was in conflict with another session and had to be sacrificed for resolution.

int SESSION_NO_ERROR

Constant indicating that no error occurred during the preparation or the activation of this session.

int SESSION_UNKNOWN_ERROR

Constant indicating that an unknown error occurred while processing this session.

int SESSION_VERIFICATION_FAILED

Constant indicating that an error occurred during the verification phase of this session.

int STAGED_SESSION_ACTIVATION_FAILED

This constant was deprecated in API level 33. use SESSION_ACTIVATION_FAILED.

int STAGED_SESSION_CONFLICT

This constant was deprecated in API level 33. use SESSION_CONFLICT.

int STAGED_SESSION_NO_ERROR

This constant was deprecated in API level 33. use SESSION_NO_ERROR.

int STAGED_SESSION_UNKNOWN

This constant was deprecated in API level 33. use SESSION_UNKNOWN_ERROR.

int STAGED_SESSION_VERIFICATION_FAILED

This constant was deprecated in API level 33. use SESSION_VERIFICATION_FAILED.

Inherited constants

Fields

public static final Creator<PackageInstaller.SessionInfo> CREATOR

Public methods

Intent createDetailsIntent()

Return an Intent that can be started to view details about this install session.

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

Bitmap getAppIcon()

Return an icon representing the app being installed.

CharSequence getAppLabel()

Return a label representing the app being installed.

String getAppPackageName()

Return the package name this session is working with.

int[] getChildSessionIds()

Returns the set of session IDs that will be committed when this session is committed if this session is a multi-package session.

long getCreatedMillis()

The timestamp of the initial creation of the session.

boolean getDontKillApp()

Get the value set in SessionParams#setDontKillApp(boolean).

int getInstallLocation()

Get the value set in SessionParams#setInstallLocation(int).

int getInstallReason()

Return the reason for installing this package.

String getInstallerAttributionTag()
String getInstallerPackageName()

Return the package name of the app that owns this session.

int getInstallerUid()

Returns the Uid of the owner of the session.

int getMode()

Get the mode of the session as set in the constructor of the SessionParams.

int getOriginatingUid()

Get the value set in SessionParams#setOriginatingUid(int).

Uri getOriginatingUri()

Get the value set in SessionParams#setOriginatingUri(Uri).

int getPackageSource()

Get the package source that was set in PackageInstaller.SessionParams#setPackageSource(int).

int getParentSessionId()

Returns the parent multi-package session ID if this session belongs to one, INVALID_ID otherwise.

float getProgress()

Return current overall progress of this session, between 0 and 1.

Uri getReferrerUri()

Get the value set in SessionParams#setReferrerUri(Uri) Note: This value will only be non-null for the owner of the session.

int getRequireUserAction()

Whether user action was required by the installer.

int getSessionId()

Return the ID for this session.

long getSize()

Get the value as set in SessionParams#setSize(long).

int getStagedSessionErrorCode()

If something went wrong with a staged session, clients can check this error code to understand which kind of failure happened.

String getStagedSessionErrorMessage()

Text description of the error code returned by getStagedSessionErrorCode, or empty string if no error was encountered.

long getUpdatedMillis()

The timestamp of the last update that occurred to the session, including changing of states in case of staged sessions.

UserHandle getUser()

Return the user associated with this session.

boolean hasParentSessionId()

Returns true if session has a valid parent session, otherwise false.

boolean isActive()

Return if this session is currently active.

boolean isApplicationEnabledSettingPersistent()

Returns true if this session will keep the existing application enabled setting after installation.

boolean isCommitted()

Returns true if Session#commit(IntentSender)} was called for this session.

boolean isMultiPackage()

Returns true if this session is a multi-package session containing references to other sessions.

boolean isPreApprovalRequested()

Returns whether this session has requested user pre-approval.

boolean isRequestUpdateOwnership()
boolean isSealed()

Return if this session is sealed.

boolean isStaged()

Returns true if this session is a staged session.

boolean isStagedSessionActive()

Returns true if this session is an active staged session.

boolean isStagedSessionApplied()

Whether the staged session has been applied successfully, meaning that all of its packages have been activated and no further action is required.

boolean isStagedSessionFailed()

Whether something went wrong and the staged session is declared as failed, meaning that it will be ignored at next reboot.

boolean isStagedSessionReady()

Whether the staged session is ready to be applied at next reboot.

boolean isUnarchival()

Returns true if the session is an unarchival.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

INVALID_ID

Added in API level 29
public static final int INVALID_ID

A session ID that does not exist or is invalid.

Constant Value: -1 (0xffffffff)

SESSION_ACTIVATION_FAILED

Added in API level 33
public static final int SESSION_ACTIVATION_FAILED

Constant indicating that an error occurred during the activation phase of this session.

Constant Value: 2 (0x00000002)

SESSION_CONFLICT

Added in API level 33
public static final int SESSION_CONFLICT

Constant indicating that the session was in conflict with another session and had to be sacrificed for resolution.

Constant Value: 4 (0x00000004)

SESSION_NO_ERROR

Added in API level 33
public static final int SESSION_NO_ERROR

Constant indicating that no error occurred during the preparation or the activation of this session.

Constant Value: 0 (0x00000000)

SESSION_UNKNOWN_ERROR

Added in API level 33
public static final int SESSION_UNKNOWN_ERROR

Constant indicating that an unknown error occurred while processing this session.

Constant Value: 3 (0x00000003)

SESSION_VERIFICATION_FAILED

Added in API level 33
public static final int SESSION_VERIFICATION_FAILED

Constant indicating that an error occurred during the verification phase of this session.

Constant Value: 1 (0x00000001)

STAGED_SESSION_ACTIVATION_FAILED

Added in API level 29
Deprecated in API level 33
public static final int STAGED_SESSION_ACTIVATION_FAILED

This constant was deprecated in API level 33.
use SESSION_ACTIVATION_FAILED.

Constant Value: 2 (0x00000002)

STAGED_SESSION_CONFLICT

Added in API level 31
Deprecated in API level 33
public static final int STAGED_SESSION_CONFLICT

This constant was deprecated in API level 33.
use SESSION_CONFLICT.

Constant Value: 4 (0x00000004)

STAGED_SESSION_NO_ERROR

Added in API level 29
Deprecated in API level 33
public static final int STAGED_SESSION_NO_ERROR

This constant was deprecated in API level 33.
use SESSION_NO_ERROR.

Constant Value: 0 (0x00000000)

STAGED_SESSION_UNKNOWN

Added in API level 29
Deprecated in API level 33
public static final int STAGED_SESSION_UNKNOWN

This constant was deprecated in API level 33.
use SESSION_UNKNOWN_ERROR.

Constant Value: 3 (0x00000003)

STAGED_SESSION_VERIFICATION_FAILED

Added in API level 29
Deprecated in API level 33
public static final int STAGED_SESSION_VERIFICATION_FAILED

This constant was deprecated in API level 33.
use SESSION_VERIFICATION_FAILED.

Constant Value: 1 (0x00000001)

Fields

CREATOR

Added in API level 21
public static final Creator<PackageInstaller.SessionInfo> CREATOR

Public methods

createDetailsIntent

Added in API level 21
public Intent createDetailsIntent ()

Return an Intent that can be started to view details about this install session. This may surface actions such as pause, resume, or cancel.

In some cases, a matching Activity may not exist, so ensure you safeguard against this.

Returns
Intent This value may be null.

describeContents

Added in API level 21
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getAppIcon

Added in API level 21
public Bitmap getAppIcon ()

Return an icon representing the app being installed. May be null if unavailable.

Returns
Bitmap

getAppLabel

Added in API level 21
public CharSequence getAppLabel ()

Return a label representing the app being installed. May be null if unavailable.

Returns
CharSequence

getAppPackageName

Added in API level 21
public String getAppPackageName ()

Return the package name this session is working with. May be null if unknown.

Returns
String

getChildSessionIds

Added in API level 29
public int[] getChildSessionIds ()

Returns the set of session IDs that will be committed when this session is committed if this session is a multi-package session.

Returns
int[] This value cannot be null.

getCreatedMillis

Added in API level 30
public long getCreatedMillis ()

The timestamp of the initial creation of the session.

Returns
long

getDontKillApp

Added in API level 34
public boolean getDontKillApp ()

Get the value set in SessionParams#setDontKillApp(boolean).

Returns
boolean

getInstallLocation

Added in API level 27
public int getInstallLocation ()

Get the value set in SessionParams#setInstallLocation(int).

Returns
int

getInstallReason

Added in API level 26
public int getInstallReason ()

Return the reason for installing this package.

Returns
int The install reason. Value is PackageManager.INSTALL_REASON_UNKNOWN, PackageManager.INSTALL_REASON_POLICY, PackageManager.INSTALL_REASON_DEVICE_RESTORE, PackageManager.INSTALL_REASON_DEVICE_SETUP, PackageManager.INSTALL_REASON_USER, or android.content.pm.PackageManager.INSTALL_REASON_ROLLBACK

getInstallerAttributionTag

Added in API level 31
public String getInstallerAttributionTag ()

Returns
String attribution tag of the context that created this session This value may be null.

getInstallerPackageName

Added in API level 21
public String getInstallerPackageName ()

Return the package name of the app that owns this session.

Returns
String This value may be null.

getInstallerUid

Added in API level 34
public int getInstallerUid ()

Returns the Uid of the owner of the session.

Returns
int

getMode

Added in API level 27
public int getMode ()

Get the mode of the session as set in the constructor of the SessionParams.

Returns
int One of SessionParams#MODE_FULL_INSTALL or SessionParams#MODE_INHERIT_EXISTING

getOriginatingUid

Added in API level 27
public int getOriginatingUid ()

Get the value set in SessionParams#setOriginatingUid(int).

Returns
int

getOriginatingUri

Added in API level 27
public Uri getOriginatingUri ()

Get the value set in SessionParams#setOriginatingUri(Uri). Note: This value will only be non-null for the owner of the session.

Returns
Uri

getParentSessionId

Added in API level 29
public int getParentSessionId ()

Returns the parent multi-package session ID if this session belongs to one, INVALID_ID otherwise.

Returns
int

getProgress

Added in API level 21
public float getProgress ()

Return current overall progress of this session, between 0 and 1.

Note that this progress may not directly correspond to the value reported by PackageInstaller.Session#setStagingProgress(float), as the system may carve out a portion of the overall progress to represent its own internal installation work.

Returns
float

getReferrerUri

Added in API level 27
public Uri getReferrerUri ()

Get the value set in SessionParams#setReferrerUri(Uri) Note: This value will only be non-null for the owner of the session.

Returns
Uri

getRequireUserAction

Added in API level 31
public int getRequireUserAction ()

Whether user action was required by the installer.

Note: a return value of USER_ACTION_NOT_REQUIRED does not guarantee that the install will not result in user action.

Returns
int SessionParams#USER_ACTION_NOT_REQUIRED, SessionParams#USER_ACTION_REQUIRED or SessionParams#USER_ACTION_UNSPECIFIED Value is PackageInstaller.SessionParams.USER_ACTION_UNSPECIFIED, PackageInstaller.SessionParams.USER_ACTION_REQUIRED, or PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED

getSessionId

Added in API level 21
public int getSessionId ()

Return the ID for this session.

Returns
int

getSize

Added in API level 27
public long getSize ()

Get the value as set in SessionParams#setSize(long).

The value is a hint and does not have to match the actual size.

Returns
long

getStagedSessionErrorCode

Added in API level 29
public int getStagedSessionErrorCode ()

If something went wrong with a staged session, clients can check this error code to understand which kind of failure happened. Only meaningful if isStaged is true.

Returns
int

getStagedSessionErrorMessage

Added in API level 29
public String getStagedSessionErrorMessage ()

Text description of the error code returned by getStagedSessionErrorCode, or empty string if no error was encountered.

Returns
String This value cannot be null.

getUpdatedMillis

Added in API level 29
public long getUpdatedMillis ()

The timestamp of the last update that occurred to the session, including changing of states in case of staged sessions.
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z.

Returns
long Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z.

getUser

Added in API level 29
public UserHandle getUser ()

Return the user associated with this session.

Returns
UserHandle This value cannot be null.

hasParentSessionId

Added in API level 30
public boolean hasParentSessionId ()

Returns true if session has a valid parent session, otherwise false.

Returns
boolean

isActive

Added in API level 21
public boolean isActive ()

Return if this session is currently active.

A session is considered active whenever there is ongoing forward progress being made, such as the installer holding an open Session instance while streaming data into place, or the system optimizing code as the result of Session#commit(IntentSender).

If the installer closes the Session without committing, the session is considered inactive until the installer opens the session again.

Returns
boolean

isApplicationEnabledSettingPersistent

Added in API level 34
public boolean isApplicationEnabledSettingPersistent ()

Returns true if this session will keep the existing application enabled setting after installation.

Returns
boolean

isCommitted

Added in API level 29
public boolean isCommitted ()

Returns true if Session#commit(IntentSender)} was called for this session.

Returns
boolean

isMultiPackage

Added in API level 29
public boolean isMultiPackage ()

Returns true if this session is a multi-package session containing references to other sessions.

Returns
boolean

isPreApprovalRequested

Added in API level 34
public boolean isPreApprovalRequested ()

Returns whether this session has requested user pre-approval.

Returns
boolean

isRequestUpdateOwnership

Added in API level 34
public boolean isRequestUpdateOwnership ()

Returns
boolean true if the installer requested the update ownership enforcement for the packages in this session.

isSealed

Added in API level 26
public boolean isSealed ()

Return if this session is sealed.

Once sealed, no further changes may be made to the session. A session is sealed the moment Session#commit(IntentSender) is called.

Returns
boolean

isStaged

Added in API level 29
public boolean isStaged ()

Returns true if this session is a staged session.

Returns
boolean

isStagedSessionActive

Added in API level 30
public boolean isStagedSessionActive ()

Returns true if this session is an active staged session. We consider a session active if it has been committed and it is either pending verification, or will be applied at next reboot.

Staged session is active iff:

In case of a multi-package session, reasoning above is applied to the parent session, since that is the one that should have been committed.

Returns
boolean

isStagedSessionApplied

Added in API level 29
public boolean isStagedSessionApplied ()

Whether the staged session has been applied successfully, meaning that all of its packages have been activated and no further action is required. Only meaningful if isStaged is true.

Returns
boolean

isStagedSessionFailed

Added in API level 29
public boolean isStagedSessionFailed ()

Whether something went wrong and the staged session is declared as failed, meaning that it will be ignored at next reboot. Only meaningful if isStaged is true.

Returns
boolean

isStagedSessionReady

Added in API level 29
public boolean isStagedSessionReady ()

Whether the staged session is ready to be applied at next reboot. Only meaningful if isStaged is true.

Returns
boolean

isUnarchival

Added in API level 35
public boolean isUnarchival ()

Returns true if the session is an unarchival.

Returns
boolean

writeToParcel

Added in API level 21
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES