72513a1a5ae3d120e372e3480bc87afe64a4c1e3
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_configuration.cpp
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file    task_configuration.cpp
18  * @version 1.0
19  * @author  Tomasz Iwanek
20  * @brief   implementation file for configuration task
21  */
22 #include "task_configuration.h"
23
24 #include <string>
25 #include <sstream>
26 #include <memory>
27 #include <sys/time.h>
28 #include <ctime>
29 #include <cstdlib>
30 #include <limits.h>
31 #include <regex.h>
32 #include <vconf.h>
33
34 #include <dpl/utils/wrt_utility.h>
35 #include <dpl/utils/path.h>
36 #include <dpl/wrt-dao-ro/common_dao_types.h>
37 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
38 #include <dpl/wrt-dao-ro/global_config.h>
39 #include <dpl/wrt-dao-ro/config_parser_data.h>
40 #include <dpl/localization/w3c_file_localization.h>
41
42 #include <libiriwrapper.h>
43 #include <app_manager.h>
44
45 #include "root_parser.h"
46 #include "widget_parser.h"
47 #include "parser_runner.h"
48
49 #include <widget_install/widget_install_errors.h>
50 #include <widget_install/widget_install_context.h>
51 #include <widget_install_to_external.h>
52 #include <widget_install/widget_unzip.h>
53 #include <widget_install/job_widget_install.h>
54 #include <widget_install/task_commons.h>
55
56 #include <installer_log.h>
57
58 using namespace WrtDB;
59
60 namespace {
61 const char* const CONFIG_XML = "config.xml";
62 const char* const WITH_OSP_XML = "res/wgt/config.xml";
63 const char* const OSP_MANIFEST_XML = "info/manifest.xml";
64
65 //allowed: a-z, A-Z, 0-9
66 const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}.{1,}$";
67 const char* REG_NAME_PATTERN = "^[a-zA-Z0-9._-]{1,}$";
68 const size_t PACKAGE_ID_LENGTH = 10;
69
70 static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
71 static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
72 static const DPL::String SETTING_VALUE_ENCRYPTION_DISABLE = L"disable";
73 const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME = L"install-location";
74 const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT = L"prefer-external";
75 const DPL::String SETTING_VALUE_INSTALLTOEXT_AUTO = L"auto";
76 const std::string XML_EXTENSION = ".xml";
77
78 bool hasExtension(const std::string& filename, const std::string& extension)
79 {
80     _D("Looking for extension %s in %s", extension.c_str(), filename.c_str());
81     size_t fileLen = filename.length();
82     size_t extLen = extension.length();
83     if (fileLen < extLen) {
84         _E("Filename %s is shorter than extension %s", filename.c_str(), extension.c_str());
85         return false;
86     }
87     return (0 == filename.compare(fileLen - extLen, extLen, extension));
88 }
89 } // namespace anonymous
90
91 namespace Jobs {
92 namespace WidgetInstall {
93
94 TaskConfiguration::TaskConfiguration(InstallerContext& context) :
95     DPL::TaskDecl<TaskConfiguration>(this),
96     m_context(context),
97     m_widgetConfig(m_context.widgetConfig.configInfo)
98 {
99     AddStep(&TaskConfiguration::StartStep);
100
101     AddStep(&TaskConfiguration::SetupTempDirStep);
102     AddStep(&TaskConfiguration::CheckPackageTypeStep);
103
104     AddStep(&TaskConfiguration::ParseXMLConfigStep);
105
106     AddStep(&TaskConfiguration::TizenIdStep);
107     AddStep(&TaskConfiguration::ApplicationTypeStep);
108     AddStep(&TaskConfiguration::ResourceEncryptionStep);
109     AddStep(&TaskConfiguration::InstallationFSLocationStep);
110
111     AddStep(&TaskConfiguration::DetectUpdateInstallationStep);
112     AddStep(&TaskConfiguration::CheckRDSSupportStep);
113     AddStep(&TaskConfiguration::ConfigureWidgetLocationStep);
114     AddStep(&TaskConfiguration::PkgmgrStartStep);
115
116     AddStep(&TaskConfiguration::AppendTasklistStep);
117
118     AddStep(&TaskConfiguration::EndStep);
119 }
120
121 void TaskConfiguration::StartStep()
122 {
123     _D("--------- <TaskConfiguration> : START ----------");
124 }
125
126 void TaskConfiguration::EndStep()
127 {
128     _D("--------- <TaskConfiguration> : END ----------");
129 }
130
131 void TaskConfiguration::PkgmgrStartStep()
132 {
133     pkgMgrInterface()->sendSignal(
134             PKGMGR_PROGRESS_KEY,
135             PKGMGR_START_VALUE);
136 }
137
138 void TaskConfiguration::AppendTasklistStep()
139 {
140     if (!m_context.isUpdateMode) {
141         _D("TaskConfiguration -> new installation task list");
142         m_context.job->appendNewInstallationTaskList();
143     } else {
144         _D("TaskConfiguration -> update installation task list");
145         m_context.job->appendUpdateInstallationTaskList();
146     }
147 }
148
149 std::shared_ptr<PackageManager::IPkgmgrSignal> TaskConfiguration::pkgMgrInterface()
150 {
151     return m_context.job->GetInstallerStruct().pkgmgrInterface;
152 }
153
154 void TaskConfiguration::SetupTempDirStep()
155 {
156     _D("widgetPath: %s", m_context.requestedPath.c_str());
157     _D("tempPath: %s", m_tempDir.c_str());
158     if (m_context.mode.extension == InstallMode::ExtensionType::DIR) {
159         if (m_context.mode.command ==
160                 InstallMode::Command::REINSTALL) {
161             std::ostringstream tempPathBuilder;
162             tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
163             tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
164             tempPathBuilder << "/";
165             tempPathBuilder << m_context.requestedPath;
166             m_tempDir = tempPathBuilder.str();
167         } else {
168             m_tempDir = m_context.requestedPath;
169         }
170     } else {
171         m_tempDir =
172             Jobs::WidgetInstall::createTempPath(
173                     m_context.mode.rootPath ==
174                         InstallMode::RootPath::RO);
175         if(!hasExtension(m_context.requestedPath, XML_EXTENSION)) //unzip everything except xml files
176         {
177             WidgetUnzip wgtUnzip;
178             wgtUnzip.unzipWgtFile(m_context.requestedPath, m_tempDir);
179         }
180         else
181         {
182             _D("From browser installation - unzip is not done");
183         }
184     }
185 }
186
187 void TaskConfiguration::ParseXMLConfigStep()
188 {
189     parseWidgetXMLConfig(
190             m_context.requestedPath, m_tempDir,
191             m_context.widgetConfig.packagingType,
192             m_context.mode.command == InstallMode::Command::REINSTALL);
193     _D("widget packaging type : %d", static_cast<WrtDB::PkgType>(m_context.widgetConfig.packagingType.pkgType));
194 }
195
196 void TaskConfiguration::TizenIdStep()
197 {
198     bool shouldMakeAppid = false;
199     using namespace PackageManager;
200
201     if (!!m_widgetConfig.tizenAppId) {
202         _D("Setting tizenAppId provided in config.xml: %s", DPL::ToUTF8String(*m_widgetConfig.tizenAppId).c_str());
203
204         m_context.widgetConfig.tzAppid = *m_widgetConfig.tizenAppId;
205         //check package id.
206         if (!!m_widgetConfig.tizenPkgId) {
207             _D("Setting tizenPkgId provided in config.xml: %s", DPL::ToUTF8String(*m_widgetConfig.tizenPkgId).c_str());
208
209             m_context.widgetConfig.tzPkgid = *m_widgetConfig.tizenPkgId;
210         } else {
211             DPL::String appid = *m_widgetConfig.tizenAppId;
212             if (appid.length() > PACKAGE_ID_LENGTH) {
213                 m_context.widgetConfig.tzPkgid =
214                     appid.substr(0, PACKAGE_ID_LENGTH);
215             } else {
216                 //old version appid only has 10byte random character is able to install for a while.
217                 //this case appid equal pkgid.
218                 m_context.widgetConfig.tzPkgid =
219                     *m_widgetConfig.tizenAppId;
220                 shouldMakeAppid = true;
221             }
222         }
223     } else {
224         shouldMakeAppid = true;
225         TizenPkgId pkgId = WidgetDAOReadOnly::generatePkgId();
226         _D("Checking if pkg id is unique");
227         while (true) {
228             if (!validateTizenPackageID(pkgId)) {
229                 //path exist, chose another one
230                 pkgId = WidgetDAOReadOnly::generatePkgId();
231                 continue;
232             }
233             break;
234         }
235         m_context.widgetConfig.tzPkgid = pkgId;
236         _D("tizen_id name was generated by WRT: %ls", m_context.widgetConfig.tzPkgid.c_str());
237     }
238
239     if (shouldMakeAppid == true) {
240         DPL::OptionalString name;
241         DPL::OptionalString defaultLocale = m_widgetConfig.defaultlocale;
242
243         FOREACH(localizedData, m_widgetConfig.localizedDataSet)
244         {
245             Locale i = localizedData->first;
246             if (!!defaultLocale) {
247                 if (defaultLocale == i) {
248                     name = localizedData->second.name;
249                     break;
250                 }
251             } else {
252                 name = localizedData->second.name;
253                 break;
254             }
255         }
256         regex_t regx;
257         if (regcomp(&regx, REG_NAME_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
258             _D("Regcomp failed");
259         }
260
261         _D("Name : %ls", (*name).c_str());
262         if (!name || (regexec(&regx, DPL::ToUTF8String(*name).c_str(),
263                               static_cast<size_t>(0), NULL, 0) != REG_NOERROR))
264         {
265             const std::string allowedString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
266             std::ostringstream genName;
267             struct timeval tv;
268             gettimeofday(&tv, NULL);
269             unsigned int seed = time(NULL) + tv.tv_usec;
270
271             genName << "_" << allowedString[rand_r(&seed) % allowedString.length()];
272             name = DPL::FromUTF8String(genName.str());
273             _D("name was generated by WRT");
274         }
275         regfree(&regx);
276         _D("Name : %ls", (*name).c_str());
277         std::ostringstream genid;
278         genid << m_context.widgetConfig.tzPkgid << "." << name;
279         _D("tizen appid was generated by WRT : %s", genid.str().c_str());
280
281         DPL::OptionalString appid = DPL::FromUTF8String(genid.str());
282         NormalizeAndTrimSpaceString(appid);
283         m_context.widgetConfig.tzAppid = *appid;
284     }
285
286     // send start signal of pkgmgr
287     pkgMgrInterface()->setPkgname(DPL::ToUTF8String(m_context.widgetConfig.tzPkgid));
288
289     _D("Tizen App Id : %ls", (m_context.widgetConfig.tzAppid).c_str());
290     _D("Tizen Pkg Id : %ls", (m_context.widgetConfig.tzPkgid).c_str());
291 }
292
293 void TaskConfiguration::ConfigureWidgetLocationStep()
294 {
295     m_context.locations =
296         WidgetLocation(DPL::ToUTF8String(m_context.widgetConfig.tzPkgid),
297                        m_context.requestedPath, m_tempDir,
298                        m_context.widgetConfig.packagingType,
299                        m_context.mode.rootPath ==
300                            InstallMode::RootPath::RO,
301                            m_context.mode.extension);
302     m_context.locations->registerAppid(
303         DPL::ToUTF8String(m_context.widgetConfig.tzAppid));
304
305     _D("widgetSource %s", m_context.requestedPath.c_str());
306 }
307
308 void TaskConfiguration::DetectUpdateInstallationStep()
309 {
310     WidgetUpdateInfo update;
311     // checking installed web application
312     Try {
313         // no excpetion means, it isn't update mode
314         update = detectWidgetUpdate(m_widgetConfig,
315                                     m_context.widgetConfig.tzAppid);
316         checkWidgetUpdate(update);
317
318         m_context.isUpdateMode = true;
319
320         //if update, notify pkgmgr that this is update
321         pkgMgrInterface()->sendSignal( PKGMGR_START_KEY, PKGMGR_START_UPDATE);
322     }
323     Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
324         pkgMgrInterface()->sendSignal(PKGMGR_START_KEY, PKGMGR_START_INSTALL);
325
326         m_context.isUpdateMode = false;
327
328         if (!validateTizenApplicationID(
329             m_context.widgetConfig.tzAppid))
330         {
331             _E("tizen application ID is already used");
332             ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetConfigFileInvalid,
333                 "invalid config");
334         }
335         if (!validateTizenPackageID(m_context.widgetConfig.tzPkgid)) {
336             _E("tizen package ID is already used");
337             ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageAlreadyInstalled,
338                 "package is already installed");
339         }
340     }
341 }
342
343 void TaskConfiguration::CheckRDSSupportStep()
344 {
345     //update needs RDS support to go ahead
346     if(m_context.isUpdateMode)
347     {
348         if (!checkSupportRDSUpdate(m_widgetConfig)) {
349             ThrowMsg(Jobs::WidgetInstall::Exceptions::NotSupportRDSUpdate,
350                 "RDS update failed");
351         }
352     }
353 }
354
355 bool TaskConfiguration::validateTizenApplicationID(
356     const WrtDB::TizenAppId &tizenAppId)
357 {
358     _D("tizen application ID = [%ls]", tizenAppId.c_str());
359
360     regex_t reg;
361     if (regcomp(&reg, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
362         _D("Regcomp failed");
363     }
364
365     if (regexec(&reg, DPL::ToUTF8String(tizenAppId).c_str(), 0, NULL, 0)
366         == REG_NOMATCH)
367     {
368         regfree(&reg);
369         return false;
370     }
371     regfree(&reg);
372     return true;
373 }
374
375 bool TaskConfiguration::validateTizenPackageID(
376     const WrtDB::TizenPkgId &tizenPkgId)
377 {
378     std::string pkgId = DPL::ToUTF8String(tizenPkgId);
379
380     std::string installPath =
381         std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
382         "/" + pkgId;
383
384     struct stat dirStat;
385     if ((stat(installPath.c_str(), &dirStat) == 0))
386     {
387         return false;
388     }
389     return true;
390 }
391
392 bool TaskConfiguration::checkWidgetUpdate(
393     const WidgetUpdateInfo &update)
394 {
395     if (update.existingVersion.IsNull() || update.incomingVersion.IsNull()) {
396         return false;
397     }
398
399     _D("existing version = '%ls", update.existingVersion->Raw().c_str());
400     _D("incoming version = '%ls", update.incomingVersion->Raw().c_str());
401     _D("Tizen AppID = %ls", update.tzAppId.c_str());
402
403     // TODO: step Check running state
404     bool isRunning = false;
405     int ret =
406         app_manager_is_running(DPL::ToUTF8String(update.tzAppId).c_str(),
407                                &isRunning);
408     if (APP_MANAGER_ERROR_NONE != ret) {
409         _E("Fail to get running state");
410         ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
411                 "widget is running");
412     }
413
414     if (true == isRunning) {
415         // get app_context for running application
416         // app_context must be released with app_context_destroy
417         app_context_h appCtx = NULL;
418         ret =
419             app_manager_get_app_context(
420                 DPL::ToUTF8String(update.tzAppId).c_str(),
421                 &appCtx);
422         if (APP_MANAGER_ERROR_NONE != ret) {
423             _E("Fail to get app_context");
424             ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
425                     "widget is running");
426         }
427
428         // terminate app_context_h
429         ret = app_manager_terminate_app(appCtx);
430         if (APP_MANAGER_ERROR_NONE != ret) {
431             _E("Fail to terminate running application");
432             app_context_destroy(appCtx);
433             ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
434                     "widget is running");
435         } else {
436             app_context_destroy(appCtx);
437             // app_manager_terminate_app isn't sync API
438             // wait until application isn't running (50ms * 100)
439             bool isStillRunning = true;
440             int checkingloop = 100;
441             struct timespec duration = { 0, 50 * 1000 * 1000 };
442             while (--checkingloop >= 0) {
443                 nanosleep(&duration, NULL);
444                 int ret =
445                     app_manager_is_running(
446                         DPL::ToUTF8String(update.tzAppId).c_str(),
447                         &isStillRunning);
448                 if (APP_MANAGER_ERROR_NONE != ret) {
449                     _E("Fail to get running state");
450                     ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
451                             "widget is running");
452                 }
453                 if (!isStillRunning) {
454                     break;
455                 }
456             }
457             if (isStillRunning) {
458                 _E("Fail to terminate running application");
459                 ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
460                         "widget is running");
461             }
462             _D("terminate application");
463         }
464     }
465     //...
466
467     m_context.widgetConfig.tzAppid = update.tzAppId;
468
469     if (!!update.existingVersion ||
470             m_context.mode.extension ==
471             InstallMode::ExtensionType::DIR) {
472         return true;
473     }
474
475     return false;
476 }
477
478 void TaskConfiguration::parseWidgetXMLConfig(
479     const std::string &widgetSource,
480     const std::string &tempPath,
481     WrtDB::PackagingType pkgType,
482     bool isReinstall)
483 {
484     // Parse config
485     ParserRunner parser;
486     Try
487     {
488         if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
489             parser.Parse(widgetSource,
490                          ElementParserPtr(
491                              new RootParser<WidgetParser>(m_widgetConfig,
492                                                           DPL::FromUTF32String(
493                                                               L"widget"))));
494         } else {
495             std::string configFile;
496             configFile = tempPath + "/" + CONFIG_XML;
497             if (!WrtUtilFileExists(configFile)) {
498                 configFile = tempPath + "/" + WITH_OSP_XML;
499             }
500
501             if (isReinstall) {
502                 // checking RDS data directory
503                 if (access(configFile.c_str(), F_OK) != 0) {
504                     std::string tzAppId =
505                         widgetSource.substr(widgetSource.find_last_of("/")+1);
506                     WidgetDAOReadOnly dao(WidgetDAOReadOnly::getTzAppId(DPL::FromUTF8String(tzAppId)));
507                     configFile = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
508                     configFile += "/";
509                     configFile += WITH_OSP_XML;
510                 }
511             }
512
513             if(!DPL::Utils::Path(configFile).Exists())
514             {
515                 ThrowMsg(Exceptions::MissingConfig, "Config file not exists");
516             }
517
518 #ifdef SCHEMA_VALIDATION_ENABLED
519             if(!parser.Validate(configFilePath, WRT_WIDGETS_XML_SCHEMA))
520             {
521                 _E("Invalid configuration file - schema validation failed");
522                 ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Failed to parse config.xml file");
523             }
524 #endif
525             parser.Parse(configFile,
526                     ElementParserPtr(
527                         new RootParser<WidgetParser>(m_widgetConfig,
528                             DPL::
529                             FromUTF32String(
530                                 L"widget"))));
531         }
532     }
533     Catch(ElementParser::Exception::ParseError)
534     {
535         _E("Failed to parse config.xml file");
536         ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Parser exeption");
537     }
538     Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
539     {
540         _E("Failed to find installed widget - give proper tizenId");
541         ThrowMsg(Exceptions::RDSDeltaFailure, "WidgetNotExist");
542     }
543     Catch(Exceptions::WidgetConfigFileNotFound){
544         _E("Failed to find config.xml");
545         ThrowMsg(Exceptions::MissingConfig, "Parser exeption");
546     }
547 }
548
549 WidgetUpdateInfo TaskConfiguration::detectWidgetUpdate(
550     const ConfigParserData &configInfo,
551     const WrtDB::TizenAppId &tizenId)
552 {
553     _D("Checking up widget package for config.xml...");
554     OptionalWidgetVersion incomingVersion;
555
556     if (!configInfo.version.IsNull()) {
557         incomingVersion =
558             DPL::Optional<WidgetVersion>(
559                 WidgetVersion(*configInfo.version));
560     }
561
562     WidgetDAOReadOnly dao(tizenId);
563
564     OptionalWidgetVersion optVersion;
565     DPL::OptionalString version = dao.getVersion();
566     if (!version.IsNull()) {
567         optVersion = OptionalWidgetVersion(WidgetVersion(*version));
568     }
569
570     return WidgetUpdateInfo(
571         dao.getTzAppId(),
572         optVersion,
573         incomingVersion);
574 }
575
576 void TaskConfiguration::CheckPackageTypeStep()
577 {
578     if (hasExtension(m_context.requestedPath, XML_EXTENSION)) {
579         _D("Hosted app installation");
580         m_context.widgetConfig.packagingType = PKG_TYPE_HOSTED_WEB_APP;
581         return;
582     }
583
584     std::string configFile = m_tempDir + "/" + OSP_MANIFEST_XML;
585     if (WrtUtilFileExists(configFile)) {
586         m_context.widgetConfig.packagingType = PKG_TYPE_HYBRID_WEB_APP;
587         return;
588     }
589
590     m_context.widgetConfig.packagingType = PKG_TYPE_NOMAL_WEB_APP;
591 }
592
593 void TaskConfiguration::ApplicationTypeStep() //TODO: is this really needed as WAC is not supported?
594 {
595     AppType widgetAppType = APP_TYPE_UNKNOWN;
596     FOREACH(iterator, m_widgetConfig.nameSpaces) {
597         _D("namespace = [%ls]", (*iterator).c_str());
598
599         if (*iterator == ConfigurationNamespace::TizenWebAppNamespaceName) {
600             widgetAppType = APP_TYPE_TIZENWEBAPP;
601             break;
602         }
603     }
604
605     m_context.widgetConfig.webAppType = widgetAppType;
606
607     _D("type = [%s]", m_context.widgetConfig.webAppType.getApptypeToString().c_str());
608 }
609
610 void TaskConfiguration::ResourceEncryptionStep()
611 {    
612     m_context.needEncryption = false;
613     FOREACH(it, m_widgetConfig.settingsList)
614     {
615         if (it->m_name == SETTING_VALUE_ENCRYPTION &&
616             it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE)
617         {
618             _D("resource need encryption");
619             m_context.needEncryption = true;
620         }
621     }
622 }
623
624 bool TaskConfiguration::getMMCStatus()
625 {
626     int mmcStatus;
627     if (vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmcStatus)) {
628         _E("vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS) failed.");
629         return false;
630     }
631
632     switch(mmcStatus)
633     {
634     case VCONFKEY_SYSMAN_MMC_MOUNTED:
635         _D("mmcStatus is MMC_MOUNTED.");
636         return true;
637     case VCONFKEY_SYSMAN_MMC_REMOVED:
638     case VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED:
639         _D("mmcStatus is MMC_REMOVED or NOT_MOUNTED.");
640         return false;
641     default:
642         _E("Platform is not supported, use the default settings");
643         return false;
644     }
645 }
646
647 bool TaskConfiguration::getDefaultExternalStorage()
648 {
649     // XXX NOT IMPLEMENTED.
650     return false;
651 }
652
653 void TaskConfiguration::InstallationFSLocationStep()
654 {
655     m_context.locationType = INSTALL_LOCATION_TYPE_NOMAL;
656     DPL::String locationValue;
657
658     if (m_context.mode.installTime != InstallMode::InstallTime::PRELOAD) {
659         FOREACH(it, m_widgetConfig.settingsList) {
660             if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME) {
661                 locationValue = it->m_value;
662                 break;
663             }
664         }
665
666         if ((SETTING_VALUE_INSTALLTOEXT_PREPER_EXT == locationValue
667                     && getMMCStatus()) ||
668                 (SETTING_VALUE_INSTALLTOEXT_AUTO == locationValue
669                  && getDefaultExternalStorage())) {
670             _D("This webapp will be installed to sd card");
671             m_context.locationType = INSTALL_LOCATION_TYPE_EXTERNAL;
672         }
673     }
674 }
675
676 bool TaskConfiguration::checkSupportRDSUpdate(const WrtDB::ConfigParserData
677         &configInfo)
678 {
679     if (m_context.mode.command ==
680             InstallMode::Command::REINSTALL)
681     {
682         DPL::String configValue = SETTING_VALUE_ENCRYPTION_DISABLE;
683         DPL::String dbValue = SETTING_VALUE_ENCRYPTION_DISABLE;
684
685         WidgetDAOReadOnly dao(m_context.widgetConfig.tzAppid);
686         WrtDB::WidgetSettings widgetSettings;
687         dao.getWidgetSettings(widgetSettings);
688
689         FOREACH(it, widgetSettings) {
690             if (it->settingName == SETTING_VALUE_ENCRYPTION) {
691                 dbValue = it->settingValue;
692             }
693         }
694
695         FOREACH(data, configInfo.settingsList)
696         {
697             if (data->m_name == SETTING_VALUE_ENCRYPTION)
698             {
699                 configValue = data->m_value;
700             }
701         }
702         if (configValue != dbValue) {
703             _E("Not Support RDS mode because of encryption setting");
704             return false;
705         }
706     }
707
708     return true;
709 }
710
711 }
712 }