fix LiveboxProviderManager::RequestUpdate() problem.
authorjungmin76.park <jungmin76.park@samsung.com>
Wed, 30 Jan 2013 02:05:41 +0000 (11:05 +0900)
committerjungmin76.park <jungmin76.park@samsung.com>
Wed, 30 Jan 2013 02:10:22 +0000 (11:10 +0900)
add LiveboxPopupProvider::RequestUpdateToLivebox
add manifest validation code to LiveboxProviderManager
fix Livebox unstability issue

Change-Id: I52974a5e5eb7e7697ae55abee244cf4252bf9972
Signed-off-by: jungmin76.park <jungmin76.park@samsung.com>
inc/FShell_Livebox.h
inc/FShell_LiveboxBase.h
inc/FShell_LiveboxManagerService.h
inc/FShell_LiveboxManagerStub.h
manifest.xml
src/FShell_Livebox.cpp
src/FShell_LiveboxBase.cpp
src/FShell_LiveboxManagerService.cpp
src/FShell_LiveboxManagerStub.cpp
src/FShell_LiveboxPopup.cpp

index 8e5ee1d..ec90989 100644 (file)
@@ -47,7 +47,7 @@ public:
                                                int width, int height, int period, int priority);
        virtual ~_Livebox();
        void OnAdded(void);
-       void OnUpdate(void);
+       void OnUpdate(const Tizen::Base::String& argument);
        void OnResize(int width, int height);
        void OnRemoved();
        void OnForeground();
@@ -64,7 +64,7 @@ public:
 
 private:
        result SendAddRequest(int width, int height);
-       result SendUpdateRequest(int width, int height);
+       result SendUpdateRequest(int width, int height, const Tizen::Base::String& argument);
        result SendResizeRequest(int width, int height);
        result SendRemoveRequest();
 
index 47aaec4..976aedc 100644 (file)
@@ -56,11 +56,12 @@ public:
        int __priority;
 
 protected:
-       struct livebox_buffer *__buffer_info;
-       void *__buffer;
        bool __isForeground;// LB only?
        int __ipcClientId;
 
+private:
+       void *__buffer;
+       struct livebox_buffer *__buffer_info;
 };
 
 class _LiveboxRequestHelper
index ce84e40..05a5cd2 100644 (file)
@@ -23,7 +23,7 @@
 #include <FBaseObject.h>
 #include <FBaseString.h>
 #include <FBaseRtTimer.h>
-#include <FApp_IAppManagerEventListener.h>
+//#include <FApp_IAppManagerEventListener.h>
 #include <FShell_Livebox.h>
 //#include <FBaseColHashMapT.h>
 #include <FBaseColArrayListT.h>
@@ -34,7 +34,7 @@ namespace Tizen { namespace Shell  { namespace App {
 
 class LiveboxManagerService
        :public Tizen::Shell::App::_LiveboxManagerStub
-        ,public Tizen::App::_IAppManagerEventListener
+//      ,public Tizen::App::_IAppManagerEventListener
         ,public Tizen::Base::Runtime::ITimerEventListener
 {
 public:
@@ -62,7 +62,8 @@ private:
        static int OnLiveboxPeriodChaned(struct event_arg *arg, void* data);
 
        // stub implementations
-       virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName);
+       virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument);
+       virtual result RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument);
        virtual result RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int w, int h, int& shmId);
        virtual result RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int w, int h, int& shmId);
        virtual result RequestSyncSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height);
@@ -74,8 +75,8 @@ private:
        LiveboxManagerService();
        virtual ~LiveboxManagerService();
 
-       virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
-       virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
+//     virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
+//     virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
 
        virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
        virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId);
index 00d8a4c..6a54d54 100644 (file)
@@ -52,7 +52,8 @@ protected:
        virtual ~_LiveboxManagerStub(void);
 
        // handlers
-       bool OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, result* pRes);
+       bool OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument, result* pRes);
+       bool OnRequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument, result* pRes);
        bool OnRequestSharedMemoryId(const Tizen::Base::String& instanceId, int width, int height, int* pShmId);
        bool OnRequestSharedMemoryIdForPD(const Tizen::Base::String& instanceId, int width, int height, int* pShmId);
        bool OnRequestSyncSharedMemory(const Tizen::Base::String& instanceId, int width, int height, result* pRes);
@@ -61,7 +62,8 @@ protected:
        bool OnRequestReleaseSharedMemoryForPD(const Tizen::Base::String& instanceId, result* pRes);
 
        // interface to service
-       virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName) = 0;
+       virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument) = 0;
+       virtual result RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument) = 0;
        virtual result RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId) = 0;
        virtual result RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId) = 0;
        virtual result RequestSyncSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height) = 0;
