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 * @file FAppPkg_PackageManagerImpl.cpp
19 * @brief This is the implementation for the _PackageManagerImpl class.
27 #include <unique_ptr.h>
29 #include <package-manager-types.h>
31 #include <FAppPkgPackageManager.h>
32 #include <FAppPkgPackageAppInfo.h>
33 #include <FAppPkgPackageInfo.h>
34 #include <FAppPkgIPackageInstallationEventListener.h>
35 #include <FAppPkgIPackageInstallationResponseListener.h>
36 #include <FAppPkgIPackageUninstallationResponseListener.h>
37 #include <FBaseSysLog.h>
39 #include <FIoRegistry.h>
40 #include <FSysSystemTime.h>
41 #include <FBase_StringConverter.h>
43 #include "FAppPkg_PackageManagerImpl.h"
44 #include "FAppPkg_PackageInfoImpl.h"
45 #include "FAppPkg_PackageAppInfoImpl.h"
46 #include "FAppPkg_PackageParser.h"
47 #include "FApp_AppInfo.h"
48 #include "FApp_PackageManagerProxy.h"
50 using namespace Tizen::Base;
51 using namespace Tizen::Base::Runtime;
52 using namespace Tizen::Base::Collection;
53 using namespace Tizen::Io;
54 using namespace Tizen::System;
56 namespace Tizen { namespace App { namespace Package
59 PackageManager* pPackageManagerInstance = null;
61 Tizen::Base::Collection::HashMap _PackageManagerImpl::__installationList;
64 _PackageManagerEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
66 IPackageInstallationEventListener* pListener = dynamic_cast<IPackageInstallationEventListener*> (&listener);
67 SysTryReturnVoidResult(NID_APP, pListener != null, E_OUT_OF_MEMORY, "pListener instance must not be null.");
69 const _PackageManagerEventArg* pArg = dynamic_cast<const _PackageManagerEventArg*>(&arg);
70 SysTryReturnVoidResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "pArg instance must not be null.");
72 if (pArg->__eventKey == L"end")
74 if (pArg->__eventValue == L"ok")
78 SysLog(NID_APP, "Installation is Completed. [PackageId = %ls]", pArg->__packageId.GetPointer());
79 pListener->OnPackageInstallationCompleted(pArg->__packageId, PACKAGE_INSTALLATION_RESULT_SUCCESS);
83 SysLog(NID_APP, "Uninstallation is Completed. [PackageId = %ls]", pArg->__packageId.GetPointer());
84 pListener->OnPackageUninstallationCompleted(pArg->__packageId, true);
91 SysLog(NID_APP, "Installation is Completed(Error). [PackageId = %ls]", pArg->__packageId.GetPointer());
92 pListener->OnPackageInstallationCompleted(pArg->__packageId, PACKAGE_INSTALLATION_RESULT_INVALID_PACKAGE);
96 SysLog(NID_APP, "Uninstallation is Completed(Error). [PackageId = %ls]", pArg->__packageId.GetPointer());
97 pListener->OnPackageUninstallationCompleted(pArg->__packageId, false);
101 else if (pArg->__eventKey == L"install_percent")
103 std::unique_ptr<char[]> pProgress(_StringConverter::CopyToCharArrayN(pArg->__eventValue));
106 sscanf(pProgress.get(), "%d", &progress);
108 SysLog(NID_APP, "InstallationInProgress [%d]", progress);
109 pListener->OnPackageInstallationInProgress(pArg->__packageId, progress);
114 _PackageManagerImpl::GetPackageIdByAppId(const AppId& appId)
116 SysTryReturn(NID_APP, appId.IsEmpty() == false, L"", E_INVALID_ARG, "appId is empty");
120 if (appId.StartsWith(L".", 10) == true)
122 appId.SubString(0, 10, packageId);
127 char* pPackageId = null;
128 pkgmgrinfo_appinfo_h pAppInfoHandle = null;
130 std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
131 SysTryReturn(NID_APP, pAppId, L"", E_OUT_OF_MEMORY, "pAppId is null");
133 result = pkgmgrinfo_appinfo_get_appinfo(pAppId.get(), &pAppInfoHandle);
134 SysTryReturn(NID_APP, result == 0, L"", E_PKG_NOT_INSTALLED, "pkgmgrinfo_appinfo_get_appinfo() failed. result=[%d], appId=[%s]", result, pAppId.get());
136 result = pkgmgrinfo_appinfo_get_pkgname(pAppInfoHandle, &pPackageId);
138 packageId.Append(pPackageId);
142 pkgmgrinfo_appinfo_destroy_appinfo(pAppInfoHandle);
146 SysLog(NID_APP, "appId = [%ls], packageId = [%ls]", appId.GetPointer(), packageId.GetPointer());
152 _PackageManagerImpl::AddEventListener(IPackageInstallationEventListener* pListener, int priority)
154 SysTryReturnResult(NID_APP, (priority < 3) && (priority >= 0), E_INVALID_ARG, "priority is invalid.");
156 result r = E_SUCCESS;
159 std::unique_ptr< IEnumeratorT<_PackageManagerEvent*> > pEnum(__packageEventListenerList.GetEnumeratorN());
160 SysTryReturnResult(NID_APP, pEnum, E_OUT_OF_MEMORY, "The memory is insufficient.");
162 while (pEnum->MoveNext() == E_SUCCESS)
164 _PackageManagerEvent* pEvent = null;
165 pEnum->GetCurrent(pEvent);
168 if (pEvent->__pListener == pListener)
170 SysLog(NID_APP, "The event listener already exist. listener = [0x%x]", pListener);
171 return E_OBJ_ALREADY_EXIST;
176 if (__pListeningClient == null)
178 __pListeningClient = pkgmgr_client_new(PC_LISTENING);
179 SysTryReturnResult(NID_APP, __pListeningClient != null, E_SYSTEM, "pkgmgr_client_new(PC_LISTENING) failed");
181 res = pkgmgr_client_listen_status(__pListeningClient, PackageEventHandler, this);
182 if (res < PKGMGR_R_OK)
184 pkgmgr_client_free(__pListeningClient);
185 __pListeningClient = null;
187 if (res == PKGMGR_R_EINVAL)
189 SysLog(NID_APP, "pkgmgr_client_listen_status() returns ARGV error");
190 return E_INVALID_ARG;
192 else if (res == PKGMGR_R_ECOMM)
194 SysLog(NID_APP, "pkgmgr_client_listen_status() returns COMM error");
196 else if (res == PKGMGR_R_ETIMEOUT)
198 SysLog(NID_APP, "pkgmgr_client_listen_status() returns TIME_OUT error");
200 else if (res == PKGMGR_R_ERROR)
202 SysLog(NID_APP, "pkgmgr_client_listen_status() returns Unknown error");
206 SysLog(NID_APP, "pkgmgr_client_listen_status() returns Unknown error, res = %d", res);
213 _PackageManagerEvent* pEvent = new (std::nothrow) _PackageManagerEvent();
214 SysTryReturnResult(NID_APP, pEvent != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
216 r = pEvent->Construct();
217 SysTryReturnResult(NID_APP, r == E_SUCCESS, E_SYSTEM, "pEvent->Construct() failed.");
219 pEvent->__pListener = pListener;
221 r = pEvent->AddListener(*pListener, true);
222 SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "pEvent->AddListener() failed. [%s]", GetErrorMessage(r));
224 r = __packageEventListenerList.Add(pEvent);
225 SysTryReturnResult(NID_APP, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
227 SysLog(NID_APP, "Add PackageInstallationEventListener = [0x%x]", pListener);
232 _PackageManagerImpl::RemoveEventListener(IPackageInstallationEventListener* pListener)
234 std::unique_ptr< IEnumeratorT<_PackageManagerEvent*> > pEnum(__packageEventListenerList.GetEnumeratorN());
235 SysTryReturnResult(NID_APP, pEnum, E_OUT_OF_MEMORY, "The memory is insufficient.");
237 result r = E_SUCCESS;
239 while (pEnum->MoveNext() == E_SUCCESS)
241 _PackageManagerEvent* pEvent = null;
242 pEnum->GetCurrent(pEvent);
245 if (pEvent->__pListener == pListener)
247 r = __packageEventListenerList.Remove(pEvent);
248 SysTryReturnResult(NID_APP, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
252 SysLog(NID_APP, "Remove PackageInstallationEventListener = [0x%x]", pListener);
258 return E_OBJ_NOT_FOUND;
262 _PackageManagerImpl::GetPackageInfoN(const PackageId& packageId) const
264 SysTryReturn(NID_APP, packageId.IsEmpty() == false, null, E_INVALID_ARG, "[E_INVALID_ARG] packageId is empty.");
265 SysTryReturn(NID_APP, packageId.GetLength() < NATIVE_APP_MAX_APPID_LENGTH, null, E_INVALID_ARG, "packageId is invalid.(length)");
267 result r = E_SUCCESS;
268 PackageInfo* pPackageInfo = null;
270 pPackageInfo = new (std::nothrow) PackageInfo;
271 SysTryReturn(NID_APP, pPackageInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageInfo instance must not be null.");
273 _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
274 r = pPackageInfoImpl->Construct(packageId);
275 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[E_PKG_NOT_INSTALLED] packageId (%ls) is not found.", packageId.GetPointer());
285 _PackageManagerImpl::GetPackageAppInfoN(const AppId& appId) const
287 SysTryReturn(NID_APP, appId.IsEmpty() == false, null, E_INVALID_ARG, "[E_INVALID_ARG] appId is empty.");
289 result r = E_SUCCESS;
290 PackageAppInfo* pPackageAppInfo = null;
292 pPackageAppInfo = new (std::nothrow) PackageAppInfo;
293 SysTryReturn(NID_APP, pPackageAppInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageAppInfo instance must not be null.");
295 _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo);
296 r = pPackageAppInfoImpl->Construct(appId);
297 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[E_PKG_NOT_INSTALLED] appId (%ls) is not found.", appId.GetPointer());
299 return pPackageAppInfo;
302 delete pPackageAppInfo;
307 _PackageManagerImpl::GetPackageInfoListN(void) const
309 result r = E_SUCCESS;
311 ArrayList* pList = null;
313 pList = new (std::nothrow) ArrayList();
314 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
317 res = pkgmgrinfo_pkginfo_get_list(PackageInfoEventHandler, pList);
320 SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_list() is failed. result = [%d]", res);
322 pList->RemoveAll(true);
331 _PackageManagerImpl::IsPackageInstalled(const PackageId& packageId) const
333 SysTryReturn(NID_APP, packageId.IsEmpty() == false, false, E_INVALID_ARG, "packageId is empty");
336 pkgmgrinfo_pkginfo_h pPackageInfoHandle = null;
338 std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
339 SysTryReturn(NID_APP, pPackageId, false, E_OUT_OF_MEMORY, "pPackageId is null");
341 result = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &pPackageInfoHandle);
344 SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], packageId=[%s]", result, pPackageId.get());
348 if(pPackageInfoHandle)
350 pkgmgrinfo_pkginfo_destroy_pkginfo(pPackageInfoHandle);
353 SysLog(NID_APP, "packageId = [%ls] is installed.", packageId.GetPointer());
359 _PackageManagerImpl::InstallPackage(const PackageId& packageId, const String& packagePath, IPackageInstallationResponseListener* pListener)
361 SysTryReturnResult(NID_APP, packageId.IsEmpty() == false, E_INVALID_ARG, "packageId is empty.");
362 SysTryReturnResult(NID_APP, packagePath.IsEmpty() == false, E_INVALID_ARG, "packagePath is empty.");
363 SysTryReturnResult(NID_APP, File::IsFileExist(packagePath) == true, E_INVALID_ARG, "packagePath is not existed.");
365 String extension = File::GetFileExtension(packagePath);
366 SysTryReturnResult(NID_APP, extension.IsEmpty() == false, E_INVALID_ARG, "extension is empty.");
368 std::unique_ptr<char[]> pPackagePath(_StringConverter::CopyToCharArrayN(packagePath));
369 SysTryReturnResult(NID_APP, pPackagePath, E_OUT_OF_MEMORY, "pPackagePath is null");
371 std::unique_ptr<char[]> pExtension(_StringConverter::CopyToCharArrayN(extension));
372 SysTryReturnResult(NID_APP, pExtension, E_OUT_OF_MEMORY, "pExtension is null");
374 if ((strcasecmp(pExtension.get(), "tpk") == 0) || (strcasecmp(pExtension.get(), "wgt") == 0))
376 SysLog(NID_APP, "packageId = [%ls], packagePath = [%s], extension = [%s]", packageId.GetPointer(), pPackagePath.get(), pExtension.get());
380 SysLog(NID_APP, "invalid extension! - packagePath = [%s], extension = [%s]", pPackagePath.get(), pExtension.get());
384 result r = E_SUCCESS;
385 _PackageManagerProxy packageManagerProxy;
386 r = packageManagerProxy.Construct();
387 SysTryReturnResult(NID_APP, r == E_SUCCESS, E_SYSTEM, "packageManagerProxy.Construct() failed.");
389 r = packageManagerProxy.InstallPackage(packageId, packagePath, null);
390 SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "packageManagerProxy.InstallPackage() failed.");
392 if (__pRequestClient == null)
394 __pRequestClient = pkgmgr_client_new(PC_REQUEST);
395 SysTryReturnResult(NID_APP, __pRequestClient != null, E_SYSTEM, "pkgmgr_client_new(PC_REQUEST) failed");
398 int res = pkgmgr_client_install(__pRequestClient, pExtension.get(), null, pPackagePath.get(), null, PM_QUIET, InstallationEventHandler, pListener);
400 if (res < PKGMGR_R_OK)
402 pkgmgr_client_free(__pRequestClient);
403 __pRequestClient = null;
405 if (res == PKGMGR_R_EINVAL)
407 SysLog(NID_APP, "pkgmgr_client_install() returns ARGV error");
408 return E_INVALID_ARG;
410 else if (res == PKGMGR_R_ECOMM)
412 SysLog(NID_APP, "pkgmgr_client_install() returns COMM error");
414 else if (res == PKGMGR_R_ETIMEOUT)
416 SysLog(NID_APP, "pkgmgr_client_install() returns TIME_OUT error");
418 else if (res == PKGMGR_R_ERROR)
420 SysLog(NID_APP, "pkgmgr_client_install() returns Unknown error");
424 SysLog(NID_APP, "pkgmgr_client_install() returns Unknown error, res = %d", res);
434 _PackageManagerImpl::UninstallPackage(const PackageId& packageId, IPackageUninstallationResponseListener* pListener)
436 SysTryReturnResult(NID_APP, packageId.IsEmpty() == false, E_INVALID_ARG, "packageId is empty.");
437 SysTryReturnResult(NID_APP, packageId.GetLength() < NATIVE_APP_MAX_APPID_LENGTH, E_INVALID_ARG, "The packageId is invalid.(length)");
438 SysTryReturnResult(NID_APP, IsPackageInstalled(packageId) == true, E_PKG_NOT_INSTALLED, "package is not installed.");
440 result r = E_SUCCESS;
443 pkgmgrinfo_pkginfo_h pPackageInfoHandle = null;
445 _PackageManagerProxy packageManagerProxy;
446 r = packageManagerProxy.Construct();
447 SysTryReturnResult(NID_APP, r == E_SUCCESS, E_SYSTEM, "packageManagerProxy.Construct() failed.");
449 r = packageManagerProxy.UninstallPackage(packageId, pListener);
450 SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "packageManagerProxy.UninstallPackage() failed.");
452 std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
453 SysTryReturnResult(NID_APP, pPackageId != null, E_OUT_OF_MEMORY, "pPackageId is null");
455 res = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &pPackageInfoHandle);
456 SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
458 res = pkgmgrinfo_pkginfo_get_type(pPackageInfoHandle, &pType);
459 SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_type() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
461 if (__pRequestClient == null)
463 __pRequestClient = pkgmgr_client_new(PC_REQUEST);
464 SysTryReturnResult(NID_APP, __pRequestClient != null, E_SYSTEM, "pkgmgr_client_new(PC_REQUEST) failed");
467 res = pkgmgr_client_uninstall(__pRequestClient, pType, pPackageId.get(), PM_QUIET, UninstallationEventHandler, pListener);
468 SysLog(NID_APP, "pkgmgr_client_uninstall - req_id=[%d], packageId=[%s], type=[%s]", res, pPackageId.get(), pType);
470 if(pPackageInfoHandle)
472 pkgmgrinfo_pkginfo_destroy_pkginfo(pPackageInfoHandle);
475 if (res < PKGMGR_R_OK)
477 pkgmgr_client_free(__pRequestClient);
478 __pRequestClient = null;
480 if (res == PKGMGR_R_EINVAL)
482 SysLog(NID_APP, "pkgmgr_client_uninstall() returns ARGV error");
483 return E_INVALID_ARG;
485 else if (res == PKGMGR_R_ECOMM)
487 SysLog(NID_APP, "pkgmgr_client_uninstall() returns COMM error");
489 else if (res == PKGMGR_R_ETIMEOUT)
491 SysLog(NID_APP, "pkgmgr_client_uninstall() returns TIME_OUT error");
493 else if (res == PKGMGR_R_ERROR)
495 SysLog(NID_APP, "pkgmgr_client_uninstall() returns Unknown error");
499 SysLog(NID_APP, "pkgmgr_client_uninstall() returns Unknown error, res = %d", res);
509 _PackageManagerImpl::MoveToExternalStorage(const PackageId& packageId)
511 SysTryReturnResult(NID_APP, packageId.IsEmpty() == false, E_INVALID_ARG, "packageId is empty");
512 SysTryReturnResult(NID_APP, IsPackageInstalled(packageId) == true, E_PKG_NOT_INSTALLED, "package is not installed.");
516 pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
517 pkgmgrinfo_pkginfo_h packageInfoHandle = null;
519 std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
520 SysTryReturnResult(NID_APP, pPackageId != null, E_OUT_OF_MEMORY, "pPackageId is null");
522 res = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &packageInfoHandle);
523 SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
525 res = pkgmgrinfo_pkginfo_get_type(packageInfoHandle, &pType);
526 SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_type() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
528 res = pkgmgrinfo_pkginfo_get_installed_storage(packageInfoHandle, &storage);
529 SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_installed_storage() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
531 if (storage == PMINFO_EXTERNAL_STORAGE)
533 SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_installed_storage(): storage = [%d][E_INVALID_OPERATION]", storage);
534 return E_INVALID_OPERATION;
537 if (__pRequestClient == null)
539 __pRequestClient = pkgmgr_client_new(PC_REQUEST);
540 SysTryReturnResult(NID_APP, __pRequestClient != null, E_SYSTEM, "pkgmgr_client_new(PC_REQUEST) failed");
543 res = pkgmgr_client_move(__pRequestClient, pType, pPackageId.get(), PM_MOVE_TO_SDCARD, PM_QUIET);
545 if(packageInfoHandle)
547 pkgmgrinfo_pkginfo_destroy_pkginfo(packageInfoHandle);
550 if (res < PKGMGR_R_OK)
552 pkgmgr_client_free(__pRequestClient);
553 __pRequestClient = null;
555 if (res == PKGMGR_R_EINVAL)
557 SysLog(NID_APP, "pkgmgr_client_move() returns ARGV error");
558 return E_INVALID_ARG;
560 else if (res == PKGMGR_R_ERROR)
562 SysLog(NID_APP, "pkgmgr_client_move() returns Unknown error");
566 SysLog(NID_APP, "pkgmgr_client_move() returns Unknown error, res = %d", res);
576 _PackageManagerImpl::MoveToInternalStorage(const PackageId& packageId)
578 SysTryReturnResult(NID_APP, packageId.IsEmpty() == false, E_INVALID_ARG, "packageId is empty");
579 SysTryReturnResult(NID_APP, IsPackageInstalled(packageId) == true, E_PKG_NOT_INSTALLED, "package is not installed.");
583 pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
584 pkgmgrinfo_pkginfo_h packageInfoHandle = null;
586 std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
587 SysTryReturnResult(NID_APP, pPackageId != null, E_OUT_OF_MEMORY, "pPackageId is null");
589 res = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &packageInfoHandle);
590 SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
592 res = pkgmgrinfo_pkginfo_get_type(packageInfoHandle, &pType);
593 SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_type() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
595 res = pkgmgrinfo_pkginfo_get_installed_storage(packageInfoHandle, &storage);
596 SysTryReturnResult(NID_APP, res == 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_installed_storage() failed. result=[%d], packageId=[%s]", res, pPackageId.get());
598 if (storage == PMINFO_INTERNAL_STORAGE)
600 SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_installed_storage(): storage = [%d][E_INVALID_OPERATION]", storage);
601 return E_INVALID_OPERATION;
604 if (__pRequestClient == null)
606 __pRequestClient = pkgmgr_client_new(PC_REQUEST);
607 SysTryReturnResult(NID_APP, __pRequestClient != null, E_SYSTEM, "pkgmgr_client_new(PC_REQUEST) failed");
610 res = pkgmgr_client_move(__pRequestClient, pType, pPackageId.get(), PM_MOVE_TO_INTERNAL, PM_QUIET);
612 if(packageInfoHandle)
614 pkgmgrinfo_pkginfo_destroy_pkginfo(packageInfoHandle);
617 if (res < PKGMGR_R_OK)
619 pkgmgr_client_free(__pRequestClient);
620 __pRequestClient = null;
622 if (res == PKGMGR_R_EINVAL)
624 SysLog(NID_APP, "pkgmgr_client_move() returns ARGV error");
625 return E_INVALID_ARG;
627 else if (res == PKGMGR_R_ERROR)
629 SysLog(NID_APP, "pkgmgr_client_move() returns Unknown error");
633 SysLog(NID_APP, "pkgmgr_client_move() returns Unknown error, res = %d", res);
643 _PackageManagerImpl::InstallationEventHandler(int reqId, const char* pType, const char* pPackageId, const char* pKey, const char* pVal, const void* pMsg, void* pData)
645 SysLog(NID_APP, "reqId[%d], Type[%s], PackageId[%s], Key[%s], Val[%s]", reqId, pType, pPackageId, pKey, pVal);
649 IPackageInstallationResponseListener* pListener = (IPackageInstallationResponseListener*) pData;
651 if (strcmp(pKey, "end") == 0)
653 if (strcmp(pVal, "ok") == 0)
655 pListener->OnPackageInstallationResponseReceived(pPackageId, PACKAGE_INSTALLATION_RESULT_SUCCESS);
656 SysLog(NID_APP, "OnPackageInstallationResponseReceived(PACKAGE_INSTALLATION_RESULT_SUCCESS)");
660 pListener->OnPackageInstallationResponseReceived(pPackageId, PACKAGE_INSTALLATION_RESULT_INVALID_PACKAGE);
661 SysLog(NID_APP, "OnPackageInstallationResponseReceived(PACKAGE_INSTALLATION_RESULT_INVALID_PACKAGE)");
666 else if (strcmp(pKey, "install_percent") == 0)
669 sscanf(pVal, "%d", &progress);
671 pListener->OnPackageInstallationInProgressResponseReceived(pPackageId, progress);
672 SysLog(NID_APP, "OnPackageInstallationInProgressResponseReceived(%s, %d)", pPackageId, progress);
680 _PackageManagerImpl::UninstallationEventHandler(int reqId, const char* pType, const char* pPackageId, const char* pKey, const char* pVal, const void* pMsg, void* pData)
682 SysLog(NID_APP, "reqId[%d], Type[%s], PackageId[%s], Key[%s], Val[%s]", reqId, pType, pPackageId, pKey, pVal);
686 if (strcmp(pKey, "end") == 0)
688 IPackageUninstallationResponseListener* pListener = (IPackageUninstallationResponseListener*) pData;
690 if (strcmp(pVal, "ok") == 0)
692 SysLog(NID_APP, "OnPackageUninstallationResponseReceived(true)");
693 pListener->OnPackageUninstallationResponseReceived(pPackageId, true);
697 SysLog(NID_APP, "OnPackageUninstallationResponseReceived(false)");
698 pListener->OnPackageUninstallationResponseReceived(pPackageId, false);
709 _PackageManagerImpl::GetPackageInfoFromFileN(const String& filePath) const
711 SysTryReturn(NID_APP, filePath.IsEmpty() == false, null, E_INVALID_ARG, "filePath is empty.");
712 SysTryReturn(NID_APP, File::IsFileExist(filePath) == true, null, E_FILE_NOT_FOUND, "package is not existed.");
714 String extension = File::GetFileExtension(filePath);
715 SysTryReturn(NID_APP, extension.IsEmpty() == false, null, E_INVALID_ARG, "extension is empty.");
717 std::unique_ptr<char[]> pPackagePath(_StringConverter::CopyToCharArrayN(filePath));
718 SysTryReturn(NID_APP, pPackagePath, null, E_OUT_OF_MEMORY, "pPackagePath is null.");
720 std::unique_ptr<char[]> pExtension(_StringConverter::CopyToCharArrayN(extension));
721 SysTryReturn(NID_APP, pExtension, null, E_OUT_OF_MEMORY, "pExtension is null.");
723 std::unique_ptr< PackageInfo > pPackageInfo(new (std::nothrow) PackageInfo);
724 SysTryReturn(NID_APP, pPackageInfo, null, E_OUT_OF_MEMORY, "pPackageInfo instance must not be null.");
726 SysLog(NID_APP, "packagePath = [%s], extension = [%s]", pPackagePath.get(), pExtension.get());
730 if (strcasecmp(pExtension.get(), "tpk") == 0)
732 _PackageParser packageParser;
734 res = packageParser.Construct(pPackageInfo.get());
735 SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Construct() is failed. [%s]", pPackagePath.get());
737 res = packageParser.Parse(filePath);
738 SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Parse() is failed. [%s]", pPackagePath.get());
740 else if (strcasecmp(pExtension.get(), "wgt") == 0)
742 pkgmgr_info* pPkgmgrInfo = null;
744 pPkgmgrInfo = pkgmgr_client_check_pkginfo_from_file(pPackagePath.get());
745 SysTryReturn(NID_APP, pPkgmgrInfo, null, E_PARSING_FAILED, "pkgmgr_client_check_pkginfo_from_file(%s) is failed.", pPackagePath.get());
747 _package_manager_pkg_detail_info_t* pPkgInfo = (_package_manager_pkg_detail_info_t*) pPkgmgrInfo;
748 _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
750 SysLog(NID_APP, "id(%s), version(%s), label(%s), description(%s), author(%s), icon_size(%d), pkgname(%s)", pPkgInfo->pkgid, pPkgInfo->version, pPkgInfo->label,
751 pPkgInfo->pkg_description, pPkgInfo->author, pPkgInfo->icon_size, pPkgInfo->pkg_name);
753 pPackageInfoImpl->SetType(PACKAGE_TYPE_WGT);
754 pPackageInfoImpl->SetId(pPkgInfo->pkgid);
755 pPackageInfoImpl->SetVersion(pPkgInfo->version);
756 pPackageInfoImpl->SetDisplayName(pPkgInfo->label);
757 pPackageInfoImpl->SetDescription(pPkgInfo->pkg_description);
758 pPackageInfoImpl->SetAuthor(pPkgInfo->author);
760 if (pPkgInfo->privilege_list)
763 pList = g_list_first(pPkgInfo->privilege_list);
766 char* pPrivilege = (char*)pList->data;
769 pPackageInfoImpl->AddPrivilege(*new (std::nothrow) String(pPrivilege));
772 pList = g_list_next(pList);
774 g_list_free(pPkgInfo->privilege_list);
777 std::unique_ptr< PackageAppInfo > pPackageAppInfo(new (std::nothrow) PackageAppInfo);
778 SysTryReturn(NID_APP, pPackageAppInfo, null, E_OUT_OF_MEMORY, "pPackageAppInfo instance must not be null.");
780 _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
782 pPackageAppInfoImpl->SetAppId(pPkgInfo->pkg_name);
783 pPackageAppInfoImpl->SetAppName(pPkgInfo->label);
784 pPackageAppInfoImpl->SetAppDisplayName(pPkgInfo->label);
785 pPackageAppInfoImpl->SetMainApp(true);
786 if ((pPkgInfo->icon_buf) && (pPkgInfo->icon_size > 0))
788 String iconPath("/tmp/icon.png");
790 file.Construct(iconPath, "w+");
791 file.Write(pPkgInfo->icon_buf, pPkgInfo->icon_size);
793 pPackageAppInfoImpl->SetAppTempIconPath(iconPath);
796 pPackageInfoImpl->AddPackageAppInfo(*pPackageAppInfo.release());
798 pkgmgr_client_free_pkginfo(pPkgmgrInfo);
802 SysTryReturn(NID_APP, false, null, E_UNSUPPORTED_FORMAT, "invalid extension! - packagePath = [%s], extension = [%s]", pPackagePath.get(), pExtension.get());
805 return pPackageInfo.release();
809 _PackageManagerImpl::GetPackageInfoListN(const IMap& packageFilterMap) const
811 SysTryReturn(NID_APP, packageFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageFilterMap.GetCount() is invalid.");
813 std::unique_ptr<IMapEnumerator> pEnum(packageFilterMap.GetMapEnumeratorN());
814 SysTryReturn(NID_APP, pEnum, null, E_INVALID_ARG, "GetMapEnumeratorN() is failed.");
817 ArrayList* pList = null;
818 pkgmgrinfo_pkginfo_filter_h handle = null;
820 res = pkgmgrinfo_pkginfo_filter_create(&handle);
821 SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_pkginfo_filter_create() is failed. [%d]", res);
823 while(pEnum->MoveNext() == E_SUCCESS)
825 String* pKey = static_cast< String* >(pEnum->GetKey());
826 SysTryCatch(NID_APP, pKey, , E_INVALID_ARG, "GetKey() is failed.");
828 Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
829 SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
831 bool value = pVal->ToBool();
833 SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
835 if ((*pKey) == PACKAGE_FILTER_UNINSTALLABLE)
837 res = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, value);
838 SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(REMOVABLE, %d) is failed. [%d]", value, res);
840 else if ((*pKey) == PACKAGE_FILTER_DOWNLOADED)
842 res = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, !value);
843 SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(PRELOAD, %d) is failed. [%d]", !value, res);
845 else if ((*pKey) == PACKAGE_FILTER_APP_SETTING)
847 res = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, value);
848 SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(APPSETTING, %d) is failed. [%d]", value, res);
850 else if ((*pKey) == PACKAGE_FILTER_EXTERNAL_STORAGE)
852 String installedStorage;
855 installedStorage = L"installed_external";
859 installedStorage = L"installed_internal";
862 std::unique_ptr<char[]> pInstalledStorage(_StringConverter::CopyToCharArrayN(installedStorage));
863 SysTryCatch(NID_APP, pInstalledStorage, , E_OUT_OF_MEMORY, "pInstalledStorage is null.");
865 SysLog(NID_APP, "Value[%d]->[%s]", value, pInstalledStorage.get());
867 res = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE, pInstalledStorage.get());
868 SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_string(STORAGE, %s) is failed. [%d]", pInstalledStorage.get(), res);
872 SysTryCatch(NID_APP, false, , E_INVALID_ARG, "Invalid key(%ls)", pKey->GetPointer());
876 pList = new (std::nothrow) ArrayList();
877 SysTryCatch(NID_APP, pList, , E_OUT_OF_MEMORY, "ArrayList creation failure.");
880 res = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, PackageInfoHandler, pList);
883 SysLog(NID_APP, "pkgmgrinfo_pkginfo_filter_foreach_pkginfo() is failed. result = [%d]", res);
885 pList->RemoveAll(true);
892 pkgmgrinfo_pkginfo_filter_destroy(handle);
899 _PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageAppFilterMap) const
901 SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.GetCount() is invalid.");
903 std::unique_ptr<IMapEnumerator> pEnum(packageAppFilterMap.GetMapEnumeratorN());
904 SysTryReturn(NID_APP, pEnum, null, E_INVALID_ARG, "GetMapEnumeratorN() is failed.");
907 ArrayList* pList = null;
908 pkgmgrinfo_appinfo_filter_h handle = null;
910 res = pkgmgrinfo_appinfo_filter_create(&handle);
911 SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_appinfo_filter_create() is failed. [%d]", res);
913 while(pEnum->MoveNext() == E_SUCCESS)
915 String* pKey = static_cast<String*>(pEnum->GetKey());
916 SysTryCatch(NID_APP, pKey, , E_INVALID_ARG, "GetKey() is failed.");
918 if ((*pKey) == PACKAGE_APP_FILTER_MENUICON_VISIBLE)
920 Boolean* pVal = static_cast<Boolean*>(pEnum->GetValue());
921 SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
923 bool nodisplay = !(pVal->ToBool());
924 SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), nodisplay);
926 res = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, nodisplay);
927 SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(NODISPLAY, %d) is failed. [%d]", nodisplay, res);
929 else if ((*pKey) == PACKAGE_APP_FILTER_CATEGORY)
931 String* pVal = static_cast<String*>(pEnum->GetValue());
932 SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
934 SysLog(NID_APP, "Key[%ls], Value[%ls]", pKey->GetPointer(), pVal->GetPointer());
936 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pVal));
937 SysTryCatch(NID_APP, pValue, , E_OUT_OF_MEMORY, "pValue is null.");
939 res = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, pValue.get());
940 SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_filter_add_string(CATEGORY, %s) is failed. [%d]", pValue.get(), res);
944 SysTryCatch(NID_APP, false, , E_INVALID_ARG, "Invalid key(%ls)", pKey->GetPointer());
948 pList = new (std::nothrow) ArrayList();
949 SysTryCatch(NID_APP, pList, , E_OUT_OF_MEMORY, "ArrayList creation failure.");
952 res = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, PackageAppInfoHandler, pList);
955 SysLog(NID_APP, "pkgmgrinfo_appinfo_filter_foreach_appinfo() is failed. result = [%d]", res);
957 pList->RemoveAll(true);
964 pkgmgrinfo_appinfo_filter_destroy(handle);
971 _PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageFilterMap, const IMap& packageAppFilterMap) const
973 SysTryReturn(NID_APP, packageFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageFilterMap.GetCount() is invalid.");
974 SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.GetCount() is invalid.");
980 _PackageManagerImpl::PackageInfoHandler(const pkgmgrinfo_pkginfo_h handle, void* pUserData)
982 SysTryReturn(NID_APP, handle, 0, E_SYSTEM, "handle must not be null.");
983 SysTryReturn(NID_APP, pUserData, 0, E_SYSTEM, "pUserData must not be null.");
985 result r = E_SUCCESS;
986 int res = PMINFO_R_OK;
987 char* pPackageId = null;
988 ArrayList* pList = (ArrayList*)pUserData;
990 res = pkgmgrinfo_pkginfo_get_pkgname(handle, &pPackageId);
991 SysTryReturn(NID_APP, res == PMINFO_R_OK, 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkgname() is failed. [%d]", res);
993 std::unique_ptr<PackageInfo> pPackageInfo(new (std::nothrow) PackageInfo);
994 SysTryReturn(NID_APP, pPackageInfo, 0, E_OUT_OF_MEMORY, "pPackageInfo instance must not be null.");
996 _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
997 r = pPackageInfoImpl->Construct(pPackageId);
998 SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pPackageId);
1000 pList->Add(*pPackageInfo.release());
1006 _PackageManagerImpl::PackageAppInfoHandler(const pkgmgrinfo_appinfo_h handle, void* pUserData)
1008 SysTryReturn(NID_APP, handle, 0, E_SYSTEM, "handle must not be null.");
1009 SysTryReturn(NID_APP, pUserData, 0, E_SYSTEM, "pUserData must not be null.");
1011 result r = E_SUCCESS;
1012 int res = PMINFO_R_OK;
1013 char* pAppId = null;
1014 ArrayList* pList = (ArrayList*)pUserData;
1016 res = pkgmgrinfo_appinfo_get_appid(handle, &pAppId);
1017 SysTryReturn(NID_APP, res == PMINFO_R_OK, 0, E_SYSTEM, "pkgmgrinfo_appinfo_get_appid is failed. [%d]", res);
1019 std::unique_ptr<PackageAppInfo> pPackageAppInfo(new (std::nothrow) PackageAppInfo);
1020 SysTryReturn(NID_APP, pPackageAppInfo, 0, E_OUT_OF_MEMORY, "pPackageAppInfo instance must not be null.");
1022 _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get());
1023 r = pPackageAppInfoImpl->Construct(pAppId);
1024 SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pAppId);
1026 pList->Add(*pPackageAppInfo.release());
1031 _PackageManagerImpl*
1032 _PackageManagerImpl::GetInstance(void)
1034 return PackageManager::GetInstance()->__pPackageManagerImpl;
1038 _PackageManagerImpl::Construct(void)
1042 result r = __installationList.Construct();
1043 SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "The memory is insufficient.");
1048 _PackageManagerImpl::_PackageManagerImpl(void)
1049 :__pRequestClient(null),
1050 __pListeningClient(null)
1054 _PackageManagerImpl::~_PackageManagerImpl(void)
1059 _PackageManagerImpl::SendPackageEvent(PackageType type, const PackageId& packageId, const char* pEventKey, const char* pEventValue)
1061 result r = E_SUCCESS;
1062 bool install = true;
1064 if (strcmp(pEventKey, "start") == 0)
1066 if ((strcmp(pEventValue, "install") == 0) || (strcmp(pEventValue, "uninstall") == 0))
1068 String* pAppId = new (std::nothrow) String(packageId);
1069 SysTryReturnVoidResult(NID_APP, pAppId != null, E_OUT_OF_MEMORY, "pAppId instance must not be null.");
1071 String* pOperation = new (std::nothrow) String(pEventValue);
1072 SysTryReturnVoidResult(NID_APP, pOperation != null, E_OUT_OF_MEMORY, "pOperation instance must not be null.");
1074 r = __installationList.Add(*pAppId, *pOperation);
1079 SysLog(NID_APP, "Failed to add installation condition.");
1080 SetLastResult(E_SYSTEM);
1085 else if (strcmp(pEventKey, "end") == 0)
1087 String* pOperation = static_cast <String*>(__installationList.GetValue(packageId));
1090 if (pOperation->Equals("uninstall", true) == true)
1095 r = __installationList.Remove(packageId, true);
1098 SysLogException(NID_APP, r, "[%s] Remove Element [%ls] is failed from installing list.", GetErrorMessage(r), packageId.GetPointer());
1103 std::unique_ptr< IEnumeratorT<_PackageManagerEvent*> > pEnum(__packageEventListenerList.GetEnumeratorN());
1104 SysTryReturnVoidResult(NID_APP, pEnum, E_OUT_OF_MEMORY, "The memory is insufficient.");
1106 while (pEnum->MoveNext() == E_SUCCESS)
1108 _PackageManagerEvent* pEvent = null;
1109 pEnum->GetCurrent(pEvent);
1112 _PackageManagerEventArg* pEventArg= new (std::nothrow) _PackageManagerEventArg();
1113 SysTryReturnVoidResult(NID_APP, pEventArg, E_OUT_OF_MEMORY, "The memory is insufficient.");
1115 String eventKey(pEventKey);
1116 String eventValue(pEventValue);
1118 pEventArg->__packageId = packageId;
1119 pEventArg->__eventKey = eventKey;
1120 pEventArg->__eventValue = eventValue;
1121 pEventArg->__install = install;
1123 r = pEvent->Fire(*pEventArg);
1126 SysLog(NID_APP, "pEvent->Fire(*pEventArg) failed. [%s]", GetErrorMessage(r));
1129 SysLog(NID_APP, "PackageId = [%ls], Key = [%ls], Value = [%ls], install = [%d]", pEventArg->__packageId.GetPointer(), pEventArg->__eventKey.GetPointer(), pEventArg->__eventValue.GetPointer(), pEventArg->__install);
1133 SysLog(NID_APP, "pEvent is null.");
1139 _PackageManagerImpl::GetPackageInfoN(PackageType packageType, const String& packageName) const
1141 SysTryReturn(NID_APP, packageName.IsEmpty() == false, null, E_INVALID_ARG, "[E_INVALID_ARG] packageName is empty.");
1143 result r = E_SUCCESS;
1145 DbStatement* pStmt = null;
1146 DbEnumerator* pEnum = null;
1148 PackageInfo *pPackageInfo = null;
1150 query.Format( 1024, L"SELECT PkgInfo.*, AppInfo.APP_MAINMENU_ICON FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and AppInfo.PACKAGE_NAME = '%ls'", packageName.GetPointer());
1152 r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
1153 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
1155 pStmt = CreateStatementN(db, query);
1157 SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
1159 pEnum = ExecuteStatementN(db, pStmt);
1162 if (pEnum->MoveNext() == E_SUCCESS)
1164 pPackageInfo = new (std::nothrow) PackageInfo;
1165 SysTryReturn(NID_APP, pPackageInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageInfo instance must not be null.");
1167 _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
1173 String appApiVersion;
1176 String appDescription;
1180 int appStorageType = 0;
1181 DateTime appInstallationTime;
1184 pEnum->GetStringAt(1, id);
1185 pEnum->GetStringAt(3, appVersion);
1186 pEnum->GetStringAt(4, appType);
1187 pEnum->GetStringAt(5, appMimeType);
1188 pEnum->GetStringAt(6, appApiVersion);
1189 pEnum->GetStringAt(7, appName);
1190 pEnum->GetStringAt(8, appVendor);
1191 pEnum->GetStringAt(9, appDescription);
1192 pEnum->GetStringAt(10, appUrl);
1193 pEnum->GetStringAt(11, appCid);
1194 pEnum->GetStringAt(16, appRootPath);
1195 pEnum->GetIntAt(17, appStorageType);
1196 pEnum->GetDateTimeAt(18, appInstallationTime);
1197 pEnum->GetStringAt(21, appIconPath);
1199 pPackageInfoImpl->SetAppId(id);
1200 pPackageInfoImpl->SetAppVersion(appVersion);
1201 pPackageInfoImpl->SetAppMimeType(appMimeType);
1202 pPackageInfoImpl->SetAppApiVersion(appApiVersion);
1203 pPackageInfoImpl->SetAppName(appName);
1204 pPackageInfoImpl->SetAppVendor(appVendor);
1205 pPackageInfoImpl->SetAppDescription(appDescription);
1206 pPackageInfoImpl->SetAppUrl(appUrl);
1207 pPackageInfoImpl->SetAppCid(appCid);
1208 pPackageInfoImpl->SetAppRootPath(appRootPath);
1209 pPackageInfoImpl->SetAppStorageType(appStorageType);
1210 pPackageInfoImpl->SetAppInstallationTime(appInstallationTime);
1211 pPackageInfoImpl->SetAppIconPath(appIconPath);
1218 r = E_OBJ_NOT_FOUND;
1223 return pPackageInfo;
1227 _PackageManagerImpl::PackageInfoEventHandler(const pkgmgrinfo_pkginfo_h handle, void* pUserData)
1229 SysTryReturn(NID_APP, handle != null, 0, E_SYSTEM, "[E_SYSTEM] handle must not be null.");
1232 char* pPackage = null;
1233 ArrayList* pList = (ArrayList*)pUserData;
1235 PackageInfo *pPackageInfo = new (std::nothrow) PackageInfo;
1236 SysTryReturn(NID_APP, pPackageInfo != null, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageInfo instance must not be null.");
1238 _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
1240 result = pkgmgrinfo_pkginfo_get_pkgname(handle, &pPackage);
1243 SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkgname(): package = [%s]", pPackage);
1247 SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkgname() is failed. result = [%d]", result);
1250 pPackageInfoImpl->Construct(pPackage);
1251 pList->Add(*pPackageInfo);
1257 _PackageManagerImpl::GetFilteredAppIdListN(const String& feature, const String& value) const
1259 result r = E_SUCCESS;
1261 DbStatement* pStmt = null;
1262 DbEnumerator* pEnum = null;
1264 ArrayList* pList = null;
1266 query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME FROM AppInfo, AppFeature WHERE AppFeature.ID = AppInfo.UNIQUE_ID and AppFeature.NAME = '%ls' and AppFeature.VALUE = '%ls' COLLATE NOCASE", feature.GetPointer(), value.GetPointer());
1268 r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
1269 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
1271 pStmt = CreateStatementN(db, query);
1272 SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
1274 pEnum = ExecuteStatementN(db, pStmt);
1278 pList = new (std::nothrow) ArrayList();
1279 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
1282 while (pEnum->MoveNext() == E_SUCCESS)
1284 String* pPackageName = new (std::nothrow) String;
1285 SysTryReturn(NID_APP, pPackageName != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageName instance must not be null.");
1287 pEnum->GetStringAt(0, *pPackageName);
1289 pList->Add(*pPackageName);
1297 r = E_OBJ_NOT_FOUND;
1306 _PackageManagerImpl::GetDataControlInfoN(const String& providerId, const String& type) const
1308 result r = E_SUCCESS;
1310 DbStatement* pStmt = null;
1311 DbEnumerator* pEnum = null;
1313 ArrayList* pList = null;
1315 query.Format(1024, L"SELECT AppInfo.PACKAGE_NAME, DataControl.ACCESS FROM AppInfo, DataControl WHERE DataControl.ID = AppInfo.UNIQUE_ID and DataControl.PROVIDER_ID = '%ls' and DataControl.TYPE = '%ls' COLLATE NOCASE", providerId.GetPointer(), type.GetPointer());
1317 r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
1318 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
1320 pStmt = CreateStatementN(db, query);
1321 SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
1323 pEnum = ExecuteStatementN(db, pStmt);
1327 pList = new (std::nothrow) ArrayList();
1328 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
1331 while (pEnum->MoveNext() == E_SUCCESS)
1333 String* pPackageName = new (std::nothrow) String;
1334 SysTryReturn(NID_APP, pPackageName != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pPackageName instance must not be null.");
1336 String* pAccess = new (std::nothrow) String;
1337 SysTryReturn(NID_APP, pAccess != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pAccess instance must not be null.");
1339 pEnum->GetStringAt(0, *pPackageName);
1340 pList->Add(*pPackageName);
1342 pEnum->GetStringAt(1, *pAccess);
1343 pList->Add(*pAccess);
1351 r = E_OBJ_NOT_FOUND;
1360 _PackageManagerImpl::GetUiThemeListN(const PackageId& packageId) const
1362 result r = E_SUCCESS;
1364 DbStatement* pStmt = null;
1365 DbEnumerator* pEnum = null;
1367 HashMap* pList = null;
1369 query.Format(1024, L"SELECT AppFeature.NAME, AppFeature.VALUE FROM PkgInfo, AppInfo, AppFeature WHERE (AppFeature.ID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID and PkgInfo.PKG_ID = '%ls') and (AppFeature.NAME = 'SystemTheme' or AppFeature.NAME = 'UserDefinedTheme')"
1370 , packageId.GetPointer());
1372 r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
1373 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
1375 pStmt = CreateStatementN(db, query);
1376 SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
1378 pEnum = ExecuteStatementN(db, pStmt);
1382 pList = new (std::nothrow) HashMap();
1383 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "HashMap creation failure.");
1386 while (pEnum->MoveNext() == E_SUCCESS)
1388 String* pName = new (std::nothrow) String;
1389 SysTryCatch(NID_APP, pName != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pName instance must not be null.");
1391 String* pValue = new (std::nothrow) String;
1392 SysTryCatch(NID_APP, pValue != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pValue instance must not be null.");
1394 pEnum->GetStringAt(0, *pName);
1395 pEnum->GetStringAt(1, *pValue);
1397 pList->Add(*pName, *pValue);
1405 r = E_OBJ_NOT_FOUND;
1414 _PackageManagerImpl::IsAppInstalled(const AppId& appId)
1416 if (appId == _AppInfo::GetPackageId())
1422 pkgmgrinfo_pkginfo_h pPackageInfoHandle = null;
1424 std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(appId));
1425 SysTryReturn(NID_APP, pPackageId, false, E_OUT_OF_MEMORY, "pPackageId is null");
1427 result = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &pPackageInfoHandle);
1428 SysTryReturn(NID_APP, result == 0, false, E_APP_NOT_INSTALLED, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], packageId=[%s]", result, pPackageId.get());
1430 if(pPackageInfoHandle)
1432 pkgmgrinfo_pkginfo_destroy_pkginfo(pPackageInfoHandle);
1439 _PackageManagerImpl::PackageEventHandler(int req_id, const char* pkg_type, const char* pkg_name,
1440 const char* key, const char* val, const void* pmsg, void* data)
1442 SysLog(NID_APP, "PackageEventHandler - req_id: %d, pkg_type: %s, pkg_name: %s, key: %s, val: %s", req_id, pkg_type,
1443 pkg_name, key, val);
1445 PackageType type = PACKAGE_TYPE_TPK;
1446 PackageId packageId(pkg_name);
1448 if (strcmp(pkg_type, "tpk") == 0)
1450 type = PACKAGE_TYPE_TPK;
1452 else if (strcmp(pkg_type, "wgt") == 0)
1454 type = PACKAGE_TYPE_WGT;
1458 SysLog(NID_APP, "Invalid type - pkg_type: %s", pkg_type);
1462 _PackageManagerImpl* pThis = _PackageManagerImpl::GetInstance();
1463 pThis->SendPackageEvent(type, packageId, key, val);
1469 _PackageManagerImpl::GetAppIdOfDataControlN(const String& providerId)
1471 result r = E_SUCCESS;
1473 DbStatement* pStmt = null;
1474 DbEnumerator* pEnum = null;
1476 String* pAppId = null;
1478 query.Format(1024, L"SELECT PkgInfo.PKG_ID FROM PkgInfo, AppInfo, DataControl WHERE DataControl.PROVIDER_ID = '%ls' and DataControl.ID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID",
1479 providerId.GetPointer());
1481 r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
1482 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
1484 pStmt = CreateStatementN(db, query);
1485 SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
1487 pEnum = ExecuteStatementN(db, pStmt);
1491 if (pEnum->MoveNext() == E_SUCCESS)
1493 pAppId = new (std::nothrow) String;
1494 SysTryReturn(NID_APP, pAppId != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory");
1496 pEnum->GetStringAt(0, *pAppId);
1508 _PackageManagerImpl::GetPackageInfoN(const String& providerId, const String& operationId) const
1510 result r = E_SUCCESS;
1511 PackageInfo* pPkgInfo = null;
1513 DbStatement* pStmt = null;
1514 DbEnumerator* pEnum = null;
1517 query.Format(1024, L"SELECT PkgInfo.PKG_ID FROM PkgInfo, AppInfo, AppInfoLookup, AppControl, Capability "
1518 "WHERE AppControl.PROVIDER_ID ='%ls' and Capability.OPERATION_ID ='%ls' and AppControl.ID = AppInfoLookup.AppControlID "
1519 "and Capability.ID = AppInfoLookup.CapabilityID and AppInfoLookup.AppInfoID = AppInfo.UNIQUE_ID and AppInfo.ID = PkgInfo.UNIQUE_ID "
1520 "GROUP BY AppInfoID"
1521 , providerId.GetPointer(), operationId.GetPointer());
1523 r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
1524 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
1526 pStmt = CreateStatementN(db, query);
1527 SysTryCatch(NID_APP, pStmt != null, GetLastResult(), GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
1529 pEnum = ExecuteStatementN(db, pStmt);
1532 if (pEnum->MoveNext() == E_SUCCESS)
1534 PackageId packageId;
1535 pEnum->GetStringAt(0, packageId);
1537 pPkgInfo = GetPackageInfoN(packageId);
1544 r = E_OBJ_NOT_FOUND;
1553 _PackageManagerImpl::GetPackageAppInfoImplListN(const String& packageId) const
1555 result r = E_SUCCESS;
1557 DbStatement* pStmt = null;
1558 DbEnumerator* pEnum = null;
1561 PackageInfo* pPkgInfo = null;
1562 _PackageInfoImpl* pPackageInfoImpl = null;
1563 ArrayList* pList = null;
1565 pPkgInfo = GetPackageInfoN(packageId);
1566 SysTryCatch(NID_APP, pPkgInfo != null, , r, "[%s] GetPackageInfoN() is failed", GetErrorMessage(r));
1568 pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo);
1569 query.Format(1024, L"SELECT * FROM AppInfo WHERE ID = %d", pPackageInfoImpl->GetUniqueId());
1571 r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
1572 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
1574 pStmt = CreateStatementN(db, query);
1575 SysTryCatch(NID_APP, pStmt != null, GetLastResult(),
1576 GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
1578 pEnum = ExecuteStatementN(db, pStmt);
1582 pList = new (std::nothrow) ArrayList;
1583 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Container allocation failure.");
1587 while (pEnum->MoveNext() == E_SUCCESS)
1589 _PackageAppInfoImpl* pPackageAppInfoImpl = new (std::nothrow) _PackageAppInfoImpl;
1590 SysTryReturn(NID_APP, pPackageAppInfoImpl != null, null, E_OUT_OF_MEMORY, "pPackageAppInfoImpl instance must not be null.");
1596 String mainmenuIcon;
1598 String quickpanelIcon;
1602 pEnum->GetIntAt(0, uniqueId);
1603 pEnum->GetIntAt(1, pkgId);
1604 pEnum->GetStringAt(2, name);
1605 pEnum->GetStringAt(3, defaultapp);
1606 pEnum->GetStringAt(4, mainmenuIcon);
1607 pEnum->GetStringAt(5, settingIcon);
1608 pEnum->GetStringAt(7, quickpanelIcon);
1609 pEnum->GetIntAt(9, appFeature);
1610 pEnum->GetStringAt(10, packageName);
1612 pPackageAppInfoImpl->SetUniqueId(uniqueId);
1613 pPackageAppInfoImpl->SetPkgId(pkgId);
1614 pPackageAppInfoImpl->SetName(name);
1615 pPackageAppInfoImpl->SetDefault(defaultapp);
1616 pPackageAppInfoImpl->SetMainmenuIcon(mainmenuIcon);
1617 pPackageAppInfoImpl->SetSettingIcon(settingIcon);
1618 pPackageAppInfoImpl->SetQuickpanelIcon(quickpanelIcon);
1619 pPackageAppInfoImpl->SetAppFeature(appFeature);
1620 pPackageAppInfoImpl->SetPackageName(packageName);
1622 pList->Add(*pPackageAppInfoImpl);
1635 _PackageManagerImpl::GetPackageAppFeatureListN(const PackageId& packageId, const Tizen::Base::String& appExecutableName) const
1637 ArrayList* pAppInfoList = GetPackageAppInfoImplListN(packageId);
1638 SysTryReturn(NID_APP, pAppInfoList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] AppInfo list instance must not be null.");
1640 ArrayList* pResult = null;
1642 for (int i = 0; i < pAppInfoList->GetCount(); i++)
1644 const _PackageAppInfoImpl* pAppInfoImpl = static_cast<const _PackageAppInfoImpl*>(pAppInfoList->GetAt(i));
1645 if (pAppInfoImpl == null)
1650 if (pAppInfoImpl->GetName() == appExecutableName)
1652 pResult = pAppInfoImpl->GetAppFeatureListN();
1658 pAppInfoList->RemoveAll(true);
1659 delete pAppInfoList;
1664 HashMapT<String, _AppFeatureInfoImpl*>*
1665 _PackageManagerImpl::GetPackageAppFeatureMapN(const PackageId& packageId, const Tizen::Base::String& appExecutableName) const
1667 ArrayList* pAppInfoList = GetPackageAppInfoImplListN(packageId);
1668 SysTryReturn(NID_APP, pAppInfoList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] AppInfo list instance must not be null.");
1670 HashMapT<String, _AppFeatureInfoImpl*>* pResult = null;
1672 std::auto_ptr<IEnumerator> pEnum(pAppInfoList->GetEnumeratorN());
1674 while (pEnum->MoveNext() == E_SUCCESS)
1676 const _PackageAppInfoImpl* pAppInfoImpl = static_cast<const _PackageAppInfoImpl*>(pEnum->GetCurrent());
1677 if (pAppInfoImpl == null)
1682 if (pAppInfoImpl->GetName() == appExecutableName)
1684 pResult = pAppInfoImpl->GetAppFeatureMapN();
1690 pAppInfoList->RemoveAll(true);
1691 delete pAppInfoList;
1697 _PackageManagerImpl::GetAppLaunchConditionListN(const String& packageName) const
1699 result r = E_SUCCESS;
1701 DbStatement* pStmt = null;
1702 DbEnumerator* pEnum = null;
1704 ArrayList* pList = null;
1706 query.Format(1024, L"SELECT LaunchCondition.* FROM LaunchCondition, AppInfo WHERE AppInfo.UNIQUE_ID = LaunchCondition.ID and AppInfo.PACKAGE_NAME = '%ls'", packageName.GetPointer());
1708 r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
1709 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
1711 pStmt = CreateStatementN(db, query);
1712 SysTryCatch(NID_APP, pStmt != null, GetLastResult(),
1713 GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
1715 pEnum = ExecuteStatementN(db, pStmt);
1718 pList = new (std::nothrow) ArrayList;
1719 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Container allocation failure.");
1723 while (pEnum->MoveNext() == E_SUCCESS)
1725 _LaunchConditionInfoImpl* pLaunchCondtion = new (std::nothrow) _LaunchConditionInfoImpl;
1726 SysTryReturn(NID_APP, pLaunchCondtion != null, null, E_OUT_OF_MEMORY, "pLaunchCondtion instance must not be null.");
1731 pEnum->GetStringAt(1, name);
1732 pEnum->GetStringAt(2, value);
1734 pLaunchCondtion->SetName(name);
1735 pLaunchCondtion->SetValue(value);
1737 pList->Add(*pLaunchCondtion);
1739 SysLog(NID_APP, "Name[%ls], Value[%ls]", name.GetPointer(), value.GetPointer());
1751 _PackageManagerImpl::GetPackageName(const PackageId& packageId, const String* pName, char* pPackageName, int bufferSize)
1753 result r = E_SUCCESS;
1755 DbStatement* pStmt = null;
1756 DbEnumerator* pEnum = null;
1758 Tizen::Base::String packageName;
1764 L"SELECT AppInfo.PACKAGE_NAME FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and AppInfo.APP_DEFAULT = '%s' and PkgInfo.PKG_ID = '%ls'",
1765 "True", packageId.GetPointer());
1771 L"SELECT AppInfo.PACKAGE_NAME FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and APP_NAME = '%ls' and PkgInfo.PKG_ID = '%ls'",
1772 pName->GetPointer(), packageId.GetPointer());
1775 r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
1776 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
1778 pStmt = CreateStatementN(db, query);
1779 SysTryCatch(NID_APP, pStmt != null, GetLastResult(),
1780 GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
1782 pEnum = ExecuteStatementN(db, pStmt);
1785 if (pEnum->MoveNext() == E_SUCCESS)
1787 pEnum->GetStringAt(0, packageName);
1788 snprintf(pPackageName, bufferSize, "%ls", packageName.GetPointer());
1794 r = E_OBJ_NOT_FOUND;
1804 _PackageManagerImpl::GetDefaultAppExecutableName(const PackageId& packageId)
1806 result r = E_SUCCESS;
1808 DbStatement* pStmt = null;
1809 DbEnumerator* pEnum = null;
1811 String executableName;
1815 L"SELECT AppInfo.APP_NAME FROM AppInfo, PkgInfo WHERE AppInfo.ID = PkgInfo.UNIQUE_ID and AppInfo.APP_DEFAULT = '%s' and PkgInfo.PKG_ID = '%ls'",
1816 "True", packageId.GetPointer());
1818 r = db.Construct(PACKAGE_DATABASE_FILE_NAME, "r");
1819 SysTryCatch(NID_APP, r == E_SUCCESS, , r, "[%s] An error occurs while opening a database.", GetErrorMessage(r));
1821 pStmt = CreateStatementN(db, query);
1822 SysTryCatch(NID_APP, pStmt != null, GetLastResult(),
1823 GetLastResult(), "[%s] An error occurs while creating a database statement.", GetErrorMessage(GetLastResult()));
1825 pEnum = ExecuteStatementN(db, pStmt);
1828 if (pEnum->MoveNext() == E_SUCCESS)
1830 pEnum->GetStringAt(0, executableName);
1836 r = E_OBJ_NOT_FOUND;
1843 return executableName;
1847 _PackageManagerImpl::CreateStatementN(Database& db, const String& query)
1849 result r = E_SUCCESS;
1850 DbStatement* pStmt = null;
1852 for (int i = 0; i < MAX_DATABASE_RETRY_COUNT; i++)
1854 pStmt = db.CreateStatementN(query);
1855 r = GetLastResult();
1857 if (r != E_OBJECT_LOCKED)
1863 SysLog(NID_APP, "RetryCount[%d] CreateStatementN - E_OBJECT_LOCKED", i);
1874 _PackageManagerImpl::ExecuteStatementN(Database& db, const DbStatement* pStmt)
1876 result r = E_SUCCESS;
1877 DbEnumerator* pEnum = null;
1879 for (int i = 0; i < MAX_DATABASE_RETRY_COUNT; i++)
1881 pEnum = db.ExecuteStatementN(*pStmt);
1882 r = GetLastResult();
1884 if (r != E_OBJECT_LOCKED)
1890 SysLog(NID_APP, "RetryCount[%d] ExecuteStatementN - E_OBJECT_LOCKED", i);
1900 } } } // Tizen::App::Package