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

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

Add more logging in StagingManager

Test: adb install-multi-package apex + apk
Test: looked at logcat before and after reboot
Change-Id: I96f1ba9cb62f8161aab86c00666ad3806938aa70
parent c7ed3861
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -180,6 +180,8 @@ public class StagingManager {
            checkDowngrade(session, activePackage, pkg);
            result.add(pkg);
        }
        Slog.d(TAG, "Session " + session.sessionId + " has following APEX packages: ["
                + result.stream().map(p -> p.packageName).collect(Collectors.joining(",")) + "]");
        return result;
    }

@@ -206,7 +208,7 @@ public class StagingManager {
            throws PackageManagerException {
        final long activeVersion = activePackage.applicationInfo.longVersionCode;
        final long newVersionCode = newPackage.applicationInfo.longVersionCode;
        boolean allowsDowngrade = PackageManagerServiceUtils.isDowngradePermitted(
        final boolean allowsDowngrade = PackageManagerServiceUtils.isDowngradePermitted(
                session.params.installFlags, activePackage.applicationInfo.flags);
        if (activeVersion > newVersionCode && !allowsDowngrade) {
            if (!mApexManager.abortActiveSession()) {
@@ -225,6 +227,7 @@ public class StagingManager {
    }

    private void preRebootVerification(@NonNull PackageInstallerSession session) {
        Slog.d(TAG, "Starting preRebootVerification for session " + session.sessionId);
        final boolean hasApex = sessionContainsApex(session);
        // APEX checks. For single-package sessions, check if they contain an APEX. For
        // multi-package sessions, find all the child sessions that contain an APEX.
@@ -243,6 +246,8 @@ public class StagingManager {

        if (sessionContainsApk(session)) {
            try {
                Slog.d(TAG, "Running a pre-reboot verification for APKs in session "
                        + session.sessionId + " by performing a dry-run install");
                installApksInSession(session, /* preReboot */ true);
                // TODO(b/118865310): abort the session on apexd.
            } catch (PackageManagerException e) {
@@ -277,6 +282,7 @@ public class StagingManager {
        // On the other hand, if the order of the calls was inverted (first call apexd, then mark
        // 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.
        Slog.d(TAG, "Marking session " + session.sessionId + " as ready");
        session.setStagedSessionReady();
        if (!hasApex) {
            // Session doesn't contain apex, nothing to do.
@@ -315,6 +321,7 @@ public class StagingManager {
    }

    private void resumeSession(@NonNull PackageInstallerSession session) {
        Slog.d(TAG, "Resuming session " + session.sessionId);
        final boolean hasApex = sessionContainsApex(session);
        if (hasApex) {
            // Check with apexservice whether the apex packages have been activated.
@@ -348,9 +355,12 @@ public class StagingManager {
                        + "retry at next reboot.");
                return;
            }
            Slog.i(TAG, "APEX packages in session " + session.sessionId
                    + " were successfully activated. Proceeding with APK packages, if any");
        }
        // The APEX part of the session is activated, proceed with the installation of APKs.
        try {
            Slog.d(TAG, "Installing APK packages in session " + session.sessionId);
            installApksInSession(session, /* preReboot */ false);
        } catch (PackageManagerException e) {
            session.setStagedSessionFailed(e.error, e.getMessage());
@@ -370,6 +380,7 @@ public class StagingManager {
            return;
        }

        Slog.d(TAG, "Marking session " + session.sessionId + " as applied");
        session.setStagedSessionApplied();
        if (hasApex) {
            mApexManager.markStagedSessionSuccessful(session.sessionId);