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.
19 * @file FApp_ContextManager.h
20 * @brief This is the header file of the _ContextManager class.
22 * This header file contains the declarations of the _ContextManager class.
25 #ifndef _FAPP_INTERNAL_CONTEXT_MANAGER_H_
26 #define _FAPP_INTERNAL_CONTEXT_MANAGER_H_
30 #include <FBaseObject.h>
31 #include <FBaseString.h>
32 #include <FBaseColArrayListT.h>
33 #include <FAppTypes.h>
34 #include <FBaseRtIEventListener.h>
36 #include <FApp_Types.h>
38 namespace Tizen { namespace Base { namespace Collection { class ArrayList; } } }
40 namespace Tizen { namespace App {
45 OOM_APP_TYPE_LAUNCHING,
46 OOM_APP_TYPE_FOREGROUND_HIGH,
47 OOM_APP_TYPE_SERVICE_HIGH,
48 OOM_APP_TYPE_FOREGROUND,
49 OOM_APP_TYPE_SERVICE_MID,
50 OOM_APP_TYPE_BACKGROUND_HIGH,
51 OOM_APP_TYPE_SERVICE_LOW,
52 OOM_APP_TYPE_BACKGROUND
58 _AppContext(const AppId& appId,
59 const Tizen::Base::String& executableName,
70 Tizen::Base::String ToString(void) const;
74 Tizen::Base::String executableName;
83 class _IContextManagerEventListener
84 : virtual public Tizen::Base::Runtime::IEventListener
87 virtual void OnApplicationTerminated(const _AppContext& appInfo) = 0;
91 * @class _ContextManager
99 typedef std::map<int, _AppContext*> AppContexts;
102 _ContextManager(void);
103 ~_ContextManager(void);
105 result Construct(void);
106 result Register(const PackageId& appId, const Tizen::Base::String& executableName, _AppType appType, int pid, int ipcClientId, bool isSystemService);
107 result Unregister(int pid);
108 const _AppContext* Find(const AppId& appId, const Tizen::Base::String& executableName) const;
109 const _AppContext* Find(int pid);
110 result GetAppListN(Tizen::Base::Collection::ArrayList* pArray) const;
111 void SetEventListener(_IContextManagerEventListener& listener);
113 void AbonormalAppTerminationHanlder(int pid, const AppId& appId, const Tizen::Base::String& execName);
114 static int OnAppTerminate(int pid, void *data);// app_dead_signal_listener
115 void Dump(void) const;
119 _ContextManager(const _ContextManager& rhs);
120 _ContextManager& operator=(const _ContextManager& rhs);
121 _OomAppType GetOomAppType(const AppId& appId, const int pid) const;
122 bool IsErrorProneApp(const AppId& appId) const;
126 * This is static helper class
131 static Tizen::Base::String QueryFeatureFromPackageManager(const AppId& appId, const Tizen::Base::String& execName, const Tizen::Base::String& feature);
132 // static Tizen::Base::String GetExecNameFromPackageName(const Tizen::Base::String& packageName);
136 const unsigned long __magic;
137 AppContexts __appContexts;
138 _IContextManagerEventListener* __pEventListener;
139 Tizen::Base::Collection::ArrayListT<Tizen::Base::String> __errorProneAppIds;
144 #endif //_FAPP_INTERNAL_CONTEXT_MANAGER_H_