Cleanup entity creation
This commit is contained in:
parent
24bbe66954
commit
675e6cfcf6
@ -48,7 +48,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<App>::shared_from_this;
|
using std::enable_shared_from_this<App>::shared_from_this;
|
||||||
|
|
||||||
void enumerateDevices();
|
void enumerateDevices();
|
||||||
void waitForDevice();
|
void waitForDevice();
|
||||||
void aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle);
|
void aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle);
|
||||||
|
@ -54,8 +54,13 @@ void App::waitForUSBDevice()
|
|||||||
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
||||||
{
|
{
|
||||||
strand_.dispatch([this, self = this->shared_from_this(), socket = std::move(socket)]() mutable {
|
strand_.dispatch([this, self = this->shared_from_this(), socket = std::move(socket)]() mutable {
|
||||||
if(androidAutoEntity_ == nullptr)
|
if(androidAutoEntity_ != nullptr)
|
||||||
{
|
{
|
||||||
|
tcpWrapper_.close(*socket);
|
||||||
|
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
usbHub_->cancel();
|
usbHub_->cancel();
|
||||||
@ -72,12 +77,6 @@ void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
|||||||
androidAutoEntity_.reset();
|
androidAutoEntity_.reset();
|
||||||
this->waitForDevice();
|
this->waitForDevice();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tcpWrapper_.close(*socket);
|
|
||||||
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +90,7 @@ void App::stop()
|
|||||||
if(androidAutoEntity_ != nullptr)
|
if(androidAutoEntity_ != nullptr)
|
||||||
{
|
{
|
||||||
androidAutoEntity_->stop();
|
androidAutoEntity_->stop();
|
||||||
|
androidAutoEntity_.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -99,8 +99,12 @@ void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
|
|||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[App] Device connected.";
|
OPENAUTO_LOG(info) << "[App] Device connected.";
|
||||||
|
|
||||||
if(androidAutoEntity_ == nullptr)
|
if(androidAutoEntity_ != nullptr)
|
||||||
{
|
{
|
||||||
|
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connectedAccessoriesEnumerator_->cancel();
|
connectedAccessoriesEnumerator_->cancel();
|
||||||
@ -117,11 +121,6 @@ void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
|
|||||||
this->waitForDevice();
|
this->waitForDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::enumerateDevices()
|
void App::enumerateDevices()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user