index 2441cde..e0267db 100644 (file)
@@ -1,15 +1,12 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<Manifest xmlns="http://schemas.tizen.org/2012/06/manifest">
+<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest">
     <Id>gi2qxenosh</Id>
     <Version>1.0.0</Version>
     <Type>C++App</Type>
-    <Vendors>
-        <Vendor Locale="eng-GB"/>
-    </Vendors>
+    <Author/>
     <Descriptions>
         <Description Locale="eng-GB"/>
     </Descriptions>
-    <Url/>
     <Requirements>
         <Feature Name="http://tizen.org/feature/platform.core.cpu.arch">x86</Feature>
         <Feature Name="http://tizen.org/feature/platform.core.fpu.arch">vfpv3</Feature>
     </Requirements>
     <Apps>
         <ApiVersion>2.1</ApiVersion>
-        <Secret/>
         <Privileges>
             <Privilege>http://tizen.org/privilege/application.launch</Privilege>
             <Privilege>http://tizen.org/privilege/appmanager.launch</Privilege>
+            <Privilege>http://tizen.org/privilege/application.kill</Privilege>
         </Privileges>
-        <ServiceApp AutoRestart="False" Default="True" ExecutableName="osp-livebox-service" LaunchOnBoot="False">
-            <Names>
-                <Name Locale="eng-GB">tizen livebox service</Name>
-            </Names>
+        <ServiceApp Name="osp-livebox-service" Main="True">
+            <DisplayNames>
+                <DisplayName Locale="eng-GB">tizen livebox service</DisplayName>
+            </DisplayNames>
             <Icons/>
-            <AppControls/>
             <DataControls/>
             <LaunchConditions/>
             <Notifications/>
index 31807b2..3d92247 100644 (file)
@@ -99,11 +99,11 @@ _Livebox::OnRemoved()
 }
 
 void
-_Livebox::OnUpdate(void)
+_Livebox::OnUpdate(const String& argument)
 {
        SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
 
-       SendUpdateRequest(__width, __height);
+       SendUpdateRequest(__width, __height, argument);
 }
 
 void
@@ -150,12 +150,9 @@ _Livebox::OnPopupDestoyed(void)
        if (__pLiveboxPopup)
        {
                __pLiveboxPopup->OnPopupDestoyed();
-               __pLiveboxPopup->ReleaseSharedMem();
                delete __pLiveboxPopup;
+               __pLiveboxPopup = null;
        }
-
-       __pLiveboxPopup = null;
-
        RestartLifeDurationTimer();
 }
 
@@ -179,7 +176,7 @@ _Livebox::SendAddRequest(int width, int height)
 }
 
 result
-_Livebox::SendUpdateRequest(int width, int height)
+_Livebox::SendUpdateRequest(int width, int height, const String& argument)
 {
        std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
 
@@ -276,12 +273,14 @@ _Livebox::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
        {
                SysLog(NID_APP, "lifeDuration timer is expired, so terminating livebox app(%ls)..", __providerId.GetPointer() );
 
+               ReleaseSharedMem();
                AppManager::GetInstance()->TerminateApplication(__appId);
+
        }
        else if( &timer == &__UpdateTimer)
        {
                SysLog(NID_APP, "update timer is expired for livebox app(%ls)..", __providerId.GetPointer() );
-               OnUpdate();
+               OnUpdate(L"");
        }
 }
 
