diff --git a/fod/Android.bp b/fod/Android.bp deleted file mode 100644 index 9e12bf2..0000000 --- a/fod/Android.bp +++ /dev/null @@ -1,36 +0,0 @@ -// -// 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: "vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_sm8350", - init_rc: ["vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_sm8350.rc"], - vintf_fragments: ["vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_sm8350.xml"], - srcs: [ - "service.cpp", - "FingerprintInscreen.cpp", - ], - vendor: true, - shared_libs: [ - "libbase", - "libhardware", - "libhidlbase", - "liblog", - "libutils", - "vendor.lineage.biometrics.fingerprint.inscreen@1.0", - "//hardware/xiaomi:vendor.xiaomi.hardware.fingerprintextension@1.0", - ], -} diff --git a/fod/FingerprintInscreen.cpp b/fod/FingerprintInscreen.cpp deleted file mode 100644 index 892bb23..0000000 --- a/fod/FingerprintInscreen.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - * 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 - -#include -#include -#include - -#define FINGERPRINT_ACQUIRED_VENDOR 6 - -#define COMMAND_NIT 10 -#define PARAM_NIT_FOD 1 -#define PARAM_NIT_NONE 0 - -#define FOD_STATUS_PATH "/sys/devices/virtual/touch/tp_dev/fod_status" -#define FOD_STATUS_ON 1 -#define FOD_STATUS_OFF 0 - -#define FOD_UI_PATH "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_ui" - -#define FOD_HBM_PATH "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_hbm" -#define FOD_HBM_ON 1 -#define FOD_HBM_OFF 0 - -#define FOD_SENSOR_X 588 -#define FOD_SENSOR_Y 2358 -#define FOD_SENSOR_SIZE 264 - -namespace { - -template -static void set(const std::string& path, const T& value) { - std::ofstream file(path); - file << value; -} - -static bool readBool(int fd) { - char c; - int rc; - - rc = lseek(fd, 0, SEEK_SET); - if (rc) { - LOG(ERROR) << "failed to seek fd, err: " << rc; - return false; - } - - rc = read(fd, &c, sizeof(char)); - if (rc != 1) { - LOG(ERROR) << "failed to read bool from fd, err: " << rc; - return false; - } - - return c != '0'; -} - -} // anonymous namespace - -namespace vendor { -namespace lineage { -namespace biometrics { -namespace fingerprint { -namespace inscreen { -namespace V1_0 { -namespace implementation { - -FingerprintInscreen::FingerprintInscreen() { - xiaomiFingerprintService = IXiaomiFingerprint::getService(); - - std::thread([this]() { - int fd = open(FOD_UI_PATH, O_RDONLY); - if (fd < 0) { - LOG(ERROR) << "failed to open fd, err: " << fd; - return; - } - - struct pollfd fodUiPoll = { - .fd = fd, - .events = POLLERR | POLLPRI, - .revents = 0, - }; - - while (true) { - int rc = poll(&fodUiPoll, 1, -1); - if (rc < 0) { - LOG(ERROR) << "failed to poll fd, err: " << rc; - continue; - } - - xiaomiFingerprintService->extCmd(COMMAND_NIT, - readBool(fd) ? PARAM_NIT_FOD : PARAM_NIT_NONE); - } - }).detach(); -} - -Return FingerprintInscreen::getPositionX() { - return FOD_SENSOR_X; -} - -Return FingerprintInscreen::getPositionY() { - return FOD_SENSOR_Y; -} - -Return FingerprintInscreen::getSize() { - return FOD_SENSOR_SIZE; -} - -Return FingerprintInscreen::onStartEnroll() { - return Void(); -} - -Return FingerprintInscreen::onFinishEnroll() { - return Void(); -} - -Return FingerprintInscreen::onPress() { - return Void(); -} - -Return FingerprintInscreen::onRelease() { - set(FOD_HBM_PATH, FOD_HBM_OFF); - return Void(); -} - -Return FingerprintInscreen::onShowFODView() { - set(FOD_STATUS_PATH, FOD_STATUS_ON); - return Void(); -} - -Return FingerprintInscreen::onHideFODView() { - set(FOD_STATUS_PATH, FOD_STATUS_OFF); - return Void(); -} - -Return FingerprintInscreen::handleAcquired(int32_t acquiredInfo, int32_t vendorCode) { - std::lock_guard _lock(mCallbackLock); - if (mCallback == nullptr) { - return false; - } - - if (acquiredInfo == FINGERPRINT_ACQUIRED_VENDOR) { - if (vendorCode == 22) { - Return ret = mCallback->onFingerDown(); - if (!ret.isOk()) { - LOG(ERROR) << "FingerDown() error: " << ret.description(); - } - return true; - } - - if (vendorCode == 23) { - Return ret = mCallback->onFingerUp(); - if (!ret.isOk()) { - LOG(ERROR) << "FingerUp() error: " << ret.description(); - } - return true; - } - } - - return false; -} - -Return FingerprintInscreen::handleError(int32_t error, int32_t vendorCode) { - LOG(ERROR) << "error: " << error << ", vendorCode: " << vendorCode; - return false; -} - -Return FingerprintInscreen::setLongPressEnabled(bool) { - return Void(); -} - -Return FingerprintInscreen::getDimAmount(int32_t /* brightness */) { - return 0; -} - -Return FingerprintInscreen::shouldBoostBrightness() { - return false; -} - -Return FingerprintInscreen::setCallback(const sp& 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 deleted file mode 100644 index 8cad941..0000000 --- a/fod/FingerprintInscreen.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 -#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; -using ::vendor::xiaomi::hardware::fingerprintextension::V1_0::IXiaomiFingerprint; - -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& callback) override; - -private: - sp xiaomiFingerprintService; - - 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/service.cpp b/fod/service.cpp deleted file mode 100644 index d8526f6..0000000 --- a/fod/service.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.xiaomi_sm8350" - -#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/fod/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_sm8350.rc b/fod/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_sm8350.rc deleted file mode 100644 index 058cf85..0000000 --- a/fod/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_sm8350.rc +++ /dev/null @@ -1,11 +0,0 @@ -on boot - chown system system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_hbm - chown system system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_ui - chown system system /sys/devices/virtual/touch/tp_dev/fod_status - -service fingerprint-inscreen-1-0 /vendor/bin/hw/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_sm8350 - interface vendor.lineage.biometrics.fingerprint.inscreen@1.0::IFingerprintInscreen default - class hal - user system - group system - shutdown critical diff --git a/fod/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_sm8350.xml b/fod/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_sm8350.xml deleted file mode 100644 index e03c70c..0000000 --- a/fod/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.xiaomi_sm8350.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - vendor.lineage.biometrics.fingerprint.inscreen - hwbinder - 1.0 - - IFingerprintInscreen - default - - - diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 948715e..4b43a83 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -43,12 +43,6 @@ /data/vendor/goodix(/.*)? u:object_r:vendor_fingerprint_data_file:s0 /vendor/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-service\.xiaomi_sm8350 u:object_r:hal_fingerprint_default_exec:s0 -# FOD -/vendor/bin/hw/vendor\.lineage\.biometrics\.fingerprint\.inscreen@1.0-service\.xiaomi_sm8350 u:object_r:hal_lineage_fod_default_exec:s0 -/sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_hbm u:object_r:vendor_sysfs_fod:s0 -/sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_ui u:object_r:vendor_sysfs_fod:s0 -/sys/devices/virtual/touch/tp_dev/fod_status u:object_r:vendor_sysfs_fod:s0 - # Thermal /data/vendor/thermal(/.*)? u:object_r:thermal_data_file:s0 /vendor/bin/mi_thermald u:object_r:mi_thermald_exec:s0 diff --git a/sepolicy/vendor/hal_lineage_fod_default.te b/sepolicy/vendor/hal_lineage_fod_default.te deleted file mode 100644 index 60ce291..0000000 --- a/sepolicy/vendor/hal_lineage_fod_default.te +++ /dev/null @@ -1,11 +0,0 @@ -type vendor_sysfs_fod, sysfs_type, fs_type; - -allow hal_lineage_fod_default vendor_sysfs_fod:file rw_file_perms; -allow hal_lineage_fod_default vendor_sysfs_graphics:dir r_dir_perms; -allow hal_lineage_fod_default vendor_sysfs_graphics:file rw_file_perms; - -allow hal_lineage_fod_default vendor_hal_fingerprint_hwservice_xiaomi:hwservice_manager { find }; - -binder_call(hal_lineage_fod_default, hal_fingerprint_default) - -hal_client_domain(hal_lineage_fod_default, hal_fingerprint)