diff --git a/rebootescrow/aidl/default/RebootEscrow.cpp b/rebootescrow/aidl/default/RebootEscrow.cpp index 94d09010d9..5ae96f6086 100644 --- a/rebootescrow/aidl/default/RebootEscrow.cpp +++ b/rebootescrow/aidl/default/RebootEscrow.cpp @@ -29,7 +29,7 @@ namespace rebootescrow { using ::android::base::unique_fd; ndk::ScopedAStatus RebootEscrow::storeKey(const std::vector& kek) { - int rawFd = TEMP_FAILURE_RETRY(::open(REBOOT_ESCROW_DEVICE, O_WRONLY | O_NOFOLLOW | O_CLOEXEC)); + int rawFd = TEMP_FAILURE_RETRY(::open(devicePath_.c_str(), O_WRONLY | O_NOFOLLOW | O_CLOEXEC)); unique_fd fd(rawFd); if (fd.get() < 0) { LOG(WARNING) << "Could not open reboot escrow device"; @@ -48,7 +48,7 @@ ndk::ScopedAStatus RebootEscrow::storeKey(const std::vector& kek) { } ndk::ScopedAStatus RebootEscrow::retrieveKey(std::vector* _aidl_return) { - int rawFd = TEMP_FAILURE_RETRY(::open(REBOOT_ESCROW_DEVICE, O_RDONLY | O_NOFOLLOW | O_CLOEXEC)); + int rawFd = TEMP_FAILURE_RETRY(::open(devicePath_.c_str(), O_RDONLY | O_NOFOLLOW | O_CLOEXEC)); unique_fd fd(rawFd); if (fd.get() < 0) { LOG(WARNING) << "Could not open reboot escrow device"; diff --git a/rebootescrow/aidl/default/include/rebootescrow-impl/RebootEscrow.h b/rebootescrow/aidl/default/include/rebootescrow-impl/RebootEscrow.h index 1ed73978d9..00ff16b2ea 100644 --- a/rebootescrow/aidl/default/include/rebootescrow-impl/RebootEscrow.h +++ b/rebootescrow/aidl/default/include/rebootescrow-impl/RebootEscrow.h @@ -23,11 +23,14 @@ namespace android { namespace hardware { namespace rebootescrow { -static const char* REBOOT_ESCROW_DEVICE = "/dev/access-kregistry"; - class RebootEscrow : public BnRebootEscrow { + public: + explicit RebootEscrow(const std::string& devicePath) : devicePath_(devicePath) {} ndk::ScopedAStatus storeKey(const std::vector& kek) override; ndk::ScopedAStatus retrieveKey(std::vector* _aidl_return) override; + + private: + const std::string devicePath_; }; } // namespace rebootescrow diff --git a/rebootescrow/aidl/default/service.cpp b/rebootescrow/aidl/default/service.cpp index bd2378e513..8a8086b498 100644 --- a/rebootescrow/aidl/default/service.cpp +++ b/rebootescrow/aidl/default/service.cpp @@ -17,15 +17,21 @@ #include "rebootescrow-impl/RebootEscrow.h" #include +#include #include #include using aidl::android::hardware::rebootescrow::RebootEscrow; +constexpr auto kRebootEscrowDeviceProperty = "ro.rebootescrow.device"; +constexpr auto kRebootEscrowDeviceDefault = "/dev/access-kregistry"; + int main() { ABinderProcess_setThreadPoolMaxThreadCount(0); - auto re = ndk::SharedRefBase::make(); + auto rebootEscrowDevicePath = + android::base::GetProperty(kRebootEscrowDeviceProperty, kRebootEscrowDeviceDefault); + auto re = ndk::SharedRefBase::make(rebootEscrowDevicePath); const std::string instance = std::string() + RebootEscrow::descriptor + "/default"; binder_status_t status = AServiceManager_addService(re->asBinder().get(), instance.c_str()); CHECK(status == STATUS_OK);