diff --git a/fod/Android.bp b/fod/Android.bp new file mode 100644 index 0000000..50acf06 --- /dev/null +++ b/fod/Android.bp @@ -0,0 +1,35 @@ +// +// Copyright (C) 2019 The LineageOS 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. + +cc_binary { + relative_install_path: "hw", + defaults: ["hidl_defaults"], + name: "lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710", + init_rc: ["lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710.rc"], + srcs: [ + "service.cpp", + "FingerprintInscreen.cpp", + ], + shared_libs: [ + "libbase", + "libhardware", + "libhidlbase", + "libhidltransport", + "liblog", + "libhwbinder", + "libutils", + "vendor.lineage.biometrics.fingerprint.inscreen@1.0", + ], +} diff --git a/fod/FingerprintInscreen.cpp b/fod/FingerprintInscreen.cpp new file mode 100644 index 0000000..c445859 --- /dev/null +++ b/fod/FingerprintInscreen.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2019 The LineageOS 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 "FingerprintInscreenService" + +#include "FingerprintInscreen.h" +#include +#include +#include +#include + +namespace { + +template +static void set(const std::string& path, const T& value) { + std::ofstream file(path); + file << value; + LOG(INFO) << "wrote path: " << path << ", value: " << value << "\n"; +} + +template +static T get(const std::string& path, const T& def) { + std::ifstream file(path); + T result; + + file >> result; + return file.fail() ? def : result; +} + +} // anonymous namespace + +namespace vendor { +namespace lineage { +namespace biometrics { +namespace fingerprint { +namespace inscreen { +namespace V1_0 { +namespace implementation { + +FingerprintInscreen::FingerprintInscreen() { +} + +Return FingerprintInscreen::getPositionX() { + return FOD_POS_X; +} + +Return FingerprintInscreen::getPositionY() { + return FOD_POS_Y; +} + +Return FingerprintInscreen::getSize() { + return FOD_SIZE; +} + +Return FingerprintInscreen::onStartEnroll() { + return Void(); +} + +Return FingerprintInscreen::onFinishEnroll() { + return Void(); +} + +Return FingerprintInscreen::onPress() { + return Void(); +} + +Return FingerprintInscreen::onRelease() { + return Void(); +} + +Return FingerprintInscreen::onShowFODView() { + return Void(); +} + +Return FingerprintInscreen::onHideFODView() { + return Void(); +} + +Return FingerprintInscreen::handleAcquired(int32_t acquiredInfo, int32_t vendorCode) { + LOG(ERROR) << "acquiredInfo: " << acquiredInfo << ", vendorCode: " << vendorCode << "\n"; + return false; +} + +Return FingerprintInscreen::handleError(int32_t error, int32_t vendorCode) { + LOG(ERROR) << "error: " << error << ", vendorCode: " << vendorCode << "\n"; + return false; +} + +Return FingerprintInscreen::setLongPressEnabled(bool) { + return Void(); +} + +Return FingerprintInscreen::getDimAmount(int32_t) { + int dimAmount = 0; + LOG(INFO) << "dimAmount = " << dimAmount; + + return dimAmount; +} + +Return FingerprintInscreen::shouldBoostBrightness() { + return false; +} + +Return FingerprintInscreen::setCallback(const sp<::vendor::lineage::biometrics::fingerprint::inscreen::V1_0::IFingerprintInscreenCallback>& callback) { + { + std::lock_guard _lock(mCallbackLock); + mCallback = callback; + } + return Void(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace inscreen +} // namespace fingerprint +} // namespace biometrics +} // namespace lineage +} // namespace vendor diff --git a/fod/FingerprintInscreen.h b/fod/FingerprintInscreen.h new file mode 100644 index 0000000..b243ac1 --- /dev/null +++ b/fod/FingerprintInscreen.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2019 The LineageOS 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. + */ + +#ifndef VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H +#define VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H + +#include + +namespace vendor { +namespace lineage { +namespace biometrics { +namespace fingerprint { +namespace inscreen { +namespace V1_0 { +namespace implementation { + +using ::android::sp; +using ::android::hardware::Return; +using ::android::hardware::Void; + +class FingerprintInscreen : public IFingerprintInscreen { +public: + FingerprintInscreen(); + Return getPositionX() override; + Return getPositionY() override; + Return getSize() override; + Return onStartEnroll() override; + Return onFinishEnroll() override; + Return onPress() override; + Return onRelease() override; + Return onShowFODView() override; + Return onHideFODView() override; + Return handleAcquired(int32_t acquiredInfo, int32_t vendorCode) override; + Return handleError(int32_t error, int32_t vendorCode) override; + Return setLongPressEnabled(bool enabled) override; + Return getDimAmount(int32_t brightness) override; + Return shouldBoostBrightness() override; + Return setCallback(const sp<::vendor::lineage::biometrics::fingerprint::inscreen::V1_0::IFingerprintInscreenCallback>& callback) override; + +private: + std::mutex mCallbackLock; + sp mCallback; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace inscreen +} // namespace fingerprint +} // namespace biometrics +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H diff --git a/fod/lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710.rc b/fod/lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710.rc new file mode 100644 index 0000000..8d61e01 --- /dev/null +++ b/fod/lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710.rc @@ -0,0 +1,6 @@ +service fingerprint-inscreen-1-0 /system/bin/hw/lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710 + interface vendor.lineage.biometrics.fingerprint.inscreen@1.0::IFingerprintInscreen default + class hal + user system + group system + shutdown critical diff --git a/fod/service.cpp b/fod/service.cpp new file mode 100644 index 0000000..dc6dbe4 --- /dev/null +++ b/fod/service.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2019 The LineageOS 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 "lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710" + +#include +#include + +#include "FingerprintInscreen.h" + +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; + +using vendor::lineage::biometrics::fingerprint::inscreen::V1_0::IFingerprintInscreen; +using vendor::lineage::biometrics::fingerprint::inscreen::V1_0::implementation::FingerprintInscreen; + +using android::OK; +using android::status_t; + +int main() { + android::sp service = new FingerprintInscreen(); + + configureRpcThreadpool(1, true); + + status_t status = service->registerAsService(); + if (status != OK) { + LOG(ERROR) << "Cannot register FOD HAL service."; + return 1; + } + + LOG(INFO) << "FOD HAL service ready."; + + joinRpcThreadpool(); + + LOG(ERROR) << "FOD HAL service failed to join thread pool."; + return 1; +} diff --git a/overlay-lineage/packages/apps/Settings/res/values/lineage_config.xml b/overlay-lineage/packages/apps/Settings/res/values/lineage_config.xml new file mode 100644 index 0000000..b7be82f --- /dev/null +++ b/overlay-lineage/packages/apps/Settings/res/values/lineage_config.xml @@ -0,0 +1,25 @@ + + + + + + + 1 + +