/* * Copyright (C) The Android Open Source Project * Copyright (C) 2025 oxmc / PawletOS * * SPDX-License-Identifier: Apache-2.0 */ #include #include #include #include "BootControl.h" using aidl::android::hardware::boot::BootControl; using aidl::android::hardware::boot::IBootControl; // Block device paths — resolved at runtime via the GPT "by-name" symlinks // that ueventd creates from the partition labels set by mkimg.sh / sgdisk. static constexpr const char* kMiscDevice = "/dev/block/by-name/misc"; static constexpr const char* kBootADevice = "/dev/block/by-name/boot_a"; static constexpr const char* kBootBDevice = "/dev/block/by-name/boot_b"; int main() { android::base::InitLogging(nullptr, android::base::KernelLogger); // Single-threaded is sufficient — update_engine calls are serialised. ABinderProcess_setThreadPoolMaxThreadCount(0); auto bc = ndk::SharedRefBase::make( kMiscDevice, kBootADevice, kBootBDevice); const std::string instance = std::string(IBootControl::descriptor) + "/default"; binder_status_t status = AServiceManager_addService(bc->asBinder().get(), instance.c_str()); if (status != STATUS_OK) { LOG(FATAL) << "Failed to register " << instance << " (binder status=" << status << ")"; return 1; } LOG(INFO) << "PawletOS boot_control HAL ready: " << instance; ABinderProcess_joinThreadPool(); // joinThreadPool only returns on a fatal error. return EXIT_FAILURE; }