sm7125: Add fod hidl

sm7125: fod: Write to brightness path directly

Change-Id: Ib71ba0e2da3d8f48219547b3b53ada4598396299

sm7125: fod: Properly reset previous brightness
Change-Id: I84130099269e6f934dbc85165cec62451e89259a
fourteen-wip
Willi Ye 3 years ago committed by Simon1511
parent 8a3a8e973e
commit 191efc0692
  1. 7
      common.mk
  2. 8
      configs/framework_compatibility_matrix.xml
  3. 45
      fod/Android.mk
  4. 194
      fod/FingerprintInscreen.cpp
  5. 73
      fod/FingerprintInscreen.h
  6. 50
      fod/service.cpp
  7. 9
      fod/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125.rc
  8. 11
      fod/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125.xml
  9. 4
      interfaces/Android.bp
  10. 14
      interfaces/biometrics/fingerprint/3.0/Android.bp
  11. 7
      interfaces/biometrics/fingerprint/3.0/ISehBiometricsFingerprint.hal
  12. 4
      proprietary-files.txt
  13. 2
      rootdir/etc/init.target.rc
  14. 2
      sepolicy/vendor/file_contexts

@ -146,6 +146,10 @@ PRODUCT_PACKAGES += \
android.hardware.drm@1.3-service.clearkey \ android.hardware.drm@1.3-service.clearkey \
libdrmclearkeyplugin libdrmclearkeyplugin
# Fingerprint
PRODUCT_PACKAGES += \
vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125
# fastbootd # fastbootd
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
fastbootd fastbootd
@ -276,7 +280,8 @@ PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.software.verified_boot.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.verified_boot.xml \ frameworks/native/data/etc/android.software.verified_boot.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.verified_boot.xml \
frameworks/native/data/etc/android.software.vulkan.deqp.level-2020-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml \ frameworks/native/data/etc/android.software.vulkan.deqp.level-2020-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml \
frameworks/native/data/etc/com.nxp.mifare.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/com.nxp.mifare.xml \ frameworks/native/data/etc/com.nxp.mifare.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/com.nxp.mifare.xml \
frameworks/native/data/etc/handheld_core_hardware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/handheld_core_hardware.xml frameworks/native/data/etc/handheld_core_hardware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/handheld_core_hardware.xml \
vendor/lineage/config/permissions/vendor.lineage.biometrics.fingerprint.inscreen.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/vendor.lineage.biometrics.fingerprint.inscreen.xml
# Power # Power
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \

@ -74,6 +74,14 @@
<instance>gnss_vendor</instance> <instance>gnss_vendor</instance>
</interface> </interface>
</hal> </hal>
<hal format="hidl" optional="true">
<name>vendor.lineage.biometrics.fingerprint.inscreen</name>
<version>1.0</version>
<interface>
<name>IFingerprintInscreen</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="true"> <hal format="hidl" optional="true">
<name>android.hardware.keymaster</name> <name>android.hardware.keymaster</name>
<version>4.0</version> <version>4.0</version>

@ -0,0 +1,45 @@
#
# 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.
#
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
FingerprintInscreen.cpp \
service.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SHARED_LIBRARIES := \
libbase \
libhardware \
libhidlbase \
liblog \
libhwbinder \
libutils \
vendor.lineage.biometrics.fingerprint.inscreen@1.0 \
vendor.samsung.hardware.biometrics.fingerprint@3.0
LOCAL_MODULE := vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125
LOCAL_INIT_RC := vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125.rc
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_OWNER := samsung
LOCAL_VINTF_FRAGMENTS := vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125.xml
LOCAL_VENDOR_MODULE := true
include $(BUILD_EXECUTABLE)

