Merge "Add STAGED_SESSION_ prefix to error codes."

This commit is contained in:
Dario Freni
2019-02-04 10:34:09 +00:00
committed by Android (Google) Code Review
6 changed files with 32 additions and 20 deletions

View File

@@ -11465,11 +11465,12 @@ package android.content.pm {
method public boolean isSessionReady();
method public boolean isStaged();
method public void writeToParcel(android.os.Parcel, int);
field public static final int ACTIVATION_FAILED = 2; // 0x2
field public static final android.os.Parcelable.Creator<android.content.pm.PackageInstaller.SessionInfo> CREATOR;
field public static final int INVALID_ID = -1; // 0xffffffff
field public static final int NO_ERROR = 0; // 0x0
field public static final int VERIFICATION_FAILED = 1; // 0x1
field public static final int STAGED_SESSION_ACTIVATION_FAILED = 2; // 0x2
field public static final int STAGED_SESSION_NO_ERROR = 0; // 0x0
field public static final int STAGED_SESSION_UNKNOWN = 3; // 0x3
field public static final int STAGED_SESSION_VERIFICATION_FAILED = 1; // 0x1
}
public static class PackageInstaller.SessionParams implements android.os.Parcelable {

View File

@@ -1625,26 +1625,35 @@ public class PackageInstaller {
private static final int[] NO_SESSIONS = {};
/** @hide */
@IntDef(value = {NO_ERROR, VERIFICATION_FAILED, ACTIVATION_FAILED})
@IntDef(prefix = { "STAGED_SESSION_" }, value = {
STAGED_SESSION_NO_ERROR,
STAGED_SESSION_VERIFICATION_FAILED,
STAGED_SESSION_ACTIVATION_FAILED,
STAGED_SESSION_UNKNOWN})
@Retention(RetentionPolicy.SOURCE)
public @interface StagedSessionErrorCode{}
/**
* Constant indicating that no error occurred during the preparation or the activation of
* this staged session.
*/
public static final int NO_ERROR = 0;
public static final int STAGED_SESSION_NO_ERROR = 0;
/**
* Constant indicating that an error occurred during the verification phase (pre-reboot) of
* this staged session.
*/
public static final int VERIFICATION_FAILED = 1;
public static final int STAGED_SESSION_VERIFICATION_FAILED = 1;
/**
* Constant indicating that an error occurred during the activation phase (post-reboot) of
* this staged session.
*/
public static final int ACTIVATION_FAILED = 2;
public static final int STAGED_SESSION_ACTIVATION_FAILED = 2;
/**
* Constant indicating that an unknown error occurred while processing this staged session.
*/
public static final int STAGED_SESSION_UNKNOWN = 3;
/** {@hide} */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)

View File

@@ -567,8 +567,8 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
session = new PackageInstallerSession(mInternalCallback, mContext, mPm, this,
mInstallThread.getLooper(), mStagingManager, sessionId, userId,
installerPackageName, callingUid, params, createdMillis, stageDir, stageCid, false,
false, null, SessionInfo.INVALID_ID, false, false, false, SessionInfo.NO_ERROR,
"");
false, null, SessionInfo.INVALID_ID, false, false, false,
SessionInfo.STAGED_SESSION_NO_ERROR, "");
synchronized (mSessions) {
mSessions.put(sessionId, session);

View File

@@ -267,7 +267,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
@GuardedBy("mLock")
private boolean mStagedSessionFailed;
@GuardedBy("mLock")
private int mStagedSessionErrorCode = SessionInfo.NO_ERROR;
private int mStagedSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
@GuardedBy("mLock")
private String mStagedSessionErrorMessage;
@@ -2004,7 +2004,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
mStagedSessionReady = true;
mStagedSessionApplied = false;
mStagedSessionFailed = false;
mStagedSessionErrorCode = SessionInfo.NO_ERROR;
mStagedSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
mStagedSessionErrorMessage = "";
}
mCallback.onStagedSessionChanged(this);
@@ -2030,7 +2030,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
mStagedSessionReady = false;
mStagedSessionApplied = true;
mStagedSessionFailed = false;
mStagedSessionErrorCode = SessionInfo.NO_ERROR;
mStagedSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
mStagedSessionErrorMessage = "";
}
mCallback.onStagedSessionChanged(this);
@@ -2298,7 +2298,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
final boolean isFailed = readBooleanAttribute(in, ATTR_IS_FAILED);
final boolean isApplied = readBooleanAttribute(in, ATTR_IS_APPLIED);
final int stagedSessionErrorCode = readIntAttribute(in, ATTR_STAGED_SESSION_ERROR_CODE,
SessionInfo.NO_ERROR);
SessionInfo.STAGED_SESSION_NO_ERROR);
final String stagedSessionErrorMessage = readStringAttribute(in,
ATTR_STAGED_SESSION_ERROR_MESSAGE);

View File

@@ -215,7 +215,7 @@ public class StagingManager {
if (!success) {
session.setStagedSessionFailed(
SessionInfo.VERIFICATION_FAILED,
SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
"APEX staging failed, check logcat messages from apexd for more details.");
}
@@ -227,7 +227,7 @@ public class StagingManager {
for (ApexInfo apexPackage : apexInfoList.apexInfos) {
if (!validateApexSignature(apexPackage.packagePath,
apexPackage.packageName)) {
session.setStagedSessionFailed(SessionInfo.VERIFICATION_FAILED,
session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
"APK-container signature verification failed for package "
+ apexPackage.packageName + ". Signature of file "
+ apexPackage.packagePath + " does not match the signature of "
@@ -240,7 +240,7 @@ public class StagingManager {
session.setStagedSessionReady();
if (!sendMarkStagedSessionReadyRequest(session.sessionId)) {
session.setStagedSessionFailed(SessionInfo.VERIFICATION_FAILED,
session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
"APEX staging failed, check logcat messages from apexd for more "
+ "details.");
}
@@ -276,7 +276,7 @@ public class StagingManager {
return;
}
if (apexSessionInfo.isActivationFailed || apexSessionInfo.isUnknown) {
session.setStagedSessionFailed(SessionInfo.ACTIVATION_FAILED,
session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED,
"APEX activation failed. Check logcat messages from apexd for "
+ "more information.");
return;
@@ -301,8 +301,9 @@ public class StagingManager {
}
// The APEX part of the session is activated, proceed with the installation of APKs.
if (!installApksInSession(session)) {
session.setStagedSessionFailed(SessionInfo.ACTIVATION_FAILED,
"APK installation for staged session " + session.sessionId + " failed.");
session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED,
"APEX activation failed. Check logcat messages from apexd for "
+ "more information.");
return;
}
session.setStagedSessionApplied();

View File

@@ -173,7 +173,8 @@ public class PackageInstallerSessionTest {
/* isReady */ staged ? true : false,
/* isFailed */ false,
/* isApplied */false,
/* stagedSessionErrorCode */ PackageInstaller.SessionInfo.VERIFICATION_FAILED,
/* stagedSessionErrorCode */
PackageInstaller.SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
/* stagedSessionErrorMessage */ "some error");
}