Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af8ff1c9 authored by JW Wang's avatar JW Wang
Browse files

Rename STAGED_SESSION* error codes (2/n)

Rename the error codes as they will be used by
non-staged sessions as well.

Bug: 210359798
Test: atest StagingManagerTest \
            PackageInstallerSessionTest \
            CtsStagedInstallHostTestCases

Change-Id: Iec572d7a85f2615204ac069a42edb569ecadb294
parent 189f6926
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -12762,11 +12762,16 @@ package android.content.pm {
    method public void writeToParcel(android.os.Parcel, int);
    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 STAGED_SESSION_ACTIVATION_FAILED = 2; // 0x2
    field public static final int STAGED_SESSION_CONFLICT = 4; // 0x4
    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
    field public static final int SESSION_ACTIVATION_FAILED = 2; // 0x2
    field public static final int SESSION_CONFLICT = 4; // 0x4
    field public static final int SESSION_NO_ERROR = 0; // 0x0
    field public static final int SESSION_UNKNOWN_ERROR = 3; // 0x3
    field public static final int SESSION_VERIFICATION_FAILED = 1; // 0x1
    field @Deprecated public static final int STAGED_SESSION_ACTIVATION_FAILED = 2; // 0x2
    field @Deprecated public static final int STAGED_SESSION_CONFLICT = 4; // 0x4
    field @Deprecated public static final int STAGED_SESSION_NO_ERROR = 0; // 0x0
    field @Deprecated public static final int STAGED_SESSION_UNKNOWN = 3; // 0x3
    field @Deprecated public static final int STAGED_SESSION_VERIFICATION_FAILED = 1; // 0x1
  }
  public static class PackageInstaller.SessionParams implements android.os.Parcelable {
+45 −15
Original line number Diff line number Diff line
@@ -2367,43 +2367,73 @@ public class PackageInstaller {
        private static final int[] NO_SESSIONS = {};

        /** @hide */
        @IntDef(prefix = { "STAGED_SESSION_" }, value = {
                STAGED_SESSION_NO_ERROR,
                STAGED_SESSION_VERIFICATION_FAILED,
                STAGED_SESSION_ACTIVATION_FAILED,
                STAGED_SESSION_UNKNOWN,
                STAGED_SESSION_CONFLICT})
        @IntDef(prefix = { "SESSION_" }, value = {
                SESSION_NO_ERROR,
                SESSION_VERIFICATION_FAILED,
                SESSION_ACTIVATION_FAILED,
                SESSION_UNKNOWN_ERROR,
                SESSION_CONFLICT})
        @Retention(RetentionPolicy.SOURCE)
        public @interface SessionErrorCode {}
        /**
         * Constant indicating that no error occurred during the preparation or the activation of
         * this staged session.
         * @deprecated use {@link #SESSION_NO_ERROR}.
         */
        @Deprecated
        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.
         * @deprecated use {@link #SESSION_VERIFICATION_FAILED}.
         */
        @Deprecated
        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.
         * @deprecated use {@link #SESSION_ACTIVATION_FAILED}.
         */
        @Deprecated
        public static final int STAGED_SESSION_ACTIVATION_FAILED = 2;

        /**
         * Constant indicating that an unknown error occurred while processing this staged session.
         * @deprecated use {@link #SESSION_UNKNOWN_ERROR}.
         */
        @Deprecated
        public static final int STAGED_SESSION_UNKNOWN = 3;

        /**
         * Constant indicating that the session was in conflict with another staged session and had
         * to be sacrificed for resolution.
         * @deprecated use {@link #SESSION_CONFLICT}.
         */
        @Deprecated
        public static final int STAGED_SESSION_CONFLICT = 4;

        /**
         * Constant indicating that no error occurred during the preparation or the activation of
         * this session.
         */
        public static final int SESSION_NO_ERROR = 0;

        /**
         * Constant indicating that an error occurred during the verification phase of
         * this session.
         */
        public static final int SESSION_VERIFICATION_FAILED = 1;

        /**
         * Constant indicating that an error occurred during the activation phase of
         * this session.
         */
        public static final int SESSION_ACTIVATION_FAILED = 2;

        /**
         * Constant indicating that an unknown error occurred while processing this session.
         */
        public static final int SESSION_UNKNOWN_ERROR = 3;

        /**
         * Constant indicating that the session was in conflict with another session and had
         * to be sacrificed for resolution.
         */
        public static final int SESSION_CONFLICT = 4;

        private static String userActionToString(int requireUserAction) {
            switch(requireUserAction) {
                case SessionParams.USER_ACTION_REQUIRED:
+2 −2
Original line number Diff line number Diff line
@@ -799,7 +799,7 @@ public abstract class ApexManager {
                throw new RuntimeException(re);
            } catch (Exception e) {
                throw new PackageManagerException(
                        PackageInstaller.SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
                        PackageInstaller.SessionInfo.SESSION_VERIFICATION_FAILED,
                        "apexd verification failed : " + e.getMessage());
            }
        }
@@ -826,7 +826,7 @@ public abstract class ApexManager {
                throw new RuntimeException(re);
            } catch (Exception e) {
                throw new PackageManagerException(
                        PackageInstaller.SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
                        PackageInstaller.SessionInfo.SESSION_VERIFICATION_FAILED,
                        "Failed to mark apexd session as ready : " + e.getMessage());
            }
        }
+2 −2
Original line number Diff line number Diff line
@@ -331,7 +331,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
                StagingManager.StagedSession stagedSession = session.mStagedSession;
                if (!stagedSession.isInTerminalState() && stagedSession.hasParentSessionId()
                        && getSession(stagedSession.getParentSessionId()) == null) {
                    stagedSession.setSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED,
                    stagedSession.setSessionFailed(SessionInfo.SESSION_ACTIVATION_FAILED,
                            "An orphan staged session " + stagedSession.sessionId() + " is found, "
                                + "parent " + stagedSession.getParentSessionId() + " is missing");
                    continue;
@@ -843,7 +843,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
                mSilentUpdatePolicy, mInstallThread.getLooper(), mStagingManager, sessionId,
                userId, callingUid, installSource, params, createdMillis, 0L, stageDir, stageCid,
                null, null, false, false, false, false, null, SessionInfo.INVALID_ID,
                false, false, false, SessionInfo.STAGED_SESSION_NO_ERROR, "");
                false, false, false, SessionInfo.SESSION_NO_ERROR, "");

        synchronized (mSessions) {
            mSessions.put(sessionId, session);
+6 −6
Original line number Diff line number Diff line
@@ -460,7 +460,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    @GuardedBy("mLock")
    private boolean mSessionFailed;
    @GuardedBy("mLock")
    private int mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
    private int mSessionErrorCode = SessionInfo.SESSION_NO_ERROR;
    @GuardedBy("mLock")
    private String mSessionErrorMessage;

@@ -2092,7 +2092,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        if (isStaged()) {
            // This will clean up the session when it reaches the terminal state
            mStagedSession.setSessionFailed(
                    SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, msgWithErrorCode);
                    SessionInfo.SESSION_VERIFICATION_FAILED, msgWithErrorCode);
            mStagedSession.notifyEndPreRebootVerification();
        } else {
            // Session is sealed and committed but could not be verified, we need to destroy it.
@@ -2547,7 +2547,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        if (isStaged()) {
            mSessionProvider.getSessionVerifier().verifyStaged(mStagedSession, (error, msg) -> {
                mStagedSession.notifyEndPreRebootVerification();
                if (error == SessionInfo.STAGED_SESSION_NO_ERROR) {
                if (error == SessionInfo.SESSION_NO_ERROR) {
                    mStagingManager.commitSession(mStagedSession);
                }
            });
@@ -4168,7 +4168,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            mSessionReady = true;
            mSessionApplied = false;
            mSessionFailed = false;
            mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
            mSessionErrorCode = SessionInfo.SESSION_NO_ERROR;
            mSessionErrorMessage = "";
        }
        mCallback.onSessionChanged(this);
@@ -4196,7 +4196,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            mSessionReady = false;
            mSessionApplied = true;
            mSessionFailed = false;
            mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR;
            mSessionErrorCode = SessionInfo.SESSION_NO_ERROR;
            mSessionErrorMessage = "";
            Slog.d(TAG, "Marking session " + sessionId + " as applied");
        }
@@ -4705,7 +4705,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        final boolean isFailed = in.getAttributeBoolean(null, ATTR_IS_FAILED, false);
        final boolean isApplied = in.getAttributeBoolean(null, ATTR_IS_APPLIED, false);
        final int sessionErrorCode = in.getAttributeInt(null, ATTR_SESSION_ERROR_CODE,
                SessionInfo.STAGED_SESSION_NO_ERROR);
                SessionInfo.SESSION_NO_ERROR);
        final String sessionErrorMessage = readStringAttribute(in, ATTR_SESSION_ERROR_MESSAGE);

        if (!isStagedSessionStateValid(isReady, isApplied, isFailed)) {
Loading