@ -0,0 +1,194 @@
/*
* 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 BRIGHTNESS_PATH "/sys/class/backlight/panel0-backlight/brightness"
#define TSP_CMD_PATH "/sys/class/sec/tsp/cmd"
#define SEM_FINGER_STATE 22
#define SEM_PARAM_PRESSED 2
#define SEM_PARAM_RELEASED 1
#define SEM_AOSP_FQNAME "android.hardware.biometrics.fingerprint@2.1::IBiometricsFingerprint"
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;
}
static hidl_vec<int8_t> stringToVec(const std::string& str) {
auto vec = hidl_vec<int8_t>();
vec.resize(str.size() + 1);
for (size_t i = 0; i < str.size(); ++i) {
vec[i] = (int8_t) str[i];
}
vec[str.size()] = '\0';
return vec;
}
FingerprintInscreen::FingerprintInscreen() {
mSehBiometricsFingerprintService = ISehBiometricsFingerprint::getService();
}
void FingerprintInscreen::requestResult(int, const hidl_vec<int8_t>&) {
// Ignore all results
}
Return<void> FingerprintInscreen::onStartEnroll() {
return Void();
}
Return<void> FingerprintInscreen::onFinishEnroll() {
return Void();
}
Return<void> FingerprintInscreen::onPress() {
mPreviousBrightness = get<std::string>(BRIGHTNESS_PATH, "");
set(BRIGHTNESS_PATH, "425");
set(TSP_CMD_PATH, "fod_enable,1,1,0");
mSehBiometricsFingerprintService->sehRequest(SEM_FINGER_STATE,
SEM_PARAM_PRESSED, stringToVec(SEM_AOSP_FQNAME), FingerprintInscreen::requestResult);
return Void();
}
Return<void> 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();
}
Return<void> FingerprintInscreen::onShowFODView() {
return Void();
}
Return<void> FingerprintInscreen::onHideFODView() {
set(TSP_CMD_PATH, "fod_enable,0");
if (!mPreviousBrightness.empty()) {
set(BRIGHTNESS_PATH, mPreviousBrightness);
mPreviousBrightness = "";
}
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 == 10002) {
Return<void> ret = mCallback->onFingerDown();
if (!ret.isOk()) {
LOG(ERROR) << "FingerDown() error: " << ret.description();
}
return true;
} else if (vendorCode == 10001) {
Return<void> ret = mCallback->onFingerUp();
if (!ret.isOk()) {
LOG(ERROR) << "FingerUp() error: " << ret.description();
}
return true;
}
}
LOG(ERROR) << "acquiredInfo: " << acquiredInfo << ", vendorCode: " << vendorCode << "\n";
return false;
}
Return<bool> FingerprintInscreen::handleError(int32_t, int32_t) {
return false;
}
Return<void> FingerprintInscreen::setLongPressEnabled(bool) {
return Void();
}
Return<int32_t> FingerprintInscreen::getDimAmount(int32_t cur_brightness) {
if (cur_brightness <= 12) {
return 2200 / std::max(cur_brightness, 10);
} else if (cur_brightness <= 16) {
return 3000 / cur_brightness;
} else if (cur_brightness <= 20) {
return 3700 / cur_brightness;
} else {
return 4400 / cur_brightness;
}
}
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 440;
}
Return<int32_t> FingerprintInscreen::getPositionY() {
return 2020;
}
Return<int32_t> FingerprintInscreen::getSize() {
return 200;
}
} // namespace implementation
} // namespace V1_0
} // namespace inscreen
} // namespace fingerprint
} // namespace biometrics
} // namespace lineage
} // namespace vendor

@ -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/samsung/hardware/biometrics/fingerprint/3.0/ISehBiometricsFingerprint.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 ::android::hardware::hidl_vec;
using ::vendor::samsung::hardware::biometrics::fingerprint::V3_0::ISehBiometricsFingerprint;
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<ISehBiometricsFingerprint> mSehBiometricsFingerprintService;
std::mutex mCallbackLock;
sp<IFingerprintInscreenCallback> mCallback;
std::string mPreviousBrightness;
static void requestResult(int retval, const hidl_vec<int8_t>& outBuf);
};
} // 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

@ -0,0 +1,50 @@
/*
* 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.
*/
#define LOG_TAG "lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125"
#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;
}

