Terminate apps when MoveToSD() API
authorDuyoung Jang <duyoung.jang@samsung.com>
Mon, 27 May 2013 01:40:50 +0000 (10:40 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Mon, 27 May 2013 01:40:50 +0000 (10:40 +0900)
Change-Id: I4ef650a1dc988bac53baa2cb289dde897fa6f629
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
inc/InstallerDefs.h
src/Context/InstallationContext.cpp
src/Manager/InstallerManager.cpp
src/Step/SystemCheckStep.cpp
src/Step/SystemCheckStep.h
src/Step/UninstallStep.cpp
src/Util/InstallerUtil.cpp
src/Util/InstallerUtil.h
src/XmlHandler/ManifestGenerator.cpp
src/XmlHandler/ManifestHandler.cpp

index 6683534..67a5c71 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130525.1]"
+#define OSP_INSTALLER_VERSION "version=[20130527.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
@@ -311,6 +311,7 @@ enum CategoryType
 
 enum InstallationStorage
 {
+       INSTALLATION_STORAGE_NONE,
        INSTALLATION_STORAGE_INTERNAL,
        INSTALLATION_STORAGE_EXTERNAL,
 
index 9a57b1c..a4d2a15 100755 (executable)
@@ -56,7 +56,7 @@ InstallationContext::InstallationContext(void)
 ,__isCsc(false)
 ,__isUninstallable(false)
 ,__operation(INSTALLER_OPERATION_INSTALL)
-,__storage(INSTALLATION_STORAGE_INTERNAL)
+,__storage(INSTALLATION_STORAGE_NONE)
 ,__rootCertType(ROOT_CERTIFICATE_NONE)
 ,__privilegeLevel(PRIVILEGE_LEVEL_PUBLIC)
 ,__pApp2ExtHandle(null)
index cf31ee7..6f229ed 100755 (executable)
@@ -1266,9 +1266,6 @@ InstallerManager::RequestMove(const PackageId& packageId, int moveType)
                DirEntry entry = pDirEnum->GetCurrentDirEntry();
 
                String entryName = entry.GetName();
-               //String rootDirectory = rootPath;
-               //rootDirectory += L"/";
-               //rootDirectory += entryName;
 
                if (entryName == L"." || entryName == L"..")
                {
@@ -1285,17 +1282,16 @@ InstallerManager::RequestMove(const PackageId& packageId, int moveType)
                pDirDetails->name = (char*) calloc(1, (sizeof(char) * length) + 1);
                snprintf(pDirDetails->name, length + 1, "%ls", entryName.GetPointer());
 
-               String bin(L"bin");
-               String res(L"res");
-               String icons(L"icons");
+               String data(L"data");
+               String shared(L"shared");
 
-               if (entryName.Contains(bin) || entryName.Contains(res) || entryName.Contains(icons))
+               if (entryName.Contains(data) || entryName.Contains(shared))
                {
-                       pDirDetails->type = APP2EXT_DIR_RO;
+                       pDirDetails->type = APP2EXT_DIR_RW;
                }
                else
                {
-                       pDirDetails->type = APP2EXT_DIR_RW;
+                       pDirDetails->type = APP2EXT_DIR_RO;
                }
 
                AppLog("------------------------------------------");
index e7dc759..0cbc791 100755 (executable)
@@ -100,6 +100,7 @@ SystemCheckStep::OnStateVersionCheck(void)
 {
        InstallerError error = INSTALLER_ERROR_NONE;
        int res = 0;
+       bool result = true;
 
        std::unique_ptr< PackageInfo > pPackageInfo(_PackageManagerImpl::GetInstance()->GetPackageInfoN(__pContext->__packageId));
        if (pPackageInfo)
@@ -157,8 +158,8 @@ SystemCheckStep::OnStateVersionCheck(void)
                                AppLog("AutoRestart[%ls] is updated.", pAppInfoImpl->GetAppFeature(key).GetPointer());
                        }
 
-                       res = CheckAppStatus(appId);
-                       TryReturn(res, INSTALLER_ERROR_FATAL_ERROR, "CheckAppStatus(%ls) failed.", appId.GetPointer());
+                       result = InstallerUtil::TerminateApp(appId);
+                       TryReturn(result == true, INSTALLER_ERROR_FATAL_ERROR, "TerminateApp(%ls) failed.", appId.GetPointer());
                }
        }
 
