2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #ifndef _APP_SERVICE_H_
19 #define _APP_SERVICE_H_
23 #include <FAppTypes.h>
25 #include <FApp_IAppManagerEventListener.h>
27 namespace Tizen { namespace App
29 class _AppManagerStub;
30 class _ConditionManagerStub;
31 class _ContextManager;
32 class _CommunicationDispatcher;
33 class _PackageManagerStub;
34 class _NotificationManagerStub;
37 namespace Tizen { namespace Io
40 class _MmcStorageManagerStub;
43 namespace Tizen { namespace System
45 class _DeviceManagerService;
48 class _AccessoryManagerService;
53 * @brief This creates and initializes major system services such as channel, appmanager, and others.
54 * And ContextManager watchs running apps(processes) and callbacks to appmanager when app destroyed.
56 * @ remarks AppService is system service of OSP, and starts at first among them.
59 : public Tizen::App::ServiceApp
60 , public Tizen::App::Package::IPackageInstallationEventListener
61 , public Tizen::App::_IAppManagerEventListener
62 , virtual public Tizen::Base::Runtime::IEventListener
65 static Tizen::App::ServiceApp* CreateInstance(void);
68 virtual ~AppService();
70 virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
71 virtual bool OnAppInitialized(void);
72 virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
73 virtual void OnLowMemory(void);
74 virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
75 virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList *pArgs);
77 // IPackageInstallationEventListener
78 virtual void OnPackageInstallationCompleted(const Tizen::App::PackageId& packageId, Tizen::App::Package::PackageInstallationResult installationResult);
79 virtual void OnPackageUninstallationCompleted(const Tizen::App::PackageId& packageId, bool uninstallationResult);
80 virtual void OnPackageInstallationInProgress(const Tizen::App::PackageId& packageId, int progress);
82 static void OnPowerOffNotiReceived(void* pData);
85 bool InitializeIpc(void);
86 bool InitializeServices(void);
88 bool LaunchSystemServices(void);
89 bool LaunchUserServices(void);
90 bool LaunchChannelService(void);
91 bool LaunchSecurityService(void);
92 Tizen::Base::Collection::ArrayList* GetPackageEventArgsN(const Tizen::App::AppId& appId);
93 virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
94 virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
96 static int CreateProcess(const Tizen::Base::String& appId);
97 static result SetOomAdj(int pid, int adj);
100 class _TaskHandlerThread
101 : public Tizen::Base::Runtime::Thread
104 _TaskHandlerThread(AppService& mgr);
105 virtual ~_TaskHandlerThread(void);
107 virtual bool OnStart(void);
108 virtual void OnStop(void);
109 virtual void OnUserEventReceivedN(RequestId reqId, Tizen::Base::Collection::IList* pArgs);
115 Tizen::App::_CommunicationDispatcher* __pCommunicationDispatcher;
116 Tizen::App::_ContextManager* __pContextMgr;
117 Tizen::App::_AppManagerStub* __pAppManagerStub;
118 Tizen::App::_ConditionManagerStub* __pConditionManagerStub;
119 _TaskHandlerThread __handlerThread;
120 Tizen::System::_DeviceManagerService* __pDeviceManagerService;
121 Tizen::System::_SystemService* __pSystemService;
122 Tizen::System::_AccessoryManagerService* __pAccessoryManagerService;
123 Tizen::System::_AlarmService* __pAlarmService;
124 Tizen::App::_PackageManagerStub* __pPackageManagerStub;
125 Tizen::App::_NotificationManagerStub* __pNotificationManagerStub;
126 Tizen::Io::_MmcStorageManagerStub* __pMmcStorageManagerStub;