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

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

Merge "Allow StagingManager to abort individual staged session"

parents 0d96dc18 44ad95be
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -208,6 +208,13 @@ abstract class ApexManager {
     */
    abstract boolean abortActiveSession();

    /**
     * Abandons the staged session with the given sessionId.
     *
     * @return {@code true} upon success, {@code false} if any remote exception occurs
     */
    abstract boolean abortStagedSession(int sessionId) throws PackageManagerException;

    /**
     * Uninstalls given {@code apexPackage}.
     *
@@ -495,6 +502,21 @@ abstract class ApexManager {
            }
        }

        @Override
        boolean abortStagedSession(int sessionId) throws PackageManagerException {
            try {
                mApexService.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());
            }
        }

        @Override
        boolean uninstallApex(String apexPackagePath) {
            try {
@@ -682,6 +704,11 @@ abstract class ApexManager {
            throw new UnsupportedOperationException();
        }

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

        @Override
        boolean uninstallApex(String apexPackagePath) {
            throw new UnsupportedOperationException();
+6 −3
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ public class StagingManager {
        }
        final long activeVersion = activePackage.applicationInfo.longVersionCode;
        if (activeVersion != session.params.requiredInstalledVersionCode) {
            if (!mApexManager.abortActiveSession()) {
            if (!mApexManager.abortStagedSession(session.sessionId)) {
                Slog.e(TAG, "Failed to abort apex session " + session.sessionId);
            }
            throw new PackageManagerException(
@@ -234,7 +234,7 @@ public class StagingManager {
        final boolean allowsDowngrade = PackageManagerServiceUtils.isDowngradePermitted(
                session.params.installFlags, activePackage.applicationInfo.flags);
        if (activeVersion > newVersionCode && !allowsDowngrade) {
            if (!mApexManager.abortActiveSession()) {
            if (!mApexManager.abortStagedSession(session.sessionId)) {
                Slog.e(TAG, "Failed to abort apex session " + session.sessionId);
            }
            throw new PackageManagerException(
@@ -678,7 +678,10 @@ public class StagingManager {
                                + " because it is not active or APEXD is not reachable");
                return;
            }
            mApexManager.abortActiveSession();
            try {
                mApexManager.abortStagedSession(session.sessionId);
            } catch (Exception ignore) {
            }
        }
    }