Installer check setting value, if install-location is auto.
authorSoyoung Kim <sy037.kim@samsung.com>
Mon, 23 Sep 2013 11:30:32 +0000 (20:30 +0900)
committersung-su.kim <sung-su.kim@samsung.com>
Fri, 4 Oct 2013 12:37:05 +0000 (21:37 +0900)
[Issue#]   P130919-00555
[Problem]  WebApp install to internal storage
           even if installation storage set to external on setting menu.
[Cause]    Installer doesn't check setting value about installation storage.
[Solution] Installer will check setting value about install-location.
[Description]
           Two values to determine the location of the installation
           1. install location element value in config.xml, internal-only|auto|preper-external
           2. install location setting menu in target, internal|SD card
           Installed on SD card conditions
           1. config type sets preper_external & inserted MMC
           2. config type sets auto & target type sets SD card
           3. config type sets auto & target type sets internal & out of internal memory

Change-Id: I7dfb193a72e3e765b9d908574246f2212a5e6c4e

src/jobs/widget_install/task_configuration.cpp
src/jobs/widget_install/task_configuration.h

index c0ec745..42cadcc 100644 (file)
@@ -29,6 +29,7 @@
 #include <cstdlib>
 #include <limits.h>
 #include <regex.h>
+#include <vconf.h>
 
 #include <dpl/utils/wrt_utility.h>
 #include <dpl/utils/path.h>
@@ -69,11 +70,9 @@ const size_t PACKAGE_ID_LENGTH = 10;
 static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
 static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
 static const DPL::String SETTING_VALUE_ENCRYPTION_DISABLE = L"disable";
-const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME =
-    L"install-location";
-const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT =
-    L"prefer-external";
-
+const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME = L"install-location";
+const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT = L"prefer-external";
+const DPL::String SETTING_VALUE_INSTALLTOEXT_AUTO = L"auto";
 const std::string XML_EXTENSION = ".xml";
 
 bool hasExtension(const std::string& filename, const std::string& extension)
@@ -622,20 +621,55 @@ void TaskConfiguration::ResourceEncryptionStep()
     }
 }
 
+bool TaskConfiguration::getMMCStatus()
+{
+    int mmcStatus;
+    if (vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmcStatus)) {
+        _E("vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS) failed.");
+        return false;
+    }
+
+    switch(VCONFKEY_SYSMAN_MMC_STATUS)
+    {
+    case VCONFKEY_SYSMAN_MMC_MOUNTED:
+        _D("mmcStatus is MMC_MOUNTED.");
+        return true;
+    case VCONFKEY_SYSMAN_MMC_REMOVED:
+    case VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED:
+        _D("mmcStatus is MMC_REMOVED or NOT_MOUNTED.");
+        return false;
+    default:
+        _E("Platform is not supported, use the default settings");
+        return false;
+    }
+}
+
+bool TaskConfiguration::getDefaultExternalStorage()
+{
+    // XXX NOT IMPLEMENTED.
+    return false;
+}
+
 void TaskConfiguration::InstallationFSLocationStep()
 {
     m_context.locationType = INSTALL_LOCATION_TYPE_NOMAL;
+    DPL::String locationValue;
+
     if (m_context.mode.installTime != InstallMode::InstallTime::PRELOAD) {
         FOREACH(it, m_widgetConfig.settingsList) {
-            if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME &&
-                it->m_value ==
-                SETTING_VALUE_INSTALLTOEXT_PREPER_EXT)
-            {
-                _D("This widget will be installed to sd card");
-                m_context.locationType =
-                    INSTALL_LOCATION_TYPE_EXTERNAL;
+            if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME) {
+                locationValue = it->m_value;
+                break;
             }
         }
+
+        if ((SETTING_VALUE_INSTALLTOEXT_PREPER_EXT == locationValue
+                    && getMMCStatus()) ||
+                (SETTING_VALUE_INSTALLTOEXT_AUTO == locationValue
+                 && getDefaultExternalStorage())) {
+            _D("This webapp will be installed to sd card");
+            m_context.locationType = INSTALL_LOCATION_TYPE_EXTERNAL;
+        }
     }
 }
 
index 44b02be..167c3e4 100644 (file)
@@ -60,6 +60,8 @@ class TaskConfiguration : public DPL::TaskDecl<TaskConfiguration>
     bool checkWidgetUpdate(const WidgetUpdateInfo &update);
     void ApplicationTypeStep(const WrtDB::ConfigParserData &configInfo);
     bool checkSupportRDSUpdate(const WrtDB::ConfigParserData &configInfo);
+    bool getDefaultExternalStorage();
+    bool getMMCStatus();
 
     std::shared_ptr<PackageManager::IPkgmgrSignal> pkgMgrInterface();