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

Commit 3e3159c8 authored by David Anderson's avatar David Anderson
Browse files

libsnapshot: Move first-stage pid var constant into IDeviceInfo.

This will fail in vts_libsnapshot_test because the pid isn't set (and
even if it was, we don't want to kill any running snapuserd instances).
Rather than start an instance just for the sake of killing it, use
dependency injection instead.

Bug: N/A
Test: vts_libsnapshot_test
Change-Id: I1569f927e018319cf4008673a32d5526573d8d57
parent 13e33f7f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -120,5 +120,9 @@ bool DeviceInfo::SetSlotAsUnbootable([[maybe_unused]] unsigned int slot) {
#endif
}

std::string DeviceInfo::GetSnapuserdFirstStagePidVar() const {
    return kSnapuserdFirstStagePidVar;
}

}  // namespace snapshot
}  // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ class DeviceInfo final : public SnapshotManager::IDeviceInfo {
    bool SetBootControlMergeStatus(MergeStatus status) override;
    bool SetSlotAsUnbootable(unsigned int slot) override;
    bool IsRecovery() const override;
    std::string GetSnapuserdFirstStagePidVar() const override;

  private:
    bool EnsureBootHal();
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ class MockDeviceInfo : public SnapshotManager::IDeviceInfo {
    MOCK_METHOD(bool, SetBootControlMergeStatus, (MergeStatus status), (override));
    MOCK_METHOD(bool, SetSlotAsUnbootable, (unsigned int slot), (override));
    MOCK_METHOD(bool, IsRecovery, (), (const, override));
    MOCK_METHOD(std::string, GetSnapuserdFirstStagePidVar, (), (const, override));
};

}  // namespace android::snapshot
+1 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ class ISnapshotManager {
        virtual bool SetSlotAsUnbootable(unsigned int slot) = 0;
        virtual bool IsRecovery() const = 0;
        virtual bool IsTestDevice() const { return false; }
        virtual std::string GetSnapuserdFirstStagePidVar() const = 0;
    };
    virtual ~ISnapshotManager() = default;

+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ class TestDeviceInfo : public SnapshotManager::IDeviceInfo {
        return true;
    }
    bool IsTestDevice() const override { return true; }
    std::string GetSnapuserdFirstStagePidVar() const override { return {}; }

    bool IsSlotUnbootable(uint32_t slot) { return unbootable_slots_.count(slot) != 0; }

Loading