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

Commit ab4d7354 authored by Nikita Ioffe's avatar Nikita Ioffe
Browse files

Populate error message if apexd.markStagedSessionReady fails

Test: atest CtsStagedInstallHostTestCases
Bug: 136548037
Bug: 122952270
Change-Id: I6fde70418990ee27c1966619badc437c9bffb697
parent 880190e1
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -158,9 +158,9 @@ abstract class ApexManager {
     * applied at next reboot.
     *
     * @param sessionId the identifier of the {@link PackageInstallerSession} being marked as ready.
     * @return true upon success, false if the session is unknown.
     * @throws PackageManagerException if call to apexd fails
     */
    abstract boolean markStagedSessionReady(int sessionId);
    abstract void markStagedSessionReady(int sessionId) throws PackageManagerException;

    /**
     * Marks a staged session as successful.
@@ -402,12 +402,16 @@ abstract class ApexManager {
        }

        @Override
        boolean markStagedSessionReady(int sessionId) {
        void markStagedSessionReady(int sessionId) throws PackageManagerException {
            try {
                return mApexService.markStagedSessionReady(sessionId);
                mApexService.markStagedSessionReady(sessionId);
            } catch (RemoteException re) {
                Slog.e(TAG, "Unable to contact apexservice", re);
                throw new RuntimeException(re);
            } catch (Exception e) {
                throw new PackageManagerException(
                        PackageInstaller.SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
                        "Failed to mark apexd session as ready : " + e.getMessage());
            }
        }

@@ -576,7 +580,7 @@ abstract class ApexManager {
        }

        @Override
        boolean markStagedSessionReady(int sessionId) {
        void markStagedSessionReady(int sessionId) {
            throw new UnsupportedOperationException();
        }

+8 −4
Original line number Diff line number Diff line
@@ -278,10 +278,14 @@ public class StagingManager {
        // session as ready), then if a device gets rebooted right after the call to apexd, only
        // apex part of the train will be applied, leaving device in an inconsistent state.
        session.setStagedSessionReady();
        if (hasApex && !mApexManager.markStagedSessionReady(session.sessionId)) {
            session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
                            "APEX staging failed, check logcat messages from apexd for more "
                            + "details.");
        if (!hasApex) {
            // Session doesn't contain apex, nothing to do.
            return;
        }
        try {
            mApexManager.markStagedSessionReady(session.sessionId);
        } catch (PackageManagerException e) {
            session.setStagedSessionFailed(e.error, e.getMessage());
        }
    }