#include "InstallerUtil.h"
-#define OSP_INSTALLER_VERSION "version=[20130612.2]"
+#define OSP_INSTALLER_VERSION "version=[20130613.1]"
#define DIR_BIN L"/bin"
#define DIR_INFO L"/info"
Tizen::Base::String __description;
Tizen::App::PackageId __storeClientId;
Tizen::Base::String __additionalErrorString;
+ Tizen::Base::String __cscInfo;
int __certType;
void* __pPkgmgrInstaller;
{
AppLog("INSTALLER_OPTION_CSC is detected.");
__pContext->__isCsc = true;
+ __pContext->__cscInfo = *pOptionalData;
}
installerType = INSTALLER_TYPE_PACKAGE;
String storeClientId;
String removable;
+ String path;
while (pEnum->MoveNext() == E_SUCCESS)
{
{
removable = (*pValue);
}
+
+ if (pKey->Equals(L"path", false) == true)
+ {
+ path = (*pValue);
+ }
}
if (storeClientId.IsEmpty() == false)
__pContext->__isUninstallable = true;
AppLog(" # removable = [true]");
}
+
+ if (__pContext->__isCsc == true)
+ {
+ if (path.IsEmpty() == false)
+ {
+ std::unique_ptr< PackageInfo > pPackageInfo(_PackageManagerImpl::GetInstance()->GetPackageInfoFromFileN(path));
+ TryReturn(pPackageInfo, false, "GetPackageInfoFromFileN() failed. [%s]", GetErrorMessage(GetLastResult()));
+
+ __pContext->__packageId = pPackageInfo->GetId();
+ AppLog(" # packageId = [%ls]", __pContext->__packageId.GetPointer());
+ }
+ }
}
return true;
}
bool
-InstallerManager::IsUninstallUpdates(const PackageId& packageId, String& originPath)
+InstallerManager::IsUninstallUpdates(const PackageId& packageId, String& originPath, bool& isCscPackage)
{
+ String cscInfo;
String roXmlPath;
roXmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, packageId.GetPointer());
+
if (File::IsFileExist(roXmlPath) == true)
{
String rwXmlPath;
rwXmlPath.Format(1024, DIR_RW_PACKAGE_SYSTEM_MANIFEST, packageId.GetPointer());
if (File::IsFileExist(rwXmlPath) == true)
{
+ InstallerUtil::Remove(rwXmlPath);
+
String preloadedAppPath(PATH_USR_APPS);
preloadedAppPath += L"/";
preloadedAppPath += packageId;
return true;
}
}
- else
+ else if(InstallerUtil::IsCscPackage(packageId, cscInfo) == true)
{
- //if (CSC_preloaded && update)
- //{
- // originPath = cscPackagePath;
- //}
+ String tokenDelimiter(":");
+
+ std::unique_ptr< IMap > pMap(InstallerUtil::ParseN(cscInfo, tokenDelimiter));
+ TryReturn(pMap, false, "ParseN() failed. [%s]", GetErrorMessage(GetLastResult()));
+
+ std::unique_ptr< IMapEnumerator > pEnum(pMap->GetMapEnumeratorN());
+ TryReturn(pEnum, false, "GetMapEnumeratorN() failed. [%s]", GetErrorMessage(GetLastResult()));
+
+ String removable;
+ String path;
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pKey = static_cast< String* > (pEnum->GetKey());
+ TryReturn(pEnum, false, "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
+
+ String* pValue = static_cast< String* > (pEnum->GetValue());
+ TryReturn(pEnum, false, "GetValue() failed. [%s]", GetErrorMessage(GetLastResult()));
+
+ AppLog("key = [%ls], value = [%ls]", pKey->GetPointer(), pValue->GetPointer());
+
+ if (pKey->Equals(L"removable", false) == true)
+ {
+ removable = (*pValue);
+ }
+
+ if (pKey->Equals(L"path", false) == true)
+ {
+ path = (*pValue);
+ }
+ }
+
+ if (removable.Equals(L"false", false) == true)
+ {
+ isCscPackage = true;
+
+ AppLog("uninstall updates for csc-preloaded app [%ls]", path.GetPointer());
+ originPath = cscInfo;
+
+ return true;
+ }
+ else
+ {
+ AppLog("uninstall package for csc-preloaded app. [%ls]");
+ }
}
return false;
}
int
-InstallerManager::RequestCsc(const String& buffer, InstallerOption option)
+InstallerManager::RequestCsc(const String& buffer, InstallerOption option, void* pPkgmgrInstaller)
{
int errorType = 0;
if (op.Equals(L"install", false) == true)
{
- errorType = InstallerManager::Request(path, INSTALLER_OPERATION_INSTALL, option, null, &buffer);
+ errorType = InstallerManager::Request(path, INSTALLER_OPERATION_INSTALL, option, pPkgmgrInstaller, &buffer);
}
else if (op.Equals(L"uninstall", false) == true)
{
bool IsHistoryFileLogOn() const;
static bool SendEvent(InstallationContext* pContext, const Tizen::App::PackageId& packageId, const Tizen::Base::String& key, const Tizen::Base::String& val);
- static bool IsUninstallUpdates(const Tizen::App::PackageId& packageId, Tizen::Base::String& originPath);
+ static bool IsUninstallUpdates(const Tizen::App::PackageId& packageId, Tizen::Base::String& originPath, bool& isCscPackage);
static int Request(const Tizen::Base::String& path, InstallerOperation operation, InstallerOption option, void* pPkgmgrInstaller, const Tizen::Base::String* pOptionalData = null);
static int RequestRecursiveDirectory(const Tizen::Base::String& path, int& errorType);
static int RequestByCommand(int argc, char **argv);
static int ReqeustByTest(void);
static int RequestMove(const Tizen::App::PackageId& packageId, int moveType);
- static int RequestCsc(const Tizen::Base::String& buffer, InstallerOption option);
+ static int RequestCsc(const Tizen::Base::String& buffer, InstallerOption option, void* pPkgmgrInstaller = null);
private:
InstallerManager(const InstallerManager& value);
InstallerUtil::TerminateApps(const PackageId& packageId)
{
std::unique_ptr< PackageInfo > pPackageInfo(_PackageManagerImpl::GetInstance()->GetPackageInfoN(packageId));
+ TryReturn(pPackageInfo, false, "GetPackageInfoN() failed.");
_PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
TryReturn(pPackageInfoImpl, false, "GetInstance() failed.");
return true;
}
+
+bool
+InstallerUtil::IsUninstallable(const PackageId& packageId)
+{
+ bool res = false;
+
+ std::unique_ptr< PackageInfo > pPackageInfo(_PackageManagerImpl::GetInstance()->GetPackageInfoN(packageId));
+ TryReturn(pPackageInfo, false, "GetPackageInfoN() failed.");
+
+ _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
+ TryReturn(pPackageInfoImpl, false, "GetInstance() failed.");
+
+ res = pPackageInfoImpl->IsUninstallable();
+
+ AppLog("packageId[%ls]: Uninstallable = [%s]", packageId.GetPointer(), res?"true":"false");
+
+ return res;
+}
+
+bool
+InstallerUtil::IsCscPackage(const PackageId& packageId, String& cscInfo)
+{
+ bool res = false;
+ int result = 0;
+ char* pPath = null;
+ pkgmgrinfo_pkginfo_h handle = null;
+
+ std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
+ TryReturn(pPackageId, false, "pPackageId is null.");
+
+ result = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &handle);
+ TryReturn(result == PMINFO_R_OK, false, "pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], package=[%s]", result, pPackageId.get());
+
+ result = pkgmgrinfo_pkginfo_get_csc_path(handle, &pPath);
+ TryReturn(result == PMINFO_R_OK, false, "pkgmgrinfo_pkginfo_get_csc_path() failed. result=[%d], package=[%s]", result, pPackageId.get());
+
+ AppLog("csc_path = [%s]", pPath);
+
+ cscInfo = pPath;
+
+ if (cscInfo.IsEmpty() == false)
+ {
+ res = true;
+ AppLog("packageId[%ls]: cscInfo = [%ls]", packageId.GetPointer(), cscInfo.GetPointer());
+ }
+
+ if (handle)
+ {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ }
+
+ return res;
+}
static bool TerminateApp(const Tizen::App::AppId& appId);
static bool TerminateApps(const Tizen::App::PackageId& packageId);
+ static bool IsUninstallable(const Tizen::App::PackageId& packageId);
+ static bool IsCscPackage(const Tizen::App::PackageId& packageId, Tizen::Base::String& cscInfo);
+
private:
static char LogChangeHexToStr(int hex);
InstallerUtil(const InstallerUtil& value);
__pWriter->WriteAttribute("appsetting", appSetting);
__pWriter->WriteAttribute("storeclient-id", __pContext->__storeClientId);
__pWriter->WriteAttribute("url", __pContext->__url);
+ __pWriter->WriteAttribute("csc_path", __pContext->__cscInfo);
__pWriter->StartElement("label");
__pWriter->WriteString(__pContext->__displayName);
case PKGMGR_REQ_UNINSTALL:
{
+ bool isCscPackage = false;
PackageId reqeustPackageId;
path.SubString(0, PACKAGE_ID_LENGTH, reqeustPackageId);
AppLog("reqeustPackage = %ls", reqeustPackageId.GetPointer());
String originPath;
- if (InstallerManager::IsUninstallUpdates(reqeustPackageId, originPath) == true)
+ if (InstallerManager::IsUninstallUpdates(reqeustPackageId, originPath, isCscPackage) == true)
{
- AppLog("originPath = [%ls]", originPath.GetPointer());
-
+ AppLog("originPath = [%ls], isCscPackage = [%s]", originPath.GetPointer(), isCscPackage?"true":"false");
optionalData = reqeustPackageId;
- errorType = InstallerManager::Request(originPath, INSTALLER_OPERATION_INSTALL, INSTALLER_OPTION_RESET_PRELOADED, _pi, &optionalData);
+
+ if (isCscPackage == false)
+ {
+ errorType = InstallerManager::Request(originPath, INSTALLER_OPERATION_INSTALL, INSTALLER_OPTION_RESET_PRELOADED, _pi, &optionalData);
+ }
+ else
+ {
+ InstallerOption option = INSTALLER_OPTION_RESET_PRELOADED;
+ option = (InstallerOption)(option | INSTALLER_OPTION_CSC);
+
+ errorType = InstallerManager::RequestCsc(originPath, option, _pi);
+ }
}
else
{