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

Commit 7c46fe36 authored by Gavin Corkery's avatar Gavin Corkery
Browse files

Ensure staged rollback status is logged on boot

In the cases that a logging parent cannot be found for any packages
in a rollback, the watchdog event should still be logged. Ensure
that the state of a rollback is captured on boot by removing the
condition of only saving a rollback id if there is a logging package,
and by adding a symbolic null package to the list of logging packages
on boot if none were found. Expand tests to verify.

Bug: 149957011
Test: atest StagedRollbackTest
Test: atest NetworkStagedRollbackTest
Change-Id: I56f8afb6730e59fbe67ea8747e0da3aca19a0d8a
parent b629d69d
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -218,11 +218,7 @@ public final class RollbackPackageHealthObserver implements PackageHealthObserve
                        packageInstaller.getSessionInfo(sessionId);
                if (sessionInfo.isStagedSessionReady() && markStagedSessionHandled(rollbackId)) {
                    mContext.unregisterReceiver(listener);
                    if (logPackage != null) {
                        // We save the rollback id so that after reboot, we can log if rollback was
                        // successful or not. If logPackage is null, then there is nothing to log.
                    saveStagedRollbackId(rollbackId);
                    }
                    WatchdogRollbackLogger.logEvent(logPackage,
                            FrameworkStatsLog
                            .WATCHDOG_ROLLBACK_OCCURRED__ROLLBACK_TYPE__ROLLBACK_BOOT_TRIGGERED,
+6 −0
Original line number Diff line number Diff line
@@ -159,6 +159,12 @@ public final class WatchdogRollbackLogger {
            return;
        }

        // If no logging packages are found, use a null package to ensure the rollback status
        // is still logged.
        if (oldLoggingPackages.isEmpty()) {
            oldLoggingPackages.add(null);
        }

        for (VersionedPackage oldLoggingPackage : oldLoggingPackages) {
            if (sessionInfo.isStagedSessionApplied()) {
                logEvent(oldLoggingPackage,
+2 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ public class NetworkStagedRollbackTest extends BaseHostJUnit4Test {

    private static final String ROLLBACK_INITIATE = "ROLLBACK_INITIATE";
    private static final String ROLLBACK_BOOT_TRIGGERED = "ROLLBACK_BOOT_TRIGGERED";
    private static final String ROLLBACK_SUCCESS = "ROLLBACK_SUCCESS";

    private WatchdogEventLogger mLogger = new WatchdogEventLogger();

@@ -93,6 +94,7 @@ public class NetworkStagedRollbackTest extends BaseHostJUnit4Test {
                    REASON_EXPLICIT_HEALTH_CHECK, null));
            assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_BOOT_TRIGGERED, null,
                    null, null));
            assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_SUCCESS, null, null, null));
        } finally {
            // Reconnect internet again so we won't break tests which assume internet available
            getDevice().executeShellCommand("svc wifi enable");
+5 −1
Original line number Diff line number Diff line
@@ -76,10 +76,10 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {

    private static final String REASON_APP_CRASH = "REASON_APP_CRASH";
    private static final String REASON_NATIVE_CRASH = "REASON_NATIVE_CRASH";
    private static final String REASON_EXPLICIT_HEALTH_CHECK = "REASON_EXPLICIT_HEALTH_CHECK";

    private static final String ROLLBACK_INITIATE = "ROLLBACK_INITIATE";
    private static final String ROLLBACK_BOOT_TRIGGERED = "ROLLBACK_BOOT_TRIGGERED";
    private static final String ROLLBACK_SUCCESS = "ROLLBACK_SUCCESS";

    private WatchdogEventLogger mLogger = new WatchdogEventLogger();

@@ -146,6 +146,7 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
                REASON_APP_CRASH, TESTAPP_A));
        assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_BOOT_TRIGGERED, null,
                null, null));
        assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_SUCCESS, null, null, null));
    }

    @Test
@@ -179,6 +180,7 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
                        REASON_NATIVE_CRASH, null));
        assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_BOOT_TRIGGERED, null,
                null, null));
        assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_SUCCESS, null, null, null));
    }

    @Test
@@ -219,6 +221,7 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
                        REASON_NATIVE_CRASH, null));
        assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_BOOT_TRIGGERED, null,
                null, null));
        assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_SUCCESS, null, null, null));
    }

    /**
@@ -290,6 +293,7 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
                REASON_APP_CRASH, TESTAPP_A));
        assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_BOOT_TRIGGERED, null,
                null, null));
        assertTrue(watchdogEventOccurred(watchdogEvents, ROLLBACK_SUCCESS, null, null, null));
    }

    /**