Loading rebootescrow/aidl/default/RebootEscrow.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ namespace rebootescrow { using ::android::base::unique_fd; ndk::ScopedAStatus RebootEscrow::storeKey(const std::vector<int8_t>& 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"; Loading @@ -48,7 +48,7 @@ ndk::ScopedAStatus RebootEscrow::storeKey(const std::vector<int8_t>& kek) { } ndk::ScopedAStatus RebootEscrow::retrieveKey(std::vector<int8_t>* _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"; Loading rebootescrow/aidl/default/include/rebootescrow-impl/RebootEscrow.h +5 −2 Original line number Diff line number Diff line Loading @@ -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<int8_t>& kek) override; ndk::ScopedAStatus retrieveKey(std::vector<int8_t>* _aidl_return) override; private: const std::string devicePath_; }; } // namespace rebootescrow Loading rebootescrow/aidl/default/service.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -17,15 +17,21 @@ #include "rebootescrow-impl/RebootEscrow.h" #include <android-base/logging.h> #include <android-base/properties.h> #include <android/binder_manager.h> #include <android/binder_process.h> 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<RebootEscrow>(); auto rebootEscrowDevicePath = android::base::GetProperty(kRebootEscrowDeviceProperty, kRebootEscrowDeviceDefault); auto re = ndk::SharedRefBase::make<RebootEscrow>(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); Loading Loading
rebootescrow/aidl/default/RebootEscrow.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ namespace rebootescrow { using ::android::base::unique_fd; ndk::ScopedAStatus RebootEscrow::storeKey(const std::vector<int8_t>& 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"; Loading @@ -48,7 +48,7 @@ ndk::ScopedAStatus RebootEscrow::storeKey(const std::vector<int8_t>& kek) { } ndk::ScopedAStatus RebootEscrow::retrieveKey(std::vector<int8_t>* _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"; Loading
rebootescrow/aidl/default/include/rebootescrow-impl/RebootEscrow.h +5 −2 Original line number Diff line number Diff line Loading @@ -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<int8_t>& kek) override; ndk::ScopedAStatus retrieveKey(std::vector<int8_t>* _aidl_return) override; private: const std::string devicePath_; }; } // namespace rebootescrow Loading
rebootescrow/aidl/default/service.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -17,15 +17,21 @@ #include "rebootescrow-impl/RebootEscrow.h" #include <android-base/logging.h> #include <android-base/properties.h> #include <android/binder_manager.h> #include <android/binder_process.h> 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<RebootEscrow>(); auto rebootEscrowDevicePath = android::base::GetProperty(kRebootEscrowDeviceProperty, kRebootEscrowDeviceDefault); auto re = ndk::SharedRefBase::make<RebootEscrow>(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); Loading