Merge "Allow subclass to override getS2rS2dConfig." into main am: 06b9e8ae94

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3264419

Change-Id: Ie177d2d1025beb42f4241b7d0c0114672e2d9f05
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2024-09-12 23:21:26 +00:00
committed by Automerger Merge Worker
2 changed files with 16 additions and 2 deletions

View File

@@ -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<VehiclePropValuePool::RecyclableType>;
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;

View File

@@ -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<VehiclePropConfig> FakeVehicleHardware::getAllPropertyConfigs() const {
std::vector<VehiclePropConfig> allConfigs = mServerSidePropStore->getAllConfigs();
if (mAddExtraTestVendorConfigs) {