-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fajita: Introduce in-screen fingerprint HAL
Change-Id: I0c034def5803ab80e6158a4c4d1caf1eeaa92841
- Loading branch information
Showing
9 changed files
with
383 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,10 @@ DEVICE_PACKAGE_OVERLAYS += \ | |
$(LOCAL_PATH)/overlay \ | ||
$(LOCAL_PATH)/overlay-lineage | ||
|
||
# Permissions | ||
PRODUCT_COPY_FILES += \ | ||
vendor/lineage/config/permissions/vendor.lineage.biometrics.fingerprint.inscreen.xml:system/etc/permissions/vendor.lineage.biometrics.fingerprint.inscreen.xml | ||
|
||
# Device uses high-density artwork where available | ||
PRODUCT_AAPT_CONFIG := normal | ||
PRODUCT_AAPT_PREF_CONFIG := xxhdpi | ||
|
@@ -37,6 +41,10 @@ PRODUCT_AAPT_PREF_CONFIG := xxhdpi | |
TARGET_SCREEN_HEIGHT := 2340 | ||
TARGET_SCREEN_WIDTH := 1080 | ||
|
||
# Fingerprint | ||
PRODUCT_PACKAGES += \ | ||
[email protected]_fajita | ||
|
||
# Inherit from oneplus sdm845-common | ||
$(call inherit-product, device/oneplus/sdm845-common/common.mk) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// 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: "[email protected]_fajita", | ||
init_rc: ["[email protected]_fajita.rc"], | ||
srcs: ["service.cpp", "FingerprintInscreen.cpp"], | ||
shared_libs: [ | ||
"libbase", | ||
"libhardware", | ||
"libhidlbase", | ||
"libhidltransport", | ||
"liblog", | ||
"libhwbinder", | ||
"libutils", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
/* | ||
* 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 <android-base/logging.h> | ||
#include <hidl/HidlTransportSupport.h> | ||
#include <fstream> | ||
|
||
#define FINGERPRINT_ACQUIRED_VENDOR 6 | ||
|
||
#define OP_ENABLE_FP_LONGPRESS 3 | ||
#define OP_DISABLE_FP_LONGPRESS 4 | ||
#define OP_RESUME_FP_ENROLL 8 | ||
#define OP_FINISH_FP_ENROLL 10 | ||
|
||
#define OP_DISPLAY_AOD_MODE 8 | ||
#define OP_DISPLAY_NOTIFY_PRESS 9 | ||
#define OP_DISPLAY_SET_DIM 10 | ||
|
||
// This is not a typo by me. It's by OnePlus. | ||
#define HBM_ENABLE_PATH "/sys/class/drm/card0-DSI-1/op_friginer_print_hbm" | ||
#define DIM_AMOUNT_PATH "/sys/class/drm/card0-DSI-1/dim_alpha" | ||
|
||
namespace vendor { | ||
namespace lineage { | ||
namespace biometrics { | ||
namespace fingerprint { | ||
namespace inscreen { | ||
namespace V1_0 { | ||
namespace implementation { | ||
|
||
/* | ||
* Write value to path and close file. | ||
*/ | ||
template <typename T> | ||
static void set(const std::string& path, const T& value) { | ||
std::ofstream file(path); | ||
file << value; | ||
} | ||
|
||
template <typename T> | ||
static T get(const std::string& path, const T& def) { | ||
std::ifstream file(path); | ||
T result; | ||
|
||
file >> result; | ||
return file.fail() ? def : result; | ||
} | ||
|
||
FingerprintInscreen::FingerprintInscreen() { | ||
this->mVendorFpService = IVendorFingerprintExtensions::getService(); | ||
this->mVendorDisplayService = IOneplusDisplay::getService(); | ||
} | ||
|
||
Return<void> FingerprintInscreen::onStartEnroll() { | ||
this->mVendorFpService->updateStatus(OP_DISABLE_FP_LONGPRESS); | ||
this->mVendorFpService->updateStatus(OP_RESUME_FP_ENROLL); | ||
|
||
return Void(); | ||
} | ||
|
||
Return<void> FingerprintInscreen::onFinishEnroll() { | ||
this->mVendorFpService->updateStatus(OP_FINISH_FP_ENROLL); | ||
|
||
return Void(); | ||
} | ||
|
||
Return<void> FingerprintInscreen::onPress() { | ||
this->mVendorDisplayService->setMode(OP_DISPLAY_AOD_MODE, 2); | ||
this->mVendorDisplayService->setMode(OP_DISPLAY_SET_DIM, 1); | ||
set(HBM_ENABLE_PATH, 1); | ||
this->mVendorDisplayService->setMode(OP_DISPLAY_NOTIFY_PRESS, 1); | ||
|
||
return Void(); | ||
} | ||
|
||
Return<void> FingerprintInscreen::onRelease() { | ||
this->mVendorDisplayService->setMode(OP_DISPLAY_AOD_MODE, 0); | ||
this->mVendorDisplayService->setMode(OP_DISPLAY_SET_DIM, 0); | ||
set(HBM_ENABLE_PATH, 0); | ||
this->mVendorDisplayService->setMode(OP_DISPLAY_NOTIFY_PRESS, 0); | ||
|
||
return Void(); | ||
} | ||
|
||
Return<void> FingerprintInscreen::onShowFODView() { | ||
return Void(); | ||
} | ||
|
||
Return<void> FingerprintInscreen::onHideFODView() { | ||
this->mVendorDisplayService->setMode(OP_DISPLAY_AOD_MODE, 0); | ||
this->mVendorDisplayService->setMode(OP_DISPLAY_SET_DIM, 0); | ||
set(HBM_ENABLE_PATH, 0); | ||
this->mVendorDisplayService->setMode(OP_DISPLAY_NOTIFY_PRESS, 0); | ||
|
||
return Void(); | ||
} | ||
|
||
Return<bool> FingerprintInscreen::handleAcquired(int32_t acquiredInfo, int32_t vendorCode) { | ||
std::lock_guard<std::mutex> _lock(mCallbackLock); | ||
if (mCallback == nullptr) { | ||
return false; | ||
} | ||
|
||
if (acquiredInfo == FINGERPRINT_ACQUIRED_VENDOR) { | ||
if (vendorCode == 0) { | ||
Return<void> ret = mCallback->onFingerDown(); | ||
if (!ret.isOk()) { | ||
LOG(ERROR) << "FingerDown() error: " << ret.description(); | ||
} | ||
return true; | ||
} | ||
|
||
if (vendorCode == 1) { | ||
Return<void> ret = mCallback->onFingerUp(); | ||
if (!ret.isOk()) { | ||
LOG(ERROR) << "FingerUp() error: " << ret.description(); | ||
} | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
Return<bool> FingerprintInscreen::handleError(int32_t, int32_t) { | ||
return false; | ||
} | ||
|
||
Return<void> FingerprintInscreen::setLongPressEnabled(bool enabled) { | ||
this->mVendorFpService->updateStatus( | ||
enabled ? OP_ENABLE_FP_LONGPRESS : OP_DISABLE_FP_LONGPRESS); | ||
|
||
return Void(); | ||
} | ||
|
||
Return<int32_t> FingerprintInscreen::getDimAmount(int32_t) { | ||
int dimAmount = get(DIM_AMOUNT_PATH, 0); | ||
LOG(INFO) << "dimAmount = " << dimAmount; | ||
|
||
return dimAmount; | ||
} | ||
|
||
Return<bool> FingerprintInscreen::shouldBoostBrightness() { | ||
return false; | ||
} | ||
|
||
Return<void> FingerprintInscreen::setCallback(const sp<IFingerprintInscreenCallback>& callback) { | ||
{ | ||
std::lock_guard<std::mutex> _lock(mCallbackLock); | ||
mCallback = callback; | ||
} | ||
|
||
return Void(); | ||
} | ||
|
||
Return<int32_t> FingerprintInscreen::getPositionX() { | ||
return 444; | ||
} | ||
|
||
Return<int32_t> FingerprintInscreen::getPositionY() { | ||
return 1966; | ||
} | ||
|
||
Return<int32_t> FingerprintInscreen::getSize() { | ||
return 190; | ||
} | ||
|
||
} // namespace implementation | ||
} // namespace V1_0 | ||
} // namespace inscreen | ||
} // namespace fingerprint | ||
} // namespace biometrics | ||
} // namespace lineage | ||
} // namespace vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* 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 <vendor/lineage/biometrics/fingerprint/inscreen/1.0/IFingerprintInscreen.h> | ||
#include <vendor/oneplus/fingerprint/extension/1.0/IVendorFingerprintExtensions.h> | ||
#include <vendor/oneplus/hardware/display/1.0/IOneplusDisplay.h> | ||
|
||
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::oneplus::fingerprint::extension::V1_0::IVendorFingerprintExtensions; | ||
using ::vendor::oneplus::hardware::display::V1_0::IOneplusDisplay; | ||
|
||
class FingerprintInscreen : public IFingerprintInscreen { | ||
public: | ||
FingerprintInscreen(); | ||
|
||
Return<void> onStartEnroll() override; | ||
Return<void> onFinishEnroll() override; | ||
Return<void> onPress() override; | ||
Return<void> onRelease() override; | ||
Return<void> onShowFODView() override; | ||
Return<void> onHideFODView() override; | ||
Return<bool> handleAcquired(int32_t acquiredInfo, int32_t vendorCode) override; | ||
Return<bool> handleError(int32_t error, int32_t vendorCode) override; | ||
Return<void> setLongPressEnabled(bool enabled) override; | ||
Return<int32_t> getDimAmount(int32_t cur_brightness) override; | ||
Return<bool> shouldBoostBrightness() override; | ||
Return<void> setCallback(const sp<IFingerprintInscreenCallback>& callback) override; | ||
Return<int32_t> getPositionX() override; | ||
Return<int32_t> getPositionY() override; | ||
Return<int32_t> getSize() override; | ||
|
||
private: | ||
sp<IOneplusDisplay> mVendorDisplayService; | ||
sp<IVendorFingerprintExtensions> mVendorFpService; | ||
|
||
std::mutex mCallbackLock; | ||
sp<IFingerprintInscreenCallback> 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
on init | ||
chown system system /sys/class/drm/card0-DSI-1/op_friginer_print_hbm | ||
chmod 0660 /sys/class/drm/card0-DSI-1/op_friginer_print_hbm | ||
|
||
service fingerprint-inscreen-1-0 /system/bin/hw/[email protected]_fajita | ||
interface [email protected]::IFingerprintInscreen default | ||
class hal | ||
user system | ||
group system | ||
shutdown critical |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "[email protected]_fajita" | ||
|
||
#include <android-base/logging.h> | ||
#include <hidl/HidlTransportSupport.h> | ||
|
||
#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<IFingerprintInscreen> 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; | ||
} |
Oops, something went wrong.