add exception handling code for abnormal app termination
authorjungmin76.park <jungmin76.park@samsung.com>
Mon, 28 Oct 2013 11:34:54 +0000 (20:34 +0900)
committerjungmin76.park <jungmin76.park@samsung.com>
Mon, 28 Oct 2013 13:40:58 +0000 (22:40 +0900)
Change-Id: Ia765c0bf93037ebde24330f0c09c1bd831da5d4f
Signed-off-by: jungmin76.park <jungmin76.park@samsung.com>
inc/FShell_AppContext.h
inc/FShell_AppWidgetManagerService.h
src/FShell_AppContext.cpp
src/FShell_AppWidgetManagerService.cpp

index 5d50ab3..d6bca4f 100644 (file)
@@ -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;
index 418ac9d..bd7470b 100644 (file)
@@ -28,6 +28,7 @@
 #include <FBaseRtThread.h>
 #include <FBaseColHashMapT.h>
 #include <FSysISettingEventListener.h>
+#include <FApp_IAppEventListener.h>
 #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);
index 779b43f..b1704ee 100644 (file)
@@ -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;
index f892ab5..36a9940 100644 (file)
@@ -30,6 +30,7 @@
 #include <FSystem.h>
 #include <FBaseComparerT.h>
 #include <FApp_AppManagerImpl.h>
+#include <FSys_SettingInfoImpl.h>
 #include <FShell_AppWidgetManagerImpl.h>
 #include <FIo_IpcServer.h>
 #include <FBase_StringConverter.h>
@@ -71,6 +72,8 @@ AppWidgetManagerService::~AppWidgetManagerService(void)
        __pingTimer.Cancel();
 
        DeinitializeCoreDaemonEventReceiver();
+       _AppManagerImpl::GetInstance()->RemoveAppEventListener(*this);
+       _SettingInfoImpl::RemoveSettingEventListener(*this);
 
        IMapEnumeratorT<String, _AppContext*>* 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,