From 8542cf67731cbdc4eb4b1ea5444b416cd8cc3810 Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Mon, 25 May 2020 10:55:56 +0000 Subject: [PATCH] sm7125: fod: add surfaceflinger extension lib Change-Id: I51fb56c0a20e3cac83afb46ed6a6e2f967159d18 --- BoardConfigCommon.mk | 3 +++ fod/Android.bp | 7 +++++++ fod/FingerprintInscreen.cpp | 15 +++------------ fod/FodExtension.cpp | 29 +++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 fod/Android.bp create mode 100644 fod/FodExtension.cpp diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 6e13037..5f51553 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -147,6 +147,9 @@ AUDIOSERVER_MULTILIB := 32 # Keymaster TARGET_KEYMASTER_VARIANT := samsung +# FOD +TARGET_SURFACEFLINGER_FOD_LIB := //$(COMMON_PATH):libfod_extension.sm7125 + # HIDL manifests DEVICE_MANIFEST_FILE := $(COMMON_PATH)/configs/manifest.xml DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE := $(COMMON_PATH)/configs/framework_compatibility_matrix.xml diff --git a/fod/Android.bp b/fod/Android.bp new file mode 100644 index 0000000..0fd1e5f --- /dev/null +++ b/fod/Android.bp @@ -0,0 +1,7 @@ +cc_library_static { + name: "libfod_extension.sm7125", + srcs: ["FodExtension.cpp"], + include_dirs: [ + "frameworks/native/services/surfaceflinger/CompositionEngine/include" + ], +} diff --git a/fod/FingerprintInscreen.cpp b/fod/FingerprintInscreen.cpp index f3867a6..5ca5055 100644 --- a/fod/FingerprintInscreen.cpp +++ b/fod/FingerprintInscreen.cpp @@ -24,8 +24,8 @@ #define FINGERPRINT_ACQUIRED_VENDOR 6 -#define BRIGHTNESS_PATH "/sys/class/backlight/panel0-backlight/brightness" #define TSP_CMD_PATH "/sys/class/sec/tsp/cmd" +#define MASK_BRIGHTNESS_PATH "/sys/class/lcd/panel/mask_brightness" #define SEM_FINGER_STATE 22 #define SEM_PARAM_PRESSED 2 @@ -70,6 +70,7 @@ static hidl_vec stringToVec(const std::string& str) { FingerprintInscreen::FingerprintInscreen() { mSehBiometricsFingerprintService = ISehBiometricsFingerprint::getService(); + set(MASK_BRIGHTNESS_PATH, "319"); } void FingerprintInscreen::requestResult(int, const hidl_vec&) { @@ -85,10 +86,8 @@ Return FingerprintInscreen::onFinishEnroll() { } Return FingerprintInscreen::onPress() { - mPreviousBrightness = get(BRIGHTNESS_PATH, ""); - set(BRIGHTNESS_PATH, "425"); set(TSP_CMD_PATH, "fod_enable,1,1,0"); - mSehBiometricsFingerprintService->sehRequest(SEM_FINGER_STATE, + mSehBiometricsFingerprintService->sehRequest(SEM_FINGER_STATE, SEM_PARAM_PRESSED, stringToVec(SEM_AOSP_FQNAME), FingerprintInscreen::requestResult); return Void(); } @@ -97,10 +96,6 @@ Return FingerprintInscreen::onRelease() { mSehBiometricsFingerprintService->sehRequest(SEM_FINGER_STATE, SEM_PARAM_RELEASED, stringToVec(SEM_AOSP_FQNAME), FingerprintInscreen::requestResult); set(TSP_CMD_PATH, "fod_enable,0"); - if (!mPreviousBrightness.empty()) { - set(BRIGHTNESS_PATH, mPreviousBrightness); - mPreviousBrightness = ""; - } return Void(); } @@ -110,10 +105,6 @@ Return FingerprintInscreen::onShowFODView() { Return FingerprintInscreen::onHideFODView() { set(TSP_CMD_PATH, "fod_enable,0"); - if (!mPreviousBrightness.empty()) { - set(BRIGHTNESS_PATH, mPreviousBrightness); - mPreviousBrightness = ""; - } return Void(); } diff --git a/fod/FodExtension.cpp b/fod/FodExtension.cpp new file mode 100644 index 0000000..e355173 --- /dev/null +++ b/fod/FodExtension.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 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. + */ + +#include + +uint32_t getFodZOrder(uint32_t z, bool touched) { + (void) touched; + return z; +} + +uint32_t getFodUsageBits(uint32_t usageBits, bool touched) { + if (touched) { + usageBits |= 0x400000000LL; + } + return usageBits; +}