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

Commit d217630d authored by Steve Paik's avatar Steve Paik
Browse files

Fix Default VHAL to send ON request when device boots

Bug: 117947229
Test: Reboot Mojave, it stays on
Change-Id: Ia36d71343e43d59c07dc76b3cc7b7d45376d898c
(cherry picked from commit b91f9c3bad3948cb5804949a858835219e9aeac3)
parent 85d87d6b
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);