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 |
int |
STAGED_SESSION_CONFLICT
This constant was deprecated
in API level 33.
use |
int |
STAGED_SESSION_NO_ERROR
This constant was deprecated
in API level 33.
use |
int |
STAGED_SESSION_UNKNOWN
This constant was deprecated
in API level 33.
use |
int |
STAGED_SESSION_VERIFICATION_FAILED
This constant was deprecated
in API level 33.
use |
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 |
int
|
getInstallLocation()
Get the value set in |
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 |
int
|
getOriginatingUid()
Get the value set in |
Uri
|
getOriginatingUri()
Get the value set in |
int
|
getPackageSource()
Get the package source that was set in
|
int
|
getParentSessionId()
Returns the parent multi-package session ID if this session belongs to one,
|
float
|
getProgress()
Return current overall progress of this session, between 0 and 1. |
Uri
|
getReferrerUri()
Get the value set in |
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 |
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 |
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 |
boolean
|
isCommitted()
Returns |
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 |
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
public static final int INVALID_ID
A session ID that does not exist or is invalid.
Constant Value: -1 (0xffffffff)
SESSION_ACTIVATION_FAILED
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
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
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
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
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
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
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
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
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
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
Public methods
createDetailsIntent
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 . |
See also:
describeContents
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
public Bitmap getAppIcon ()
Return an icon representing the app being installed. May be null
if unavailable.
Returns | |
---|---|
Bitmap |
getAppLabel
public CharSequence getAppLabel ()
Return a label representing the app being installed. May be null
if unavailable.
Returns | |
---|---|
CharSequence |
getAppPackageName
public String getAppPackageName ()
Return the package name this session is working with. May be null
if unknown.
Returns | |
---|---|
String |
getChildSessionIds
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
public long getCreatedMillis ()
The timestamp of the initial creation of the session.
Returns | |
---|---|
long |
getDontKillApp
public boolean getDontKillApp ()
Get the value set in SessionParams#setDontKillApp(boolean)
.
Returns | |
---|---|
boolean |
getInstallLocation
public int getInstallLocation ()
Get the value set in SessionParams#setInstallLocation(int)
.
Returns | |
---|---|
int |
getInstallReason
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
public String getInstallerAttributionTag ()
Returns | |
---|---|
String |
attribution tag of the context
that created this session
This value may be null . |
getInstallerPackageName
public String getInstallerPackageName ()
Return the package name of the app that owns this session.
Returns | |
---|---|
String |
This value may be null . |
getInstallerUid
public int getInstallerUid ()
Returns the Uid of the owner of the session.
Returns | |
---|---|
int |
getMode
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
public int getOriginatingUid ()
Get the value set in SessionParams#setOriginatingUid(int)
.
Returns | |
---|---|
int |
getOriginatingUri
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 |
getPackageSource
public int getPackageSource ()
Get the package source that was set in
PackageInstaller.SessionParams#setPackageSource(int)
.
getParentSessionId
public int getParentSessionId ()
Returns the parent multi-package session ID if this session belongs to one,
INVALID_ID
otherwise.
Returns | |
---|---|
int |
getProgress
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
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
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.
getSessionId
public int getSessionId ()
Return the ID for this session.
Returns | |
---|---|
int |
getSize
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
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
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
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
public UserHandle getUser ()
Return the user associated with this session.
Returns | |
---|---|
UserHandle |
This value cannot be null . |
hasParentSessionId
public boolean hasParentSessionId ()
Returns true if session has a valid parent session, otherwise false.
Returns | |
---|---|
boolean |
isActive
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
public boolean isApplicationEnabledSettingPersistent ()
Returns true
if this session will keep the existing application enabled setting
after installation.
Returns | |
---|---|
boolean |
isCommitted
public boolean isCommitted ()
Returns true
if Session#commit(IntentSender)
} was called for this
session.
Returns | |
---|---|
boolean |
isMultiPackage
public boolean isMultiPackage ()
Returns true if this session is a multi-package session containing references to other sessions.
Returns | |
---|---|
boolean |
isPreApprovalRequested
public boolean isPreApprovalRequested ()
Returns whether this session has requested user pre-approval.
Returns | |
---|---|
boolean |
isRequestUpdateOwnership
public boolean isRequestUpdateOwnership ()
Returns | |
---|---|
boolean |
true if the installer requested the update ownership enforcement
for the packages in this session. |
isSealed
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
public boolean isStaged ()
Returns true if this session is a staged session.
Returns | |
---|---|
boolean |
isStagedSessionActive
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:
- It is committed, i.e.
SessionInfo#isCommitted()
istrue
, and - it is not applied, i.e.
SessionInfo#isStagedSessionApplied()
isfalse
, and - it is not failed, i.e.
SessionInfo#isStagedSessionFailed()
isfalse
.
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
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
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
public boolean isStagedSessionReady ()
Whether the staged session is ready to be applied at next reboot. Only meaningful if
isStaged
is true.
Returns | |
---|---|
boolean |
isUnarchival
public boolean isUnarchival ()
Returns true if the session is an unarchival.
Returns | |
---|---|
boolean |
writeToParcel
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 |