From: Jaesung Ku Date: Wed, 10 Jul 2013 12:25:35 +0000 (+0900) Subject: Update for AppLifecycleEvent X-Git-Tag: submit/tizen/20131210.080830^2^2~273 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01dbcc35ceb20dddbd575ccaf2520f26764c69e5;p=platform%2Fframework%2Fnative%2Fappfw.git Update for AppLifecycleEvent Change-Id: Iae82d760cc08d463d33755a89ae67410106f54df Signed-off-by: Jaesung Ku --- diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt old mode 100644 new mode 100755 index 0a04640..954d3fd --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -66,6 +66,7 @@ SET (${this_target}_SOURCE_FILES FApp_AppSettingImpl.cpp FApp_LongevityManager.cpp FApp_AppControlResponseEvent.cpp + FApp_AppLifecycleEvent.cpp ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SINGLETON_CLEANUP -fvisibility=hidden") diff --git a/src/app/FApp_AppLifecycleEvent.cpp b/src/app/FApp_AppLifecycleEvent.cpp new file mode 100755 index 0000000..9fccdc5 --- /dev/null +++ b/src/app/FApp_AppLifecycleEvent.cpp @@ -0,0 +1,85 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FApp_AppLifecycleEvent.cpp + * @brief This is the implementation for the _AppLifecycleEvent.cpp class. + */ + +#include + +#include "FApp_Types.h" +#include "FApp_AppLifecycleEvent.h" +#include "FApp_AppLifecycleEventArg.h" +#include "FApp_IAppLifecycleEventListener.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + + +namespace Tizen { namespace App +{ + +_AppLifecycleEventArg::_AppLifecycleEventArg(void) +{ +} + +_AppLifecycleEventArg::_AppLifecycleEventArg(const AppId& appId, _AppLifecycleEventType appLifecycleEventType) + : __appId(appId) + , __appLifecycleEventType(appLifecycleEventType) +{ +} + +_AppLifecycleEventArg::~_AppLifecycleEventArg(void) +{ +} + +const AppId +_AppLifecycleEventArg::GetAppId(void) const +{ + return __appId; +} + +_AppLifecycleEventType + +_AppLifecycleEventArg::GetAppLifecycleEventType(void) const +{ + return __appLifecycleEventType; +} + +/////////////////////////////////////////////////////// +//_AppLifecycleEvent +/////////////////////////////////////////////////////// +result +_AppLifecycleEvent::Construct(void) +{ + return _Event::Initialize(); +} + +void +_AppLifecycleEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IAppLifecycleEventListener* pListener = dynamic_cast<_IAppLifecycleEventListener*>(&listener); + SysTryReturnVoidResult(NID_APP, pListener != null, E_INVALID_STATE, "Invalid listener : listener(0x%x), arg(0x%x)", &listener, &arg); + + const _AppLifecycleEventArg* pEventArg = dynamic_cast(&arg); + SysTryReturnVoidResult(NID_APP, pEventArg != null, E_INVALID_STATE, "Invalid arg : listener(0x%x), arg(0x%x)", &listener, &arg); + + pListener->OnAppLifecycleEventReceived(pEventArg->GetAppId(), pEventArg->GetAppLifecycleEventType()); +} + +} } // Tizen::App + diff --git a/src/app/FApp_AppManagerImpl.cpp b/src/app/FApp_AppManagerImpl.cpp index f696327..fe907a7 100755 --- a/src/app/FApp_AppManagerImpl.cpp +++ b/src/app/FApp_AppManagerImpl.cpp @@ -68,6 +68,9 @@ #include "FApp_Aul.h" #include "FSys_SystemInfoImpl.h" +#include "FApp_AppLifecycleEvent.h" +#include "FApp_AppLifecycleEventArg.h" +#include "FApp_IAppLifecycleEventListener.h" using namespace Tizen::App::Package; using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -269,6 +272,9 @@ result _AppManagerImpl::Construct(void) { __appManagerEvent.Construct(); + __appLifecycleEvent.Construct(); + __appListForAppLifecycle.Construct(0, 0, __strHashCodeProvider, __comparer); + __mutex.Create(); _IAppManager* pMgr = _AppManagerProxy::GetService(); //todo : uncomment following _SysTryReturn or put assert. @@ -1270,4 +1276,107 @@ _AppManagerImpl::ClearUserPreferenceForAppControlResolution(const AppId& appId) return pMgr->ClearUserPreferenceForAppControlResolution(appId); } +result +_AppManagerImpl::AddAppLifecycleEventListener(_IAppLifecycleEventListener& listener) +{ + return __appLifecycleEvent.AddListener(listener, false); +} + +result +_AppManagerImpl::RemoveAppLifecycleEventListener(_IAppLifecycleEventListener& listener) +{ + return __appLifecycleEvent.RemoveListener(listener); +} + +result +_AppManagerImpl::RegisterAppForAppLifecycleEvent(const AppId& appId) +{ + SysLog(NID_APP, "Enter"); + + result r = __mutex.Acquire(); + + bool isContained = false; + r = __appListForAppLifecycle.ContainsKey(appId, isContained); + + int currentRefCnt = 0; + if(isContained) + { + r = __appListForAppLifecycle.GetValue(appId, currentRefCnt); + r = __appListForAppLifecycle.SetValue(appId, ++currentRefCnt); + } + else + { + r = __appListForAppLifecycle.Add(appId, currentRefCnt); + + _IAppManager* pMgr = _AppManagerProxy::GetService(); + SysTryReturnResult(NID_APP, pMgr, E_SYSTEM, "_AppManagerProxy::GetService() is failed."); + + r = pMgr->RegisterAppForAppLifecycleEvent(appId, -1); + SysLog(NID_APP, "The appId(%ls) is registered.", appId.GetPointer()); + } + r = __mutex.Release(); + + SysLog(NID_APP, "Exit"); + + return r; +} + +result +_AppManagerImpl::UnregisterAppForAppLifecycleEvent(const AppId& appId) +{ + SysLog(NID_APP, "Enter"); + + result r = __mutex.Acquire(); + + bool isContained = false; + r = __appListForAppLifecycle.ContainsKey(appId, isContained); + + if(isContained) + { + int currentRefCnt = 0; + r = __appListForAppLifecycle.GetValue(appId, currentRefCnt); + + currentRefCnt--; + + if (currentRefCnt < 0) + { + r = __appListForAppLifecycle.Remove(appId); + + _IAppManager* pMgr = _AppManagerProxy::GetService(); + SysTryReturnResult(NID_APP, pMgr, E_SYSTEM, "_AppManagerProxy::GetService() is failed."); + + r = pMgr->UnregisterAppForAppLifecycleEvent(appId, -1); + + SysLog(NID_APP, "The appId(%ls) is unregistered.", appId.GetPointer()); + } + else + { + r = __appListForAppLifecycle.SetValue(appId, currentRefCnt); + } + } + else + { + SysLog(NID_APP, "The appId(%ls) is not registered.", appId.GetPointer()); + } + + r = __mutex.Release(); + + SysLog(NID_APP, "Exit"); + + return r; + +} + +result +_AppManagerImpl::OnAppLifecycleEventReceived(int clientId,const AppId& appId, _AppLifecycleEventType appLifecycleEventType) +{ + SysLog(NID_APP, "Enter appId(%ls), appLifecycleEventType(%d)", appId.GetPointer(), appLifecycleEventType); + + _AppLifecycleEventArg* pArg = new (std::nothrow)_AppLifecycleEventArg(appId, appLifecycleEventType); + SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + __appLifecycleEvent.FireAsync(*pArg); + return E_SUCCESS; +} + }} // Tizen::App diff --git a/src/app/FApp_AppManagerProxy.cpp b/src/app/FApp_AppManagerProxy.cpp index 56e76af..05f884b 100755 --- a/src/app/FApp_AppManagerProxy.cpp +++ b/src/app/FApp_AppManagerProxy.cpp @@ -34,6 +34,7 @@ #include "FApp_AppManagerEventArg.h" #include "FApp_AppManagerProxy.h" #include "FApp_AppManagerIpcMessage.h" +#include "FApp_IAppLifecycleEventListener.h" namespace { @@ -196,6 +197,7 @@ _AppManagerProxy::OnIpcResponseReceived(_IpcClient& client, const IPC::Message& IPC_BEGIN_MESSAGE_MAP(_AppManagerProxy, message) IPC_MESSAGE_HANDLER_EX(AppManager_OnEventReceived, &client, OnEventReceived ) IPC_MESSAGE_HANDLER_EX(AppManager_OnTerminateApplicationRequested, &client, OnTerminateApplicationRequested ) + IPC_MESSAGE_HANDLER_EX(AppManager_OnAppLifecycleEventReceived, &client, OnAppLifecycleEventReceived ) IPC_END_MESSAGE_MAP() } @@ -279,4 +281,53 @@ _AppManagerProxy::ClearUserPreferenceForAppControlResolution(const AppId& appId) return response; } +result +_AppManagerProxy::RegisterAppForAppLifecycleEvent(const AppId& appId, int clientId) +{ + SysLog(NID_APP, "begin."); + result response = E_SUCCESS; + std::auto_ptr pMsg (new (std::nothrow) AppManager_RegisterAppForAppLifecycleEvent(appId, &response)); + result r = __pIpcClient->SendRequest(*pMsg.get()); + SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed."); + + SysLog(NID_APP, "end."); + return response; +} + +result +_AppManagerProxy::UnregisterAppForAppLifecycleEvent(const AppId& appId, int clientId) +{ + SysLog(NID_APP, "begin."); + result response = E_SUCCESS; + std::auto_ptr pMsg (new (std::nothrow) AppManager_UnregisterAppForAppLifecycleEvent(appId, &response)); + result r = __pIpcClient->SendRequest(*pMsg.get()); + SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed."); + + SysLog(NID_APP, "end."); + return response; +} + +void +_AppManagerProxy::OnAppLifecycleEventReceived(const AppId& appId, int appLifecycleEventType) +{ + SysTryLog(NID_APP, __pServiceEventListener != null, "__pServiceEventListener instance must not be null."); + + _AppLifecycleEventType eventType; + + if (appLifecycleEventType == 0) + { + eventType = _APP_LIFECYCLE_EVENT_LAUNCH; + } + else if (appLifecycleEventType == 1) + { + eventType = _APP_LIFECYCLE_EVENT_TERMINATE; + } + else + { + SysLog(NID_APP, "Not expected appLifecycleEventType(%d)", appLifecycleEventType); + } + + __pServiceEventListener->OnAppLifecycleEventReceived(-1, appId, eventType); +} + } } // Tizen::App diff --git a/src/app/inc/FApp_AppLifecycleEvent.cpp b/src/app/inc/FApp_AppLifecycleEvent.cpp new file mode 100755 index 0000000..175adbc --- /dev/null +++ b/src/app/inc/FApp_AppLifecycleEvent.cpp @@ -0,0 +1,84 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FApp_AppLifecycleEvent.cpp + * @brief This is the implementation for the _AppLifecycleEvent.cpp class. + */ + +#include + +#include "FApp_Types.h" +#include "FApp_AppLifecycleEvent.h" +#include "FApp_AppLifecycleEventArg.h" +#include "FApp_IAppLifecycleEventListener.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + + +namespace Tizen { namespace App +{ + +_AppLifecycleEventArg::_AppLifecycleEventArg(void) +{ +} + +_AppLifecycleEventArg::_AppLifecycleEventArg(const AppId& appId, _AppLifecycleEventType appLifecycleEventType) + : __appId(appId) + , __appLifecycleEventType(appLifecycleEventType) +{ +} + +_AppLifecycleEventArg::~_AppLifecycleEventArg(void) +{ +} + +const AppId +_AppLifecycleEventArg::GetAppId(void) const +{ + return __appId; +} + +_AppLifecycleEventType +_AppLifecycleEventArg::GetAppLifecycleEventType(void) const +{ + return __appLifecycleEventType; +} + +/////////////////////////////////////////////////////// +//_AppLifecycleEvent +/////////////////////////////////////////////////////// +result +_AppLifecycleEvent::Construct(void) +{ + return _Event::Initialize(); +} + +void +_AppLifecycleEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IAppLifecycleEventListener* pListener = dynamic_cast<_IAppLifecycleEventListener*>(&listener); + SysTryReturnVoidResult(NID_APP, pListener != null, E_INVALID_STATE, "Invalid listener : listener(0x%x), arg(0x%x)", &listener, &arg); + + const _AppLifecycleEventArg* pEventArg = dynamic_cast(&arg); + SysTryReturnVoidResult(NID_APP, pEventArg != null, E_INVALID_STATE, "Invalid arg : listener(0x%x), arg(0x%x)", &listener, &arg); + + pListener->OnAppLifecycleEventReceived(pEventArg->GetAppId(), pEventArg->GetAppLifecycleEventType()); +} + +} } // Tizen::App + diff --git a/src/app/inc/FApp_AppLifecycleEvent.h b/src/app/inc/FApp_AppLifecycleEvent.h new file mode 100755 index 0000000..e63d5cc --- /dev/null +++ b/src/app/inc/FApp_AppLifecycleEvent.h @@ -0,0 +1,50 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FApp_AppLifecycleEvent.h + * @brief This is the header file of _AppLifecycleEvent + */ + +#ifndef _FAPP_INTERNAL_APP_LIFECYCLE_EVENT_H_ +#define _FAPP_INTERNAL_APP_LIFECYCLE_EVENT_H_ + +#include +#include + +namespace Tizen { namespace App +{ + +/** +* @class _AppLifecycleEvent +* @brief This class contains application lifecycle event +* @since 2.2 +*/ +class _AppLifecycleEvent + : public Tizen::Base::Runtime::_Event +{ +public: + result Construct(void); + +protected: + void FireImpl(Tizen::Base::Runtime::IEventListener& lstener, const Tizen::Base::Runtime::IEventArg& arg); + +}; //_AppLifecycleEvent + +} } // Tizen::App + +#endif // _FAPP_INTERNAL_APP_LIFECYCLE_EVENT_H_ + diff --git a/src/app/inc/FApp_AppLifecycleEventArg.h b/src/app/inc/FApp_AppLifecycleEventArg.h new file mode 100755 index 0000000..b5655f0 --- /dev/null +++ b/src/app/inc/FApp_AppLifecycleEventArg.h @@ -0,0 +1,62 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FApp_AppLifecycleEventArg.h + * @brief This is the header file of _AppLifecycleEventArg class. + */ + +#ifndef _FAPP_INTERNAL_APP_LIFECYCLE_EVENT_ARG_H_ +#define _FAPP_INTERNAL_APP_LIFECYCLE_EVENT_ARG_H_ + +#include +#include +#include +#include + +#include "FApp_AppManagerEvent.h" + +namespace Tizen { namespace App +{ + +/** + * @class _AppLifecycleEventArg + * @brief + * @since 2.2 + * + */ +class _OSP_EXPORT_ _AppLifecycleEventArg + : public Tizen::Base::Object + , public Tizen::Base::Runtime::IEventArg +{ +public: + _AppLifecycleEventArg(void); + _AppLifecycleEventArg(const AppId& appId, _AppLifecycleEventType appType); + virtual ~_AppLifecycleEventArg(void); + + const AppId GetAppId(void) const; + _AppLifecycleEventType GetAppLifecycleEventType(void) const; + +private: + AppId __appId; + _AppLifecycleEventType __appLifecycleEventType; + +}; //_AppLifecycleEventArg + +} } // Tizen::App + +#endif // _FAPP_INTERNAL_APP_LIFECYCLE_EVENT_ARG_H_ + diff --git a/src/app/inc/FApp_AppManagerImpl.h b/src/app/inc/FApp_AppManagerImpl.h index ef49d07..fefdcda 100755 --- a/src/app/inc/FApp_AppManagerImpl.h +++ b/src/app/inc/FApp_AppManagerImpl.h @@ -34,10 +34,13 @@ #include #include #include +#include +#include #include "FApp_Types.h" #include "FApp_AppManagerEvent.h" #include "FApp_IAppManagerServiceEventListener.h" +#include "FApp_AppLifecycleEvent.h" namespace Tizen { namespace Base { @@ -61,6 +64,7 @@ class _ConditionManagerProxy; class _IAppManagerEventListener; class _IAppEventListener; class _AppManagerEventArg; +class _IAppLifecycleEventListener; class _AppLifecycleManager @@ -360,6 +364,8 @@ public: virtual result OnTerminateApplicationRequested(int clientId); + virtual result OnAppLifecycleEventReceived(int clientId, const AppId& appId, _AppLifecycleEventType appLifecycleEventType); + static void SetAppManagerService(_IAppManager* pAppManager ); _OSP_LOCAL_ Tizen::Base::Runtime::_LibraryImpl& GetUiLibraryImpl(void); @@ -382,6 +388,14 @@ public: result ClearUserPreferenceForAppControlResolution(const AppId& appId); + result AddAppLifecycleEventListener(_IAppLifecycleEventListener& listener); + + result RemoveAppLifecycleEventListener(_IAppLifecycleEventListener& listener); + + result RegisterAppForAppLifecycleEvent(const AppId& appId); + + result UnregisterAppForAppLifecycleEvent(const AppId& appId); + private: _OSP_LOCAL_ _AppManagerImpl(void); @@ -411,6 +425,11 @@ private: _AppLifecycleManager __lifeManager; _AppManagerEvent __appManagerEvent; Tizen::Base::Collection::LinkedListT __activeAppEventListenerList; + Tizen::App::_AppLifecycleEvent __appLifecycleEvent; + Tizen::Base::Collection::HashMapT __appListForAppLifecycle; + Tizen::Base::ComparerT __comparer; + Tizen::Base::StringHashCodeProvider __strHashCodeProvider; + Tizen::Base::Runtime::Mutex __mutex; friend class AppManager; friend class _AppControlImpl; diff --git a/src/app/inc/FApp_AppManagerIpcMessage.h b/src/app/inc/FApp_AppManagerIpcMessage.h index fa0ac1a..de90495 100755 --- a/src/app/inc/FApp_AppManagerIpcMessage.h +++ b/src/app/inc/FApp_AppManagerIpcMessage.h @@ -43,3 +43,6 @@ IPC_MESSAGE_CONTROL1(AppManager_OnEventReceived, Tizen::App::_AppManagerEventArg IPC_MESSAGE_CONTROL1(AppManager_AddEventListener, int) IPC_MESSAGE_CONTROL1(AppManager_RemoveEventListener, int) IPC_MESSAGE_CONTROL0(AppManager_OnTerminateApplicationRequested) +IPC_MESSAGE_CONTROL2(AppManager_OnAppLifecycleEventReceived, Tizen::App::AppId, int) +IPC_SYNC_MESSAGE_CONTROL1_1(AppManager_RegisterAppForAppLifecycleEvent, Tizen::App::AppId, result) +IPC_SYNC_MESSAGE_CONTROL1_1(AppManager_UnregisterAppForAppLifecycleEvent, Tizen::App::AppId, result) diff --git a/src/app/inc/FApp_AppManagerProxy.h b/src/app/inc/FApp_AppManagerProxy.h index 6408dbc..1cccff8 100755 --- a/src/app/inc/FApp_AppManagerProxy.h +++ b/src/app/inc/FApp_AppManagerProxy.h @@ -40,6 +40,9 @@ class _IAppManagerEventListener; class _IAppManagerServiceEventListener; class _AppManagerEventArg; +class _IAppLifecycleEventListener; + + class _OSP_EXPORT_ _AppManagerProxy : public _IAppManager , public Tizen::Io::_IIpcClientEventListener @@ -71,6 +74,10 @@ public: virtual result ClearUserPreferenceForAppControlResolution(const AppId& appId); + virtual result RegisterAppForAppLifecycleEvent(const AppId& appId, int clientId); + + virtual result UnregisterAppForAppLifecycleEvent(const AppId& appId, int clientId); + static _IAppManager* GetService(void); static void SetService(_IAppManager* pAppManager); @@ -88,6 +95,7 @@ private: bool OnEventReceived(const Tizen::App::_AppManagerEventArg& arg); void OnTerminateApplicationRequested(void); + void OnAppLifecycleEventReceived(const AppId& appId, int appLifecycleEventType); private: static _IAppManager* __pSelf; diff --git a/src/app/inc/FApp_IAppLifecycleEventListener.h b/src/app/inc/FApp_IAppLifecycleEventListener.h new file mode 100755 index 0000000..36706f9 --- /dev/null +++ b/src/app/inc/FApp_IAppLifecycleEventListener.h @@ -0,0 +1,56 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FApp_IAppLifecycleEventListener.h + * @brief This is the header file for _IAppLifecycleEventListener class. + */ + +#ifndef _FAPP_INTERNAL_IAPP_LIFECYCLE_EVENT_LISTENER_H_ +#define _FAPP_INTERNAL_IAPP_LIFECYCLE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace App { + +/** +* @interface _IAppLifecycleEventListener +* @brief This is a tagging interface that all event listeners must implement. +* +* The event listener can listen when the specific event, such as launch and terminate is fired. +* +*/ +class _IAppLifecycleEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + */ + virtual ~_IAppLifecycleEventListener() {} + + /** + * This method will be called when the application's lifecycle event gets triggerred. + */ + virtual void OnAppLifecycleEventReceived(const AppId& appId, Tizen::App::_AppLifecycleEventType type) = 0; + +}; // _IAppLifecycleEventListener + +}} //Tizen::App + +#endif // _FAPP_INTERNAL_IAPP_LIFECYCLE_EVENT_LISTENER_H_ + diff --git a/src/app/inc/FApp_IAppManager.h b/src/app/inc/FApp_IAppManager.h index 5108c76..a8e1bda 100755 --- a/src/app/inc/FApp_IAppManager.h +++ b/src/app/inc/FApp_IAppManager.h @@ -52,6 +52,10 @@ public: virtual bool IsUserPreferredAppForAppControlResolution(const AppId& appId) = 0; virtual result ClearUserPreferenceForAppControlResolution(const AppId& appId) = 0; + + virtual result RegisterAppForAppLifecycleEvent(const AppId& appId, int clientId) = 0; + virtual result UnregisterAppForAppLifecycleEvent(const AppId& appId, int clientId) = 0; + }; }} // Tizen::App diff --git a/src/app/inc/FApp_IAppManagerServiceEventListener.h b/src/app/inc/FApp_IAppManagerServiceEventListener.h old mode 100644 new mode 100755 index c9daf69..22c1c0e --- a/src/app/inc/FApp_IAppManagerServiceEventListener.h +++ b/src/app/inc/FApp_IAppManagerServiceEventListener.h @@ -45,6 +45,8 @@ class _IAppManagerServiceEventListener public: virtual result OnServiceEventReceived(int clientId, const _AppManagerEventArg& arg) = 0; virtual result OnTerminateApplicationRequested(int clientId) = 0; + virtual result OnAppLifecycleEventReceived(int clientId, const AppId& appId, _AppLifecycleEventType appLifecycleEventType) = 0; + }; // _IAppManagerServiceEventListener } } // Tizen::App diff --git a/src/app/inc/FApp_Types.h b/src/app/inc/FApp_Types.h old mode 100644 new mode 100755 index b7e9d8a..1ea292e --- a/src/app/inc/FApp_Types.h +++ b/src/app/inc/FApp_Types.h @@ -61,6 +61,12 @@ enum _AppEvent _APP_EVENT_RAISE, }; +enum _AppLifecycleEventType +{ + _APP_LIFECYCLE_EVENT_LAUNCH = 0, + _APP_LIFECYCLE_EVENT_TERMINATE, +}; + /** * @enum _ApphandlerType * Defines the application provider type