From fad11013dc0cf27dd54071aebaaa28e81f3a315f Mon Sep 17 00:00:00 2001 From: Yu Shan Date: Thu, 12 Sep 2024 14:30:04 -0700 Subject: [PATCH] Allow subclass to override getS2rS2dConfig. For host-side fake VHAL, it does not have access to android system property so it needs to override the config. Flag: EXEMPT HAL change Test: Presubmit Bug: 365994148 Change-Id: Ica0483bd5c9dc4dc2a5301acf5115745a4aa46fb --- .../fake_impl/hardware/include/FakeVehicleHardware.h | 11 +++++++++++ .../fake_impl/hardware/src/FakeVehicleHardware.cpp | 7 +++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h b/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h index ec69894cd0..ad14a9b3f8 100644 --- a/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h +++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h @@ -49,6 +49,11 @@ namespace fake { class FakeVehicleHardware : public IVehicleHardware { public: + // Supports Suspend_to_ram. + static constexpr int32_t SUPPORT_S2R = 0x1; + // Supports Suspend_to_disk. + static constexpr int32_t SUPPORT_S2D = 0x4; + using ValueResultType = VhalResult; FakeVehicleHardware(); @@ -117,6 +122,12 @@ class FakeVehicleHardware : public IVehicleHardware { bool UseOverrideConfigDir(); + // Gets the config whether S2R or S2D is supported, must returns a bit flag made up of + // SUPPORT_S2R and SUPPORT_S2D, for example, 0x0 means no support, 0x5 means support both. + // The default implementation is reading this from system property: + // "ro.vendor.fake_vhal.ap_power_state_req.config". + int32_t getS2rS2dConfig(); + private: // Expose private methods to unit test. friend class FakeVehicleHardwareTestHelper; diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp index 237a4c4967..edb1d34e29 100644 --- a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp +++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp @@ -396,8 +396,7 @@ void FakeVehicleHardware::init() { VehiclePropertyStore::TokenFunction tokenFunction = nullptr; if (cfg.prop == toInt(VehicleProperty::AP_POWER_STATE_REQ)) { - int config = GetIntProperty(POWER_STATE_REQ_CONFIG_PROPERTY, /*default_value=*/0); - cfg.configArray[0] = config; + cfg.configArray[0] = getS2rS2dConfig(); } else if (cfg.prop == OBD2_FREEZE_FRAME) { tokenFunction = [](const VehiclePropValue& propValue) { return propValue.timestamp; }; } @@ -426,6 +425,10 @@ void FakeVehicleHardware::init() { }); } +int32_t FakeVehicleHardware::getS2rS2dConfig() { + return GetIntProperty(POWER_STATE_REQ_CONFIG_PROPERTY, /*default_value=*/0); +} + std::vector FakeVehicleHardware::getAllPropertyConfigs() const { std::vector allConfigs = mServerSidePropStore->getAllConfigs(); if (mAddExtraTestVendorConfigs) {