fingerprint: Add fps extension script
Bug: 208400345
Test: build Pass
Change-Id: If9334ac3a837c9bf85709335075f3a666eeef06d
diff --git a/fingerprint/extension/Android.bp b/fingerprint/extension/Android.bp
new file mode 100644
index 0000000..4f64c3c
--- /dev/null
+++ b/fingerprint/extension/Android.bp
@@ -0,0 +1,6 @@
+sh_binary {
+ name: "fingerprint.extension.sh",
+ init_rc: ["init.fingerprint.extension.rc"],
+ src: "fingerprint.extension.sh",
+ system_ext_specific: true,
+}
diff --git a/fingerprint/extension/fingerprint.extension.mk b/fingerprint/extension/fingerprint.extension.mk
new file mode 100644
index 0000000..1ef2374
--- /dev/null
+++ b/fingerprint/extension/fingerprint.extension.mk
@@ -0,0 +1,11 @@
+# Fingerprint extension feature
+ifneq (,$(filter userdebug, $(TARGET_BUILD_VARIANT)))
+SOONG_CONFIG_fp_hal_feature += report_bug_support
+SOONG_CONFIG_fp_hal_feature_report_bug_support := true
+BOARD_SEPOLICY_DIRS += hardware/google/pixel-sepolicy/fingerprint-extension/vendor/
+SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS += hardware/google/pixel-sepolicy/fingerprint-extension/system_ext/public/
+SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS += hardware/google/pixel-sepolicy/fingerprint-extension/system_ext/private/
+PRODUCT_PACKAGES += \
+ fps_ext_bug_lib \
+ fingerprint.extension.sh
+endif
diff --git a/fingerprint/extension/fingerprint.extension.sh b/fingerprint/extension/fingerprint.extension.sh
new file mode 100644
index 0000000..ff70377
--- /dev/null
+++ b/fingerprint/extension/fingerprint.extension.sh
@@ -0,0 +1,63 @@
+#!/system/bin/sh
+
+# BetterBug required fields
+am='am start -a com.google.android.apps.betterbug.intent.FILE_BUG_DEEPLINK --ez EXTRA_DEEPLINK true '
+issueTitle=' --es EXTRA_ISSUE_TITLE '
+additionalComment=' --es EXTRA_ADDITIONAL_COMMENT '
+componentId=' --el EXTRA_COMPONENT_ID '
+requireBugReport=' --ez EXTRA_REQUIRE_BUGREPORT '
+bugAssign=' --es EXTRA_BUG_ASSIGNEE '
+ccGroup=' --es EXTRA_CC '
+
+# BetterBug title
+kAuthTitle="UDFPS Fingerprint authentication has high failed rate"
+kLockoutTitle="UDFPS Fingerprint has too many lockout counts"
+kLatencyTitle="UDFPS Fingerprint took long to unlock device"
+
+# BetterBug context comment
+kAuthComment="This bug is auto created by fingerprint HAL to track fingerprint authentication"
+kLockoutComment="This bug is auto created by fingerprint HAL to track fingerprint lockout"
+kLatencyComment="This bug is auto created by fingerprint HAL to track fingerprint latency"
+
+# BetterBug assign & CC owner
+kBugAssign='fps-triage@google.com'
+kCcGroup='eddielan@google.com'
+kComponentId='817555'
+
+# Command to send intent to BetterBug
+commonCommand="$componentId ${kComponentId//\ /\\ }
+ $requireBugReport true
+ $bugAssign ${kBugAssign//\ /\\ }
+ $ccGroup ${kCcGroup//\ /\\ }"
+authCommand="$am $issueTitle ${kAuthTitle//\ /\\ }
+ $additionalComment ${kAuthComment//\ /\\ }"
+lockoutCommand="$am $issueTitle ${kLockoutTitle//\ /\\ }
+ $additionalComment ${kLockoutComment//\ /\\ }"
+latencyCommand="$am $issueTitle ${kLatencyTitle//\ /\\ }
+ $additionalComment ${kLatencyComment//\ /\\ }"
+
+# Type of bug being triggered
+# 1. Latency
+# 2. Lockout
+# 3. Finerprint authentication(FRR)
+bug_type="$1"
+
+send=1
+if [ "$bug_type" == "latency" ]; then
+ intentCommand="$latencyCommand $commonCommand"
+elif [ "$bug_type" == "lockout" ]; then
+ intentCommand="$lockoutCommand $commonCommand"
+elif [ "$bug_type" == "auth" ]; then
+ intentCommand="$authCommand $commonCommand"
+else
+ send=0
+ echo "Unknown bug_type $bug_type"
+fi
+
+if [ $send -eq 1 ]
+then
+ eval $intentCommand
+fi
+
+# Exit
+exit 0
diff --git a/fingerprint/extension/init.fingerprint.extension.rc b/fingerprint/extension/init.fingerprint.extension.rc
new file mode 100644
index 0000000..9277ce0
--- /dev/null
+++ b/fingerprint/extension/init.fingerprint.extension.rc
@@ -0,0 +1,19 @@
+# init-fingerprint-extension-sh is to send intent command to app
+# for tracking fingerprint issue.
+service fingerprint-extension-bug-latency /system_ext/bin/fingerprint.extension.sh latency
+ group shell
+ user shell
+ disabled
+ oneshot
+
+service fingerprint-extension-bug-lockout /system_ext/bin/fingerprint.extension.sh lockout
+ group shell
+ user shell
+ disabled
+ oneshot
+
+service fingerprint-extension-bug-auth /system_ext/bin/fingerprint.extension.sh auth
+ group shell
+ user shell
+ disabled
+ oneshot