Add new triggers
This commit is contained in:
parent
b6c705544b
commit
c63494334b
@ -44,6 +44,8 @@ public:
|
||||
void waitForUSBDevice();
|
||||
void start(aasdk::tcp::ITCPEndpoint::SocketPointer socket);
|
||||
void stop();
|
||||
void pause();
|
||||
void resume();
|
||||
void onAndroidAutoQuit() override;
|
||||
bool disableAutostartEntity = false;
|
||||
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
|
||||
void start(IAndroidAutoEntityEventHandler& eventHandler) override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void onVersionResponse(uint16_t majorCode, uint16_t minorCode, aasdk::proto::enums::VersionResponseStatus::Enum status) override;
|
||||
void onHandshake(const aasdk::common::DataConstBuffer& payload) override;
|
||||
void onServiceDiscoveryRequest(const aasdk::proto::messages::ServiceDiscoveryRequest& request) override;
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
|
||||
|
@ -41,6 +41,8 @@ public:
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
|
||||
|
@ -37,6 +37,8 @@ public:
|
||||
BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IBluetoothDevice::Pointer bluetoothDevice);
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
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;
|
||||
|
@ -39,6 +39,8 @@ public:
|
||||
|
||||
virtual void start(IAndroidAutoEntityEventHandler& eventHandler) = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual void pause() = 0;
|
||||
virtual void resume() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
|
||||
virtual void start() = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual void pause() = 0;
|
||||
virtual void resume() = 0;
|
||||
virtual void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) = 0;
|
||||
};
|
||||
|
||||
|
@ -44,6 +44,8 @@ public:
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
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;
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onSensorStartRequest(const aasdk::proto::messages::SensorStartRequestMessage& request) override;
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
|
||||
|
@ -84,13 +84,29 @@ void App::stop()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
isStopped_ = true;
|
||||
try {
|
||||
connectedAccessoriesEnumerator_->cancel();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by connectedAccessoriesEnumerator_->cancel()";
|
||||
}
|
||||
try {
|
||||
usbHub_->cancel();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by usbHub_->cancel();";
|
||||
}
|
||||
|
||||
if(androidAutoEntity_ != nullptr)
|
||||
{
|
||||
try {
|
||||
androidAutoEntity_->stop();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by androidAutoEntity_->stop();";
|
||||
}
|
||||
try {
|
||||
androidAutoEntity_.reset();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by androidAutoEntity_.reset();";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -152,17 +168,51 @@ void App::waitForDevice()
|
||||
usbHub_->start(std::move(promise));
|
||||
}
|
||||
|
||||
void App::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[App] pause...";
|
||||
androidAutoEntity_->pause();
|
||||
});
|
||||
}
|
||||
|
||||
void App::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
if(androidAutoEntity_ != nullptr)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[App] resume...";
|
||||
androidAutoEntity_->resume();
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[App] Ignore resume -> no androidAutoEntity_ ...";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void App::onAndroidAutoQuit()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[App] onAndroidAutoQuit.";
|
||||
|
||||
try {
|
||||
androidAutoEntity_->stop();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_->stop();";
|
||||
}
|
||||
try {
|
||||
androidAutoEntity_.reset();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_.reset();";
|
||||
}
|
||||
|
||||
if(!isStopped_)
|
||||
{
|
||||
try {
|
||||
this->waitForDevice();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by this->waitForDevice();";
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -87,6 +87,33 @@ void AndroidAutoEntity::stop()
|
||||
});
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] pause.";
|
||||
|
||||
try {
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::pause, std::placeholders::_1));
|
||||
messenger_->stop();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] exception in pause.";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] resume.";
|
||||
|
||||
try {
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::resume, std::placeholders::_1));
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] exception in resume.";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onVersionResponse(uint16_t majorCode, uint16_t minorCode, aasdk::proto::enums::VersionResponseStatus::Enum status)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] version response, version: " << majorCode
|
||||
|
@ -54,6 +54,20 @@ void AudioInputService::stop()
|
||||
});
|
||||
}
|
||||
|
||||
void AudioInputService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void AudioInputService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void AudioInputService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] fill features.";
|
||||
|
@ -53,6 +53,20 @@ void AudioService::stop()
|
||||
});
|
||||
}
|
||||
|
||||
void AudioService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void AudioService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void AudioService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioService] fill features, channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
|
@ -52,6 +52,20 @@ void BluetoothService::stop()
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] fill features";
|
||||
|
@ -53,6 +53,20 @@ void InputService::stop()
|
||||
});
|
||||
}
|
||||
|
||||
void InputService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[InputService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void InputService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[InputService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void InputService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[InputService] fill features.";
|
||||
|
@ -58,6 +58,20 @@ void SensorService::stop()
|
||||
});
|
||||
}
|
||||
|
||||
void SensorService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[SensorService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void SensorService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[SensorService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void SensorService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[SensorService] fill features.";
|
||||
|
@ -54,6 +54,20 @@ void VideoService::stop()
|
||||
});
|
||||
}
|
||||
|
||||
void VideoService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VideoService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void VideoService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VideoService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void VideoService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[VideoService] open request, priority: " << request.priority();
|
||||
|
@ -221,29 +221,39 @@ int main(int argc, char* argv[])
|
||||
});
|
||||
|
||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::TriggerAppStart, [&app]() {
|
||||
OPENAUTO_LOG(info) << "[Autoapp] Manual start android auto.";
|
||||
OPENAUTO_LOG(info) << "[Autoapp] TriggerAppStart: Manual start android auto.";
|
||||
try {
|
||||
if (std::ifstream("/tmp/android_device")) {
|
||||
app->disableAutostartEntity = false;
|
||||
app->stop();
|
||||
app->resume();
|
||||
app->waitForUSBDevice();
|
||||
}
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(info) << "[Autoapp] Exception in Manual start android auto.";
|
||||
OPENAUTO_LOG(error) << "[Autoapp] TriggerAppStart: app->waitForUSBDevice();";
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::TriggerAppStop, [&app]() {
|
||||
try {
|
||||
if (std::ifstream("/tmp/android_device")) {
|
||||
OPENAUTO_LOG(info) << "[Autoapp] Manual stop usb android auto.";
|
||||
OPENAUTO_LOG(info) << "[Autoapp] TriggerAppStop: Manual stop usb android auto.";
|
||||
app->disableAutostartEntity = true;
|
||||
system("/usr/local/bin/autoapp_helper usbreset");
|
||||
usleep(1000000);
|
||||
usleep(500000);
|
||||
try {
|
||||
app->stop();
|
||||
//app->pause();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[Autoapp] TriggerAppStop: stop();";
|
||||
}
|
||||
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[Autoapp] Manual stop wifi android auto.";
|
||||
OPENAUTO_LOG(info) << "[Autoapp] TriggerAppStop: Manual stop wifi android auto.";
|
||||
try {
|
||||
app->stop();
|
||||
//app->pause();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[Autoapp] TriggerAppStop: stop();";
|
||||
}
|
||||
|
||||
}
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(info) << "[Autoapp] Exception in manual stop android auto.";
|
||||
|
Loading…
x
Reference in New Issue
Block a user