UninstallUpdates logic is added.
authorDuyoung Jang <duyoung.jang@samsung.com>
Wed, 22 May 2013 07:49:53 +0000 (16:49 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Wed, 22 May 2013 07:49:53 +0000 (16:49 +0900)
Change-Id: I33e94f62540d2bfc53b0d6b9a56286cb9e15f9f9
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
inc/InstallerDefs.h
src/Manager/InstallerManager.cpp
src/Manager/InstallerManager.h
src/backend/backend.cpp

index 2705b49..8cb704c 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130521.1]"
+#define OSP_INSTALLER_VERSION "version=[20130522.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
@@ -220,6 +220,7 @@ enum InstallerOption
        INSTALLER_OPTION_FILELOG_ON = 32,
        INSTALLER_OPTION_UPDATE_STDOUT = 64,
        INSTALLER_OPTION_CSC = 128,
+       INSTALLER_OPTION_RESET_PRELOADED = 256,
 
 };
 
index 7176a2d..bd560f1 100755 (executable)
@@ -200,6 +200,18 @@ InstallerManager::Construct(const String& path, InstallerOperation operation, In
                {
                        AppLog("Input param(package) is null in case of cmd, hybrid package.");
                }
+
+               if (option & INSTALLER_OPTION_RESET_PRELOADED)
+               {
+                       TryReturn(__pContext->__packageId.IsEmpty() == false, INSTALLER_ERROR_INTERNAL_STATE, "packageId is empty.");
+
+                       String rootPath(PATH_OPT_USR_APPS);
+                       rootPath += L"/";
+                       rootPath += __pContext->__packageId;
+
+                       AppLog("rootPath[%ls] is deleted.", rootPath.GetPointer());
+                       InstallerUtil::Remove(rootPath);
+               }
        }
        else if (operation == INSTALLER_OPERATION_UNINSTALL)
        {
@@ -927,6 +939,38 @@ InstallerManager::SendEvent(InstallationContext* pContext, const PackageId& pack
        return true;
 }
 
+bool
+InstallerManager::IsUninstallUpdates(const PackageId& packageId, String& originPath)
+{
+       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)
+               {
+                       String preloadedAppPath(PATH_USR_APPS);
+                       preloadedAppPath += L"/";
+                       preloadedAppPath += packageId;
+
+                       AppLog("uninstall updates for preloaded app. [%ls]", preloadedAppPath.GetPointer());
+                       originPath = preloadedAppPath;
+
+                       return true;
+               }
+       }
+       else
+       {
+               //if (CSC_preloaded && update)
+               //{
+               //      originPath = cscPackagePath;
+               //}
+       }
+
+       return false;
+}
+
 int
 InstallerManager::Request(const String& path, InstallerOperation operation, InstallerOption option, void* pPkgmgrInstaller, const String* pOptionalData)
 {
index cc537cd..28aff72 100755 (executable)
@@ -61,6 +61,7 @@ public:
        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 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);
index c04ec68..840a412 100755 (executable)
@@ -173,11 +173,21 @@ main(int argc, char **argv)
        case PKGMGR_REQ_UNINSTALL:
                {
                        PackageId reqeustPackageId;
-
                        path.SubString(0, PACKAGE_ID_LENGTH, reqeustPackageId);
-
                        AppLog("reqeustPackage = %ls", reqeustPackageId.GetPointer());
-                       ret = InstallerManager::Request(reqeustPackageId, INSTALLER_OPERATION_UNINSTALL, INSTALLER_OPTION_NORMAL, _pi);
+
+                       String originPath;
+                       if (InstallerManager::IsUninstallUpdates(reqeustPackageId, originPath) == true)
+                       {
+                               AppLog("originPath = [%ls]", originPath.GetPointer());
+
+                               optionalData = reqeustPackageId;
+                               errorType = InstallerManager::Request(originPath, INSTALLER_OPERATION_INSTALL, INSTALLER_OPTION_RESET_PRELOADED, _pi, &optionalData);
+                       }
+                       else
+                       {
+                               ret = InstallerManager::Request(reqeustPackageId, INSTALLER_OPERATION_UNINSTALL, INSTALLER_OPTION_NORMAL, _pi);
+                       }
 
                        __osp_installer_report_result(reqeustPackageId, errorType);
                }