4e9f147e55
Adds pawlethwd, a native C++ system_ext daemon (coredomain) that detects peripherals, checks the hardware update catalog (ota.php?mode=hardware), verifies payloads, and flashes firmware via authorized handler plugins. - daemon/: manifest parse, libcurl HTTP + sha256, sysfs USB detection, catalog client, dlopen handler registry (fixed path + ABI + allowlist), state persistence, orchestration engine, AIDL service, main. - aidl/: IPawletHardwareUpdate (getComponents/getPendingUpdates/checkNow/...). - include/pawlet/hwh_abi.h: stable C plugin ABI. - handlers/usbdfu/: libpawlethwh_usbdfu.so, DFU 1.1 download over libusb. - sepolicy/: pawlethwd domain, pawlet_hw_data_file, service type. - schemas/, etc/supported_hardware.default.json, README design doc. - hwupdate.mk wires packages + ro.pawlet.hardware.manifest + sepolicy dir; inherited from config/common.mk. Trust: a server-named installer handler is honored only if allowlisted in the immutable supported_hardware.json, maps to a fixed dm-verity-protected .so path, is ABI/id-checked, and every payload is sha256-verified before a handler runs.
37 lines
910 B
C++
37 lines
910 B
C++
/*
|
|
* Copyright (C) 2026 oxmc / PawletOS
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <string>
|
|
|
|
namespace pawlet::hwupdate {
|
|
|
|
// Persistent per-component state: last successfully installed firmware version
|
|
// and a retry counter. Backed by a JSON file under /data/pawlet/hw.
|
|
class State {
|
|
public:
|
|
explicit State(std::string path);
|
|
|
|
void Load();
|
|
bool Save() const;
|
|
|
|
std::string InstalledVersion(const std::string& componentId) const;
|
|
void SetInstalledVersion(const std::string& componentId, const std::string& version);
|
|
|
|
int RetryCount(const std::string& componentId) const;
|
|
void SetRetryCount(const std::string& componentId, int count);
|
|
|
|
private:
|
|
struct Entry {
|
|
std::string installedVersion;
|
|
int retryCount = 0;
|
|
};
|
|
std::string path_;
|
|
std::map<std::string, Entry> entries_;
|
|
};
|
|
|
|
} // namespace pawlet::hwupdate
|