ROG2: Introduce in-screen fingerprint HAL
Change-Id: Icb7a5cece6a4e565fcd51b5335b204a17153d2da
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 5b1afa9..968671d 100755
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -99,8 +99,9 @@
TARGET_USES_QCOM_BSP := false
TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false
-#HIDL
+# HIDL
DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE += $(DEVICE_PATH)/vendor_framework_compatibility_matrix.xml
+DEVICE_FRAMEWORK_MANIFEST_FILE += $(DEVICE_PATH)/framework_manifest.xml
# Kernel
BOARD_KERNEL_CMDLINE := console=ttyMSM0,115200n8 earlycon=msm_geni_serial,0xa90000 androidboot.hardware=qcom androidboot.console=ttyMSM0 androidboot.memcg=1 lpm_levels.sleep_disabled=1 video=vfb:640x400,bpp=32,memsize=3072000 msm_rtb.filter=0x237 service_locator.enable=1 swiotlb=2048 loop.max_part=7 androidboot.usbcontroller=a600000.dwc3
diff --git a/device.mk b/device.mk
index 2d6c016..2d1bb07 100755
--- a/device.mk
+++ b/device.mk
@@ -97,6 +97,10 @@
PRODUCT_BOOT_JARS += qcom.fmradio
+# Fingerprint
+PRODUCT_PACKAGES += \
+ omni.biometrics.fingerprint.inscreen@1.0-service.asus_msmnile
+
# Frameworks
PRODUCT_PACKAGES += \
FrameworksResOverlay
diff --git a/fod/Android.bp b/fod/Android.bp
new file mode 100644
index 0000000..339e303
--- /dev/null
+++ b/fod/Android.bp
@@ -0,0 +1,32 @@
+//
+// 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: "omni.biometrics.fingerprint.inscreen@1.0-service.asus_msmnile",
+ init_rc: ["omni.biometrics.fingerprint.inscreen@1.0-service.asus_msmnile.rc"],
+ srcs: ["service.cpp", "FingerprintInscreen.cpp"],
+ shared_libs: [
+ "libbase",
+ "libhardware",
+ "libhidlbase",
+ "libhidltransport",
+ "liblog",
+ "libhwbinder",
+ "libutils",
+ "vendor.omni.biometrics.fingerprint.inscreen@1.0",
+ ],
+}
diff --git a/fod/FingerprintInscreen.cpp b/fod/FingerprintInscreen.cpp
new file mode 100644
index 0000000..90d8049
--- /dev/null
+++ b/fod/FingerprintInscreen.cpp
@@ -0,0 +1,96 @@
+/*
+ * 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 <hidl/HidlTransportSupport.h>
+
+namespace vendor {
+namespace omni {
+namespace biometrics {
+namespace fingerprint {
+namespace inscreen {
+namespace V1_0 {
+namespace implementation {
+
+Return<void> FingerprintInscreen::onStartEnroll() {
+ return Void();
+}
+
+Return<void> FingerprintInscreen::onFinishEnroll() {
+ return Void();
+}
+
+Return<void> FingerprintInscreen::onPress() {
+ return Void();
+}
+
+Return<void> FingerprintInscreen::onRelease() {
+ return Void();
+}
+
+Return<void> FingerprintInscreen::onShowFODView() {
+ return Void();
+}
+
+Return<void> FingerprintInscreen::onHideFODView() {
+ return Void();
+}
+
+Return<bool> FingerprintInscreen::handleAcquired(int32_t, int32_t) {
+ 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) {
+ return 0;
+}
+
+Return<bool> FingerprintInscreen::shouldBoostBrightness() {
+ return false;
+}
+
+Return<void> FingerprintInscreen::setCallback(const sp<IFingerprintInscreenCallback>&) {
+ return Void();
+}
+
+Return<int32_t> FingerprintInscreen::getPositionX() {
+ return 444;
+}
+
+Return<int32_t> FingerprintInscreen::getPositionY() {
+ return 1930;
+}
+
+Return<int32_t> FingerprintInscreen::getSize() {
+ return 190;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace inscreen
+} // namespace fingerprint
+} // namespace biometrics
+} // namespace omni
+} // namespace vendor
diff --git a/fod/FingerprintInscreen.h b/fod/FingerprintInscreen.h
new file mode 100644
index 0000000..68a3041
--- /dev/null
+++ b/fod/FingerprintInscreen.h
@@ -0,0 +1,62 @@
+/*
+ * 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_OMNI_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H
+#define VENDOR_OMNI_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H
+
+#include <vendor/omni/biometrics/fingerprint/inscreen/1.0/IFingerprintInscreen.h>
+
+namespace vendor {
+namespace omni {
+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() = default;
+
+ 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;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace inscreen
+} // namespace fingerprint
+} // namespace biometrics
+} // namespace omni
+} // namespace vendor
+
+#endif // VENDOR_OMNI_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H
diff --git a/fod/omni.biometrics.fingerprint.inscreen@1.0-service.asus_msmnile.rc b/fod/omni.biometrics.fingerprint.inscreen@1.0-service.asus_msmnile.rc
new file mode 100644
index 0000000..ec5935d
--- /dev/null
+++ b/fod/omni.biometrics.fingerprint.inscreen@1.0-service.asus_msmnile.rc
@@ -0,0 +1,6 @@
+service fingerprint-inscreen-1-0 /system/bin/hw/omni.biometrics.fingerprint.inscreen@1.0-service.asus_msmnile
+ interface vendor.omni.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..4e1449c
--- /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 "omni.biometrics.fingerprint.inscreen@1.0-service.asus_msmnile"
+
+#include <android-base/logging.h>
+#include <hidl/HidlTransportSupport.h>
+
+#include "FingerprintInscreen.h"
+
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+
+using vendor::omni::biometrics::fingerprint::inscreen::V1_0::IFingerprintInscreen;
+using vendor::omni::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;
+}
diff --git a/framework_manifest.xml b/framework_manifest.xml
new file mode 100644
index 0000000..ac579ab
--- /dev/null
+++ b/framework_manifest.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="framework">
+ <hal format="hidl">
+ <name>vendor.omni.biometrics.fingerprint.inscreen</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IFingerprintInscreen</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
\ No newline at end of file
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index 3b502a8..f15c9a2 100644
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -607,4 +607,7 @@
<item>3</item> <!-- COLOR_MODE_AUTOMATIC -->
</integer-array>
+ <!-- Show a custom view for FOD -->
+ <bool name="config_usesFOD">true</bool>
+
</resources>
diff --git a/prebuilt/system/etc/permissions/android.hardware.fod.xml b/prebuilt/system/etc/permissions/android.hardware.fod.xml
new file mode 100644
index 0000000..fc750d9
--- /dev/null
+++ b/prebuilt/system/etc/permissions/android.hardware.fod.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<permissions>
+ <feature name="android.hardware.fod" />
+</permissions>
\ No newline at end of file
diff --git a/sepolicy/private/file_contexts b/sepolicy/private/file_contexts
index d400ee9..4bb3de1 100644
--- a/sepolicy/private/file_contexts
+++ b/sepolicy/private/file_contexts
@@ -12,6 +12,7 @@
/xrom(/.*)? u:object_r:xrom_file:s0
# HALs
+/system/bin/hw/omni\.biometrics\.fingerprint\.inscreen@1\.0-service\.asus_msmnile u:object_r:hal_fod_asus_msmnile_exec:s0
/(product|system/product)/vendor_overlay/[0-9]+/bin/hw/android\.hardware\.light@2\.0-service u:object_r:hal_light_default_exec:s0
# Vendor overlay
diff --git a/sepolicy/private/hal_fod_asus_msmnile.te b/sepolicy/private/hal_fod_asus_msmnile.te
new file mode 100644
index 0000000..376ba85
--- /dev/null
+++ b/sepolicy/private/hal_fod_asus_msmnile.te
@@ -0,0 +1,5 @@
+type hal_fod_asus_msmnile, coredomain, domain;
+hal_server_domain(hal_fod_asus_msmnile, hal_omni_fod)
+
+type hal_fod_asus_msmnile_exec, system_file_type, exec_type, file_type;
+init_daemon_domain(hal_fod_asus_msmnile)