Files
android_vendor_pawlet/hwupdate/daemon/main.cpp
T
oxmc 4e9f147e55 hwupdate: PawletOS hardware/peripheral firmware update subsystem
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.
2026-07-18 01:11:15 -07:00

61 lines
1.8 KiB
C++

/*
* Copyright (C) 2026 oxmc / PawletOS
* SPDX-License-Identifier: Apache-2.0
*/
#include <curl/curl.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
#include <utils/String16.h>
#include <android-base/logging.h>
#include "engine.h"
#include "service.h"
#include "util.h"
using namespace pawlet::hwupdate;
namespace {
constexpr char kServiceName[] = "pawlet_hwupdate";
constexpr char kDefaultManifest[] = "/system_ext/etc/pawlet/supported_hardware.json";
constexpr char kDefaultServer[] = "https://oxmc.me/apis/aosp/ota.php?mode=hardware";
constexpr char kStateDir[] = "/data/pawlet/hw";
} // namespace
int main(int, char**) {
android::base::InitLogging(nullptr, android::base::LogdLogger());
LOG(INFO) << "pawlethwd starting";
if (curl_global_init(CURL_GLOBAL_DEFAULT) != 0) {
LOG(ERROR) << "pawlethwd: curl_global_init failed";
return 1;
}
EngineConfig cfg;
cfg.manifestPath = util::Prop("ro.pawlet.hardware.manifest", kDefaultManifest);
cfg.serverBaseUrl = util::Prop("ro.pawlet.hwupdate.uri", kDefaultServer);
cfg.stateDir = kStateDir;
cfg.autoApply = util::Prop("persist.pawlet.hwupdate.auto_apply", "true") != "false";
Engine engine(cfg);
engine.Start();
android::sp<HwUpdateService> service = android::sp<HwUpdateService>::make(&engine);
android::status_t st = android::defaultServiceManager()->addService(
android::String16(kServiceName), service);
if (st != android::OK) {
LOG(ERROR) << "pawlethwd: failed to register service: " << st;
return 1;
}
LOG(INFO) << "pawlethwd: service registered as " << kServiceName;
android::ProcessState::self()->startThreadPool();
android::IPCThreadState::self()->joinThreadPool();
engine.Stop();
curl_global_cleanup();
return 0;
}