From 5a3d5884427541ef673d003f7fbe4f6f157b92be Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Thu, 14 Sep 2023 13:31:43 +0000 Subject: [PATCH] Revert^2 "Add CAS HAL APEX" 8b19286ce39adec54b7716e522e4efc5c5b3f455 This relands the CAS HAL APEX. Bug: 297467514 Test: atest CtsMediaMiscTestCases:MediaCasTest Change-Id: I741d059688ac65f42bed45e068cd00ccc5d631f5 --- cas/aidl/default/Android.bp | 52 ++++++++++++++++++++++++++---- cas/aidl/default/SharedLibrary.cpp | 5 +-- cas/aidl/default/cas-default.rc | 2 +- cas/aidl/default/file_contexts | 3 ++ cas/aidl/default/manifest.json | 9 ++++++ 5 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 cas/aidl/default/file_contexts create mode 100644 cas/aidl/default/manifest.json diff --git a/cas/aidl/default/Android.bp b/cas/aidl/default/Android.bp index 576016ef27..9d094e0364 100644 --- a/cas/aidl/default/Android.bp +++ b/cas/aidl/default/Android.bp @@ -26,6 +26,7 @@ cc_library_static { "liblog", "libutils", "libcutils", + "libvndksupport", ], static_libs: [ "libaidlcommonsupport", @@ -43,34 +44,39 @@ cc_defaults { srcs: ["service.cpp"], + stl: "c++_static", static_libs: [ + "android.hardware.cas-V1-ndk", + "android.hardware.common-V2-ndk", "libaidlcommonsupport", + "libbase", "libcasexampleimpl", + "libcutils", + "libutils", ], shared_libs: [ - "android.hardware.cas-V1-ndk", - "libbase", "libbinder_ndk", "liblog", - "libutils", - "libcutils", + "libvndksupport", ], header_libs: ["media_plugin_headers"], - vintf_fragments: ["android.hardware.cas-service.xml"], } cc_binary { name: "android.hardware.cas-service.example", defaults: ["cas_service_example_defaults"], - init_rc: ["cas-default.rc"], + // Installed in APEX + installable: false, } +// TODO(b/297467514) Convert to VAPEX cc_binary { name: "android.hardware.cas-service.example-lazy", defaults: ["cas_service_example_defaults"], init_rc: ["cas-default-lazy.rc"], + vintf_fragments: ["android.hardware.cas-service.xml"], cflags: ["-DLAZY_SERVICE"], - overrides: ["android.hardware.cas-service.example"], + overrides: ["com.android.hardware.cas"], } cc_fuzz { @@ -84,6 +90,7 @@ cc_fuzz { "android.hardware.cas-V1-ndk", "libcutils", "liblog", + "libvndksupport", ], static_libs: [ "libaidlcommonsupport", @@ -94,3 +101,34 @@ cc_fuzz { componentid: 1344, }, } + +apex { + name: "com.android.hardware.cas", + manifest: "manifest.json", + file_contexts: "file_contexts", + key: "com.android.hardware.key", + certificate: ":com.android.hardware.certificate", + updatable: false, + vendor: true, + + binaries: [ + "android.hardware.cas-service.example", + ], + prebuilts: [ + "cas-default.rc", + "android.hardware.cas-service.xml", + ], +} + +prebuilt_etc { + name: "cas-default.rc", + src: "cas-default.rc", + installable: false, +} + +prebuilt_etc { + name: "android.hardware.cas-service.xml", + src: "android.hardware.cas-service.xml", + sub_dir: "vintf", + installable: false, +} diff --git a/cas/aidl/default/SharedLibrary.cpp b/cas/aidl/default/SharedLibrary.cpp index c12d17d0cd..6322ff303a 100644 --- a/cas/aidl/default/SharedLibrary.cpp +++ b/cas/aidl/default/SharedLibrary.cpp @@ -19,6 +19,7 @@ #include "SharedLibrary.h" #include #include +#include namespace aidl { namespace android { @@ -26,12 +27,12 @@ namespace hardware { namespace cas { SharedLibrary::SharedLibrary(const String8& path) { - mLibHandle = dlopen(path.c_str(), RTLD_NOW); + mLibHandle = android_load_sphal_library(path.c_str(), RTLD_NOW); } SharedLibrary::~SharedLibrary() { if (mLibHandle != NULL) { - dlclose(mLibHandle); + android_unload_sphal_library(mLibHandle); mLibHandle = NULL; } } diff --git a/cas/aidl/default/cas-default.rc b/cas/aidl/default/cas-default.rc index 5a603687be..0ac7fe57eb 100644 --- a/cas/aidl/default/cas-default.rc +++ b/cas/aidl/default/cas-default.rc @@ -1,4 +1,4 @@ -service vendor.cas-default /vendor/bin/hw/android.hardware.cas-service.example +service vendor.cas-default /apex/com.android.hardware.cas/bin/hw/android.hardware.cas-service.example interface aidl android.hardware.cas.IMediaCasService/default class hal user media diff --git a/cas/aidl/default/file_contexts b/cas/aidl/default/file_contexts new file mode 100644 index 0000000000..98bde537df --- /dev/null +++ b/cas/aidl/default/file_contexts @@ -0,0 +1,3 @@ +(/.*)? u:object_r:vendor_file:s0 +/etc(/.*)? u:object_r:vendor_configs_file:s0 +/bin/hw/android\.hardware\.cas-service\.example u:object_r:hal_cas_default_exec:s0 diff --git a/cas/aidl/default/manifest.json b/cas/aidl/default/manifest.json new file mode 100644 index 0000000000..16b4f6710e --- /dev/null +++ b/cas/aidl/default/manifest.json @@ -0,0 +1,9 @@ +{ + "name": "com.android.hardware.cas", + "version": 1, + // For CAS HAL to open plugins from /vendor/lib, "vendor" namespace should be imported. + // ":sphal" is an alias for the "vendor" namespace in Vendor APEX. + "requireNativeLibs": [ + ":sphal" + ] +}