summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYana Chernysheva (GitHub) <59469418+ychernysheva@users.noreply.github.com>2022-01-19 18:21:43 +0200
committerGitHub <noreply@github.com>2022-01-19 11:21:43 -0500
commitf6d2ff1cd90dd2dcb2b4fd4f5ca11224e13229ae (patch)
tree41c3a503b1265853c3a4ffadcf53aaf31fe118bb /src
parent880f4bb2e3ea048f070917077230c3bb832b999c (diff)
downloadsdl_core-f6d2ff1cd90dd2dcb2b4fd4f5ca11224e13229ae.tar.gz
Move app launcher stop before unregister app (#3825)
* Move app launcher stop before unregister app The applauncher has to be stopped before appropriate application will be unregistered. Otherwise it could lead to core crash, when Launch controller will try to run already non existed application Co-authored-by: Andrii Kalinich <AKalinich@luxoft.com> Co-authored-by: OlhaVorobiova <olha.vorobiova@dxc.com> Co-authored-by: VladSemenyuk <vsemenyuk@luxoft.com>
Diffstat (limited to 'src')
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h6
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h2
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h2
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc9
-rw-r--r--src/components/application_manager/src/app_launch/device_apps_launcher.cc18
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc5
6 files changed, 42 insertions, 0 deletions
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h
index 2dd64a2941..ca1952197a 100644
--- a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h
@@ -66,6 +66,12 @@ class AppLaunchCtrl {
* @brief OnMasterReset clear database of saved applications
*/
virtual void OnMasterReset() = 0;
+
+ /**
+ * @brief Stop - allows to stop app launcher.
+ */
+ virtual void Stop() = 0;
+
virtual ~AppLaunchCtrl() {}
};
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h
index 986f4ad4ff..32cbc46245 100644
--- a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h
@@ -69,6 +69,7 @@ class AppLaunchCtrlImpl : public AppLaunchCtrl {
void OnAppRegistered(const application_manager::Application& app) OVERRIDE;
void OnDeviceConnected(const std::string& device_mac) OVERRIDE;
void OnMasterReset() OVERRIDE;
+ void Stop() OVERRIDE;
private:
const AppLaunchSettings& settings_;
@@ -77,6 +78,7 @@ class AppLaunchCtrlImpl : public AppLaunchCtrl {
AppsLauncher apps_launcher_;
DeviceAppsLauncher device_apps_launcher_;
+ sync_primitives::Lock device_apps_launcher_lock_;
DISALLOW_COPY_AND_ASSIGN(AppLaunchCtrlImpl);
};
diff --git a/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h b/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h
index f27e4569fc..2ffec0e065 100644
--- a/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h
+++ b/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h
@@ -35,6 +35,7 @@ class DeviceAppsLauncherImpl {
};
bool StopLaunchingAppsOnDevice(const std::string& device_mac);
+ void StopLaunchingAppsOnAllDevices();
private:
sync_primitives::Lock launchers_lock_;
@@ -60,6 +61,7 @@ class DeviceAppsLauncher {
const std::string& device_mac,
const std::vector<ApplicationDataPtr>& applications_to_launch);
bool StopLaunchingAppsOnDevice(const std::string& device_mac);
+ void StopLaunchingAppsOnAllDevices();
const AppLaunchSettings& settings() const;
diff --git a/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc
index 4dafe9a8e6..05231b66b1 100644
--- a/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc
+++ b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc
@@ -83,6 +83,7 @@ bool HmiLevelSorter(const std::pair<int32_t, ApplicationDataPtr>& lval,
void AppLaunchCtrlImpl::OnDeviceConnected(const std::string& device_mac) {
SDL_LOG_AUTO_TRACE();
+
std::vector<ApplicationDataPtr> apps_on_device =
app_launch_data_.GetApplicationDataByDevice(device_mac);
std::vector<std::pair<int32_t, ApplicationDataPtr> > apps_hmi_levels;
@@ -102,6 +103,7 @@ void AppLaunchCtrlImpl::OnDeviceConnected(const std::string& device_mac) {
std::back_inserter(apps_on_device),
GetAppFromHmiLevelPair);
if (apps_on_device.size() > 0) {
+ sync_primitives::AutoLock lock(device_apps_launcher_lock_);
device_apps_launcher_.LaunchAppsOnDevice(device_mac, apps_on_device);
} else {
SDL_LOG_DEBUG("No apps in saved for device " << device_mac);
@@ -112,4 +114,11 @@ void AppLaunchCtrlImpl::OnMasterReset() {
SDL_LOG_AUTO_TRACE();
app_launch_data_.Clear();
}
+
+void AppLaunchCtrlImpl::Stop() {
+ SDL_LOG_AUTO_TRACE();
+ sync_primitives::AutoLock lock(device_apps_launcher_lock_);
+ device_apps_launcher_.StopLaunchingAppsOnAllDevices();
+}
+
} // namespace app_launch
diff --git a/src/components/application_manager/src/app_launch/device_apps_launcher.cc b/src/components/application_manager/src/app_launch/device_apps_launcher.cc
index 5f36e41efb..1bf2bbf46d 100644
--- a/src/components/application_manager/src/app_launch/device_apps_launcher.cc
+++ b/src/components/application_manager/src/app_launch/device_apps_launcher.cc
@@ -157,6 +157,20 @@ bool DeviceAppsLauncherImpl::StopLaunchingAppsOnDevice(
return true;
}
+void DeviceAppsLauncherImpl::StopLaunchingAppsOnAllDevices() {
+ SDL_LOG_AUTO_TRACE();
+ sync_primitives::AutoLock lock(launchers_lock_);
+
+ std::for_each(works_launchers_.begin(),
+ works_launchers_.end(),
+ [this](LauncherPtr launcher) {
+ launcher->Clear();
+ free_launchers_.push_back(launcher);
+ });
+
+ works_launchers_.clear();
+}
+
bool DeviceAppsLauncher::LaunchAppsOnDevice(
const std::string& device_mac,
const std::vector<ApplicationDataPtr>& applications_to_launch) {
@@ -176,6 +190,10 @@ bool DeviceAppsLauncher::StopLaunchingAppsOnDevice(
return impl_->StopLaunchingAppsOnDevice(device_mac);
}
+void DeviceAppsLauncher::StopLaunchingAppsOnAllDevices() {
+ impl_->StopLaunchingAppsOnAllDevices();
+}
+
const AppLaunchSettings& DeviceAppsLauncher::settings() const {
return settings_;
}
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index e8e3912f9a..8f959460ca 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -2651,6 +2651,11 @@ bool ApplicationManagerImpl::Init(
bool ApplicationManagerImpl::Stop() {
SDL_LOG_AUTO_TRACE();
InitiateStopping();
+
+ if (app_launch_ctrl_) {
+ app_launch_ctrl_->Stop();
+ }
+
application_list_update_timer_.Stop();
try {
if (unregister_reason_ ==