index 9db8092..8476845 100644 (file)
@@ -102,10 +102,10 @@ _LiveboxBase::_LiveboxBase(target_type type, const String& userInfo, const Strin
        ,__width(width)
        ,__height(height)
        ,__priority(priority)
-       ,__buffer_info(null)
-       ,__buffer(null)  // __pEcoreEvas(null), __pEvas(null), __current(0)
        ,__isForeground(true)
        ,__ipcClientId(-1)
+       ,__buffer_info(null)
+       ,__buffer(null)  // __pEcoreEvas(null), __pEvas(null), __current(0)
 {
        _LiveboxManagerImpl::ExtractAppIdAndProviderName(providerId, __appId, __providerName);
 
@@ -160,6 +160,7 @@ result
 _LiveboxBase::ReleaseSharedMem()
 {
        SysLog(NID_APP, "Enter");
+
     int ret;
 
     if( __buffer)
index 8f2625b..4339da2 100644 (file)
@@ -79,7 +79,7 @@ LiveboxManagerService::GetInstance(void)
 result
 LiveboxManagerService::Construct()
 {
-       _AppManagerImpl::GetInstance()->AddEventListener(*this);
+//     _AppManagerImpl::GetInstance()->AddEventListener(*this);
 
        _LiveboxManagerStub::StartIpcServer();
 
@@ -164,22 +164,30 @@ LiveboxManagerService::SetClientIds(const Tizen::App::AppId& appId, int clientId
                {
                        pLivebox->SetClientId(clientId);
                        SysLog(NID_APP, "client is registered.(%d)", clientId);
+                       if( clientId == -1)
+                       {
+                               pLivebox->ReleaseSharedMem();
+                               if(pLivebox->GetLiveboxPopup())
+                               {
+                                       pLivebox->OnPopupDestoyed();
+                               }
+                       }
                }
        }
        return E_SUCCESS;
 }
 
-void
-LiveboxManagerService::OnApplicationLaunched(const AppId& appId, _AppType type)
-{
-
-}
-
-void
-LiveboxManagerService::OnApplicationTerminated(const AppId& appId, _AppType type)
-{
-       this->SetClientIds(appId, -1);
-}
+//void
+//LiveboxManagerService::OnApplicationLaunched(const AppId& appId, _AppType type)
+//{
+//
+//}
+//
+//void
+//LiveboxManagerService::OnApplicationTerminated(const AppId& appId, _AppType type)
+//{
+//     this->SetClientIds(appId, -1);
+//}
 
 void
 LiveboxManagerService::OnIpcClientConnected(const _IpcServer& server, int clientId)
@@ -196,8 +204,7 @@ LiveboxManagerService::OnIpcClientDisconnected(const _IpcServer& server, int cli
 {
        String fullAppId = server.GetClientAppId() + "." + server.GetClientAppExecutableName();
        SysLog(NID_APP, "(%ls)\n", fullAppId.GetPointer());
-//     SysLog(NID_APP, "(appId:%ls, pid:%d, clientId:%d)\n", server.GetClientAppId().GetPointer(), server.GetClientProcessId(), clientId);
-//     this->SetClientIds(server.GetClientAppId(), -1);
+       this->SetClientIds(fullAppId, -1);
 }
 
 result
@@ -275,7 +282,7 @@ LiveboxManagerService::OnLiveboxUpdate(struct event_arg *arg, void* data)
                _Livebox* pLivebox = LiveboxManagerService::GetInstance()->Find(arg->pkgname, arg->id);
                SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
 
-               pLivebox->OnUpdate();
+               pLivebox->OnUpdate(L"");
        }
 
        return 0;
@@ -291,7 +298,7 @@ LiveboxManagerService::UpdateAllLiveboxesByAppId(const String& providerId)
 
                if ( pLivebox->__providerId == providerId )
                {
-                       pLivebox->OnUpdate();
+                       pLivebox->OnUpdate(L"");
                }
        }
        return E_SUCCESS;
@@ -325,6 +332,10 @@ LiveboxManagerService::OnLiveboxPopupCreate(struct event_arg *arg, void* data)
        _Livebox* pLivebox = LiveboxManagerService::GetInstance()->Find(arg->pkgname, arg->id);
        SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
 
+       /*if( pLivebox->GetLiveboxPopup() )
+       {
+               pLivebox->OnPopupDestoyed();
+       }*/
        pLivebox->OnPopupCreated(arg->info.pd_create.w, arg->info.pd_create.h);
 
     return 0;
@@ -334,15 +345,12 @@ LiveboxManagerService::OnLiveboxPopupCreate(struct event_arg *arg, void* data)
  LiveboxManagerService::OnLiveboxPopupDestroy(struct event_arg *arg, void* data)
 {
        SysTryReturn (NID_APP, arg->type == event_arg::EVENT_PD_DESTROY, -EPERM, E_SUCCESS, "invalid argument from master");
-       SysLog(NID_APP, "packageName(%s), id(%s), width(%d), height(%d), priority(%d)", arg->pkgname, arg->id);
-       SysLog(NID_APP, "Enter");
-
+       SysLog(NID_APP, "packageName(%s), id(%s)", arg->pkgname, arg->id);
        _Livebox* pLivebox = LiveboxManagerService::GetInstance()->Find(arg->pkgname, arg->id);
        SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
 
        pLivebox->OnPopupDestoyed();
 
-        SysLog(NID_APP, "Exit");
     return 0;
 }
 
@@ -425,6 +433,8 @@ LiveboxManagerService::InitializeMasterDaemonEventReceiver(const char *pServiceE
     cbs.disconnected = LiveboxDisconnected,
     cbs.pause = OnLivePause,
     cbs.resume = OnLiveboxResume,
+//    cbs.lb_pause = OnLivePause,
+//    cbs.lb_resume = OnLiveboxResume,
     cbs.lb_create = OnLiveboxCreate,
     cbs.lb_destroy = OnLiveboxDestroy,
     cbs.update_content = OnLiveboxUpdate,
@@ -458,7 +468,7 @@ LiveboxManagerService::DeinitializeMasterDaemonEventReceiver()
 ///////////////////////////////////////////////////////
 
 result
-LiveboxManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName)//, const Tizen::Base::String& param)
+LiveboxManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument)
 {
        SysLog(NID_APP, "%ls, %ls", appId.GetPointer(), providerName.GetPointer() );
 
@@ -477,6 +487,7 @@ LiveboxManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tizen
 
                        pArray->Construct();
                        pArray->Add(pLivebox);
+                       pArray->Add(new String(argument));
 
                        result r = __handlerThread.SendUserEvent(LOCAL_EVENT_REQUEST_UPDATE, pArray);
                        SysTryLog(NID_APP, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r));
@@ -490,6 +501,37 @@ LiveboxManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tizen
 }
 
 result
