#include <FApp_Types.h>
#include <FApp_IAppEventListener.h>
-namespace Tizen { namespace Base { namespace Collection {
- class HashMap;
- class ArrayList;
- class Queue;
-} } }
+namespace Tizen { namespace Base { namespace Collection {
+class HashMap;
+class ArrayList;
+class Queue;
+}}}
namespace Tizen { namespace App {
class _AppContext
{
public:
- _AppContext(const PackageId& packageId,
- const Tizen::Base::String& executableName,
+ _AppContext(const AppId& appId,
_AppType appType,
int pid,
int ipcClientId,
Tizen::Base::String GetAppId(void) const;
public:
- Tizen::Base::String packageId;
- Tizen::Base::String executableName;
- _AppType appType;
- int pId;
- int ipcClientId;
- AppUiState uiState;
+ const AppId appId;
+ const _AppType appType;
+ const int pId;
+ const int ipcClientId;
bool isRegistered;
- bool isSystemService;
+ const bool isSystemService;
}; //_AppContext
class _IContextManagerEventListener
~_ContextManager(void);
result Construct(void);
- result Register(const PackageId& packageId, const Tizen::Base::String& executableName, _AppType appType, int pid, int ipcClientId, bool isSystemService);
+ result Register(const AppId& appId, _AppType appType, int pid, int ipcClientId, bool isSystemService);
result Unregister(int pid);
- const _AppContext* Find(const PackageId& packageId, const Tizen::Base::String& executableName) const;
+ 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 AppTerminationHanlder(int pid, const Tizen::Base::String& pkgId, const Tizen::Base::String& execName);
+ void AppTerminationHandler(int pid, const AppId& appId);
void Dump(void) const;
void AddSystemServiceApp(const AppId& appId) const;
void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
class _Util
{
public:
- static Tizen::Base::String QueryFeatureFromPackageManager(const AppId& appId, const Tizen::Base::String& execName, const Tizen::Base::String& feature);
+ static Tizen::Base::String QueryFeatureFromPackageManager(const AppId& appId, const Tizen::Base::String& feature);
};
private:
#include <FBaseSysLog.h>
#include <FIoFile.h>
#include <FAppTypes.h>
+#include <FAppPkgPackageAppInfo.h>
+
#include <FBase_StringConverter.h>
#include <FApp_Aul.h>
#include <FApp_AppManagerImpl.h>
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Base::Runtime;
+using namespace Tizen::App::Package;
using namespace Tizen::Io;
namespace Tizen { namespace App {
///////////////////////////////////////////////////
// _AppContext
///////////////////////////////////////////////////
-_AppContext::_AppContext(const PackageId& packageId, const String& executableName, _AppType appType, int pid, int ipcClientId, bool isSystemService)
-: packageId(packageId)
-, executableName(executableName)
+_AppContext::_AppContext(const AppId& appId, _AppType appType, int pid, int ipcClientId, bool isSystemService)
+: appId(appId)
, appType(appType)
, pId(pid)
, ipcClientId(ipcClientId)
-, uiState(APP_UI_STATE_BACKGROUND)
, isRegistered(true)
, isSystemService(isSystemService)
{
_AppContext::ToString(void) const
{
Tizen::Base::String ret;
- ret.Format(1024, L"%ls.%ls(pid:%d)", packageId.GetPointer(), executableName.GetPointer(), pId);
+ ret.Format(1024, L"%ls(pid:%d)", appId.GetPointer(), pId);
return ret;
}
String
_AppContext::GetAppId(void) const
{
- Tizen::Base::String ret;
- ret.Format(1024, L"%ls.%ls", packageId.GetPointer(), executableName.GetPointer());
- return ret;
+ return appId;
}
}
result
-_ContextManager::Register(const PackageId& pkgId, const String& executableName, _AppType appType, int pid, int ipcClientId, bool isSystemService )
+_ContextManager::Register(const AppId& appId, _AppType appType, int pid, int ipcClientId, bool isSystemService )
{
if( __appContexts[pid] != null)
{
- SysAssertf( isSystemService == true, "The application (app(%ls), pid:%d) is registered twice.", pkgId.GetPointer(), pid);
+ SysAssertf( isSystemService == true, "The application (app(%ls), pid:%d) is registered twice.", appId.GetPointer(), pid);
return E_SUCCESS;
}
- _AppContext* pAppContext = new (std::nothrow) _AppContext(pkgId, executableName, appType, pid, ipcClientId, isSystemService);
+ _AppContext* pAppContext = new (std::nothrow) _AppContext(appId, appType, pid, ipcClientId, isSystemService);
__appContexts[pid] = pAppContext;
+ const String pkgId = _PackageManagerImpl::GetPackageIdByAppId(appId);
+
String appRoot(L"/opt/usr/apps/");
appRoot.Append(pkgId);
String compatFile(appRoot);
{
_MmcStorageManagerService* pMmcMgr = _MmcStorageManagerService::GetInstance();
pMmcMgr->__pVirtualRootList->Add(new (std::nothrow) String(pkgId), new (std::nothrow) String(appRoot));
- SysLog(NID_APP, "Virtual root application (%ls) is registered.", pkgId.GetPointer());
+ SysLog(NID_APP, "Virtual root application (%ls) is registered.", appId.GetPointer());
}
// ==== set oom policy for ServiceApp
result r = E_SUCCESS;
- switch (GetOomAppType(pkgId, pid))
+ switch (GetOomAppType(appId, pid))
{
case OOM_APP_TYPE_SYSTEM:
break;
}
SysLog(NID_APP, "Set OOM : result is %s", GetErrorMessage(r));
- SysLog(NID_APP, "The %s (app(%ls), pid:%d) Registered.", isSystemService ? "application":"system service", pkgId.GetPointer(), pid);
+ SysLog(NID_APP, "The %s (app(%ls), pid:%d) Registered.", isSystemService ? "application":"system service", appId.GetPointer(), pid);
Dump();
return E_SUCCESS;
}
SysTryReturn(NID_APP, pAppContext != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "Unknown pid(%d).", pid);
pAppContext->isRegistered = false;
- SysLog(NID_APP, "(app(%ls), pid:%d) Unregistered.", pAppContext->packageId.GetPointer(), pid);
+ SysLog(NID_APP, "(app(%ls), pid:%d) Unregistered.", pAppContext->appId.GetPointer(), pid);
- AppTerminationHanlder( pAppContext->pId, pAppContext->packageId, pAppContext->executableName);
+ AppTerminationHandler(pAppContext->pId, pAppContext->appId);
if (__pEventListener != null )
{
SysLog(NID_APP, "__appContexts.erase(%d) returns (%d). It seems to be invalid.", pid, res);
}
- SysLog(NID_APP, "app info is removed (%ls, %d)", pAppContext->executableName.GetPointer(), pid);
+ SysLog(NID_APP, "app info is removed (%ls, %d)", pAppContext->appId.GetPointer(), pid);
Dump();
}
void
-_ContextManager::AppTerminationHanlder(int pid, const String& pkgId, const String& execName)
+_ContextManager::AppTerminationHandler(int pid, const AppId& appId)
{
SysLog(NID_APP, "Enter");
- const String& needToAutoRestartOnFailure = _Util::QueryFeatureFromPackageManager(pkgId, execName, L"AutoRestart");
+ const String& needToAutoRestartOnFailure = _Util::QueryFeatureFromPackageManager(appId, L"AutoRestart");
if (needToAutoRestartOnFailure == "True")
{
- String appId = pkgId + L'.' + execName;
-
if (IsSystemServiceApp(appId))
{
SysLog(NID_APP, "The application(%ls) is configured as AutoRestart, so It will be restarted.", appId.GetPointer());
}
const _AppContext*
-_ContextManager::Find(const PackageId& packageId, const Tizen::Base::String& executableName) const
+_ContextManager::Find(const AppId& appId) const
{
AppContexts::const_iterator it;
{
const _AppContext* const pAppContext = (*it).second;
- if (pAppContext != null && pAppContext->packageId == packageId && pAppContext->executableName == executableName)
+ if (pAppContext != null && pAppContext->appId == appId)
{
return pAppContext;
}
{
if ( pArray != null)
{
- pArray->Add(pAppContext->packageId);
+ pArray->Add(pAppContext->appId);
}
- logText.Append(pAppContext->packageId);
+ logText.Append(pAppContext->appId);
logText.Append(L", ");
}
}
__pEventListener->OnApplicationTerminated(appId);
_AppContext* pAppContext = __appContexts[pid];
- SysTryReturnVoidResult(NID_APP, pAppContext != null, E_INVALID_STATE, "Not registered pid(%d)", pid);
+ if (pAppContext == null)
+ {
+ SysLog(NID_APP, "Not registered pid(%d)", pid);
+ return;
+ }
if (pAppContext->isRegistered)
{
* _ContextManager::Util
*/
-/*String
-_ContextManager::_Util::GetExecNameFromPackageName(const String& packageName)
-{
- String execName;
- const String prefix(L"org.tizen.1234567890");
- const int prefixLen = prefix.GetLength();
- packageName.SubString(prefixLen, execName);
-
- return execName;
-}*/
-
String
-_ContextManager::_Util::QueryFeatureFromPackageManager(const String& appId, const String& execName, const String& feature)
+_ContextManager::_Util::QueryFeatureFromPackageManager(const AppId& appId, const String& feature)
{
- ArrayList* pFeatureList = Tizen::App::Package::_PackageManagerImpl::GetInstance()->GetPackageAppFeatureListN(appId, execName);
- String ret = L"";
-
- if (pFeatureList == null)
- {
- SysLog(NID_APP, "%ls does not have any feature.", appId.GetPointer());
- return ret;
- }
+ std::unique_ptr<PackageAppInfo> pInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
+ SysTryReturn(NID_APP, pInfo.get() != null, L"", E_SYSTEM, "Cannot acquire appInfo for %ls with feature %ls.", appId.GetPointer(), feature.GetPointer());
- for (int i = 0; i < pFeatureList->GetCount(); i++)
+ const _PackageAppInfoImpl* pInfoImpl = _PackageAppInfoImpl::GetInstance(pInfo.get());
+ if (pInfoImpl == null)
{
- const Tizen::App::Package::_AppFeatureInfoImpl* pInfo = static_cast<const Tizen::App::Package::_AppFeatureInfoImpl*>(pFeatureList->GetAt(i));
- SysLog(NID_APP, "%ls, %ls", pInfo->GetName().GetPointer(), pInfo->GetValue().GetPointer());
- if (pInfo != null && pInfo->GetName() == feature)
- {
- ret = pInfo->GetValue();
- break;
- }
+ SysLog(NID_APP, "No impl instance for %ls.", appId.GetPointer());
+ return L"";
}
- pFeatureList->RemoveAll(true);
- delete pFeatureList;
-
- return ret;
+ return pInfoImpl->GetAppFeature(feature);
}
} } // Tizen::App