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

Commit a5bf2d25 authored by Mohammad Samiul Islam's avatar Mohammad Samiul Islam Committed by Android (Google) Code Review
Browse files

Merge changes from topic "unblock-rollback"

* changes:
  Fail blocking staged session when rollback is committed
  Cleanup how we handle abort of active apex session
parents e02da8f2 8f050435
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11900,6 +11900,7 @@ package android.content.pm {
    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_NO_ERROR = 0; // 0x0
    field public static final int STAGED_SESSION_OTHER_ERROR = 4; // 0x4
    field public static final int STAGED_SESSION_UNKNOWN = 3; // 0x3
    field public static final int STAGED_SESSION_VERIFICATION_FAILED = 1; // 0x1
  }
+8 −1
Original line number Diff line number Diff line
@@ -2075,7 +2075,8 @@ public class PackageInstaller {
                STAGED_SESSION_NO_ERROR,
                STAGED_SESSION_VERIFICATION_FAILED,
                STAGED_SESSION_ACTIVATION_FAILED,
                STAGED_SESSION_UNKNOWN})
                STAGED_SESSION_UNKNOWN,
                STAGED_SESSION_OTHER_ERROR})
        @Retention(RetentionPolicy.SOURCE)
        public @interface StagedSessionErrorCode{}
        /**
@@ -2101,6 +2102,12 @@ public class PackageInstaller {
         */
        public static final int STAGED_SESSION_UNKNOWN = 3;

        /**
         * Constant indicating that a known error occurred while processing this staged session, but
         * the error could not be matched to other categories.
         */
        public static final int STAGED_SESSION_OTHER_ERROR = 4;

        /** {@hide} */
        @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
        public int sessionId;
+1 −0
Original line number Diff line number Diff line
@@ -11900,6 +11900,7 @@ package android.content.pm {
    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_NO_ERROR = 0; // 0x0
    field public static final int STAGED_SESSION_OTHER_ERROR = 4; // 0x4
    field public static final int STAGED_SESSION_UNKNOWN = 3; // 0x3
    field public static final int STAGED_SESSION_VERIFICATION_FAILED = 1; // 0x1
  }
+8 −11
Original line number Diff line number Diff line
@@ -270,11 +270,12 @@ public abstract class ApexManager {
    abstract boolean revertActiveSessions();

    /**
     * Abandons the staged session with the given sessionId.
     * Abandons the staged session with the given sessionId. Client should handle {@code false}
     * return value carefully as failure here can leave device in inconsistent state.
     *
     * @return {@code true} upon success, {@code false} if any remote exception occurs
     * @return {@code true} upon success, {@code false} if any exception occurs
     */
    abstract boolean abortStagedSession(int sessionId) throws PackageManagerException;
    abstract boolean abortStagedSession(int sessionId);

    /**
     * Uninstalls given {@code apexPackage}.
@@ -753,17 +754,13 @@ public abstract class ApexManager {
        }

        @Override
        boolean abortStagedSession(int sessionId) throws PackageManagerException {
        boolean abortStagedSession(int sessionId) {
            try {
                waitForApexService().abortStagedSession(sessionId);
                return true;
            } catch (RemoteException re) {
                Slog.e(TAG, "Unable to contact apexservice", re);
                return false;
            } catch (Exception e) {
                throw new PackageManagerException(
                        PackageInstaller.SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
                        "Failed to abort staged session : " + e.getMessage());
                Slog.e(TAG, e.getMessage(), e);
                return false;
            }
        }

@@ -1122,7 +1119,7 @@ public abstract class ApexManager {
        }

        @Override
        boolean abortStagedSession(int sessionId) throws PackageManagerException {
        boolean abortStagedSession(int sessionId) {
            throw new UnsupportedOperationException();
        }

+7 −5
Original line number Diff line number Diff line
@@ -3321,7 +3321,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    /** {@hide} */
    void setStagedSessionReady() {
        synchronized (mLock) {
            if (mDestroyed) return; // Do not allow destroyed staged session to change state
            // Do not allow destroyed/failed staged session to change state
            if (mDestroyed || mStagedSessionFailed) return;
            mStagedSessionReady = true;
            mStagedSessionApplied = false;
            mStagedSessionFailed = false;
@@ -3332,10 +3333,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    }

    /** {@hide} */
    void setStagedSessionFailed(@StagedSessionErrorCode int errorCode,
                                String errorMessage) {
    void setStagedSessionFailed(@StagedSessionErrorCode int errorCode, String errorMessage) {
        synchronized (mLock) {
            if (mDestroyed) return; // Do not allow destroyed staged session to change state
            // Do not allow destroyed/failed staged session to change state
            if (mDestroyed || mStagedSessionFailed) return;
            mStagedSessionReady = false;
            mStagedSessionApplied = false;
            mStagedSessionFailed = true;
@@ -3350,7 +3351,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    /** {@hide} */
    void setStagedSessionApplied() {
        synchronized (mLock) {
            if (mDestroyed) return; // Do not allow destroyed staged session to change state
            // Do not allow destroyed/failed staged session to change state
            if (mDestroyed || mStagedSessionFailed) return;
            mStagedSessionReady = false;
            mStagedSessionApplied = true;
            mStagedSessionFailed = false;
Loading