diff options
author | Duyoung Jang <duyoung.jang@samsung.com> | 2013-09-24 13:36:42 +0900 |
---|---|---|
committer | Duyoung Jang <duyoung.jang@samsung.com> | 2013-09-26 13:56:01 +0900 |
commit | cd018ed4eb8b81950f1a6bdda9f4329a91800369 (patch) | |
tree | a43f5353c1119f89c53b4dffdd75e4958a0a698e | |
parent | 84c3dfe13c6bef5dfa404baedca912dca7e29446 (diff) | |
download | installer-cd018ed4eb8b81950f1a6bdda9f4329a91800369.tar.gz installer-cd018ed4eb8b81950f1a6bdda9f4329a91800369.tar.bz2 installer-cd018ed4eb8b81950f1a6bdda9f4329a91800369.zip |
Fix update logic for compat
Change-Id: I788ebcd5c64340ebc099bc066afdd307b48b6528
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
-rwxr-xr-x | inc/InstallerDefs.h | 2 | ||||
-rwxr-xr-x | src/Manager/InstallerManager.cpp | 83 | ||||
-rwxr-xr-x | src/Manager/InstallerManager.h | 4 | ||||
-rwxr-xr-x | src/Manager/SignatureManager.cpp | 2 | ||||
-rwxr-xr-x | src/Step/SystemCheckStep.cpp | 21 | ||||
-rwxr-xr-x | src/backend/backend.cpp | 2 |
6 files changed, 74 insertions, 40 deletions
diff --git a/inc/InstallerDefs.h b/inc/InstallerDefs.h index 35e6b34..ec046ce 100755 --- a/inc/InstallerDefs.h +++ b/inc/InstallerDefs.h @@ -23,7 +23,7 @@ #include "InstallerUtil.h" -#define OSP_INSTALLER_VERSION "version=[20130924.1]" +#define OSP_INSTALLER_VERSION "version=[20130926.1]" #define DIR_BIN L"/bin" #define DIR_INFO L"/info" diff --git a/src/Manager/InstallerManager.cpp b/src/Manager/InstallerManager.cpp index b5a3051..848e4bf 100755 --- a/src/Manager/InstallerManager.cpp +++ b/src/Manager/InstallerManager.cpp @@ -160,7 +160,7 @@ InstallerManager::Construct(const String& path, InstallerOperation operation, In if (pOptionalData) { ParseOptionalData(pOptionalData); - SendEvent(__pContext, __pContext->__packageId, "start", "install"); + SendEvent(__pContext->__pPkgmgrInstaller, __pContext->__packageId, "start", "install"); } else { @@ -196,6 +196,8 @@ InstallerManager::Construct(const String& path, InstallerOperation operation, In { if (option & INSTALLER_OPTION_CSC) { + TryReturn(pOptionalData, INSTALLER_ERROR_INTERNAL_STATE, "pOptionalData(cscInfo) is null."); + AppLog("INSTALLER_OPTION_CSC is detected."); __pContext->__isCsc = true; __pContext->__cscInfo = *pOptionalData; @@ -237,7 +239,7 @@ InstallerManager::Construct(const String& path, InstallerOperation operation, In __pContext->SetCurrentInstallationStep(INSTALLER_STEP_INIT_UNINSTALL); __pContext->__packageId = newPath; - SendEvent(__pContext, __pContext->__packageId, "start", "uninstall"); + SendEvent(__pContext->__pPkgmgrInstaller, __pContext->__packageId, "start", "uninstall"); } else if (operation == INSTALLER_OPERATION_REINSTALL) { @@ -248,7 +250,7 @@ InstallerManager::Construct(const String& path, InstallerOperation operation, In __pContext->SetCurrentInstallationStep(INSTALLER_STEP_RDS_INIT); __pContext->__packageId = newPath; - SendEvent(__pContext, __pContext->__packageId, "start", "install"); + SendEvent(__pContext->__pPkgmgrInstaller, __pContext->__packageId, "start", "install"); } __pContext->SetInstallerOperation(operation); @@ -335,7 +337,7 @@ InstallerManager::GetNext(void) InstallerError InstallerManager::Init(void) { - SendEvent(__pContext, __pContext->__packageId, "install_percent", "0"); + SendEvent(__pContext->__pPkgmgrInstaller, __pContext->__packageId, "install_percent", "0"); return __pInstaller->OnInit(); } @@ -348,7 +350,7 @@ InstallerManager::Error(void) InstallerError InstallerManager::Register(void) { - SendEvent(__pContext, __pContext->__packageId, "install_percent", "60"); + SendEvent(__pContext->__pPkgmgrInstaller, __pContext->__packageId, "install_percent", "60"); return __pInstaller->OnRegister(); } @@ -428,8 +430,8 @@ InstallerManager::Activate(void) CATCH: if (error == INSTALLER_ERROR_NONE) { - SendEvent(__pContext, __pContext->__packageId, "install_percent", "100"); - SendEvent(__pContext, __pContext->__packageId, "end", "ok"); + SendEvent(__pContext->__pPkgmgrInstaller, __pContext->__packageId, "install_percent", "100"); + SendEvent(__pContext->__pPkgmgrInstaller, __pContext->__packageId, "end", "ok"); } else { @@ -441,8 +443,8 @@ CATCH: errorString += L":"; errorString += __pContext->__additionalErrorString; } - SendEvent(__pContext, __pContext->__packageId, "error", errorString); - SendEvent(__pContext, __pContext->__packageId, "end", "fail"); + SendEvent(__pContext->__pPkgmgrInstaller, __pContext->__packageId, "error", errorString); + SendEvent(__pContext->__pPkgmgrInstaller, __pContext->__packageId, "end", "fail"); } return error; @@ -742,11 +744,11 @@ InstallerManager::ReqeustByTest(void) } else if (readBuf[0] == '>') { - errorType = InstallerManager::RequestMove(path, PM_MOVE_TO_SDCARD); + errorType = InstallerManager::RequestMove(path, PM_MOVE_TO_SDCARD, null); } else if (readBuf[0] == '<') { - errorType = InstallerManager::RequestMove(path, PM_MOVE_TO_INTERNAL); + errorType = InstallerManager::RequestMove(path, PM_MOVE_TO_INTERNAL, null); } else if (readBuf[0] == '#') { @@ -995,26 +997,24 @@ InstallerManager::IsHistoryFileLogOn() const } bool -InstallerManager::SendEvent(InstallationContext* pContext, const PackageId& packageId, const String& key, const String& val) +InstallerManager::SendEvent(void* pPkgmgrInstaller, const PackageId& packageId, const String& key, const String& val) { - TryReturn(pContext, false, "pContext is null."); + TryReturn(pPkgmgrInstaller, false, "pPkgmgrInstaller is null."); TryReturn(key.IsEmpty() == false, false, "key is empty."); TryReturn(val.IsEmpty() == false, false, "val is empty."); - InstallerOperation operation = pContext->GetInstallerOperation(); - - if (pContext->__pPkgmgrInstaller == null) - { - AppLog("pContext->__pPkgmgrInstaller is null. [%ls]", packageId.GetPointer()); - return false; - } - - if (operation == INSTALLER_OPERATION_UNINSTALL) + InstallerManager* pInstallManager = InstallerManager::GetInstance(); + InstallationContext* pContext = pInstallManager->GetContext(); + if (pContext) { - if (key == L"install_percent") + InstallerOperation operation = pContext->GetInstallerOperation(); + if (operation == INSTALLER_OPERATION_UNINSTALL) { - AppLog("install_percent is skipped. [%ls]", packageId.GetPointer()); - return true; + if (key == L"install_percent") + { + AppLog("install_percent is skipped. [%ls]", packageId.GetPointer()); + return true; + } } } @@ -1036,7 +1036,7 @@ InstallerManager::SendEvent(InstallationContext* pContext, const PackageId& pack std::unique_ptr<char[]> pVal(_StringConverter::CopyToCharArrayN(value)); TryReturn(pVal, false, "pVal is null."); - pkgmgr_installer_send_signal((pkgmgr_installer*) pContext->__pPkgmgrInstaller, "tpk", pPackageId.get(), pKey.get(), pVal.get()); + pkgmgr_installer_send_signal((pkgmgr_installer*) pPkgmgrInstaller, "tpk", pPackageId.get(), pKey.get(), pVal.get()); AppLog("pkgmgr_installer_send_signal(tpk, %s, %s, %s)", pPackageId.get(), pKey.get(), pVal.get()); return true; @@ -1396,8 +1396,10 @@ InstallerManager::RequestByCommand(int argc, char **argv) } int -InstallerManager::RequestMove(const PackageId& packageId, int moveType) +InstallerManager::RequestMove(const PackageId& packageId, int moveType, void* pPkgmgrInstaller) { + TryReturn(packageId.IsEmpty() == false, INSTALLER_ERROR_INTERNAL_STATE, "packageId is empty."); + result r = E_SUCCESS; int res = 0; InstallerError errorType = INSTALLER_ERROR_NONE; @@ -1410,8 +1412,10 @@ InstallerManager::RequestMove(const PackageId& packageId, int moveType) _PackageInfoImpl* pPackageInfoImpl = null; String rootPath; + SendEvent(pPkgmgrInstaller, packageId, "start", "move"); + std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId)); - TryReturn(pPackageId, INSTALLER_ERROR_OUT_OF_MEMORY, "pPackageId is null"); + TryReturn(pPackageId, INSTALLER_ERROR_OUT_OF_MEMORY, "pPackageId is null."); if (moveType == PM_MOVE_TO_INTERNAL) { @@ -1419,15 +1423,15 @@ InstallerManager::RequestMove(const PackageId& packageId, int moveType) } pPackageInfo = _PackageManagerImpl::GetInstance()->GetPackageInfoN(packageId); - TryCatch(pPackageInfo != null, errorType = INSTALLER_ERROR_INTERNAL_STATE, "GetPackageInfoN() failed"); + TryCatch(pPackageInfo != null, errorType = INSTALLER_ERROR_INTERNAL_STATE, "GetPackageInfoN() failed."); pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo); - TryCatch(pPackageInfoImpl, errorType = INSTALLER_ERROR_INTERNAL_STATE, "GetInstance() failed"); + TryCatch(pPackageInfoImpl, errorType = INSTALLER_ERROR_INTERNAL_STATE, "GetInstance() failed."); rootPath = pPackageInfoImpl->GetAppRootPath(); pHandle = app2ext_init(APP2EXT_SD_CARD); - TryCatch(pHandle, errorType = INSTALLER_ERROR_INTERNAL_STATE, "app2ext_init() failed"); + TryCatch(pHandle, errorType = INSTALLER_ERROR_INTERNAL_STATE, "app2ext_init() failed."); if (location == APP2EXT_MOVE_TO_PHONE) { @@ -1435,13 +1439,13 @@ InstallerManager::RequestMove(const PackageId& packageId, int moveType) } pDir = new (std::nothrow) Directory; - TryCatch(pDir, errorType = INSTALLER_ERROR_OUT_OF_MEMORY, "pDir is null"); + TryCatch(pDir, errorType = INSTALLER_ERROR_OUT_OF_MEMORY, "pDir is null."); r = pDir->Construct(rootPath); TryCatch(!IsFailed(r), errorType = INSTALLER_ERROR_INTERNAL_STATE, "pDir->Construct() failed, path = [%ls]", rootPath.GetPointer()); pDirEnum = pDir->ReadN(); - TryCatch(pDirEnum, errorType = INSTALLER_ERROR_INTERNAL_STATE, "pDirEnum is null"); + TryCatch(pDirEnum, errorType = INSTALLER_ERROR_INTERNAL_STATE, "pDirEnum is null."); while (pDirEnum->MoveNext() == E_SUCCESS) { @@ -1468,7 +1472,7 @@ InstallerManager::RequestMove(const PackageId& packageId, int moveType) app2ext_dir_details* pDirDetails = null; pDirDetails = (app2ext_dir_details*) calloc(1, sizeof(app2ext_dir_details)); - TryCatch(pDirDetails, errorType = INSTALLER_ERROR_INTERNAL_STATE, "pDirDetails is null"); + TryCatch(pDirDetails, errorType = INSTALLER_ERROR_INTERNAL_STATE, "pDirDetails is null."); length = entryName.GetLength(); pDirDetails->name = (char*) calloc(1, (sizeof(char) * length) + 1); @@ -1494,7 +1498,7 @@ InstallerManager::RequestMove(const PackageId& packageId, int moveType) } res = pHandle->interface.move(pPackageId.get(), pDirectoryList, location); - TryCatch(res == 0, errorType = INSTALLER_ERROR_INTERNAL_STATE, "pHandle->interface.move() failed [%d]", res); + TryCatch(res == 0, errorType = INSTALLER_ERROR_INTERNAL_STATE, "pHandle->interface.move() failed. res = [%d]", res); CATCH: if (pHandle) @@ -1524,6 +1528,15 @@ CATCH: delete pDir; delete pPackageInfo; + if (errorType == INSTALLER_ERROR_NONE) + { + SendEvent(pPkgmgrInstaller, packageId, "end", "ok"); + } + else + { + SendEvent(pPkgmgrInstaller, packageId, "end", "fail"); + } + return errorType; } diff --git a/src/Manager/InstallerManager.h b/src/Manager/InstallerManager.h index 99f227e..899b5b7 100755 --- a/src/Manager/InstallerManager.h +++ b/src/Manager/InstallerManager.h @@ -57,14 +57,14 @@ public: bool IsFileLogOn() const; 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 SendEvent(void* pPkgmgrInstaller, 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, 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 RequestMove(const Tizen::App::PackageId& packageId, int moveType, void* pPkgmgrInstaller); static int RequestCsc(const Tizen::Base::String& buffer, InstallerOption option, void* pPkgmgrInstaller = null); static int RequestRecovery(void); diff --git a/src/Manager/SignatureManager.cpp b/src/Manager/SignatureManager.cpp index 877c227..e076a0e 100755 --- a/src/Manager/SignatureManager.cpp +++ b/src/Manager/SignatureManager.cpp @@ -557,7 +557,7 @@ SignatureManager::GetApiVisibility(RootCertificateType certType) int SignatureManager::GetPrivilegeLevel(int apiVisibility) { - if (apiVisibility == _API_VISIBILITY_PARTNER_MANUFACTURER || apiVisibility == _API_VISIBILITY_PARTNER_OPERATOR) + if (apiVisibility == _API_VISIBILITY_PLATFORM) { return PRIVILEGE_LEVEL_PLATFORM; } diff --git a/src/Step/SystemCheckStep.cpp b/src/Step/SystemCheckStep.cpp index ce923ed..ce32abd 100755 --- a/src/Step/SystemCheckStep.cpp +++ b/src/Step/SystemCheckStep.cpp @@ -21,6 +21,7 @@ #include <FAppPkgPackageInfo.h> #include <FAppPkgPackageAppInfo.h> +#include <FIoFile.h> #include <FAppPkg_PackageInfoImpl.h> #include <FAppPkg_PackageManagerImpl.h> #include <FApp_Aul.h> @@ -28,11 +29,13 @@ #include "InstallationContext.h" #include "SystemCheckStep.h" #include "DatabaseManager.h" +#include "CompatibilityManager.h" using namespace Tizen::App; using namespace Tizen::App::Package; using namespace Tizen::Base; using namespace Tizen::Base::Collection; +using namespace Tizen::Io; SystemCheckStep::SystemCheckStep(void) :__state(STATE_VERSION_CHECK) @@ -153,6 +156,24 @@ SystemCheckStep::OnStateVersionCheck(void) result = InstallerUtil::TerminateApp(appId); TryReturn(result == true, INSTALLER_ERROR_FATAL_ERROR, "TerminateApp(%ls) failed.", appId.GetPointer()); } + + CompatibilityManager compatibilityManager; + compatibilityManager.Construct(__pContext); + + String rootPath = pPackageInfoImpl->GetAppRootPath(); + String compatPath = rootPath + L"/info/compat.info"; + if (File::IsFileExist(compatPath) == true) + { + result = compatibilityManager.FinalizeDataCaging(rootPath); + TryReturn(result == true, INSTALLER_ERROR_UNMOUNT_FAILED, "FinalizeDataCaging(%ls) failed.", rootPath.GetPointer()); + } + + String virtualRootInfoFile = rootPath + VIRTUAL_ROOT_INFO_FILE; + if (File::IsFileExist(virtualRootInfoFile) == true) + { + result = compatibilityManager.FinalizeVirtualRoot(rootPath, __pContext->__packageId); + TryReturn(result == true, INSTALLER_ERROR_UNMOUNT_FAILED, "FinalizeVirtualRoot(%ls) failed.", rootPath.GetPointer()); + } } GoNextState(); diff --git a/src/backend/backend.cpp b/src/backend/backend.cpp index 48cc502..323eb41 100755 --- a/src/backend/backend.cpp +++ b/src/backend/backend.cpp @@ -230,7 +230,7 @@ main(int argc, char **argv) int moveType = -1; moveType = pkgmgr_installer_get_move_type(_pi); - InstallerManager::RequestMove(path, moveType); + InstallerManager::RequestMove(path, moveType, _pi); } else { |