Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 588c0bb6 authored by Enrico Granata's avatar Enrico Granata Committed by android-build-merger
Browse files

Merge "VehicleHal::set() should not be able to tamper with a property's...

Merge "VehicleHal::set() should not be able to tamper with a property's AVAILABLE status Properties being (UN)AVAILABLE is used as a one-way communication mechanism from the hardware to the operating system, and not viceversa." into pi-dev
am: 7371502a

Change-Id: I34da1fcbf74deb9e1d7bc3d078c8f6e9c956a204
parents 06ebee3a 7371502a
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) {
            return status;
        }
    } else if (mHvacPowerProps.count(propValue.prop)) {
        // TODO(75328113): this should be handled by property status
        auto hvacPowerOn = mPropStore->readValueOrNull(
            toInt(VehicleProperty::HVAC_POWER_ON),
            (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT));
@@ -165,6 +166,22 @@ StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) {
        }
    }

    if (propValue.status != VehiclePropertyStatus::AVAILABLE) {
        // Android side cannot set property status - this value is the
        // purview of the HAL implementation to reflect the state of
        // its underlying hardware
        return StatusCode::INVALID_ARG;
    }
    auto currentPropValue = mPropStore->readValueOrNull(propValue);

    if (currentPropValue == nullptr) {
        return StatusCode::INVALID_ARG;
    }
    if (currentPropValue->status != VehiclePropertyStatus::AVAILABLE) {
        // do not allow Android side to set() a disabled/error property
        return StatusCode::NOT_AVAILABLE;
    }

    if (!mPropStore->writeValue(propValue)) {
        return StatusCode::INVALID_ARG;
    }