Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 2017 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 #ifndef ANDROID_HARDWARE_OEMLOCK_OEMLOCK_H
     18 #define ANDROID_HARDWARE_OEMLOCK_OEMLOCK_H
     19 
     20 #include <android/hardware/oemlock/1.0/IOemLock.h>
     21 
     22 #include <Avb.client.h>
     23 
     24 namespace android {
     25 namespace hardware {
     26 namespace oemlock {
     27 
     28 using ::android::hardware::oemlock::V1_0::IOemLock;
     29 using ::android::hardware::oemlock::V1_0::OemLockSecureStatus;
     30 using ::android::hardware::oemlock::V1_0::OemLockStatus;
     31 using ::android::hardware::hidl_vec;
     32 using ::android::hardware::Return;
     33 
     34 using ::nugget::app::avb::CarrierUnlock;
     35 
     36 using AvbClient = ::nugget::app::avb::IAvb;
     37 
     38 struct OemLock : public IOemLock {
     39     OemLock(AvbClient& avbApp) : _avbApp{avbApp} {}
     40     ~OemLock() override = default;
     41 
     42     // Methods from ::android::hardware::oemlock::V1_0::IOemLock follow.
     43     Return<void> getName(getName_cb _hidl_cb) override;
     44     Return<OemLockSecureStatus> setOemUnlockAllowedByCarrier(
     45             bool allowed, const hidl_vec<uint8_t>& signature) override;
     46     Return<void> isOemUnlockAllowedByCarrier(isOemUnlockAllowedByCarrier_cb _hidl_cb) override;
     47     Return<OemLockStatus> setOemUnlockAllowedByDevice(bool allowed) override;
     48     Return<void> isOemUnlockAllowedByDevice(isOemUnlockAllowedByDevice_cb _hidl_cb) override;
     49 
     50     static bool carrierUnlockFromSignature(const hidl_vec<uint8_t>& signature,
     51                                            CarrierUnlock* unlock);
     52 
     53 private:
     54     AvbClient& _avbApp;
     55 };
     56 
     57 } // namespace oemlock
     58 } // namespace hardware
     59 } // namespace android
     60 
     61 #endif // ANDROID_HARDWARE_OEMLOCK_OEMLOCK_H
     62