Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h +9 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ constexpr int WHEEL_FRONT_RIGHT = (int)VehicleAreaWheel::RIGHT_FRONT; constexpr int WHEEL_REAR_LEFT = (int)VehicleAreaWheel::LEFT_REAR; constexpr int WHEEL_REAR_RIGHT = (int)VehicleAreaWheel::RIGHT_REAR; constexpr int INITIAL_USER_INFO = (int)VehicleProperty::INITIAL_USER_INFO; constexpr int SWITCH_USER = (int)VehicleProperty::SWITCH_USER; /** * This property is used for test purpose to generate fake events. Here is the test package that Loading Loading @@ -1019,6 +1020,14 @@ const ConfigDeclaration kVehicleProperties[]{ .changeMode = VehiclePropertyChangeMode::ON_CHANGE, }, }, { .config = { .prop = toInt(VehicleProperty::SWITCH_USER), .access = VehiclePropertyAccess::READ_WRITE, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, }, }, }; } // impl Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp +8 −2 Original line number Diff line number Diff line Loading @@ -73,10 +73,16 @@ bool EmulatedPassthroughConnector::onDump(const hidl_handle& handle, void EmulatedPassthroughConnector::dumpUserHal(int fd, std::string indent) { if (mInitialUserResponseFromCmd != nullptr) { dprintf(fd, "%sInitial User Info: %s\n", indent.c_str(), dprintf(fd, "%sInitialUserInfo response: %s\n", indent.c_str(), toString(*mInitialUserResponseFromCmd).c_str()); } else { dprintf(fd, "%sNo Initial User Info\n", indent.c_str()); dprintf(fd, "%sNo InitialUserInfo response\n", indent.c_str()); } if (mSwitchUserResponseFromCmd != nullptr) { dprintf(fd, "%sSwitchUser response: %s\n", indent.c_str(), toString(*mSwitchUserResponseFromCmd).c_str()); } else { dprintf(fd, "%sNo SwitchUser response\n", indent.c_str()); } } Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleHalServer.cpp +77 −4 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ #define LOG_TAG "VehicleHalServer" #include "VehicleHalServer.h" #include <fstream> Loading Loading @@ -244,7 +246,9 @@ StatusCode VehicleHalServer::onSetProperty(const VehiclePropValue& value, bool u } break; case INITIAL_USER_INFO: return onSetInitialUserInfo(value, updateStatus); return onSetInitialUserInfoResponse(value, updateStatus); case SWITCH_USER: return onSetSwitchUserResponse(value, updateStatus); default: break; } Loading Loading @@ -282,7 +286,7 @@ StatusCode VehicleHalServer::onSetProperty(const VehiclePropValue& value, bool u * - if it's 3, then don't send a property change (so Android can emulate a timeout) * */ StatusCode VehicleHalServer::onSetInitialUserInfo(const VehiclePropValue& value, StatusCode VehicleHalServer::onSetInitialUserInfoResponse(const VehiclePropValue& value, bool updateStatus) { // TODO: LOG calls below might be more suited to be DEBUG, but those are not being logged // (even when explicitly calling setprop log.tag. As this class should be using ALOG instead of Loading Loading @@ -320,7 +324,7 @@ StatusCode VehicleHalServer::onSetInitialUserInfo(const VehiclePropValue& value, // mInitialUserResponseFromCmd is used for just one request std::unique_ptr<VehiclePropValue> response = std::move(mInitialUserResponseFromCmd); // TODO(b/138709788): rather than populate the raw values directly, it should use the // TODO(b/150409377): rather than populate the raw values directly, it should use the // libraries that convert a InitialUserInfoResponse into a VehiclePropValue) switch (response->areaId) { Loading Loading @@ -350,4 +354,73 @@ StatusCode VehicleHalServer::onSetInitialUserInfo(const VehiclePropValue& value, return StatusCode::OK; } /** * Used to emulate SWITCH_USER - see onSetInitialUserInfoResponse() for usage. */ StatusCode VehicleHalServer::onSetSwitchUserResponse(const VehiclePropValue& value, bool updateStatus) { if (value.value.int32Values.size() == 0) { LOG(ERROR) << "set(SWITCH_USER): no int32values, ignoring it: " << toString(value); return StatusCode::INVALID_ARG; } if (value.areaId != 0) { LOG(INFO) << "set(SWITCH_USER) called from lshal; storing it: " << toString(value); mSwitchUserResponseFromCmd.reset(new VehiclePropValue(value)); return StatusCode::OK; } LOG(INFO) << "set(SWITCH_USER) called from Android: " << toString(value); int32_t requestId = value.value.int32Values[0]; // Create the update property and set common values auto updatedValue = createVehiclePropValue(VehiclePropertyType::MIXED, 0); updatedValue->prop = SWITCH_USER; updatedValue->timestamp = elapsedRealtimeNano(); if (mSwitchUserResponseFromCmd == nullptr) { updatedValue->value.int32Values.resize(3); updatedValue->value.int32Values[0] = requestId; updatedValue->value.int32Values[1] = (int32_t)SwitchUserMessageType::VEHICLE_RESPONSE; updatedValue->value.int32Values[2] = (int32_t)SwitchUserStatus::SUCCESS; LOG(INFO) << "no lshal response; returning VEHICLE_RESPONSE / SUCCESS: " << toString(*updatedValue); onPropertyValueFromCar(*updatedValue, updateStatus); return StatusCode::OK; } // mSwitchUserResponseFromCmd is used for just one request std::unique_ptr<VehiclePropValue> response = std::move(mSwitchUserResponseFromCmd); // TODO(b/150409377): move code below to a local function like sendUserHalResponse(), // as it's the same for all (like onSetInitialUserInfoResponse) switch (response->areaId) { case 1: LOG(INFO) << "returning response with right request id"; *updatedValue = *response; updatedValue->areaId = 0; updatedValue->value.int32Values[0] = requestId; break; case 2: LOG(INFO) << "returning response with wrong request id"; *updatedValue = *response; updatedValue->areaId = 0; updatedValue->value.int32Values[0] = -requestId; break; case 3: LOG(INFO) << "not generating a property change event because of lshal prop: " << toString(*response); return StatusCode::OK; default: LOG(ERROR) << "invalid action on lshal response: " << toString(*response); return StatusCode::INTERNAL_ERROR; } LOG(INFO) << "updating property to: " << toString(*updatedValue); onPropertyValueFromCar(*updatedValue, updateStatus); return StatusCode::OK; } } // namespace android::hardware::automotive::vehicle::V2_0::impl automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleHalServer.h +4 −2 Original line number Diff line number Diff line Loading @@ -53,13 +53,15 @@ class VehicleHalServer : public IVehicleServer { VehiclePropValuePtr createHwInputKeyProp(VehicleHwKeyInputAction action, int32_t keyCode, int32_t targetDisplay); StatusCode onSetInitialUserInfo(const VehiclePropValue& value, bool updateStatus); StatusCode onSetInitialUserInfoResponse(const VehiclePropValue& value, bool updateStatus); StatusCode onSetSwitchUserResponse(const VehiclePropValue& value, bool updateStatus); // data members protected: // TODO(b/146207078): it might be clearer to move members below to an EmulatedUserHal class std::unique_ptr<VehiclePropValue> mInitialUserResponseFromCmd; std::unique_ptr<VehiclePropValue> mSwitchUserResponseFromCmd; private: GeneratorHub mGeneratorHub{ Loading Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h +9 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ constexpr int WHEEL_FRONT_RIGHT = (int)VehicleAreaWheel::RIGHT_FRONT; constexpr int WHEEL_REAR_LEFT = (int)VehicleAreaWheel::LEFT_REAR; constexpr int WHEEL_REAR_RIGHT = (int)VehicleAreaWheel::RIGHT_REAR; constexpr int INITIAL_USER_INFO = (int)VehicleProperty::INITIAL_USER_INFO; constexpr int SWITCH_USER = (int)VehicleProperty::SWITCH_USER; /** * This property is used for test purpose to generate fake events. Here is the test package that Loading Loading @@ -1019,6 +1020,14 @@ const ConfigDeclaration kVehicleProperties[]{ .changeMode = VehiclePropertyChangeMode::ON_CHANGE, }, }, { .config = { .prop = toInt(VehicleProperty::SWITCH_USER), .access = VehiclePropertyAccess::READ_WRITE, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, }, }, }; } // impl Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp +8 −2 Original line number Diff line number Diff line Loading @@ -73,10 +73,16 @@ bool EmulatedPassthroughConnector::onDump(const hidl_handle& handle, void EmulatedPassthroughConnector::dumpUserHal(int fd, std::string indent) { if (mInitialUserResponseFromCmd != nullptr) { dprintf(fd, "%sInitial User Info: %s\n", indent.c_str(), dprintf(fd, "%sInitialUserInfo response: %s\n", indent.c_str(), toString(*mInitialUserResponseFromCmd).c_str()); } else { dprintf(fd, "%sNo Initial User Info\n", indent.c_str()); dprintf(fd, "%sNo InitialUserInfo response\n", indent.c_str()); } if (mSwitchUserResponseFromCmd != nullptr) { dprintf(fd, "%sSwitchUser response: %s\n", indent.c_str(), toString(*mSwitchUserResponseFromCmd).c_str()); } else { dprintf(fd, "%sNo SwitchUser response\n", indent.c_str()); } } Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleHalServer.cpp +77 −4 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ #define LOG_TAG "VehicleHalServer" #include "VehicleHalServer.h" #include <fstream> Loading Loading @@ -244,7 +246,9 @@ StatusCode VehicleHalServer::onSetProperty(const VehiclePropValue& value, bool u } break; case INITIAL_USER_INFO: return onSetInitialUserInfo(value, updateStatus); return onSetInitialUserInfoResponse(value, updateStatus); case SWITCH_USER: return onSetSwitchUserResponse(value, updateStatus); default: break; } Loading Loading @@ -282,7 +286,7 @@ StatusCode VehicleHalServer::onSetProperty(const VehiclePropValue& value, bool u * - if it's 3, then don't send a property change (so Android can emulate a timeout) * */ StatusCode VehicleHalServer::onSetInitialUserInfo(const VehiclePropValue& value, StatusCode VehicleHalServer::onSetInitialUserInfoResponse(const VehiclePropValue& value, bool updateStatus) { // TODO: LOG calls below might be more suited to be DEBUG, but those are not being logged // (even when explicitly calling setprop log.tag. As this class should be using ALOG instead of Loading Loading @@ -320,7 +324,7 @@ StatusCode VehicleHalServer::onSetInitialUserInfo(const VehiclePropValue& value, // mInitialUserResponseFromCmd is used for just one request std::unique_ptr<VehiclePropValue> response = std::move(mInitialUserResponseFromCmd); // TODO(b/138709788): rather than populate the raw values directly, it should use the // TODO(b/150409377): rather than populate the raw values directly, it should use the // libraries that convert a InitialUserInfoResponse into a VehiclePropValue) switch (response->areaId) { Loading Loading @@ -350,4 +354,73 @@ StatusCode VehicleHalServer::onSetInitialUserInfo(const VehiclePropValue& value, return StatusCode::OK; } /** * Used to emulate SWITCH_USER - see onSetInitialUserInfoResponse() for usage. */ StatusCode VehicleHalServer::onSetSwitchUserResponse(const VehiclePropValue& value, bool updateStatus) { if (value.value.int32Values.size() == 0) { LOG(ERROR) << "set(SWITCH_USER): no int32values, ignoring it: " << toString(value); return StatusCode::INVALID_ARG; } if (value.areaId != 0) { LOG(INFO) << "set(SWITCH_USER) called from lshal; storing it: " << toString(value); mSwitchUserResponseFromCmd.reset(new VehiclePropValue(value)); return StatusCode::OK; } LOG(INFO) << "set(SWITCH_USER) called from Android: " << toString(value); int32_t requestId = value.value.int32Values[0]; // Create the update property and set common values auto updatedValue = createVehiclePropValue(VehiclePropertyType::MIXED, 0); updatedValue->prop = SWITCH_USER; updatedValue->timestamp = elapsedRealtimeNano(); if (mSwitchUserResponseFromCmd == nullptr) { updatedValue->value.int32Values.resize(3); updatedValue->value.int32Values[0] = requestId; updatedValue->value.int32Values[1] = (int32_t)SwitchUserMessageType::VEHICLE_RESPONSE; updatedValue->value.int32Values[2] = (int32_t)SwitchUserStatus::SUCCESS; LOG(INFO) << "no lshal response; returning VEHICLE_RESPONSE / SUCCESS: " << toString(*updatedValue); onPropertyValueFromCar(*updatedValue, updateStatus); return StatusCode::OK; } // mSwitchUserResponseFromCmd is used for just one request std::unique_ptr<VehiclePropValue> response = std::move(mSwitchUserResponseFromCmd); // TODO(b/150409377): move code below to a local function like sendUserHalResponse(), // as it's the same for all (like onSetInitialUserInfoResponse) switch (response->areaId) { case 1: LOG(INFO) << "returning response with right request id"; *updatedValue = *response; updatedValue->areaId = 0; updatedValue->value.int32Values[0] = requestId; break; case 2: LOG(INFO) << "returning response with wrong request id"; *updatedValue = *response; updatedValue->areaId = 0; updatedValue->value.int32Values[0] = -requestId; break; case 3: LOG(INFO) << "not generating a property change event because of lshal prop: " << toString(*response); return StatusCode::OK; default: LOG(ERROR) << "invalid action on lshal response: " << toString(*response); return StatusCode::INTERNAL_ERROR; } LOG(INFO) << "updating property to: " << toString(*updatedValue); onPropertyValueFromCar(*updatedValue, updateStatus); return StatusCode::OK; } } // namespace android::hardware::automotive::vehicle::V2_0::impl
automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleHalServer.h +4 −2 Original line number Diff line number Diff line Loading @@ -53,13 +53,15 @@ class VehicleHalServer : public IVehicleServer { VehiclePropValuePtr createHwInputKeyProp(VehicleHwKeyInputAction action, int32_t keyCode, int32_t targetDisplay); StatusCode onSetInitialUserInfo(const VehiclePropValue& value, bool updateStatus); StatusCode onSetInitialUserInfoResponse(const VehiclePropValue& value, bool updateStatus); StatusCode onSetSwitchUserResponse(const VehiclePropValue& value, bool updateStatus); // data members protected: // TODO(b/146207078): it might be clearer to move members below to an EmulatedUserHal class std::unique_ptr<VehiclePropValue> mInitialUserResponseFromCmd; std::unique_ptr<VehiclePropValue> mSwitchUserResponseFromCmd; private: GeneratorHub mGeneratorHub{ Loading