From f455993e87c38d9bacba8e558c1c6a39d752dda2 Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Tue, 8 Oct 2013 22:18:36 +0900 Subject: [PATCH] add retry code to wait SettingInfo service initialized Change-Id: Ic729356933e2c6907d464a958f79accee3770c4e Signed-off-by: jungmin76.park --- inc/FShell_AppWidgetManagerService.h | 1 + src/FShell_AppWidgetManagerService.cpp | 47 ++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/inc/FShell_AppWidgetManagerService.h b/inc/FShell_AppWidgetManagerService.h index 28b78f2..e1f5411 100644 --- a/inc/FShell_AppWidgetManagerService.h +++ b/inc/FShell_AppWidgetManagerService.h @@ -114,6 +114,7 @@ private: result RequestUpdateAllSuspened(void) const; static void InitSingleton(void); static void DestroySingleton(void); + static bool SetSettingEventListener(Tizen::System::ISettingEventListener& listener); private: static AppWidgetManagerService* __pTheInstance; diff --git a/src/FShell_AppWidgetManagerService.cpp b/src/FShell_AppWidgetManagerService.cpp index 6ec33b2..ef54c8c 100644 --- a/src/FShell_AppWidgetManagerService.cpp +++ b/src/FShell_AppWidgetManagerService.cpp @@ -52,22 +52,11 @@ using namespace Tizen::Shell::App; namespace { -// provider.h -enum instance_destroy_type -{ - INSTANCE_DESTROY_DEFAULT, - INSTANCE_DESTROY_PKGMGR, - INSTANCE_DESTROY_TERMINATE, - INSTANCE_DESTROY_FAULT, - INSTANCE_DESTROY_UNKNOWN, -}; - static const char APPNAME_OSP_APPWIDGET_SERVICE[] = "osp-appwidget-service"; static const int TIMER_DURATION_PING = 120000; //extern const int UPDATE_PERIOD_MSEC_MIN; } - AppWidgetManagerService* AppWidgetManagerService::__pTheInstance = null; AppWidgetManagerService::AppWidgetManagerService(void) @@ -155,10 +144,40 @@ AppWidgetManagerService::Construct(const char* pCoreDaemonId) SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute Construct."); _AppWidgetManagerStub::StartIpcServer(); + InitializeCoreDaemonEventReceiver(pCoreDaemonId); + + SetSettingEventListener(*this); + + return E_SUCCESS; +} + +bool +AppWidgetManagerService::SetSettingEventListener(Tizen::System::ISettingEventListener& listener) +{ + const int MAX_TRY_COUNT = 10; + const int TRY_SLEEP_TIME = 250; + int count = 0; + + while (true) + { + result r = SettingInfo::AddSettingEventListener(listener); + if (r == E_SUCCESS) + { + SysLog(NID_APP, "Succeeded to invoke AddSettingEventListener"); + return true; + } - SettingInfo::AddSettingEventListener(*this); + if (count >= MAX_TRY_COUNT) + { + SysLog(NID_APP, "Failed to invoke AddSettingEventListener"); + break; + } - return InitializeCoreDaemonEventReceiver(pCoreDaemonId); + count++; + Thread::Sleep(TRY_SLEEP_TIME); + SysLog(NID_APP, "%d th retry...", count); + } + return false; } int @@ -353,7 +372,7 @@ AppWidgetManagerService::OnAppWidgetDestroy(struct event_arg *arg, void* data) SysAssertf(arg != null && arg->type == event_arg::EVENT_DELETE, "The status of data-provider-master is invalid."); SysLog(NID_SHELL, "lb_destroy.type (%d)", arg->info.lb_destroy.type); - if (arg->info.lb_destroy.type == INSTANCE_DESTROY_PKGMGR) + if (arg->info.lb_destroy.type == event_arg::event_data::lb_destroy::INSTANCE_DESTROY_PKGMGR) { SysLog(NID_SHELL, "INSTANCE_DESTROY_PKGMGR type, ignored."); return 0; -- 2.7.4