Skip to content

Commit

Permalink
make some variable names more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
silverchris committed Aug 13, 2022
1 parent 7db9d13 commit 4eb2728
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 74 deletions.
2 changes: 1 addition & 1 deletion include/autoapp/Projection/InputDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class InputDevice : public IInputDevice {

void audio_focus(aasdk::messenger::ChannelId channel_id, aasdk::proto::enums::AudioFocusState_Enum state);
void video_focus(bool state);
void poll(asio::error_code error);
void poll(asio::error_code errorCode);
bool canceled_;
};
}
2 changes: 1 addition & 1 deletion include/autoapp/Service/AndroidAutoEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AndroidAutoEntity
void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest &request) override;
void onPingRequest(const aasdk::proto::messages::PingRequest &request) override;
void onPingResponse(const aasdk::proto::messages::PingResponse &response) override;
void onChannelError(const aasdk::error::Error &e) override;
void onChannelError(const aasdk::error::Error &error) override;
void onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest &request) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion include/autoapp/Service/BluetoothService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BluetoothService
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse &response) override;
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest &request) override;
void onBluetoothPairingRequest(const aasdk::proto::messages::BluetoothPairingRequest &request) override;
void onChannelError(const aasdk::error::Error &e) override;
void onChannelError(const aasdk::error::Error &error) override;

private:
using std::enable_shared_from_this<BluetoothService>::shared_from_this;
Expand Down
2 changes: 1 addition & 1 deletion include/autoapp/Service/InputService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class InputService :
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse &response) override;
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest &request) override;
void onBindingRequest(const aasdk::proto::messages::BindingRequest &request) override;
void onChannelError(const aasdk::error::Error &e) override;
void onChannelError(const aasdk::error::Error &error) override;
void onButtonEvent(const projection::ButtonEvent &event) override;
void onTouchEvent(const projection::TouchEvent &event) override;

Expand Down
2 changes: 1 addition & 1 deletion include/autoapp/Service/NavigationService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class NavigationService
void resume() override;
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse &response) override;
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest &request) override;
void onChannelError(const aasdk::error::Error &e) override;
void onChannelError(const aasdk::error::Error &error) override;

private:
using std::enable_shared_from_this<NavigationService>::shared_from_this;
Expand Down
2 changes: 1 addition & 1 deletion include/autoapp/Service/VideoService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class VideoService
const aasdk::common::DataConstBuffer &buffer) override;
void onAVMediaIndication(const aasdk::common::DataConstBuffer &buffer) override;
void onVideoFocusRequest(const aasdk::proto::messages::VideoFocusRequest &request) override;
void onChannelError(const aasdk::error::Error &e) override;
void onChannelError(const aasdk::error::Error &error) override;


