1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <aidl/android/hardware/oemlock/BnOemLock.h> 20 21 #include "common/libs/security/oemlock.h" 22 #include "common/libs/transport/channel.h" 23 #include "common/libs/utils/result.h" 24 25 namespace aidl { 26 namespace android { 27 namespace hardware { 28 namespace oemlock { 29 30 using namespace cuttlefish; 31 32 struct OemLock : public BnOemLock { 33 public: 34 OemLock(transport::Channel& channel); 35 36 // Methods from ::android::hardware::oemlock::IOemLock follow. 37 ::ndk::ScopedAStatus getName(std::string* out_name) override; 38 ::ndk::ScopedAStatus isOemUnlockAllowedByCarrier(bool* out_allowed) override; 39 ::ndk::ScopedAStatus isOemUnlockAllowedByDevice(bool* out_allowed) override; 40 ::ndk::ScopedAStatus setOemUnlockAllowedByCarrier(bool in_allowed, 41 const std::vector<uint8_t>&, 42 OemLockSecureStatus* _aidl_return) override; 43 ::ndk::ScopedAStatus setOemUnlockAllowedByDevice(bool in_allowed) override; 44 45 private: 46 transport::Channel& channel_; 47 48 Result<void> requestValue(secure_env::OemLockField field, bool *out); 49 Result<void> setValue(secure_env::OemLockField field, bool value); 50 }; 51 52 } // namespace oemlock 53 } // namespace hardware 54 } // namespace android 55 } // aidl 56