Move and rename some members (1/n)
This is a preliminary change to apply READY/FAILED/APPLIED to
non-staged sessions.
* Move mSession* fields to PackageInstallerSession as they
will be useful to both staged and non-staged sessions.
* Rename some members as they will be applicable to both staged
and non-staged sessions.
Bug: 210359798
Test: atest StagingManagerTest \
PackageInstallerSessionTest \
CtsStagedInstallHostTestCases
Change-Id: Ie1b09aa4c7cbc843712c731a1b903d26684b2e30
This commit is contained in:
@@ -2374,7 +2374,7 @@ public class PackageInstaller {
|
||||
STAGED_SESSION_UNKNOWN,
|
||||
STAGED_SESSION_CONFLICT})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface StagedSessionErrorCode{}
|
||||
public @interface SessionErrorCode {}
|
||||
/**
|
||||
* Constant indicating that no error occurred during the preparation or the activation of
|
||||
* this staged session.
|
||||
@@ -2486,13 +2486,13 @@ public class PackageInstaller {
|
||||
public int[] childSessionIds = NO_SESSIONS;
|
||||
|
||||
/** {@hide} */
|
||||
public boolean isStagedSessionApplied;
|
||||
public boolean isSessionApplied;
|
||||
/** {@hide} */
|
||||
public boolean isStagedSessionReady;
|
||||
public boolean isSessionReady;
|
||||
/** {@hide} */
|
||||
public boolean isStagedSessionFailed;
|
||||
private int mStagedSessionErrorCode;
|
||||
private String mStagedSessionErrorMessage;
|
||||
public boolean isSessionFailed;
|
||||
private int mSessionErrorCode;
|
||||
private String mSessionErrorMessage;
|
||||
|
||||
/** {@hide} */
|
||||
public boolean isCommitted;
|
||||
@@ -2553,11 +2553,11 @@ public class PackageInstaller {
|
||||
if (childSessionIds == null) {
|
||||
childSessionIds = NO_SESSIONS;
|
||||
}
|
||||
isStagedSessionApplied = source.readBoolean();
|
||||
isStagedSessionReady = source.readBoolean();
|
||||
isStagedSessionFailed = source.readBoolean();
|
||||
mStagedSessionErrorCode = source.readInt();
|
||||
mStagedSessionErrorMessage = source.readString();
|
||||
isSessionApplied = source.readBoolean();
|
||||
isSessionReady = source.readBoolean();
|
||||
isSessionFailed = source.readBoolean();
|
||||
mSessionErrorCode = source.readInt();
|
||||
mSessionErrorMessage = source.readString();
|
||||
isCommitted = source.readBoolean();
|
||||
rollbackDataPolicy = source.readInt();
|
||||
createdMillis = source.readLong();
|
||||
@@ -2951,7 +2951,7 @@ public class PackageInstaller {
|
||||
* since that is the one that should have been {@link Session#commit committed}.
|
||||
*/
|
||||
public boolean isStagedSessionActive() {
|
||||
return isStaged && isCommitted && !isStagedSessionApplied && !isStagedSessionFailed
|
||||
return isStaged && isCommitted && !isSessionApplied && !isSessionFailed
|
||||
&& !hasParentSessionId();
|
||||
}
|
||||
|
||||
@@ -2992,7 +2992,7 @@ public class PackageInstaller {
|
||||
*/
|
||||
public boolean isStagedSessionApplied() {
|
||||
checkSessionIsStaged();
|
||||
return isStagedSessionApplied;
|
||||
return isSessionApplied;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3001,7 +3001,7 @@ public class PackageInstaller {
|
||||
*/
|
||||
public boolean isStagedSessionReady() {
|
||||
checkSessionIsStaged();
|
||||
return isStagedSessionReady;
|
||||
return isSessionReady;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3010,16 +3010,16 @@ public class PackageInstaller {
|
||||
*/
|
||||
public boolean isStagedSessionFailed() {
|
||||
checkSessionIsStaged();
|
||||
return isStagedSessionFailed;
|
||||
return isSessionFailed;
|
||||
}
|
||||
|
||||
/**
|
||||
* If something went wrong with a staged session, clients can check this error code to
|
||||
* understand which kind of failure happened. Only meaningful if {@code isStaged} is true.
|
||||
*/
|
||||
public @StagedSessionErrorCode int getStagedSessionErrorCode() {
|
||||
public @SessionErrorCode int getStagedSessionErrorCode() {
|
||||
checkSessionIsStaged();
|
||||
return mStagedSessionErrorCode;
|
||||
return mSessionErrorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3028,14 +3028,13 @@ public class PackageInstaller {
|
||||
*/
|
||||
public @NonNull String getStagedSessionErrorMessage() {
|
||||
checkSessionIsStaged();
|
||||
return mStagedSessionErrorMessage;
|
||||
return mSessionErrorMessage;
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
public void setStagedSessionErrorCode(@StagedSessionErrorCode int errorCode,
|
||||
String errorMessage) {
|
||||
mStagedSessionErrorCode = errorCode;
|
||||
mStagedSessionErrorMessage = errorMessage;
|
||||
public void setSessionErrorCode(@SessionErrorCode int errorCode, String errorMessage) {
|
||||
mSessionErrorCode = errorCode;
|
||||
mSessionErrorMessage = errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3124,11 +3123,11 @@ public class PackageInstaller {
|
||||
dest.writeBoolean(forceQueryable);
|
||||
dest.writeInt(parentSessionId);
|
||||
dest.writeIntArray(childSessionIds);
|
||||
dest.writeBoolean(isStagedSessionApplied);
|
||||
dest.writeBoolean(isStagedSessionReady);
|
||||
dest.writeBoolean(isStagedSessionFailed);
|
||||
dest.writeInt(mStagedSessionErrorCode);
|
||||
dest.writeString(mStagedSessionErrorMessage);
|
||||
dest.writeBoolean(isSessionApplied);
|
||||
dest.writeBoolean(isSessionReady);
|
||||
dest.writeBoolean(isSessionFailed);
|
||||
dest.writeInt(mSessionErrorCode);
|
||||
dest.writeString(mSessionErrorMessage);
|
||||
dest.writeBoolean(isCommitted);
|
||||
dest.writeInt(rollbackDataPolicy);
|
||||
dest.writeLong(createdMillis);
|
||||
|
||||
@@ -1623,7 +1623,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
|
||||
progress);
|
||||
}
|
||||
|
||||
public void onStagedSessionChanged(PackageInstallerSession session) {
|
||||
public void onSessionChanged(PackageInstallerSession session) {
|
||||
session.markUpdated();
|
||||
mSettingsWriteRequest.schedule();
|
||||
if (mOkToSendBroadcasts && !session.isDestroyed()) {
|
||||
|
||||
@@ -81,7 +81,7 @@ import android.content.pm.InstallationFileParcel;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageInstaller.SessionInfo;
|
||||
import android.content.pm.PackageInstaller.SessionInfo.StagedSessionErrorCode;
|
||||
import android.content.pm.PackageInstaller.SessionInfo.SessionErrorCode;
|
||||
import android.content.pm.PackageInstaller.SessionParams;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
@@ -229,8 +229,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
private static final String ATTR_IS_READY = "isReady";
|
||||
private static final String ATTR_IS_FAILED = "isFailed";
|
||||
private static final String ATTR_IS_APPLIED = "isApplied";
|
||||
private static final String ATTR_STAGED_SESSION_ERROR_CODE = "errorCode";
|
||||
private static final String ATTR_STAGED_SESSION_ERROR_MESSAGE = "errorMessage";
|
||||
private static final String ATTR_SESSION_ERROR_CODE = "errorCode";
|
||||
private static final String ATTR_SESSION_ERROR_MESSAGE = "errorMessage";
|
||||
private static final String ATTR_MODE = "mode";
|
||||
private static final String ATTR_INSTALL_FLAGS = "installFlags";
|
||||
private static final String ATTR_INSTALL_LOCATION = "installLocation";
|
||||
@@ -454,22 +454,22 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
@GuardedBy("mLock")
|
||||
private ArrayMap<String, PerFileChecksum> mChecksums = new ArrayMap<>();
|
||||
|
||||
@GuardedBy("mLock")
|
||||
private boolean mSessionApplied;
|
||||
@GuardedBy("mLock")
|
||||
private boolean mSessionReady;
|
||||
@GuardedBy("mLock")
|
||||
private boolean mSessionFailed;
|
||||
@GuardedBy("mLock")
|
||||
private int mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
|
||||
@GuardedBy("mLock")
|
||||
private String mSessionErrorMessage;
|
||||
|
||||
@Nullable
|
||||
final StagedSession mStagedSession;
|
||||
|
||||
@VisibleForTesting
|
||||
public class StagedSession implements StagingManager.StagedSession {
|
||||
@GuardedBy("mLock")
|
||||
private boolean mSessionApplied;
|
||||
@GuardedBy("mLock")
|
||||
private boolean mSessionReady;
|
||||
@GuardedBy("mLock")
|
||||
private boolean mSessionFailed;
|
||||
@GuardedBy("mLock")
|
||||
private int mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
|
||||
@GuardedBy("mLock")
|
||||
private String mSessionErrorMessage;
|
||||
|
||||
/**
|
||||
* The callback to run when pre-reboot verification has ended. Used by {@link #abandon()}
|
||||
* to delay session clean-up until it is safe to do so.
|
||||
@@ -478,15 +478,6 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
@Nullable
|
||||
private Runnable mPendingAbandonCallback;
|
||||
|
||||
StagedSession(boolean isReady, boolean isApplied, boolean isFailed, int errorCode,
|
||||
String errorMessage) {
|
||||
mSessionReady = isReady;
|
||||
mSessionApplied = isApplied;
|
||||
mSessionFailed = isFailed;
|
||||
mSessionErrorCode = errorCode;
|
||||
mSessionErrorMessage = errorMessage != null ? errorMessage : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StagingManager.StagedSession> getChildSessions() {
|
||||
if (!params.isMultiPackage) {
|
||||
@@ -534,52 +525,17 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
|
||||
@Override
|
||||
public void setSessionReady() {
|
||||
synchronized (mLock) {
|
||||
// Do not allow destroyed/failed staged session to change state
|
||||
if (mDestroyed || mSessionFailed) return;
|
||||
mSessionReady = true;
|
||||
mSessionApplied = false;
|
||||
mSessionFailed = false;
|
||||
mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
|
||||
mSessionErrorMessage = "";
|
||||
}
|
||||
mCallback.onStagedSessionChanged(PackageInstallerSession.this);
|
||||
PackageInstallerSession.this.setSessionReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSessionFailed(int errorCode, String errorMessage) {
|
||||
List<PackageInstallerSession> childSessions;
|
||||
synchronized (mLock) {
|
||||
// Do not allow destroyed/failed staged session to change state
|
||||
if (mDestroyed || mSessionFailed) return;
|
||||
mSessionReady = false;
|
||||
mSessionApplied = false;
|
||||
mSessionFailed = true;
|
||||
mSessionErrorCode = errorCode;
|
||||
mSessionErrorMessage = errorMessage;
|
||||
Slog.d(TAG, "Marking session " + sessionId + " as failed: " + errorMessage);
|
||||
childSessions = getChildSessionsLocked();
|
||||
}
|
||||
destroy();
|
||||
mCallback.onStagedSessionChanged(PackageInstallerSession.this);
|
||||
PackageInstallerSession.this.setSessionFailed(errorCode, errorMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSessionApplied() {
|
||||
List<PackageInstallerSession> childSessions;
|
||||
synchronized (mLock) {
|
||||
// Do not allow destroyed/failed staged session to change state
|
||||
if (mDestroyed || mSessionFailed) return;
|
||||
mSessionReady = false;
|
||||
mSessionApplied = true;
|
||||
mSessionFailed = false;
|
||||
mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
|
||||
mSessionErrorMessage = "";
|
||||
Slog.d(TAG, "Marking session " + sessionId + " as applied");
|
||||
childSessions = getChildSessionsLocked();
|
||||
}
|
||||
destroy();
|
||||
mCallback.onStagedSessionChanged(PackageInstallerSession.this);
|
||||
PackageInstallerSession.this.setSessionApplied();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -656,35 +612,17 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
|
||||
@Override
|
||||
public boolean isSessionReady() {
|
||||
synchronized (mLock) {
|
||||
return mSessionReady;
|
||||
}
|
||||
return PackageInstallerSession.this.isSessionReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSessionApplied() {
|
||||
synchronized (mLock) {
|
||||
return mSessionApplied;
|
||||
}
|
||||
return PackageInstallerSession.this.isSessionApplied();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSessionFailed() {
|
||||
synchronized (mLock) {
|
||||
return mSessionFailed;
|
||||
}
|
||||
}
|
||||
|
||||
@StagedSessionErrorCode int getSessionErrorCode() {
|
||||
synchronized (mLock) {
|
||||
return mSessionErrorCode;
|
||||
}
|
||||
}
|
||||
|
||||
String getSessionErrorMessage() {
|
||||
synchronized (mLock) {
|
||||
return mSessionErrorMessage;
|
||||
}
|
||||
return PackageInstallerSession.this.isSessionFailed();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -714,7 +652,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
if (mStageDirInUse) {
|
||||
// Pre-reboot verification is ongoing, not safe to clean up the session yet.
|
||||
mPendingAbandonCallback = r;
|
||||
mCallback.onStagedSessionChanged(PackageInstallerSession.this);
|
||||
mCallback.onSessionChanged(PackageInstallerSession.this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1015,8 +953,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
ArrayMap<String, PerFileChecksum> checksums,
|
||||
boolean prepared, boolean committed, boolean destroyed, boolean sealed,
|
||||
@Nullable int[] childSessionIds, int parentSessionId, boolean isReady,
|
||||
boolean isFailed, boolean isApplied, int stagedSessionErrorCode,
|
||||
String stagedSessionErrorMessage) {
|
||||
boolean isFailed, boolean isApplied, int sessionErrorCode,
|
||||
String sessionErrorMessage) {
|
||||
mCallback = callback;
|
||||
mContext = context;
|
||||
mPm = pm;
|
||||
@@ -1071,8 +1009,13 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
mPrepared = prepared;
|
||||
mCommitted.set(committed);
|
||||
mDestroyed = destroyed;
|
||||
mStagedSession = params.isStaged ? new StagedSession(isReady, isApplied, isFailed,
|
||||
stagedSessionErrorCode, stagedSessionErrorMessage) : null;
|
||||
mSessionReady = isReady;
|
||||
mSessionApplied = isApplied;
|
||||
mSessionFailed = isFailed;
|
||||
mSessionErrorCode = sessionErrorCode;
|
||||
mSessionErrorMessage =
|
||||
sessionErrorMessage != null ? sessionErrorMessage : "";
|
||||
mStagedSession = params.isStaged ? new StagedSession() : null;
|
||||
|
||||
if (isDataLoaderInstallation()) {
|
||||
if (isApexSession()) {
|
||||
@@ -1173,11 +1116,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
info.rollbackDataPolicy = params.rollbackDataPolicy;
|
||||
info.parentSessionId = mParentSessionId;
|
||||
info.childSessionIds = getChildSessionIdsLocked();
|
||||
info.isStagedSessionApplied = isStagedSessionApplied();
|
||||
info.isStagedSessionReady = isStagedSessionReady();
|
||||
info.isStagedSessionFailed = isStagedSessionFailed();
|
||||
info.setStagedSessionErrorCode(getStagedSessionErrorCode(),
|
||||
getStagedSessionErrorMessage());
|
||||
info.isSessionApplied = mSessionApplied;
|
||||
info.isSessionReady = mSessionReady;
|
||||
info.isSessionFailed = mSessionFailed;
|
||||
info.setSessionErrorCode(mSessionErrorCode, mSessionErrorMessage);
|
||||
info.createdMillis = createdMillis;
|
||||
info.updatedMillis = updatedMillis;
|
||||
info.requireUserAction = params.requireUserAction;
|
||||
@@ -4261,30 +4203,83 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
boolean isStagedSessionReady() {
|
||||
return params.isStaged && mStagedSession.isSessionReady();
|
||||
private void setSessionReady() {
|
||||
synchronized (mLock) {
|
||||
// Do not allow destroyed/failed session to change state
|
||||
if (mDestroyed || mSessionFailed) return;
|
||||
mSessionReady = true;
|
||||
mSessionApplied = false;
|
||||
mSessionFailed = false;
|
||||
mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
|
||||
mSessionErrorMessage = "";
|
||||
}
|
||||
mCallback.onSessionChanged(this);
|
||||
}
|
||||
|
||||
private void setSessionFailed(int errorCode, String errorMessage) {
|
||||
synchronized (mLock) {
|
||||
// Do not allow destroyed/failed session to change state
|
||||
if (mDestroyed || mSessionFailed) return;
|
||||
mSessionReady = false;
|
||||
mSessionApplied = false;
|
||||
mSessionFailed = true;
|
||||
mSessionErrorCode = errorCode;
|
||||
mSessionErrorMessage = errorMessage;
|
||||
Slog.d(TAG, "Marking session " + sessionId + " as failed: " + errorMessage);
|
||||
}
|
||||
destroy();
|
||||
mCallback.onSessionChanged(this);
|
||||
}
|
||||
|
||||
private void setSessionApplied() {
|
||||
synchronized (mLock) {
|
||||
// Do not allow destroyed/failed session to change state
|
||||
if (mDestroyed || mSessionFailed) return;
|
||||
mSessionReady = false;
|
||||
mSessionApplied = true;
|
||||
mSessionFailed = false;
|
||||
mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
|
||||
mSessionErrorMessage = "";
|
||||
Slog.d(TAG, "Marking session " + sessionId + " as applied");
|
||||
}
|
||||
destroy();
|
||||
mCallback.onSessionChanged(this);
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
boolean isStagedSessionApplied() {
|
||||
return params.isStaged && mStagedSession.isSessionApplied();
|
||||
boolean isSessionReady() {
|
||||
synchronized (mLock) {
|
||||
return mSessionReady;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
boolean isStagedSessionFailed() {
|
||||
return params.isStaged && mStagedSession.isSessionFailed();
|
||||
boolean isSessionApplied() {
|
||||
synchronized (mLock) {
|
||||
return mSessionApplied;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
@StagedSessionErrorCode int getStagedSessionErrorCode() {
|
||||
return params.isStaged ? mStagedSession.getSessionErrorCode()
|
||||
: SessionInfo.STAGED_SESSION_NO_ERROR;
|
||||
boolean isSessionFailed() {
|
||||
synchronized (mLock) {
|
||||
return mSessionFailed;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
String getStagedSessionErrorMessage() {
|
||||
return params.isStaged ? mStagedSession.getSessionErrorMessage() : "";
|
||||
@SessionErrorCode
|
||||
int getSessionErrorCode() {
|
||||
synchronized (mLock) {
|
||||
return mSessionErrorCode;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
String getSessionErrorMessage() {
|
||||
synchronized (mLock) {
|
||||
return mSessionErrorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4386,11 +4381,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
pw.printPair("params.isStaged", params.isStaged);
|
||||
pw.printPair("mParentSessionId", mParentSessionId);
|
||||
pw.printPair("mChildSessionIds", getChildSessionIdsLocked());
|
||||
pw.printPair("mStagedSessionApplied", isStagedSessionApplied());
|
||||
pw.printPair("mStagedSessionFailed", isStagedSessionFailed());
|
||||
pw.printPair("mStagedSessionReady", isStagedSessionReady());
|
||||
pw.printPair("mStagedSessionErrorCode", getStagedSessionErrorCode());
|
||||
pw.printPair("mStagedSessionErrorMessage", getStagedSessionErrorMessage());
|
||||
pw.printPair("mSessionApplied", mSessionApplied);
|
||||
pw.printPair("mSessionFailed", mSessionFailed);
|
||||
pw.printPair("mSessionReady", mSessionReady);
|
||||
pw.printPair("mSessionErrorCode", mSessionErrorCode);
|
||||
pw.printPair("mSessionErrorMessage", mSessionErrorMessage);
|
||||
pw.println();
|
||||
|
||||
pw.decreaseIndent();
|
||||
@@ -4556,12 +4551,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
|
||||
writeBooleanAttribute(out, ATTR_MULTI_PACKAGE, params.isMultiPackage);
|
||||
writeBooleanAttribute(out, ATTR_STAGED_SESSION, params.isStaged);
|
||||
writeBooleanAttribute(out, ATTR_IS_READY, isStagedSessionReady());
|
||||
writeBooleanAttribute(out, ATTR_IS_FAILED, isStagedSessionFailed());
|
||||
writeBooleanAttribute(out, ATTR_IS_APPLIED, isStagedSessionApplied());
|
||||
out.attributeInt(null, ATTR_STAGED_SESSION_ERROR_CODE, getStagedSessionErrorCode());
|
||||
writeStringAttribute(out, ATTR_STAGED_SESSION_ERROR_MESSAGE,
|
||||
getStagedSessionErrorMessage());
|
||||
writeBooleanAttribute(out, ATTR_IS_READY, mSessionReady);
|
||||
writeBooleanAttribute(out, ATTR_IS_FAILED, mSessionFailed);
|
||||
writeBooleanAttribute(out, ATTR_IS_APPLIED, mSessionApplied);
|
||||
out.attributeInt(null, ATTR_SESSION_ERROR_CODE, mSessionErrorCode);
|
||||
writeStringAttribute(out, ATTR_SESSION_ERROR_MESSAGE, mSessionErrorMessage);
|
||||
// TODO(patb,109941548): avoid writing to xml and instead infer / validate this after
|
||||
// we've read all sessions.
|
||||
out.attributeInt(null, ATTR_PARENT_SESSION_ID, mParentSessionId);
|
||||
@@ -4752,10 +4746,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
final boolean isReady = in.getAttributeBoolean(null, ATTR_IS_READY, false);
|
||||
final boolean isFailed = in.getAttributeBoolean(null, ATTR_IS_FAILED, false);
|
||||
final boolean isApplied = in.getAttributeBoolean(null, ATTR_IS_APPLIED, false);
|
||||
final int stagedSessionErrorCode = in.getAttributeInt(null, ATTR_STAGED_SESSION_ERROR_CODE,
|
||||
final int sessionErrorCode = in.getAttributeInt(null, ATTR_SESSION_ERROR_CODE,
|
||||
SessionInfo.STAGED_SESSION_NO_ERROR);
|
||||
final String stagedSessionErrorMessage = readStringAttribute(in,
|
||||
ATTR_STAGED_SESSION_ERROR_MESSAGE);
|
||||
final String sessionErrorMessage = readStringAttribute(in, ATTR_SESSION_ERROR_MESSAGE);
|
||||
|
||||
if (!isStagedSessionStateValid(isReady, isApplied, isFailed)) {
|
||||
throw new IllegalArgumentException("Can't restore staged session with invalid state.");
|
||||
@@ -4869,6 +4862,6 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
installerUid, installSource, params, createdMillis, committedMillis, stageDir,
|
||||
stageCid, fileArray, checksumsMap, prepared, committed, destroyed, sealed,
|
||||
childSessionIdsArray, parentSessionId, isReady, isFailed, isApplied,
|
||||
stagedSessionErrorCode, stagedSessionErrorMessage);
|
||||
sessionErrorCode, sessionErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ final class PackageSessionVerifier {
|
||||
}
|
||||
|
||||
private void onVerificationFailure(StagingManager.StagedSession session, Callback callback,
|
||||
@SessionInfo.StagedSessionErrorCode int errorCode, String errorMessage) {
|
||||
@SessionInfo.SessionErrorCode int errorCode, String errorMessage) {
|
||||
if (!ensureActiveApexSessionIsAborted(session)) {
|
||||
Slog.e(TAG, "Failed to abort apex session " + session.sessionId());
|
||||
// Safe to ignore active apex session abortion failure since session will be marked
|
||||
|
||||
@@ -32,7 +32,7 @@ import android.content.pm.ApexStagedEvent;
|
||||
import android.content.pm.IStagedApexObserver;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageInstaller.SessionInfo;
|
||||
import android.content.pm.PackageInstaller.SessionInfo.StagedSessionErrorCode;
|
||||
import android.content.pm.PackageInstaller.SessionInfo.SessionErrorCode;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
import android.content.pm.StagedApexInfo;
|
||||
@@ -129,7 +129,7 @@ public class StagingManager {
|
||||
boolean containsApkSession();
|
||||
boolean containsApexSession();
|
||||
void setSessionReady();
|
||||
void setSessionFailed(@StagedSessionErrorCode int errorCode, String errorMessage);
|
||||
void setSessionFailed(@SessionErrorCode int errorCode, String errorMessage);
|
||||
void setSessionApplied();
|
||||
void installSession(IntentSender statusReceiver);
|
||||
boolean hasParentSessionId();
|
||||
|
||||
@@ -41,7 +41,7 @@ import android.content.pm.ApexStagedEvent;
|
||||
import android.content.pm.IStagedApexObserver;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageInstaller.SessionInfo;
|
||||
import android.content.pm.PackageInstaller.SessionInfo.StagedSessionErrorCode;
|
||||
import android.content.pm.PackageInstaller.SessionInfo.SessionErrorCode;
|
||||
import android.content.pm.StagedApexInfo;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.storage.IStorageManager;
|
||||
@@ -774,7 +774,7 @@ public class StagingManagerTest {
|
||||
private boolean mIsReady = false;
|
||||
private boolean mIsApplied = false;
|
||||
private boolean mIsFailed = false;
|
||||
private @StagedSessionErrorCode int mErrorCode = -1;
|
||||
private @SessionErrorCode int mErrorCode = -1;
|
||||
private String mErrorMessage;
|
||||
private boolean mIsDestroyed = false;
|
||||
private int mParentSessionId = -1;
|
||||
@@ -827,7 +827,7 @@ public class StagingManagerTest {
|
||||
return this;
|
||||
}
|
||||
|
||||
private @StagedSessionErrorCode int getErrorCode() {
|
||||
private @SessionErrorCode int getErrorCode() {
|
||||
return mErrorCode;
|
||||
}
|
||||
|
||||
@@ -939,7 +939,7 @@ public class StagingManagerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSessionFailed(@StagedSessionErrorCode int errorCode, String errorMessage) {
|
||||
public void setSessionFailed(@SessionErrorCode int errorCode, String errorMessage) {
|
||||
Preconditions.checkState(!mIsApplied, "Already marked as applied");
|
||||
mIsFailed = true;
|
||||
mErrorCode = errorCode;
|
||||
|
||||
@@ -306,12 +306,12 @@ public class PackageInstallerSessionTest {
|
||||
assertEquals(expected.stageCid, actual.stageCid);
|
||||
assertEquals(expected.isPrepared(), actual.isPrepared());
|
||||
assertEquals(expected.isStaged(), actual.isStaged());
|
||||
assertEquals(expected.isStagedSessionApplied(), actual.isStagedSessionApplied());
|
||||
assertEquals(expected.isStagedSessionFailed(), actual.isStagedSessionFailed());
|
||||
assertEquals(expected.isStagedSessionReady(), actual.isStagedSessionReady());
|
||||
assertEquals(expected.getStagedSessionErrorCode(), actual.getStagedSessionErrorCode());
|
||||
assertEquals(expected.getStagedSessionErrorMessage(),
|
||||
actual.getStagedSessionErrorMessage());
|
||||
assertEquals(expected.isSessionApplied(), actual.isSessionApplied());
|
||||
assertEquals(expected.isSessionFailed(), actual.isSessionFailed());
|
||||
assertEquals(expected.isSessionReady(), actual.isSessionReady());
|
||||
assertEquals(expected.getSessionErrorCode(), actual.getSessionErrorCode());
|
||||
assertEquals(expected.getSessionErrorMessage(),
|
||||
actual.getSessionErrorMessage());
|
||||
assertEquals(expected.isPrepared(), actual.isPrepared());
|
||||
assertEquals(expected.isCommitted(), actual.isCommitted());
|
||||
assertEquals(expected.createdMillis, actual.createdMillis);
|
||||
|
||||
Reference in New Issue
Block a user