From 7a73caa9c2a33d3dc0251a2a659286530dc07712 Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Mon, 28 Oct 2013 20:34:54 +0900 Subject: [PATCH] add exception handling code for abnormal app termination Change-Id: Ia765c0bf93037ebde24330f0c09c1bd831da5d4f Signed-off-by: jungmin76.park --- inc/FShell_AppContext.h | 2 ++ inc/FShell_AppWidgetManagerService.h | 8 +++++++- src/FShell_AppContext.cpp | 16 ++++++++++++++++ src/FShell_AppWidgetManagerService.cpp | 27 ++++++++++++++++++++++++--- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/inc/FShell_AppContext.h b/inc/FShell_AppContext.h index 5d50ab3..d6bca4f 100644 --- a/inc/FShell_AppContext.h +++ b/inc/FShell_AppContext.h @@ -79,6 +79,8 @@ public: void OnIpcConnected(int clientId); void OnIpcDisconnected(void); + void OnApplicationTerminated(void); + _ConnectionState GetConnectionState(void) const; bool GetWaitingStatus(void) const; Tizen::App::AppId GetAppId(void) const; diff --git a/inc/FShell_AppWidgetManagerService.h b/inc/FShell_AppWidgetManagerService.h index 418ac9d..bd7470b 100644 --- a/inc/FShell_AppWidgetManagerService.h +++ b/inc/FShell_AppWidgetManagerService.h @@ -28,6 +28,7 @@ #include #include #include +#include #include "FShell_AppWidgetContext.h" #include "FShell_AppWidgetManagerStub.h" @@ -46,6 +47,7 @@ class _AppContext; */ class AppWidgetManagerService :public Tizen::Shell::App::_AppWidgetManagerStub + ,public Tizen::App::_IAppEventListener ,public Tizen::Base::Runtime::ITimerEventListener ,public Tizen::System::ISettingEventListener { @@ -66,7 +68,7 @@ private: // core daemon callbacks static int OnAppWidgetServiceConnected(struct event_arg *arg, void* data); - static int OnAppWidgetServiceCDisconnected(struct event_arg *arg, void* data); + static int OnAppWidgetServiceDisconnected(struct event_arg *arg, void* data); static int OnAppWidgetCreate(struct event_arg *arg, int *width, int *height, double *priority, void* data); static int OnAppWidgetDestroy(struct event_arg *arg, void* data); static int OnAppWidgetUpdate(struct event_arg *arg, void* data); @@ -105,6 +107,10 @@ private: // ISettingEventListener virtual void OnSettingChanged(Tizen::Base::String & key); + // _IAppEventListener + virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, int pid); + virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, int pid); + // helpers _AppContext* FindAppContext(const Tizen::App::AppId& appId) const; result RemoveAppContext(const Tizen::App::AppId& appId); diff --git a/src/FShell_AppContext.cpp b/src/FShell_AppContext.cpp index 779b43f..b1704ee 100644 --- a/src/FShell_AppContext.cpp +++ b/src/FShell_AppContext.cpp @@ -233,6 +233,22 @@ _AppContext::OnIpcDisconnected(void) } void +_AppContext::OnApplicationTerminated(void) +{ + if (GetWaitingStatus() == true ) + { + SysLog(NID_SHELL, "The application (%ls) is terminated without response.", __appId.GetPointer() ); + SetWaitingStatus(false); + + if (GetConnectionState() == CONNECTION_STATE_CONNECTING) + { + SysLog(NID_SHELL, "The application (%ls) is terminated before IPC connected, resetting connection state.", __appId.GetPointer() ); + SetConnectionState(CONNECTION_STATE_DISCONNECTED); + } + } +} + +void _AppContext::SetWaitingStatus(bool status) { __isWaitingResult = status; diff --git a/src/FShell_AppWidgetManagerService.cpp b/src/FShell_AppWidgetManagerService.cpp index f892ab5..36a9940 100644 --- a/src/FShell_AppWidgetManagerService.cpp +++ b/src/FShell_AppWidgetManagerService.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +72,8 @@ AppWidgetManagerService::~AppWidgetManagerService(void) __pingTimer.Cancel(); DeinitializeCoreDaemonEventReceiver(); + _AppManagerImpl::GetInstance()->RemoveAppEventListener(*this); + _SettingInfoImpl::RemoveSettingEventListener(*this); IMapEnumeratorT* pMapEnum = __appContextList.GetMapEnumeratorN(); if (pMapEnum != null) @@ -147,6 +150,7 @@ AppWidgetManagerService::Construct(const char* pCoreDaemonId) InitializeCoreDaemonEventReceiver(pCoreDaemonId); SetSettingEventListener(*this); + _AppManagerImpl::GetInstance()->AddAppEventListener(*this); return E_SUCCESS; } @@ -160,7 +164,7 @@ AppWidgetManagerService::SetSettingEventListener(Tizen::System::ISettingEventLis while (true) { - result r = SettingInfo::AddSettingEventListener(listener); + result r = _SettingInfoImpl::AddSettingEventListener(listener); if (r == E_SUCCESS) { SysLog(NID_APP, "Succeeded to invoke AddSettingEventListener"); @@ -199,7 +203,7 @@ AppWidgetManagerService::OnAppWidgetServiceConnected(struct event_arg *arg, void } int -AppWidgetManagerService::OnAppWidgetServiceCDisconnected(struct event_arg *arg, void* data) +AppWidgetManagerService::OnAppWidgetServiceDisconnected(struct event_arg *arg, void* data) { SysLog(NID_SHELL, "Disconnected with master daemon"); return 0; @@ -250,6 +254,23 @@ AppWidgetManagerService::FindAppWidget(const AppId& appId, const String& instanc } void +AppWidgetManagerService::OnApplicationLaunched(const AppId& appId, int pid) +{ + +} + +void +AppWidgetManagerService::OnApplicationTerminated(const AppId& appId, int pid) +{ + _AppContext* pAppContext = null; + __appContextList.GetValue(appId, pAppContext); + if (pAppContext) + { + pAppContext->OnApplicationTerminated(); + } +} + +void AppWidgetManagerService::OnIpcClientConnected(const AppId& appId, int clientId) { SysLog(NID_SHELL, "appId(%ls)", appId.GetPointer()); @@ -560,7 +581,7 @@ AppWidgetManagerService::InitializeCoreDaemonEventReceiver(const char *pCoreDaem memset(&cbs, 0, sizeof(event_handler)); cbs.connected = OnAppWidgetServiceConnected, - cbs.disconnected = OnAppWidgetServiceCDisconnected, + cbs.disconnected = OnAppWidgetServiceDisconnected, cbs.pause = OnAppWidgetBackgroundAll, cbs.resume = OnAppWidgetForegroundAll, cbs.lb_pause = OnAppWidgetBackground, -- 2.7.4