void set_service_ipc(CServiceIpcDbus* ipc) { mServiceIpc = ipc; }
CServiceIpcDbus* get_service_ipc() { return mServiceIpc; }
- void set_service_main(CServiceMain* main) { mServiceMain = main; }
- CServiceMain* get_service_main() { return mServiceMain; }
+ void set_service_main(CServiceMain* main) { mServiceMain = main; }
+ CServiceMain* get_service_main() { return mServiceMain; }
+
+ void start_app_restart_timer();
+ void stop_app_restart_timer();
private:
#ifdef BUF_SAVE_MODE
char mDumpFilename[128]{'\0', };
ma_plugin_settings* mPluginSettings{NULL};
CServiceIpcDbus* mServiceIpc{nullptr};
- CServiceMain* mServiceMain{nullptr};
+ CServiceMain* mServiceMain{nullptr};
+
+ Ecore_Timer *mAppRestartTimer{nullptr};
};
#endif /* __SERVICE_PLUGIN_H__ */
}
}
+static Eina_Bool app_restart_timer_func(void *user_data)
+{
+ CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
+ if (plugin) {
+ CServiceMain* service_main = plugin->get_service_main();
+ if (service_main) {
+ ma_service_state_e service_state = service_main->get_current_service_state();
+ if (service_state != MA_SERVICE_STATE_UTTERANCE) {
+ MAS_LOGE("[SUCCESS] Restarting service");
+ service_main->app_restart();
+ }
+ }
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+void CServicePlugin::stop_app_restart_timer()
+{
+ if (mAppRestartTimer) {
+ ecore_timer_del(mAppRestartTimer);
+ mAppRestartTimer = nullptr;
+ }
+}
+
+void CServicePlugin::start_app_restart_timer()
+{
+ stop_app_restart_timer();
+ mAppRestartTimer = ecore_timer_add(1.0f, app_restart_timer_func, this);
+}
+
static void __loaded_engine_changed_cb(void* user_data)
{
MAS_LOGD("[SUCCESS] __loaded_engine_changed_cb is called");
if (service_main) {
/* Make sure the app doesn't restart within a conversation session */
ma_service_state_e service_state = service_main->get_current_service_state();
- if (service_state == MA_SERVICE_STATE_INACTIVE ||
- service_state == MA_SERVICE_STATE_LISTENING) {
+ if (service_state != MA_SERVICE_STATE_UTTERANCE) {
MAS_LOGE("[SUCCESS] Restarting service");
service_main->app_restart();
} else {
MAS_LOGE("Cannot restart service when service_state is %d", service_state);
+ plugin->start_app_restart_timer();
}
}
}
}
#endif
+ if (mAppRestartTimer) {
+ ecore_timer_del(mAppRestartTimer);
+ mAppRestartTimer = nullptr;
+ }
+
int ret = -1;
if (NULL != mPluginHandle) {
wakeup_manager_deinitialize func = mWakeupManagerInterface.deinitialize;