diff options
author | Joonas Kylmälä <joonas.kylmala@iki.fi> | 2020-07-01 12:29:09 -0400 |
---|---|---|
committer | Joonas Kylmälä <joonas.kylmala@iki.fi> | 2020-07-01 12:29:09 -0400 |
commit | 6837345e38f07231fc244fe78011a46963828e1b (patch) | |
tree | df537efe784d9a4f7cf1c2068058156ec06400fc /oemlock | |
parent | 8cd6e8a898d0834bcdbefff98523fad12b80c4bc (diff) | |
download | device_samsung_midas_common-6837345e38f07231fc244fe78011a46963828e1b.tar.gz device_samsung_midas_common-6837345e38f07231fc244fe78011a46963828e1b.tar.bz2 device_samsung_midas_common-6837345e38f07231fc244fe78011a46963828e1b.zip |
Add oemlock HAL implementation
Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Diffstat (limited to 'oemlock')
-rw-r--r-- | oemlock/Android.bp | 31 | ||||
-rw-r--r-- | oemlock/OemLock.cpp | 58 | ||||
-rw-r--r-- | oemlock/OemLock.h | 42 | ||||
-rw-r--r-- | oemlock/android.hardware.oemlock@1.0-service.rc | 5 | ||||
-rw-r--r-- | oemlock/service.cpp | 41 |
5 files changed, 177 insertions, 0 deletions
diff --git a/oemlock/Android.bp b/oemlock/Android.bp new file mode 100644 index 0000000..82f3dbb --- /dev/null +++ b/oemlock/Android.bp @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Joonas Kylmälä +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +cc_binary { + name: "android.hardware.oemlock@1.0-service", + defaults: ["hidl_defaults"], + relative_install_path: "hw", + proprietary: true, + init_rc: ["android.hardware.oemlock@1.0-service.rc"], + srcs: [ + "OemLock.cpp", + "service.cpp", + ], + shared_libs: [ + "libhidlbase", + "libutils", + "liblog", + "android.hardware.oemlock@1.0", + ], +} diff --git a/oemlock/OemLock.cpp b/oemlock/OemLock.cpp new file mode 100644 index 0000000..d3fed55 --- /dev/null +++ b/oemlock/OemLock.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2020 Joonas Kylmälä + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "OemLock.h" + +namespace android { +namespace hardware { +namespace oemlock { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::oemlock::V1_0::OemLockStatus; +using ::android::hardware::oemlock::V1_0::OemLockSecureStatus; + +Return<void> OemLock::getName(getName_cb _hidl_cb) { + _hidl_cb(OemLockStatus::OK, "default"); + return Void(); +} + +Return<OemLockSecureStatus> OemLock::setOemUnlockAllowedByCarrier(bool allowed, const hidl_vec<uint8_t>& signature) { + (void)allowed; + (void)signature; + return OemLockSecureStatus::FAILED; +} + +Return<void> OemLock::isOemUnlockAllowedByCarrier(isOemUnlockAllowedByCarrier_cb _hidl_cb) { + _hidl_cb(OemLockStatus::OK, false); + return Void(); +} + +Return<OemLockStatus> OemLock::setOemUnlockAllowedByDevice(bool allowed) { + (void)allowed; + return OemLockStatus::FAILED; +} + +Return<void> OemLock::isOemUnlockAllowedByDevice(isOemUnlockAllowedByDevice_cb _hidl_cb) { + _hidl_cb(OemLockStatus::OK, true); + return Void(); +} + +} +} +} +} +} diff --git a/oemlock/OemLock.h b/oemlock/OemLock.h new file mode 100644 index 0000000..c0775ef --- /dev/null +++ b/oemlock/OemLock.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 Joonas Kylmälä + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include <android/hardware/oemlock/1.0/IOemLock.h> + +namespace android { +namespace hardware { +namespace oemlock { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::oemlock::V1_0::OemLockSecureStatus; +using ::android::hardware::oemlock::V1_0::OemLockStatus; + +struct OemLock : public IOemLock { + Return<void> getName(getName_cb _hidl_cb) override; + Return<OemLockSecureStatus> setOemUnlockAllowedByCarrier(bool allowed, const hidl_vec<uint8_t>& signature) override; + Return<void> isOemUnlockAllowedByCarrier(isOemUnlockAllowedByCarrier_cb _hidl_cb) override; + Return<OemLockStatus> setOemUnlockAllowedByDevice(bool allowed) override; + Return<void> isOemUnlockAllowedByDevice(isOemUnlockAllowedByDevice_cb _hidl_cb) override; +}; + +} +} +} +} +} diff --git a/oemlock/android.hardware.oemlock@1.0-service.rc b/oemlock/android.hardware.oemlock@1.0-service.rc new file mode 100644 index 0000000..1596ef9 --- /dev/null +++ b/oemlock/android.hardware.oemlock@1.0-service.rc @@ -0,0 +1,5 @@ +service vendor.oemlock-hal-1-0 /vendor/bin/hw/android.hardware.oemlock@1.0-service + interface android.hardware.oemlock@1.0::IOemLock default + class hal + user system + group system diff --git a/oemlock/service.cpp b/oemlock/service.cpp new file mode 100644 index 0000000..596e672 --- /dev/null +++ b/oemlock/service.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "android.hardware.oemlock@1.0-service" + +#include <android/hardware/oemlock/1.0/IOemLock.h> +#include <hidl/HidlTransportSupport.h> +#include <log/log.h> +#include <utils/StrongPointer.h> +#include "OemLock.h" + +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; +using android::hardware::oemlock::V1_0::IOemLock; +using android::hardware::oemlock::V1_0::implementation::OemLock; + +int main(int /* argc */, char** /* argv */) { + configureRpcThreadpool(1, true); + + android::sp<IOemLock> oemlock = new OemLock(); + if (oemlock->registerAsService() != ::android::OK) { + ALOGE("Failed to register OemLock HAL instance"); + return -1; + } + + joinRpcThreadpool(); + return 1; // joinRpcThreadpool shouldn't exit +} |