{
SysTryReturnResult(NID_APP, packageId.IsEmpty() == false, E_INVALID_ARG, "packageId is empty.");
SysTryReturnResult(NID_APP, packagePath.IsEmpty() == false, E_INVALID_ARG, "packagePath is empty.");
- SysTryReturnResult(NID_APP, File::IsFileExist(packagePath) == true, E_FILE_NOT_FOUND, "packagePath is not existed.");
+ SysTryReturnResult(NID_APP, File::IsFileExist(packagePath) == true, E_INVALID_ARG, "packagePath is not existed.");
String extension = File::GetFileExtension(packagePath);
SysTryReturnResult(NID_APP, extension.IsEmpty() == false, E_INVALID_ARG, "extension is empty.");
{
SysTryReturn(NID_APP, packageFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageFilterMap.GetCount() is invalid.");
- return null;
+ std::unique_ptr<IMapEnumerator> pEnum(packageFilterMap.GetMapEnumeratorN());
+ SysTryReturn(NID_APP, pEnum, null, E_INVALID_ARG, "GetMapEnumeratorN() is failed.");
+
+ int res = 0;
+ ArrayList* pList = null;
+ pkgmgrinfo_pkginfo_filter_h handle = null;
+
+ res = pkgmgrinfo_pkginfo_filter_create(&handle);
+ SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_pkginfo_filter_create() is failed. [%d]", res);
+
+ while(pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pKey = static_cast< String* >(pEnum->GetKey());
+ SysTryCatch(NID_APP, pKey, , E_INVALID_ARG, "GetKey() is failed.");
+
+ Boolean* pVal = static_cast< Boolean* >(pEnum->GetValue());
+ SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed.");
+
+ bool value = pVal->ToBool();
+
+ SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), value);
+
+ if ((*pKey) == PACKAGE_FILTER_UNINSTALLABLE)
+ {
+ res = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, value);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(REMOVABLE, %d) is failed. [%d]", value, res);
+ }
+ else if ((*pKey) == PACKAGE_FILTER_DOWNLOADED)
+ {
+ res = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, !value);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(PRELOAD, %d) is failed. [%d]", !value, res);
+ }
+ else if ((*pKey) == PACKAGE_FILTER_APP_SETTING)
+ {
+ res = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, value);
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(APPSETTING, %d) is failed. [%d]", value, res);
+ }
+ else if ((*pKey) == PACKAGE_FILTER_EXTERNAL_STORAGE)
+ {
+ String installedStorage;
+ if (value == true)
+ {
+ installedStorage = L"installed_external";
+ }
+ else
+ {
+ installedStorage = L"installed_internal";
+ }
+
+ std::unique_ptr<char[]> pInstalledStorage(_StringConverter::CopyToCharArrayN(installedStorage));
+ SysTryCatch(NID_APP, pInstalledStorage, , E_OUT_OF_MEMORY, "pInstalledStorage is null.");
+
+ SysLog(NID_APP, "Value[%d]->[%s]", value, pInstalledStorage.get());
+
+ res = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE, pInstalledStorage.get());
+ SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_string(STORAGE, %s) is failed. [%d]", pInstalledStorage.get(), res);
+ }
+ else
+ {
+ SysTryCatch(NID_APP, false, , E_INVALID_ARG, "Invalid key(%ls)", pKey->GetPointer());
+ }
+ }
+
+ pList = new (std::nothrow) ArrayList();
+ SysTryCatch(NID_APP, pList, , E_OUT_OF_MEMORY, "ArrayList creation failure.");
+ pList->Construct();
+
+ res = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, PackageInfoHandler, pList);
+ if (res != 0)
+ {
+ SysLog(NID_APP, "pkgmgrinfo_pkginfo_filter_foreach_pkginfo() is failed. result = [%d]", res);
+
+ pList->RemoveAll(true);
+ pList = null;
+ }
+
+CATCH:
+ if (handle)
+ {
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ }
+
+ return pList;
}
IList*
}
int
+_PackageManagerImpl::PackageInfoHandler(const pkgmgrinfo_pkginfo_h handle, void* pUserData)
+{
+ SysTryReturn(NID_APP, handle, 0, E_SYSTEM, "handle must not be null.");
+ SysTryReturn(NID_APP, pUserData, 0, E_SYSTEM, "pUserData must not be null.");
+
+ result r = E_SUCCESS;
+ int res = PMINFO_R_OK;
+ char* pPackageId = null;
+ ArrayList* pList = (ArrayList*)pUserData;
+
+ res = pkgmgrinfo_pkginfo_get_pkgname(handle, &pPackageId);
+ SysTryReturn(NID_APP, res == PMINFO_R_OK, 0, E_SYSTEM, "pkgmgrinfo_pkginfo_get_pkgname() is failed. [%d]", res);
+
+ std::unique_ptr<PackageInfo> pPackageInfo(new (std::nothrow) PackageInfo);
+ SysTryReturn(NID_APP, pPackageInfo, 0, E_OUT_OF_MEMORY, "pPackageInfo instance must not be null.");
+
+ _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
+ r = pPackageInfoImpl->Construct(pPackageId);
+ SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pPackageId);
+
+ pList->Add(*pPackageInfo.release());
+
+ return 0;
+}
+
+int
_PackageManagerImpl::PackageAppInfoHandler(const pkgmgrinfo_appinfo_h handle, void* pUserData)
{
SysTryReturn(NID_APP, handle, 0, E_SYSTEM, "handle must not be null.");