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

Commit 5deac06a authored by Hao Chen's avatar Hao Chen
Browse files

A more generalized package name for VHal proto IDLs

Test: build; test (and submit) with ag/9868729

Change-Id: Iacdf518d8c90485430a009e341dd1fd705b7ee83
parent 1c1fdca0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ void CommConn::stop() {
    }
}

void CommConn::sendMessage(emulator::EmulatorMessage const& msg) {
void CommConn::sendMessage(vhal_proto::EmulatorMessage const& msg) {
    int numBytes = msg.ByteSize();
    std::vector<uint8_t> buffer(static_cast<size_t>(numBytes));
    if (!msg.SerializeToArray(buffer.data(), numBytes)) {
@@ -61,9 +61,9 @@ void CommConn::readThread() {
            break;
        }

        emulator::EmulatorMessage rxMsg;
        vhal_proto::EmulatorMessage rxMsg;
        if (rxMsg.ParseFromArray(buffer.data(), static_cast<int32_t>(buffer.size()))) {
            emulator::EmulatorMessage respMsg;
            vhal_proto::EmulatorMessage respMsg;
            mMessageProcessor->processMessage(rxMsg, respMsg);

            sendMessage(respMsg);
+3 −3
Original line number Diff line number Diff line
@@ -44,8 +44,8 @@ class MessageProcessor {
     * Process a single message received over a CommConn. Populate the given respMsg with the reply
     * message we should send.
     */
    virtual void processMessage(emulator::EmulatorMessage const& rxMsg,
                                emulator::EmulatorMessage& respMsg) = 0;
    virtual void processMessage(vhal_proto::EmulatorMessage const& rxMsg,
                                vhal_proto::EmulatorMessage& respMsg) = 0;
};

/**
@@ -93,7 +93,7 @@ class CommConn {
    /**
     * Serialized and send the given message to the other side.
     */
    void sendMessage(emulator::EmulatorMessage const& msg);
    void sendMessage(vhal_proto::EmulatorMessage const& msg);

   protected:
    std::unique_ptr<std::thread> mReadThread;
+6 −6
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ namespace proto_msg_converter {
    CAST_COPY_PROTOBUF_VEC_TO_VHAL_TYPE(                                            \
            PROTO_VALUE, PROTO_VECNAME, VHAL_TYPE_VALUE, VHAL_TYPE_VECNAME, /*NO CAST*/)

void toProto(emulator::VehiclePropConfig* protoCfg, const VehiclePropConfig& cfg) {
void toProto(vhal_proto::VehiclePropConfig* protoCfg, const VehiclePropConfig& cfg) {
    protoCfg->set_prop(cfg.prop);
    protoCfg->set_access(toInt(cfg.access));
    protoCfg->set_change_mode(toInt(cfg.changeMode));
@@ -121,7 +121,7 @@ void toProto(emulator::VehiclePropConfig* protoCfg, const VehiclePropConfig& cfg
    protoCfg->set_max_sample_rate(cfg.maxSampleRate);
}

void fromProto(VehiclePropConfig* cfg, const emulator::VehiclePropConfig& protoCfg) {
void fromProto(VehiclePropConfig* cfg, const vhal_proto::VehiclePropConfig& protoCfg) {
    CHECK_COPY_PROTOBUF_VAR_TO_VHAL_TYPE(protoCfg, prop, cfg, prop);
    CHECK_CAST_COPY_PROTOBUF_VAR_TO_VHAL_TYPE(protoCfg, access, cfg, access,
                                              static_cast<VehiclePropertyAccess>);
@@ -130,7 +130,7 @@ void fromProto(VehiclePropConfig* cfg, const emulator::VehiclePropConfig& protoC
    COPY_PROTOBUF_VEC_TO_VHAL_TYPE(protoCfg, config_array, cfg, configArray);
    CHECK_COPY_PROTOBUF_VAR_TO_VHAL_TYPE(protoCfg, config_string, cfg, configString);

    auto cast_to_acfg = [](const emulator::VehicleAreaConfig& protoAcfg) {
    auto cast_to_acfg = [](const vhal_proto::VehicleAreaConfig& protoAcfg) {
        VehicleAreaConfig acfg;
        CHECK_COPY_PROTOBUF_VAR_TO_VHAL_TYPE(protoAcfg, area_id, &acfg, areaId);
        CHECK_COPY_PROTOBUF_VAR_TO_VHAL_TYPE(protoAcfg, min_int32_value, &acfg, minInt32Value);
@@ -148,11 +148,11 @@ void fromProto(VehiclePropConfig* cfg, const emulator::VehiclePropConfig& protoC
    CHECK_COPY_PROTOBUF_VAR_TO_VHAL_TYPE(protoCfg, max_sample_rate, cfg, maxSampleRate);
}

void toProto(emulator::VehiclePropValue* protoVal, const VehiclePropValue& val) {
void toProto(vhal_proto::VehiclePropValue* protoVal, const VehiclePropValue& val) {
    protoVal->set_prop(val.prop);
    protoVal->set_value_type(toInt(getPropType(val.prop)));
    protoVal->set_timestamp(val.timestamp);
    protoVal->set_status((emulator::VehiclePropStatus)(val.status));
    protoVal->set_status((vhal_proto::VehiclePropStatus)(val.status));
    protoVal->set_area_id(val.areaId);

    // Copy value data if it is set.
@@ -179,7 +179,7 @@ void toProto(emulator::VehiclePropValue* protoVal, const VehiclePropValue& val)
    }
}

void fromProto(VehiclePropValue* val, const emulator::VehiclePropValue& protoVal) {
void fromProto(VehiclePropValue* val, const vhal_proto::VehiclePropValue& protoVal) {
    CHECK_COPY_PROTOBUF_VAR_TO_VHAL_TYPE(protoVal, prop, val, prop);
    CHECK_COPY_PROTOBUF_VAR_TO_VHAL_TYPE(protoVal, timestamp, val, timestamp);
    CHECK_CAST_COPY_PROTOBUF_VAR_TO_VHAL_TYPE(protoVal, status, val, status,
+4 −4
Original line number Diff line number Diff line
@@ -33,15 +33,15 @@ namespace proto_msg_converter {

// VehiclePropConfig

void toProto(emulator::VehiclePropConfig* protoCfg, const VehiclePropConfig& cfg);
void toProto(vhal_proto::VehiclePropConfig* protoCfg, const VehiclePropConfig& cfg);

void fromProto(VehiclePropConfig* cfg, const emulator::VehiclePropConfig& protoCfg);
void fromProto(VehiclePropConfig* cfg, const vhal_proto::VehiclePropConfig& protoCfg);

// VehiclePropValue

void toProto(emulator::VehiclePropValue* protoVal, const VehiclePropValue& val);
void toProto(vhal_proto::VehiclePropValue* protoVal, const VehiclePropValue& val);

void fromProto(VehiclePropValue* val, const emulator::VehiclePropValue& protoVal);
void fromProto(VehiclePropValue* val, const vhal_proto::VehiclePropValue& protoVal);

}  // namespace proto_msg_converter

+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ void SocketComm::stop() {
    }
}

void SocketComm::sendMessage(emulator::EmulatorMessage const& msg) {
void SocketComm::sendMessage(vhal_proto::EmulatorMessage const& msg) {
    std::lock_guard<std::mutex> lock(mMutex);
    for (std::unique_ptr<SocketConn> const& conn : mOpenConnections) {
        conn->sendMessage(msg);
Loading