private:
Expand Down
6 changes: 3 additions & 3 deletions src/autoapp/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ void App::enumerateDevices() {
promise->then([](auto result) {
LOG(INFO) << "[App] Devices enumeration result: " << result;
},
[](auto e) {
LOG(ERROR) << "[App] Devices enumeration failed: " << e.what();
[](auto error) {
LOG(ERROR) << "[App] Devices enumeration failed: " << error.what();
});

connectedAccessoriesEnumerator_->enumerate(std::move(promise));
Expand All @@ -174,7 +174,7 @@ void App::waitForDevice() {

auto promise = aasdk::usb::IUSBHub::Promise::defer(strand_);
promise->then([&](aasdk::usb::DeviceHandle deviceHandle) { aoapDeviceHandler(std::move(deviceHandle)); },
[&](const aasdk::error::Error &e) { onUSBHubError(e); });
[&](const aasdk::error::Error &error) { onUSBHubError(error); });
usbHub_->start(std::move(promise));
startServerSocket();
}
Expand Down
60 changes: 30 additions & 30 deletions src/autoapp/Projection/InputDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void InputDevice::video_focus(bool state) {

void InputDevice::start(IInputDeviceEventHandler &eventHandler) {
std::lock_guard<decltype(mutex_)> lock(mutex_);
int rc;
int returnCode;

LOG(INFO) << "[InputDevice] start.";
eventHandler_ = &eventHandler;
Expand All @@ -93,9 +93,9 @@ void InputDevice::start(IInputDeviceEventHandler &eventHandler) {
LOG(ERROR) << EVENT_DEVICE_TS << " is not a vaild device";
}

rc = libevdev_new_from_fd(touch_fd, &touch_dev);
if (rc < 0) {
LOG(ERROR) << "Failed to init libevdev " << strerror(-rc);
returnCode = libevdev_new_from_fd(touch_fd, &touch_dev);
if (returnCode < 0) {
LOG(ERROR) << "Failed to init libevdev " << strerror(-returnCode);
}

if (libevdev_grab(touch_dev, LIBEVDEV_GRAB) < 0) {
Expand All @@ -108,9 +108,9 @@ void InputDevice::start(IInputDeviceEventHandler &eventHandler) {
LOG(ERROR) << EVENT_DEVICE_KBD << " is not a vaild device";
}

rc = libevdev_new_from_fd(kbd_fd, &keyboard_dev);
if (rc < 0) {
LOG(ERROR) << "Failed to init libevdev " << strerror(-rc);
returnCode = libevdev_new_from_fd(kbd_fd, &keyboard_dev);
if (returnCode < 0) {
LOG(ERROR) << "Failed to init libevdev " << strerror(-returnCode);
}

if (libevdev_grab(keyboard_dev, LIBEVDEV_GRAB) < 0) {
Expand All @@ -128,53 +128,53 @@ void InputDevice::start(IInputDeviceEventHandler &eventHandler) {
for (const auto &value: keymap) {
libevdev_enable_event_code(dev, EV_KEY, value.first, nullptr);
}
rc = libevdev_uinput_create_from_device(dev, LIBEVDEV_UINPUT_OPEN_MANAGED, &ui_dev);
returnCode = libevdev_uinput_create_from_device(dev, LIBEVDEV_UINPUT_OPEN_MANAGED, &ui_dev);

if (rc < 0) {
LOG(ERROR) << "Failed to init libevdev " << strerror(-rc);
if (returnCode < 0) {
LOG(ERROR) << "Failed to init libevdev " << strerror(-returnCode);
}
canceled_ = false;
timer_.expires_from_now(std::chrono::milliseconds(50));
timer_.async_wait(strand_.wrap([this](asio::error_code ec) { this->poll(ec); }));
timer_.async_wait(strand_.wrap([this](asio::error_code error) { this->poll(error); }));

}

void InputDevice::poll(asio::error_code error) {
if (error == asio::error::operation_aborted || canceled_) {
return;
}
int rc = 0;
while (rc != -EAGAIN) {
input_event ev{};
rc = libevdev_next_event(touch_dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
if (rc == LIBEVDEV_READ_STATUS_SYNC) {
int returnCode = 0;
while (returnCode != -EAGAIN) {
input_event event{};
returnCode = libevdev_next_event(touch_dev, LIBEVDEV_READ_FLAG_NORMAL, &event);
if (returnCode == LIBEVDEV_READ_STATUS_SYNC) {
LOG(ERROR) << "Input dropped";
while (rc == LIBEVDEV_READ_STATUS_SYNC) {
rc = libevdev_next_event(touch_dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
while (returnCode == LIBEVDEV_READ_STATUS_SYNC) {
returnCode = libevdev_next_event(touch_dev, LIBEVDEV_READ_FLAG_SYNC, &event);
}
LOG(DEBUG) << "Input resynced";
} else if (rc == LIBEVDEV_READ_STATUS_SUCCESS) {
handle_touch(&ev);
} else if (returnCode == LIBEVDEV_READ_STATUS_SUCCESS) {
handle_touch(&event);
}
}

rc = 0;
while (rc != -EAGAIN) {
input_event ev{};
rc = libevdev_next_event(keyboard_dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
if (rc == LIBEVDEV_READ_STATUS_SYNC) {
returnCode = 0;
while (returnCode != -EAGAIN) {
input_event event{};
returnCode = libevdev_next_event(keyboard_dev, LIBEVDEV_READ_FLAG_NORMAL, &event);
if (returnCode == LIBEVDEV_READ_STATUS_SYNC) {
LOG(ERROR) << "Input dropped";
while (rc == LIBEVDEV_READ_STATUS_SYNC) {
rc = libevdev_next_event(keyboard_dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
while (returnCode == LIBEVDEV_READ_STATUS_SYNC) {
returnCode = libevdev_next_event(keyboard_dev, LIBEVDEV_READ_FLAG_SYNC, &event);
}
LOG(DEBUG) << "Input resynced";
} else if (rc == LIBEVDEV_READ_STATUS_SUCCESS) {
handle_key(&ev);
} else if (returnCode == LIBEVDEV_READ_STATUS_SUCCESS) {
handle_key(&event);
}
}

timer_.expires_from_now(std::chrono::milliseconds(50));
timer_.async_wait(strand_.wrap([this](asio::error_code ec) { this->poll(ec); }));
timer_.async_wait(strand_.wrap([this](asio::error_code errorCode) { this->poll(errorCode); }));
}

void InputDevice::stop() {
Expand Down
28 changes: 14 additions & 14 deletions src/autoapp/Service/AndroidAutoEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void AndroidAutoEntity::start(IAndroidAutoEntityEventHandler &eventHandler) {


auto versionRequestPromise = aasdk::channel::SendPromise::defer(strand_);
versionRequestPromise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
versionRequestPromise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
controlServiceChannel_->sendVersionRequest(std::move(versionRequestPromise));
controlServiceChannel_->receive(this->shared_from_this());
});
Expand Down Expand Up @@ -130,7 +130,7 @@ void AndroidAutoEntity::onVersionResponse(uint16_t majorCode,
cryptor_->doHandshake();

auto handshakePromise = aasdk::channel::SendPromise::defer(strand_);
handshakePromise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
handshakePromise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
controlServiceChannel_->sendHandshake(cryptor_->readHandshakeBuffer(), std::move(handshakePromise));
controlServiceChannel_->receive(this->shared_from_this());
}
Expand All @@ -150,7 +150,7 @@ void AndroidAutoEntity::onHandshake(const aasdk::common::DataConstBuffer &payloa
LOG(INFO) << "[AndroidAutoEntity] continue handshake.";

auto handshakePromise = aasdk::channel::SendPromise::defer(strand_);
handshakePromise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
handshakePromise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
controlServiceChannel_->sendHandshake(cryptor_->readHandshakeBuffer(), std::move(handshakePromise));
} else {
LOG(INFO) << "[AndroidAutoEntity] Auth completed.";
Expand All @@ -159,7 +159,7 @@ void AndroidAutoEntity::onHandshake(const aasdk::common::DataConstBuffer &payloa
authCompleteIndication.set_status(aasdk::proto::enums::Status::OK);

auto authCompletePromise = aasdk::channel::SendPromise::defer(strand_);
authCompletePromise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
authCompletePromise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
controlServiceChannel_->sendAuthComplete(authCompleteIndication, std::move(authCompletePromise));
}

Expand Down Expand Up @@ -193,7 +193,7 @@ void AndroidAutoEntity::onServiceDiscoveryRequest(const aasdk::proto::messages::
[&](IService::Pointer &service) { service->fillFeatures(serviceDiscoveryResponse); });

auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
controlServiceChannel_->sendServiceDiscoveryResponse(serviceDiscoveryResponse, std::move(promise));
controlServiceChannel_->receive(this->shared_from_this());
}
Expand Down Expand Up @@ -249,7 +249,7 @@ void AndroidAutoEntity::onAudioFocusResponse(aasdk::messenger::ChannelId channel
response.set_audio_focus_state(state);

auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
controlServiceChannel_->sendAudioFocusResponse(response, std::move(promise));
});
}
Expand All @@ -260,7 +260,7 @@ void AndroidAutoEntity::onShutdownRequest(const aasdk::proto::messages::Shutdown
aasdk::proto::messages::ShutdownResponse response;
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([&]() { triggerQuit(); },
[&](const aasdk::error::Error &e) { onChannelError(e); });
[&](const aasdk::error::Error &error) { onChannelError(error); });

controlServiceChannel_->sendShutdownResponse(response, std::move(promise));
}
Expand All @@ -270,7 +270,7 @@ void AndroidAutoEntity::sendShutdownRequest() {
request.set_reason(aasdk::proto::enums::ShutdownReason::QUIT);
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {},
[&](const aasdk::error::Error &e) { onChannelError(e); });
[&](const aasdk::error::Error &error) { onChannelError(error); });

controlServiceChannel_->sendShutdownRequest(request, std::move(promise));
}
Expand All @@ -288,7 +288,7 @@ void AndroidAutoEntity::onNavigationFocusRequest(const aasdk::proto::messages::N
response.set_type(aasdk::proto::enums::NavigationFocusType::NAVIGATION_FOCUS_PROJECTED);

auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
controlServiceChannel_->sendNavigationFocusResponse(response, std::move(promise));
controlServiceChannel_->receive(this->shared_from_this());
}
Expand All @@ -298,7 +298,7 @@ void AndroidAutoEntity::onVoiceSessionRequest(const aasdk::proto::messages::Voic
<< ((request.type() == 1) ? "START" : ((request.type() == 2) ? "STOP" : "UNKNOWN"));

auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
controlServiceChannel_->receive(this->shared_from_this());
}

Expand All @@ -308,7 +308,7 @@ void AndroidAutoEntity::onPingRequest(const aasdk::proto::messages::PingRequest
aasdk::proto::messages::PingResponse response;
response.set_timestamp(request.timestamp());
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
controlServiceChannel_->sendPingResponse(response, std::move(promise));
controlServiceChannel_->receive(this->shared_from_this());
}
Expand All @@ -319,8 +319,8 @@ void AndroidAutoEntity::onPingResponse(const aasdk::proto::messages::PingRespons
controlServiceChannel_->receive(this->shared_from_this());
}

void AndroidAutoEntity::onChannelError(const aasdk::error::Error &e) {
LOG(ERROR) << "[AndroidAutoEntity] channel error: " << e.what();
void AndroidAutoEntity::onChannelError(const aasdk::error::Error &error) {
LOG(ERROR) << "[AndroidAutoEntity] channel error: " << error.what();
this->triggerQuit();
}

Expand Down Expand Up @@ -349,7 +349,7 @@ void AndroidAutoEntity::schedulePing() {

void AndroidAutoEntity::sendPing() {
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });

aasdk::proto::messages::PingRequest request;
auto timestamp =
Expand Down
8 changes: 4 additions & 4 deletions src/autoapp/Service/BluetoothService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void BluetoothService::onChannelOpenRequest(const aasdk::proto::messages::Channe
response.set_status(status);

auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
channel_->sendChannelOpenResponse(response, std::move(promise));

channel_->receive(this->shared_from_this());
Expand All @@ -97,14 +97,14 @@ void BluetoothService::onBluetoothPairingRequest(const aasdk::proto::messages::B
: aasdk::proto::enums::BluetoothPairingStatus::FAIL);

auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
channel_->sendBluetoothPairingResponse(response, std::move(promise));

channel_->receive(this->shared_from_this());
}

void BluetoothService::onChannelError(const aasdk::error::Error &e) {
LOG(ERROR) << "[BluetoothService] channel error: " << e.what();
void BluetoothService::onChannelError(const aasdk::error::Error &error) {
LOG(ERROR) << "[BluetoothService] channel error: " << error.what();
}

}
12 changes: 6 additions & 6 deletions src/autoapp/Service/InputService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void InputService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpe
response.set_status(status);

auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
channel_->sendChannelOpenResponse(response, std::move(promise));

channel_->receive(this->shared_from_this());
Expand Down Expand Up @@ -122,13 +122,13 @@ void InputService::onBindingRequest(const aasdk::proto::messages::BindingRequest
LOG(INFO) << "[InputService] binding request, status: " << status;

auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
channel_->sendBindingResponse(response, std::move(promise));
channel_->receive(this->shared_from_this());
}

void InputService::onChannelError(const aasdk::error::Error &e) {
LOG(ERROR) << "[SensorService] channel error: " << e.what();
void InputService::onChannelError(const aasdk::error::Error &error) {
LOG(ERROR) << "[SensorService] channel error: " << error.what();
}

void InputService::onButtonEvent(const projection::ButtonEvent &event) {
Expand All @@ -152,7 +152,7 @@ void InputService::onButtonEvent(const projection::ButtonEvent &event) {
}

auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
channel_->sendInputEventIndication(inputEventIndication, std::move(promise));
});
}
Expand All @@ -173,7 +173,7 @@ void InputService::onTouchEvent(const projection::TouchEvent &event) {
touchLocation->set_pointer_id(0);

auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, [&](const aasdk::error::Error &e) { onChannelError(e); });
promise->then([]() {}, [&](const aasdk::error::Error &error) { onChannelError(error); });
channel_->sendInputEventIndication(inputEventIndication, std::move(promise));
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/autoapp/Service/NavigationService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ void NavigationService::onChannelOpenRequest(const aasdk::proto::messages::Chann
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then(std::function<void(void)>([]() {}),
[this, self =
this->shared_from_this()](const aasdk::error::Error &e) -> void { this->onChannelError(e); });
this->shared_from_this()](const aasdk::error::Error &error) -> void { this->onChannelError(error); });
channel_->sendChannelOpenResponse(response, std::move(promise));

channel_->receive(this->shared_from_this());
}

void NavigationService::onChannelError(const aasdk::error::Error &e) {
LOG(ERROR) << "[NavigationChannel] channel error: " << e.what();
void NavigationService::onChannelError(const aasdk::error::Error &error) {
LOG(ERROR) << "[NavigationChannel] channel error: " << error.what();
}

void NavigationService::onNavigationStatus(const aasdk::proto::messages::NavigationRequestMessage &request) {
Expand Down
Loading

0 comments on commit 4eb2728

Please sign in to comment.