@ -0,0 +1,9 @@
service vendor.fingerprint-inscreen-1-0 /vendor/bin/hw/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125
interface vendor.lineage.biometrics.fingerprint.inscreen@1.0::IFingerprintInscreen default
class hal
user system
group system
shutdown critical
on boot
chown system system /sys/class/sec/tsp/cmd

@ -0,0 +1,11 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>vendor.lineage.biometrics.fingerprint.inscreen</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IFingerprintInscreen</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

@ -0,0 +1,4 @@
hidl_package_root {
name: "vendor.samsung.hardware",
path: "device/samsung/sm7125-common/interfaces",
}

@ -0,0 +1,14 @@
// This file is autogenerated by hidl-gen -Landroidbp.
hidl_interface {
name: "vendor.samsung.hardware.biometrics.fingerprint@3.0",
root: "vendor.samsung.hardware",
srcs: [
"ISehBiometricsFingerprint.hal",
],
interfaces: [
"android.hardware.biometrics.fingerprint@2.1",
"android.hidl.base@1.0",
],
gen_java: true,
}

@ -0,0 +1,7 @@
package vendor.samsung.hardware.biometrics.fingerprint@3.0;
import android.hardware.biometrics.fingerprint@2.1::IBiometricsFingerprint;
interface ISehBiometricsFingerprint extends android.hardware.biometrics.fingerprint@2.1::IBiometricsFingerprint {
sehRequest(int32_t cmdId, int32_t inParam, vec<int8_t> inBuf) generates (int32_t retval, vec<int8_t> outBuf);
};

@ -657,6 +657,10 @@ vendor/lib64/libsecnativefeature.so
vendor/etc/floating_feature.xml vendor/etc/floating_feature.xml
# Fingerprint # Fingerprint
vendor/bin/hw/vendor.samsung.hardware.biometrics.fingerprint@3.0-service
vendor/etc/init/vendor.samsung.hardware.biometrics.fingerprint@3.0-service.rc
vendor/lib/hw/fingerprint.default.so
vendor/lib64/hw/fingerprint.default.so
vendor/lib/libbauthserver.so vendor/lib/libbauthserver.so
vendor/lib64/libbauthserver.so vendor/lib64/libbauthserver.so
vendor/lib/libbauthtzcommon.so vendor/lib/libbauthtzcommon.so

@ -131,6 +131,8 @@ on post-fs-data
# For cpusets initialize for Silver Only first and then Silver + Gold # For cpusets initialize for Silver Only first and then Silver + Gold
# Silver Only configuration cannot work with 0-7 # Silver Only configuration cannot work with 0-7
on boot on boot
chown system system /sys/class/lcd/panel/mask_brightness
write /dev/cpuset/audio-app/cpus 1-2 write /dev/cpuset/audio-app/cpus 1-2
chown system system /sys/kernel/hbtp/display_pwr chown system system /sys/kernel/hbtp/display_pwr
start rmt_storage start rmt_storage

@ -18,3 +18,5 @@
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.fastcharge@1\.0-service\.samsung u:object_r:hal_lineage_fastcharge_default_exec:s0 /(vendor|system/vendor)/bin/hw/vendor\.lineage\.fastcharge@1\.0-service\.samsung u:object_r:hal_lineage_fastcharge_default_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch@1\.0-service\.samsung u:object_r:hal_lineage_touch_default_exec:s0 /(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch@1\.0-service\.samsung u:object_r:hal_lineage_touch_default_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.0-service.samsung-qcom\.sm7125 u:object_r:hal_lineage_livedisplay_sysfs_exec:s0 /(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.0-service.samsung-qcom\.sm7125 u:object_r:hal_lineage_livedisplay_sysfs_exec:s0
/(vendor|system/vendor)/bin/hw/vendor.samsung.hardware.biometrics.fingerprint@3.0-service u:object_r:hal_fingerprint_default_exec:s0
/(vendor|system/vendor)/bin/hw/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125 u:object_r:hal_lineage_fod_default_exec:s0

Loading…
Cancel
Save