+LiveboxManagerService::RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument)
+{
+       SysLog(NID_APP, "%ls, %ls", instanceId.GetPointer(), argument.GetPointer() );
+
+       for( int i = 0; i < __liveboxes.GetCount(); i++ )
+       {
+               _Livebox* pLivebox = null;
+               __liveboxes.GetAt(i, pLivebox);
+
+               if ( pLivebox->__instanceId == instanceId)
+               {
+                       SysLog(NID_APP, "OK");
+
+                       ArrayList* pArray = new ArrayList();
+                       SysTryReturnResult(NID_APP, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+
+                       pArray->Construct();
+                       pArray->Add(pLivebox);
+                       pArray->Add(new String(argument));
+
+                       result r = __handlerThread.SendUserEvent(LOCAL_EVENT_REQUEST_UPDATE, pArray);
+                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r));
+
+                       return E_SUCCESS;
+               }
+       }
+       SysLog(NID_APP, "Exit.");
+       return E_OBJ_NOT_FOUND;
+}
+
+result
 LiveboxManagerService::RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId)
 {
        _Livebox* pLivebox = this->Find(appId, instanceId);
@@ -568,7 +610,8 @@ LiveboxManagerService::RequestReleaseSharedMemoryForPD(const Tizen::App::AppId&
        SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
        SysTryReturnResult(NID_APP, pLivebox->GetLiveboxPopup(), E_SYSTEM, "[E_SYSTEM] GetLiveboxPopup() returns null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
 
-       return pLivebox->GetLiveboxPopup()->ReleaseSharedMem();
+//     return pLivebox->GetLiveboxPopup()->ReleaseSharedMem();
+       return E_SUCCESS;
 }
 
 LiveboxManagerService::_TaskHandlerThread::~_TaskHandlerThread(void)
@@ -590,8 +633,12 @@ LiveboxManagerService::_TaskHandlerThread::OnUserEventReceivedN(RequestId reqId,
                _Livebox* pLivebox = dynamic_cast<_Livebox*>( pArgs->GetAt(0) );
                SysTryReturnVoidResult(NID_APP, pLivebox != null, E_INVALID_STATE, "_Livebox is null!.");
 
-               pLivebox->OnUpdate();
+               String* pArgument = dynamic_cast<String*>( pArgs->GetAt(1) );
+               SysTryReturnVoidResult(NID_APP, pArgument != null, E_INVALID_STATE, "pArgument is null!.");
+
+               pLivebox->OnUpdate(*pArgument);
 
+               delete pArgument;
                pArgs->RemoveAll();
                delete pArgs;
        }
index 4ead778..ad7747e 100644 (file)
@@ -85,10 +85,18 @@ CATCH:
 
 
 bool
-_LiveboxManagerStub::OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, result* pRes)
+_LiveboxManagerStub::OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument, result* pRes)
 {
        SysLog(NID_APP, "");
-       *pRes = RequestUpdate(appId, providerName);
+       *pRes = RequestUpdate(appId, providerName, argument);
+       return true;
+}
+
+bool
+_LiveboxManagerStub::OnRequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument, result* pRes)
+{
+       SysLog(NID_APP, "");
+       *pRes = RequestUpdateInstance(instanceId, argument);
        return true;
 }
 
@@ -179,6 +187,7 @@ _LiveboxManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message
 
        IPC_BEGIN_MESSAGE_MAP(_LiveboxManagerStub, message)
                IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestUpdate, &server, OnRequestUpdate)
+               IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestUpdateInstance, &server, OnRequestUpdateInstance)
                IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestSharedMemoryId, &server, OnRequestSharedMemoryId)
                IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestSharedMemoryIdForPD, &server, OnRequestSharedMemoryIdForPD)
                IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestSyncSharedMemory, &server, OnRequestSyncSharedMemory)
index 559968b..e7860c8 100644 (file)
@@ -53,6 +53,7 @@ _LiveboxPopup::_LiveboxPopup(const String& info, const String& appId, const Stri
 _LiveboxPopup::~_LiveboxPopup()
 {
        SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d))", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
+       ReleaseSharedMem();
 }