1 #ifndef PACKAGEMANAGERINTERFACE_H_
2 #define PACKAGEMANAGERINTERFACE_H_
7 #include "bootloader/bootloader.h"
8 #include "crypto/keymanager.h"
9 #include "http/httpinterface.h"
10 #include "packagemanagerconfig.h"
11 #include "storage/invstorage.h"
12 #include "uptane/fetcher.h"
13 #include "utilities/apiqueue.h"
16 using FetcherProgressCb = std::function<void(
const Uptane::Target&,
const std::string&,
unsigned int)>;
21 enum class TargetStatus {
39 std::shared_ptr<HttpInterface> http)
40 : config(std::move(pconfig)),
41 storage_(std::move(storage)),
42 http_(std::move(http)),
43 bootloader_{
new Bootloader(std::move(bconfig), *storage_)} {}
45 virtual std::string name()
const = 0;
46 virtual Json::Value getInstalledPackages()
const = 0;
49 virtual void completeInstall()
const {
throw std::runtime_error(
"Unimplemented"); };
51 virtual bool rebootDetected() {
return bootloader_->rebootDetected(); };
52 virtual void rebootFlagClear() { bootloader_->rebootFlagClear(); };
53 virtual void updateNotify() { bootloader_->updateNotify(); };
56 virtual TargetStatus verifyTarget(
const Uptane::Target& target)
const;
61 Json::Value installed_image;
62 installed_image[
"filepath"] = installed_target.filename();
63 installed_image[
"fileinfo"][
"length"] = Json::UInt64(installed_target.length());
64 installed_image[
"fileinfo"][
"hashes"][
"sha256"] = installed_target.sha256Hash();
66 Json::Value unsigned_ecu_version;
67 unsigned_ecu_version[
"attacks_detected"] =
"";
68 unsigned_ecu_version[
"installed_image"] = installed_image;
69 unsigned_ecu_version[
"ecu_serial"] = ecu_serial.ToString();
70 unsigned_ecu_version[
"previous_timeserver_time"] =
"1970-01-01T00:00:00Z";
71 unsigned_ecu_version[
"timeserver_time"] =
"1970-01-01T00:00:00Z";
72 return unsigned_ecu_version;
77 std::shared_ptr<INvStorage> storage_;
78 std::shared_ptr<HttpInterface> http_;
79 std::unique_ptr<Bootloader> bootloader_;
81 #endif // PACKAGEMANAGERINTERFACE_H_