Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10b406eb authored by Kenny Root's avatar Kenny Root Committed by Android (Google) Code Review
Browse files

Merge "rebootescrow: use property to find device"

parents 9610b59d 7e6f5f97
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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";
@@ -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";
+5 −2
Original line number Diff line number Diff line
@@ -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
+7 −1
Original line number Diff line number Diff line
@@ -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);