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

Commit a32f2540 authored by Steve Paik's avatar Steve Paik Committed by Android (Google) Code Review
Browse files

Merge "Fix Default VHAL to send ON request when device boots"

parents f88392c9 d217630d
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -156,6 +156,29 @@ StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) {
                // Placeholder for future implementation of VMS property in the default hal. For
                // now, just returns OK; otherwise, hal clients crash with property not supported.
                return StatusCode::OK;
            case AP_POWER_STATE_REPORT:
                switch (propValue.value.int32Values[0]) {
                    case toInt(VehicleApPowerStateReport::DEEP_SLEEP_EXIT):
                    case toInt(VehicleApPowerStateReport::SHUTDOWN_CANCELLED):
                    case toInt(VehicleApPowerStateReport::WAIT_FOR_VHAL):
                        // CPMS is in WAIT_FOR_VHAL state, simply move to ON
                        doHalEvent(createApPowerStateReq(VehicleApPowerStateReq::ON, 0));
                        break;
                    case toInt(VehicleApPowerStateReport::DEEP_SLEEP_ENTRY):
                    case toInt(VehicleApPowerStateReport::SHUTDOWN_START):
                        // CPMS is in WAIT_FOR_FINISH state, send the FINISHED command
                        doHalEvent(createApPowerStateReq(VehicleApPowerStateReq::FINISHED, 0));
                        break;
                    case toInt(VehicleApPowerStateReport::ON):
                    case toInt(VehicleApPowerStateReport::SHUTDOWN_POSTPONE):
                    case toInt(VehicleApPowerStateReport::SHUTDOWN_PREPARE):
                        // Do nothing
                        break;
                    default:
                        // Unknown state
                        break;
                }
                break;
        }
    }

@@ -401,6 +424,18 @@ StatusCode EmulatedVehicleHal::handleGenerateFakeDataRequest(const VehiclePropVa
    return StatusCode::OK;
}

VehicleHal::VehiclePropValuePtr EmulatedVehicleHal::createApPowerStateReq(
    VehicleApPowerStateReq state, int32_t param) {
    auto req = getValuePool()->obtain(VehiclePropertyType::INT32_VEC, 2);
    req->prop = toInt(VehicleProperty::AP_POWER_STATE_REQ);
    req->areaId = 0;
    req->timestamp = elapsedRealtimeNano();
    req->status = VehiclePropertyStatus::AVAILABLE;
    req->value.int32Values[0] = toInt(state);
    req->value.int32Values[1] = param;
    return req;
}

VehicleHal::VehiclePropValuePtr EmulatedVehicleHal::createHwInputKeyProp(
    VehicleHwKeyInputAction action, int32_t keyCode, int32_t targetDisplay) {
    auto keyEvent = getValuePool()->obtain(VehiclePropertyType::INT32_VEC, 3);
+1 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ private:

    StatusCode handleGenerateFakeDataRequest(const VehiclePropValue& request);
    void onFakeValueGenerated(const VehiclePropValue& value);
    VehiclePropValuePtr createApPowerStateReq(VehicleApPowerStateReq req, int32_t param);
    VehiclePropValuePtr createHwInputKeyProp(VehicleHwKeyInputAction action, int32_t keyCode,
                                             int32_t targetDisplay);