diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 9c99739..1917644 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -161,6 +161,14 @@ include device/qcom/sepolicy_vndr-legacy-um/SEPolicy.mk SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/private BOARD_VENDOR_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/vendor +# Soong +SOONG_CONFIG_NAMESPACES += xiaomiSm6150Vars +SOONG_CONFIG_xiaomiSm6150Vars += \ + livedisplay_support_anti_flicker \ + livedisplay_support_sunlight_enhancement +SOONG_CONFIG_xiaomiSm6150Vars_livedisplay_support_anti_flicker ?= false +SOONG_CONFIG_xiaomiSm6150Vars_livedisplay_support_sunlight_enhancement ?= true + # Trust TARGET_TRUST_USB_CONTROL_PATH := /sys/devices/platform/soc/a600000.ssusb/usb_data_enabled TARGET_TRUST_USB_CONTROL_ENABLE := 0 diff --git a/livedisplay/Android.bp b/livedisplay/Android.bp index 88c2cbd..1d28c4d 100644 --- a/livedisplay/Android.bp +++ b/livedisplay/Android.bp @@ -13,9 +13,44 @@ // See the License for the specific language governing permissions and // limitations under the License. +soong_config_module_type { + name: "livedisplay_supported_interfaces", + module_type: "cc_defaults", + config_namespace: "xiaomiSm6150Vars", + bool_variables: [ + "livedisplay_support_anti_flicker", + "livedisplay_support_sunlight_enhancement", + ], + properties: [ + "cflags", + "vintf_fragments", + ], +} + +livedisplay_supported_interfaces { + name: "livedisplay_supported_interfaces_defaults", + soong_config_variables: { + livedisplay_support_anti_flicker: { + cflags: ["-DSUPPORT_ANTI_FLICKER"], + vintf_fragments: [ + "vendor.lineage.livedisplay@2.1_IAntiFlicker.xml", + ], + }, + livedisplay_support_sunlight_enhancement: { + cflags: ["-DSUPPORT_SUNLIGHT_ENHANCEMENT"], + vintf_fragments: [ + "vendor.lineage.livedisplay@2.1_ISunlightEnhancement.xml", + ], + }, + }, +} + cc_binary { name: "vendor.lineage.livedisplay@2.1-service.xiaomi_sm6150", - defaults: ["hidl_defaults"], + defaults: [ + "hidl_defaults", + "livedisplay_supported_interfaces_defaults", + ], vintf_fragments: ["vendor.lineage.livedisplay@2.1-service.xiaomi_sm6150.xml"], init_rc: ["vendor.lineage.livedisplay@2.1-service.xiaomi_sm6150.rc"], relative_install_path: "hw", diff --git a/livedisplay/service.cpp b/livedisplay/service.cpp index 324a5dc..b0eed1f 100644 --- a/livedisplay/service.cpp +++ b/livedisplay/service.cpp @@ -32,27 +32,29 @@ using ::vendor::lineage::livedisplay::V2_1::implementation::AntiFlicker; using ::vendor::lineage::livedisplay::V2_1::implementation::SunlightEnhancement; int main() { - android::sp antiFlicker = new AntiFlicker(); - android::sp sunlightEnhancement = new SunlightEnhancement(); - std::shared_ptr controller = std::make_shared(); android::sp pictureAdjustment = new PictureAdjustment(controller); android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/); +#ifdef SUPPORT_ANTI_FLICKER + android::sp antiFlicker = new AntiFlicker(); if (antiFlicker->registerAsService() != android::OK) { LOG(ERROR) << "Cannot register anti flicker HAL service."; return 1; } +#endif if (pictureAdjustment->registerAsService() != android::OK) { LOG(ERROR) << "Cannot register picture adjustment HAL service."; return 1; } +#ifdef SUPPORT_SUNLIGHT_ENHANCEMENT + android::sp sunlightEnhancement = new SunlightEnhancement(); if (sunlightEnhancement->registerAsService() != android::OK) { LOG(ERROR) << "Cannot register sunlight enhancement HAL service."; return 1; } - +#endif LOG(INFO) << "LiveDisplay HAL service is ready."; android::hardware::joinRpcThreadpool(); diff --git a/livedisplay/vendor.lineage.livedisplay@2.1-service.xiaomi_sm6150.xml b/livedisplay/vendor.lineage.livedisplay@2.1-service.xiaomi_sm6150.xml index a5f7f61..868425c 100644 --- a/livedisplay/vendor.lineage.livedisplay@2.1-service.xiaomi_sm6150.xml +++ b/livedisplay/vendor.lineage.livedisplay@2.1-service.xiaomi_sm6150.xml @@ -3,7 +3,5 @@ vendor.lineage.livedisplay hwbinder @2.0::IPictureAdjustment/default - @2.1::IAntiFlicker/default - @2.1::ISunlightEnhancement/default diff --git a/livedisplay/vendor.lineage.livedisplay@2.1_IAntiFlicker.xml b/livedisplay/vendor.lineage.livedisplay@2.1_IAntiFlicker.xml new file mode 100644 index 0000000..ef03c08 --- /dev/null +++ b/livedisplay/vendor.lineage.livedisplay@2.1_IAntiFlicker.xml @@ -0,0 +1,7 @@ + + + vendor.lineage.livedisplay + hwbinder + @2.1::IAntiFlicker/default + + diff --git a/livedisplay/vendor.lineage.livedisplay@2.1_ISunlightEnhancement.xml b/livedisplay/vendor.lineage.livedisplay@2.1_ISunlightEnhancement.xml new file mode 100644 index 0000000..4ddd2c3 --- /dev/null +++ b/livedisplay/vendor.lineage.livedisplay@2.1_ISunlightEnhancement.xml @@ -0,0 +1,7 @@ + + + vendor.lineage.livedisplay + hwbinder + @2.1::ISunlightEnhancement/default + +