@@ -272,44 +273,3 @@ SystemCheckStep::ExtractVersion(const String& version, int& major, int& minor, i
 
        return true;
 }
-
-bool
-SystemCheckStep::CheckAppStatus(const AppId& appId)
-{
-       bool res = true;
-
-       if (_Aul::IsRunning(appId) == true)
-       {
-               AppLog("App(%ls) is running.", appId.GetPointer());
-
-               result r = _Aul::TerminateApplication(appId);
-               TryReturn(r == E_SUCCESS, false, "TerminateApplication() failed. [%ls]", appId.GetPointer());
-
-               for (int j = 0; j < TERMINATE_RETRY_COUNT; j++)
-               {
-                       res = _Aul::IsRunning(appId);
-                       if (res == false)
-                       {
-                               AppLog("App(%ls) is terminated.", appId.GetPointer());
-                               break;
-                       }
-                       else
-                       {
-                               AppLog("App(%ls) is not terminated yet. wait count = [%d]", appId.GetPointer(), j);
-                               usleep(100000);
-                       }
-               }
-
-               if (res == true)
-               {
-                       AppLog("App(%ls) can't be terminated.", appId.GetPointer());
-                       return false;
-               }
-       }
-       else
-       {
-               AppLog("App(%ls) is not running.", appId.GetPointer());
-       }
-
-       return true;
-}
index 0585f73..da6b1b2 100755 (executable)
@@ -67,7 +67,6 @@ private:
 
        int CompareVersion(const Tizen::Base::String& oldVersion, const Tizen::Base::String& newVersion);
        bool ExtractVersion(const Tizen::Base::String& version, int& major, int& minor, int& macro);
-       bool CheckAppStatus(const Tizen::App::AppId& appId);
 
 private:
        int __state;
index 3116128..06a1398 100755 (executable)
 #include <app2ext_interface.h>
 
 #include <FIoDirectory.h>
-#include <FAppPkgPackageInfo.h>
-#include <FAppPkgPackageAppInfo.h>
 #include <FIo_FileImpl.h>
 #include <FBase_StringConverter.h>
-#include <FAppPkg_PackageManagerImpl.h>
 #include <FAppPkg_PackageInfoImpl.h>
-#include <FAppPkg_PackageAppInfoImpl.h>
 
 #include "InstallationContext.h"
 #include "UninstallStep.h"
@@ -217,22 +213,8 @@ InstallerError
 UninstallStep::OnStateTerminateApp(void)
 {
        InstallerError error = INSTALLER_ERROR_NONE;
-       std::unique_ptr< PackageInfo > pPackageInfo(_PackageManagerImpl::GetInstance()->GetPackageInfoN(__pContext->__packageId));
 
-       _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
-       TryReturn(pPackageInfoImpl, INSTALLER_ERROR_INTERNAL_STATE, "GetInstance() failed.");
-
-       std::unique_ptr< IList > pPackageAppList(pPackageInfoImpl->GetPackageAppInfoListN());
-       TryReturn(pPackageAppList, INSTALLER_ERROR_INTERNAL_STATE, "GetPackageAppInfoListN() failed.");
-
-       for (int i = 0; i < pPackageAppList->GetCount(); i++)
-       {
-               PackageAppInfo* pPackageAppInfo = dynamic_cast < PackageAppInfo* >(pPackageAppList->GetAt(i));
-               TryReturn(pPackageAppInfo, INSTALLER_ERROR_INTERNAL_STATE, "pPackageAppList->GetAt(%d) failed.", i);
-
-               AppId appId = pPackageAppInfo->GetAppId();
-               InstallerUtil::TerminateApp(appId);
-       }
+       InstallerUtil::TerminateApps(__pContext->__packageId);
 
        GoNextState();
        return error;
index 1a23da4..611f28c 100755 (executable)
 #include <FBaseErrorDefine.h>
 #include <FIoFile.h>
 #include <FIoDirectory.h>
+#include <FAppPkgPackageAppInfo.h>
+#include <FAppPkgPackageInfo.h>
 #include <FBase_StringConverter.h>
 #include <FSecCryptoSha2Hash.h>
 #include <FApp_Aul.h>
+#include <FAppPkg_PackageManagerImpl.h>
+#include <FAppPkg_PackageInfoImpl.h>
+#include <FAppPkg_PackageAppInfoImpl.h>
 
 #include "InstallerDefs.h"
 #include "InstallerUtil.h"
@@ -41,6 +46,7 @@ using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Utility;
 using namespace Tizen::App;
+using namespace Tizen::App::Package;
 using namespace Tizen::Io;
 using namespace Tizen::Security::Crypto;
 
@@ -965,3 +971,25 @@ InstallerUtil::TerminateApp(const AppId& appId)
        return true;
 }
 
