INCLUDE_DIRECTORIES (
src/system
- src/setting
- /usr/include/osp/locales/inc
- /usr/include/osp/app
- /usr/include/osp/base
- /usr/include/osp/io
- /usr/include/osp/system
- /usr/include/osp/security
/usr/include/osp/shell
/usr/include/osp/shell/core
inc
#ifndef _APP_SERVICE_H_
#define _APP_SERVICE_H_
-
#include <FSystem.h>
#include <FAppTypes.h>
#include <FAppServiceApp.h>
#include <FSysIBootEventListener.h>
#include <FApp_IAppManagerEventListener.h>
+#include <FApp_ContextManager.h>
namespace Tizen { namespace App
{
class _AppManagerStub;
class _ConditionManagerStub;
-class _ContextManager;
class _CommunicationDispatcher;
class _PackageManagerStub;
+class _IAppManagerServiceEventListener;
}}
namespace Tizen { namespace Io
{
-class _IpcServer;
class _MmcStorageManagerStub;
}}
namespace Tizen { namespace System
{
-class _AlarmService;
class _AccessoryManagerService;
class _SystemService;
}}
{
class _LockManagerStub;
}}
+
/**
* @class AppService
* @brief This creates and initializes major system services such as channel, appmanager, and others.
void ReadySystemServices(void);
void RegisterPreloadedAppCondition(void);
Tizen::Base::Collection::ArrayList* GetPackageEventArgsN(const Tizen::App::PackageId& packageId);
+
virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
Tizen::App::_PackageManagerStub* __pPackageManagerStub;
Tizen::Io::_MmcStorageManagerStub* __pMmcStorageManagerStub;
Tizen::Shell::_LockManagerStub* __pLockManagerStub;
-
}; // AppService
#endif
namespace Tizen { namespace App {
+
class _IAppManagerServiceEventListener;
+class _AppManagerEventArg;
/**
* @class _AppManagerService
virtual result RegisterApplication(const AppId& appId, _AppType appType, int pid, int clientId);
virtual result UnregisterApplication(int pid);
- virtual result InitEventListener( _IAppManagerServiceEventListener* pListener);
- virtual result AddEventListener(int clientId);
- virtual result RemoveEventListener(int clientId);
- virtual void OnApplicationTerminated(const _AppContext& appInfo);
+ virtual result InitEventListener(_IAppManagerServiceEventListener* pListener);
+
virtual void OnApplicationLaunched(const AppId& appId);
- virtual void OnApplicationTerminated(const AppId& appId);
+ virtual void OnApplicationTerminated(const AppId& appId);
virtual bool IsUserPreferredAppForAppControlResolution(const AppId& appId);
virtual result ClearUserPreferenceForAppControlResolution(const AppId& appId);
private:
result SendEventToAllListeners(const _AppManagerEventArg& arg);
-private:
- typedef Tizen::Base::Collection::HashMapT<int, _IAppManagerServiceEventListener*> _AppManagerServiceEventListeners;
- typedef Tizen::Base::Collection::IMapEnumeratorT <int, _IAppManagerServiceEventListener*> _AppManagerServiceEventListenerEnum;
+ void Dump(void);
+private:
_ContextManager* __pContextMgr;
- _AppManagerServiceEventListeners __eventListeners;
- _IAppManagerServiceEventListener* __pStub;
- _IAppManagerServiceEventListener* __pProxy;
+ _IAppManagerServiceEventListener* __pStub;
Tizen::Base::Collection::MultiHashMapT<AppId, int> __appListForAppLifecycleEvent;
- Tizen::Base::ComparerT<Tizen::Base::String> __comparer;
- Tizen::Base::StringHashCodeProvider __strHashCodeProvider;
- void Dump(void);
-friend class UTs_AppManagerServiceP;
+ friend class UTs_AppManagerServiceP;
}; //_AppManagerService
}}//Tizen::App
bool OnTerminateApplication(const AppId& appID, result *pRes);
bool OnRegisterApplication(const AppId& appId, int appType, int pid);
bool OnUnregisterApplication(int pid);
- bool OnAddEventListener(int pid);
- bool OnRemoveEventListener(int pid);
// send message to client
virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
// to client
- virtual result OnServiceEventReceived(int clientId, const _AppManagerEventArg& arg);
virtual result OnTerminateApplicationRequested(int clientId);
virtual result OnAppLifecycleEventReceived(int clientId, const AppId& appId, _AppLifecycleEventType appLifecycleEventType);
#include <FAppTypes.h>
#include <FBaseRtIEventListener.h>
#include <FBaseRtITimerEventListener.h>
+
#include <FApp_Types.h>
#include <FApp_IAppEventListener.h>
+#include <FApp_AppManagerEvent.h>
namespace Tizen { namespace Base { namespace Collection {
class HashMap;
namespace Tizen { namespace App {
+class _IAppManagerEventListener;
+
+
enum _OomAppType
{
OOM_APP_TYPE_SYSTEM,
: virtual public Tizen::Base::Runtime::IEventListener
{
public:
- virtual void OnApplicationTerminated(const _AppContext& appInfo) = 0;
virtual void OnApplicationTerminated(const AppId& appId) = 0;
virtual void OnApplicationLaunched(const AppId& appId) = 0;
};
* @class _ContextManager
* @brief
* @since 2.1
- *
- *
*/
class _ContextManager
: public Tizen::Base::Runtime::ITimerEventListener
, public Tizen::App::_IAppEventListener
- , public Tizen::Base::Object
{
typedef std::map<int, _AppContext*> AppContexts;
const _AppContext* Find(const AppId& appId) const;
const _AppContext* Find(int pid);
result GetAppListN(Tizen::Base::Collection::ArrayList* pArray) const;
+
void SetEventListener(_IContextManagerEventListener& listener);
void AppTerminationHandler(int pid, const AppId& appId);
void OnApplicationLaunched(const AppId& appId, int pid);
void OnApplicationTerminated(const AppId& appId, int pid);
+ void FireAppRegistrationEvent(const AppId& appId, _AppType appType, int pid);
+ result AddAppRegistrationEvent(_IAppManagerEventListener& listener);
+ result RemoveAppRegistrationEvent(_IAppManagerEventListener& listener);
+
private:
_ContextManager(const _ContextManager& rhs);
_ContextManager& operator=(const _ContextManager& rhs);
+
_OomAppType GetOomAppType(const AppId& appId, const int pid) const;
bool IsErrorProneApp(const AppId& appId) const;
bool IsSystemServiceApp(const AppId& appId) const;
Tizen::Base::Collection::ArrayList* __pSystemServiceAppIds;
Tizen::Base::Runtime::Timer* __pTimer;
Tizen::Base::Collection::Queue* __pRequestRestartAppIds;
+ _AppManagerEvent __appManagerEvent;
}; //_ContextManager
} } // Tizen::App
Requires(post): coreutils
Requires(post): /usr/bin/vconftool
Requires(post): ss-server
+Requires(preun): /usr/bin/systemctl
+Requires(post): /usr/bin/systemctl
%description
osp application service
%define tizen_author_sign 1
%define tizen_dist_sign 1
+%preun
+if [ $1 == 0 ]; then
+ systemctl stop boot-osp.service
+fi
+
%post
#/bin/rm -f /etc/ld.so.cache
#/sbin/ldconfig
chsmack -a aospd00043 /usr/apps/aospd00043/lib
fi
+systemctl daemon-reload
+if [ $1 == 1 ]; then
+ systemctl restart boot-osp.service
+fi
+
%files
%manifest osp-app-service.manifest
/usr/share/license/%{name}
_AlarmConditionHandler* pAlarmCondHandler = null;
_AppLaunchCondition* pAppLaunchCondition = null;
_AppLaunchCondition* pNewAppLaunchCondition;
- IMapEnumerator* pMapEnum;
- //IEnumerator* pEnum;
+ IMapEnumerator* pMapEnum = null;
Tizen::Base::Collection::HashMap updateList;
SysLog(NID_SYS, "Alarm setting event cb is invoked");
_Aul::SetPowerOffNotiListener(OnPowerOffNotiReceived, this);
- result r = _AppManagerImpl::GetInstance()->AddEventListener(*this);
- SysAssertf(!IsFailed(r), "[%s] Failed to add event listener.", GetErrorMessage(r));
+ if (__pContextMgr)
+ {
+ __pContextMgr->AddAppRegistrationEvent(*this);
+ }
vconf_set_int(VCONFKEY_APPSERVICE_STATUS, 1);
void
AppService::OnApplicationLaunched(const AppId& appId, Tizen::App::_AppType type)
{
- SysLog(NID_APP, "Enter. AppId(%ls)",appId.GetPointer());
- //SysAssert(false);
+ SysLog(NID_APP, "Enter. AppId(%ls)",appId.GetPointer());
+
static bool channelServiceLaunched = false;
static bool securityServiceLaunched = false;
if (securityServiceLaunched && channelServiceLaunched)
{
- _AppManagerImpl::GetInstance()->RemoveEventListener(*this);
+ if (__pContextMgr)
+ {
+ __pContextMgr->RemoveAppRegistrationEvent(*this);
+ }
+
InitializeServices();
LaunchSystemServices();
SysLog(NID_APP, "Do nothing.");
}
+
void
AppService::OnBootCompleted(void)
{
*/
#include <FBaseSysLog.h>
+#include <FBaseString.h>
#include <FBaseColIListT.h>
+#include <FBaseColIMapT.h>
+#include <FBaseColIMultiMapT.h>
+#include <FBaseColHashMapT.h>
+#include <FBaseColMultiHashMapT.h>
+#include <FBaseColIMapEnumeratorT.h>
+#include <FBaseColIHashCodeProviderT.h>
+
#include <FApp_AppInfo.h>
#include <FApp_Aul.h>
#include <FApp_AppManagerEventArg.h>
#include <FApp_IAppManagerServiceEventListener.h>
+#include <FApp_TemplateUtil.h>
#include "FAppPkg_PackageManagerImpl.h"
#include "FApp_ContextManager.h"
_AppManagerService::_AppManagerService(void)
: __pContextMgr(null)
, __pStub(null)
-, __pProxy(null)
{
SysLog(NID_APP, "");
}
__pContextMgr = pContextMgr;
__pContextMgr->SetEventListener(*this);
__pStub = pStub;
- __eventListeners.Construct();
- __appListForAppLifecycleEvent.Construct(0, 0, __strHashCodeProvider, __comparer);
+ __appListForAppLifecycleEvent.Construct(0, 0);
SysLog(NID_APP, "Exit\n");
return E_SUCCESS;
else
{
SysLog(NID_APP, "Sending event for %ls(%d).", appId.GetPointer(), pid);
-
- _AppManagerEventArg arg(appId, appType, _AppManagerEvent::_APP_MANAGER_EVENT_LAUNCHED);
- SendEventToAllListeners(arg);
+ __pContextMgr->FireAppRegistrationEvent(appId, appType, pid);
}
SysTryReturnResult(NID_APP, __pContextMgr != null, E_INVALID_STATE, "pContextMgr should not be null!");
result
_AppManagerService::InitEventListener( _IAppManagerServiceEventListener* pListener)
{
- __pProxy = pListener;
+ __pStub = pListener;
return E_SUCCESS;
}
-result
-_AppManagerService::AddEventListener(int clientId)
-{
- return __eventListeners.Add(clientId, null);
-}
-
-result
-_AppManagerService::RemoveEventListener(int clientId)
-{
- return __eventListeners.Remove(clientId);
-}
-
-void
-_AppManagerService::OnApplicationTerminated(const _AppContext& appInfo)
-{
- if ( appInfo.pId == _AppInfo::GetProcessId() )
- {
- SysLog(NID_APP, "Service itself is terminated.");
- return;
- }
-
- RemoveEventListener(appInfo.ipcClientId);
-
- _AppManagerEventArg arg(appInfo.appId, appInfo.appType, _AppManagerEvent::_APP_MANAGER_EVENT_TERMINATED);
- SendEventToAllListeners(arg);
-}
-
-result
-_AppManagerService::SendEventToAllListeners(const _AppManagerEventArg& arg)
-{
- _AppManagerServiceEventListenerEnum* pEnum = __eventListeners.GetMapEnumeratorN();
-
- result r = GetLastResult();
- SysTryReturn(NID_APP, pEnum != null, r, r, "[%s] Propagated.", GetErrorMessage(r));
-
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- int clientId = -1;
- r = pEnum->GetKey(clientId);
- SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagated.", GetErrorMessage(r));
-
- _IAppManagerServiceEventListener* pListener = (clientId == -1) ? __pProxy : __pStub;
-
- if ( pListener != null )
- {
- r = pListener->OnServiceEventReceived(clientId, arg);
- SysTryLog(NID_APP, !IsFailed(r), "[%s] OnServiceEventReceived fails.", GetErrorMessage(r));
- }
- }
-
- delete pEnum;
- return E_SUCCESS;
-
-CATCH:
- delete pEnum;
- return r;
-}
-
void
_AppManagerService::Dump(void)
{
// server to client message
result
-_AppManagerStub::OnServiceEventReceived(const int clientId, const _AppManagerEventArg& arg)
-{
- SysTryReturnResult(NID_APP, __pIpcServer != null, E_INVALID_STATE, "__pIpcServer is null.");
-
- result r = __pIpcServer->SendResponse(clientId, new AppManager_OnEventReceived(arg));
- SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
-
- return E_SUCCESS;
-}
-
-result
_AppManagerStub::OnTerminateApplicationRequested(int clientId)
{
SysTryReturnResult(NID_APP, __pIpcServer != null, E_INVALID_STATE, "__pIpcServer is null.");
return true;
}
-bool
-_AppManagerStub::OnAddEventListener(int pid)
-{
- SysTryReturn(NID_APP, __pIpcServer != null, true, E_INVALID_STATE, "__pIpcServer should not be null!");
-
- __pAppManagerService->AddEventListener(__pIpcServer->GetClientId());//, this);
- return true;
-}
-
-bool
-_AppManagerStub::OnRemoveEventListener(int pid)
-{
- SysTryReturn(NID_APP, __pIpcServer != null, true, E_INVALID_STATE, "__pIpcServer should not be null!");
-
- __pAppManagerService->RemoveEventListener(__pIpcServer->GetClientId());//, this);
- return true;
-}
-
void
_AppManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message)
IPC_MESSAGE_HANDLER_EX(AppManager_TerminateApplication, &server, OnTerminateApplication)
IPC_MESSAGE_HANDLER_EX(AppManager_RegisterApplication, &server, OnRegisterApplication)
IPC_MESSAGE_HANDLER_EX(AppManager_UnregisterApplication, &server, OnUnregisterApplication)
- IPC_MESSAGE_HANDLER_EX(AppManager_AddEventListener, &server, OnAddEventListener)
- IPC_MESSAGE_HANDLER_EX(AppManager_RemoveEventListener, &server, OnRemoveEventListener)
IPC_MESSAGE_HANDLER_EX(AppManager_IsUserPreferredAppForAppControlResolution, &server, OnIsUserPreferredAppForAppControlResolution)
IPC_MESSAGE_HANDLER_EX(AppManager_ClearUserPreferenceForAppControlResolution, &server, OnClearUserPreferenceForAppControlResolution)
IPC_MESSAGE_HANDLER_EX(AppManager_RegisterAppForAppLifecycleEvent, &server, OnRegisterAppForAppLifecycleEvent)
if (IsFailed(*pResException))
{
- SysLog(NID_APP, "[E_PRIVILEGE_DENIED]The application(%ls) does not have the privilege to call this method.", __pIpcServer->GetClientApplicationId().GetPointer());
+ SysLog(NID_APP, "[E_PRIVILEGE_DENIED] The application(%ls) does not have the privilege to call this method.", __pIpcServer->GetClientApplicationId().GetPointer());
*pResException = E_PRIVILEGE_DENIED;
return true;
}
#include <cstdio>
#include <cerrno>
-#include <dlfcn.h>
#include <string>
#include <FBaseColArrayList.h>
#include "FApp_ContextManager.h"
#include "FIo_MmcStorageManagerService.h"
#include "FApp_AulServer.h"
-#include "FApp_AppManagerImpl.h"
+#include "FApp_AppManagerEventArg.h"
+#include "FApp_IAppManagerEventListener.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
r = __pRequestRestartAppIds->Construct();
SysTryReturnResult(NID_APP, !IsFailed(r), r, "Queue Construct failed");
-
+
+ __appManagerEvent.Construct();
return E_SUCCESS;
}
AppTerminationHandler(pAppContext->pId, pAppContext->appId);
- if (__pEventListener != null )
- {
- __pEventListener->OnApplicationTerminated(*pAppContext);
- }
-
int res = __appContexts.erase(pid);
if (res != 1)
SysLog(NID_APP, "LaunchedApp(%ls)", appId.GetPointer());
__pEventListener->OnApplicationLaunched(appId);
}
+
void
_ContextManager::OnApplicationTerminated(const AppId& appId, int pid)
{
}
}
+void
+_ContextManager::FireAppRegistrationEvent(const AppId& appId, _AppType appType, int pid)
+{
+ _AppManagerEventArg* pArg = new (std::nothrow) _AppManagerEventArg(appId, appType, _AppManagerEvent::_APP_MANAGER_EVENT_LAUNCHED);
+
+ if (pArg)
+ {
+ __appManagerEvent.FireAsync(*pArg);
+ }
+}
+
+result
+_ContextManager::AddAppRegistrationEvent(_IAppManagerEventListener& listener)
+{
+ return __appManagerEvent.AddListener(listener, false);
+}
+
+result
+_ContextManager::RemoveAppRegistrationEvent(_IAppManagerEventListener& listener)
+{
+ return __appManagerEvent.RemoveListener(listener);
+}
+
+
/*
* _ContextManager::Util
*/
static const wchar_t* _SYSTEM_COMMAND_GET_IMEI_INTERNAL = L"osp.system.command.get.imei.internal";
static const wchar_t* _SYSTEM_COMMAND_GET_DUID_INTERNAL = L"osp.system.command.get.duid.internal";
- static const wchar_t* _SYSTEM_COMMAND_SYSTEM = L"osp.system.command.system";
-
static const wchar_t* _SYSTEM_RESULT_OK = L"osp.system.result.ok";
static const wchar_t* _SYSTEM_RESULT_ERROR = L"osp.system.result.error";
static const wchar_t* _SYSTEM_RESULT_INVALID = L"osp.system.result.invalid";
static const wchar_t* _SYSTEM_RESULT_PRIVILEGED = L"osp.system.result.privilege";
- static const wchar_t* _NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
- static const wchar_t* _NETWORK_TELEPHONY = L"http://tizen.org/feature/network.telephony";
- static const wchar_t* _NETWORK_WIFI = L"http://tizen.org/feature/network.wifi";
static const int _SYSTEM_COMMAND_ID = 1;
static const int _SYSTEM_COMMAND_ARG = 2;
}
_SystemService::~_SystemService()
{
- int ret = 0;
+ //int ret = 0;
result r = E_SUCCESS;
_AppManagerImpl* pAppManagerImpl = null;
SysTryCatch(NID_SYS, __pCommunicationDispatcher != null, r = E_SYSTEM, E_SYSTEM, "_CommunicationDispatcher is not ready");