From 80baad2ccf94f17bec1eb119c9fc4127f8b0ac42 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Thu, 26 Oct 2023 10:44:35 +0900 Subject: [PATCH 1/2] Make Fingerprint Virtual HAL APEX as default - moved apex definition beside the HAL binary definition - updated README.md about installation Bug: 306314086 Test: follow README.md to test the virtual FP HAL Change-Id: I4bb2572ca79c93cb32a273625f4e965c2505e48a --- .../fingerprint/aidl/default/Android.bp | 34 +++++++++-- biometrics/fingerprint/aidl/default/README.md | 6 -- .../fingerprint/aidl/default/apex/Android.bp | 61 ------------------- .../file_contexts => apex_file_contexts} | 0 .../manifest.json => apex_manifest.json} | 0 .../aidl/default/fingerprint-example.rc | 2 +- 6 files changed, 29 insertions(+), 74 deletions(-) delete mode 100644 biometrics/fingerprint/aidl/default/apex/Android.bp rename biometrics/fingerprint/aidl/default/{apex/file_contexts => apex_file_contexts} (100%) rename biometrics/fingerprint/aidl/default/{apex/manifest.json => apex_manifest.json} (100%) diff --git a/biometrics/fingerprint/aidl/default/Android.bp b/biometrics/fingerprint/aidl/default/Android.bp index 3bb3f3a944..8a408bcd3a 100644 --- a/biometrics/fingerprint/aidl/default/Android.bp +++ b/biometrics/fingerprint/aidl/default/Android.bp @@ -11,8 +11,6 @@ cc_binary { name: "android.hardware.biometrics.fingerprint-service.example", vendor: true, relative_install_path: "hw", - init_rc: [":fingerprint-example.rc"], - vintf_fragments: [":fingerprint-example.xml"], local_include_dirs: ["include"], srcs: [ "FakeLockoutTracker.cpp", @@ -33,6 +31,7 @@ cc_binary { "android.hardware.biometrics.common.util", ], static_libs: ["libandroid.hardware.biometrics.fingerprint.VirtualProps"], + installable: false, // install APEX instead } cc_test { @@ -143,12 +142,35 @@ sysprop_library { vendor: true, } -filegroup { +prebuilt_etc { name: "fingerprint-example.rc", - srcs: ["fingerprint-example.rc"], + src: "fingerprint-example.rc", + installable: false, } -filegroup { +prebuilt_etc { name: "fingerprint-example.xml", - srcs: ["fingerprint-example.xml"], + src: "fingerprint-example.xml", + sub_dir: "vintf", + installable: false, +} + +apex { + name: "com.android.hardware.biometrics.fingerprint.virtual", + manifest: "apex_manifest.json", + file_contexts: "apex_file_contexts", + key: "com.android.hardware.key", + certificate: ":com.android.hardware.certificate", + updatable: false, + vendor: true, + + binaries: [ + "android.hardware.biometrics.fingerprint-service.example", + ], + prebuilts: [ + // init_rc + "fingerprint-example.rc", + // vintf_fragment + "fingerprint-example.xml", + ], } diff --git a/biometrics/fingerprint/aidl/default/README.md b/biometrics/fingerprint/aidl/default/README.md index 823cd18f43..4b4533ae67 100644 --- a/biometrics/fingerprint/aidl/default/README.md +++ b/biometrics/fingerprint/aidl/default/README.md @@ -10,12 +10,6 @@ emulators. This HAL can be used on emulators, like cuttlefish, or on real devices. Add the following to your device's `.mk` file to include it: -``` -PRODUCT_PACKAGES_DEBUG += android.hardware.biometrics.fingerprint-service.example -``` - -or add the following to include it as an apex: - ``` PRODUCT_PACKAGES_DEBUG += com.android.hardware.biometrics.fingerprint.virtual ``` diff --git a/biometrics/fingerprint/aidl/default/apex/Android.bp b/biometrics/fingerprint/aidl/default/apex/Android.bp deleted file mode 100644 index 75d84a94da..0000000000 --- a/biometrics/fingerprint/aidl/default/apex/Android.bp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2023 The Android Open Source 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. - -package { - default_applicable_licenses: ["Android-Apache-2.0"], -} - -apex { - name: "com.android.hardware.biometrics.fingerprint.virtual", - manifest: "manifest.json", - file_contexts: "file_contexts", - key: "com.android.hardware.key", - certificate: ":com.android.hardware.certificate", - updatable: false, - vendor: true, - - binaries: [ - "android.hardware.biometrics.fingerprint-service.example", - ], - prebuilts: [ - // init_rc - "fingerprint-example-apex.rc", - // vintf_fragment - "fingerprint-example-apex.xml", - ], - - overrides: [ - "android.hardware.biometrics.fingerprint-service.example", - ], -} - -genrule { - name: "gen-fingerprint-example-apex.rc", - srcs: [":fingerprint-example.rc"], - out: ["fingerprint-example-apex.rc"], - cmd: "sed -e 's@/vendor/bin/@/apex/com.android.hardware.biometrics.fingerprint.virtual/bin/@' $(in) > $(out)", -} - -prebuilt_etc { - name: "fingerprint-example-apex.rc", - src: ":gen-fingerprint-example-apex.rc", - installable: false, -} - -prebuilt_etc { - name: "fingerprint-example-apex.xml", - src: ":fingerprint-example.xml", - sub_dir: "vintf", - installable: false, -} diff --git a/biometrics/fingerprint/aidl/default/apex/file_contexts b/biometrics/fingerprint/aidl/default/apex_file_contexts similarity index 100% rename from biometrics/fingerprint/aidl/default/apex/file_contexts rename to biometrics/fingerprint/aidl/default/apex_file_contexts diff --git a/biometrics/fingerprint/aidl/default/apex/manifest.json b/biometrics/fingerprint/aidl/default/apex_manifest.json similarity index 100% rename from biometrics/fingerprint/aidl/default/apex/manifest.json rename to biometrics/fingerprint/aidl/default/apex_manifest.json diff --git a/biometrics/fingerprint/aidl/default/fingerprint-example.rc b/biometrics/fingerprint/aidl/default/fingerprint-example.rc index ee4713c158..da4ea45696 100644 --- a/biometrics/fingerprint/aidl/default/fingerprint-example.rc +++ b/biometrics/fingerprint/aidl/default/fingerprint-example.rc @@ -1,4 +1,4 @@ -service vendor.fingerprint-example /vendor/bin/hw/android.hardware.biometrics.fingerprint-service.example +service vendor.fingerprint-example /apex/com.android.hardware.biometrics.fingerprint.virtual/bin/hw/android.hardware.biometrics.fingerprint-service.example class hal user nobody group nobody From e458294ba12f45d41e00fb2a865e4c013cdc9b29 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Thu, 26 Oct 2023 11:07:08 +0900 Subject: [PATCH 2/2] Use static linking for virtual fingerprint hal To make the binary smaller in APEX, use static linking. For aosp_cf_x86_64_phone target, the APEX is reduced from 1576960 to 643072 (by 933888). Bug: 306314086 Test: m Change-Id: I1d745f64fb98a97e7adb417870034044a03ce88c --- biometrics/fingerprint/aidl/default/Android.bp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/biometrics/fingerprint/aidl/default/Android.bp b/biometrics/fingerprint/aidl/default/Android.bp index 8a408bcd3a..a173a00d12 100644 --- a/biometrics/fingerprint/aidl/default/Android.bp +++ b/biometrics/fingerprint/aidl/default/Android.bp @@ -22,15 +22,20 @@ cc_binary { "Session.cpp", "main.cpp", ], + stl: "c++_static", shared_libs: [ - "libbase", "libbinder_ndk", + "liblog", + ], + static_libs: [ + "libandroid.hardware.biometrics.fingerprint.VirtualProps", + "libbase", "android.hardware.biometrics.fingerprint-V3-ndk", "android.hardware.biometrics.common-V3-ndk", "android.hardware.biometrics.common.thread", "android.hardware.biometrics.common.util", + "android.hardware.keymaster-V4-ndk", ], - static_libs: ["libandroid.hardware.biometrics.fingerprint.VirtualProps"], installable: false, // install APEX instead }