+bool
+InstallerUtil::TerminateApps(const PackageId& packageId)
+{
+       std::unique_ptr< PackageInfo > pPackageInfo(_PackageManagerImpl::GetInstance()->GetPackageInfoN(packageId));
+
+       _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo.get());
+       TryReturn(pPackageInfoImpl, false, "GetInstance() failed.");
+
+       std::unique_ptr< IList > pPackageAppList(pPackageInfoImpl->GetPackageAppInfoListN());
+       TryReturn(pPackageAppList, false, "GetPackageAppInfoListN() failed.");
+
+       for (int i = 0; i < pPackageAppList->GetCount(); i++)
+       {
+               PackageAppInfo* pPackageAppInfo = dynamic_cast < PackageAppInfo* >(pPackageAppList->GetAt(i));
+               TryReturn(pPackageAppInfo, false, "pPackageAppList->GetAt(%d) failed.", i);
+
+               AppId appId = pPackageAppInfo->GetAppId();
+               TerminateApp(appId);
+       }
+
+       return true;
+}
index da11bfc..974b9bc 100755 (executable)
@@ -87,6 +87,7 @@ public:
        static Tizen::Base::Collection::IMap* ParseN(const Tizen::Base::String& str, const Tizen::Base::String& tokenDelimiter);
 
        static bool TerminateApp(const Tizen::App::AppId& appId);
+       static bool TerminateApps(const Tizen::App::PackageId& packageId);
 
 private:
        static char LogChangeHexToStr(int hex);
index 8669169..d762a00 100755 (executable)
@@ -64,7 +64,7 @@ ManifestGenerator::Write()
        String location;
        String appSetting(L"false");
 
-       if (__pContext->__isPreloaded == true)
+       if ((__pContext->__isPreloaded == true) || (__pContext->__storage == INSTALLATION_STORAGE_INTERNAL))
        {
                location = L"internal-only";
        }
index 16e6b2d..d7fa69d 100755 (executable)
@@ -762,6 +762,9 @@ ManifestHandler::OnServiceAppEndElement(void)
 
        AppLog("</ServiceApp>");
 
+       AppLog("INSTALLATION_STORAGE = [INTERNAL]");
+       __isInternalStorage = true;
+
        return true;
 }
 
@@ -770,10 +773,18 @@ ManifestHandler::OnAppsEndElement(void)
 {
        AppLog("</Apps>");
 
-       if ((__isInternalStorage == false) && (File::IsFileExist(DIR_MEMORYCARD_INSTALLATION) == true))
+       if (__isInternalStorage == true)
+       {
+               AppLog("INSTALLATION_STORAGE = [INTERNAL]");
+               __pContext->__storage = INSTALLATION_STORAGE_INTERNAL;
+       }
+       else
        {
-               AppLog("INSTALLATION_STORAGE = [EXTERNAL]");
-               __pContext->__storage = INSTALLATION_STORAGE_EXTERNAL;
+               if (File::IsFileExist(DIR_MEMORYCARD_INSTALLATION) == true)
+               {
+                       AppLog("INSTALLATION_STORAGE = [EXTERNAL]");
+                       __pContext->__storage = INSTALLATION_STORAGE_EXTERNAL;
+               }
        }
 
        return true;
@@ -960,6 +971,9 @@ ManifestHandler::OnApiVersionValue(const char* pCharacters)
                {
                        AppLog(" - OspCompat=%s", pOspCompat);
                        __pContext->__isOspCompat = true;
+
+                       AppLog("INSTALLATION_STORAGE = [INTERNAL]");
+                       __isInternalStorage = true;
                }
        }