TaskConfiguration refactoring - part 2/3
[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
33 #include <dpl/utils/wrt_utility.h>
34 #include <dpl/utils/path.h>
35 #include <dpl/wrt-dao-ro/common_dao_types.h>
36 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
37 #include <dpl/wrt-dao-ro/global_config.h>
38 #include <dpl/wrt-dao-ro/config_parser_data.h>
39 #include <dpl/localization/w3c_file_localization.h>
40
41 #include <libiriwrapper.h>
42 #include <app_manager.h>
43
44 #include "root_parser.h"
45 #include "widget_parser.h"
46 #include "parser_runner.h"
47
48 #include <widget_install/widget_install_errors.h>
49 #include <widget_install/widget_install_context.h>
50 #include <widget_install_to_external.h>
51 #include <widget_install/widget_unzip.h>
52 #include <widget_install/job_widget_install.h>
53 #include <widget_install/task_commons.h>
54
55 #include <installer_log.h>
56
57 using namespace WrtDB;
58
59 namespace {
60 const char* const CONFIG_XML = "config.xml";
61 const char* const WITH_OSP_XML = "res/wgt/config.xml";
62 const char* const OSP_MANIFEST_XML = "info/manifest.xml";
63
64 //allowed: a-z, A-Z, 0-9
65 const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}.{1,}$";
66 const char* REG_NAME_PATTERN = "^[a-zA-Z0-9._-]{1,}$";
67 const size_t PACKAGE_ID_LENGTH = 10;
68
69 static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
70 static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
71 static const DPL::String SETTING_VALUE_ENCRYPTION_DISABLE = L"disable";
72 const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME =
73     L"install-location";
74 const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT =
75     L"prefer-external";
76
77 const std::string XML_EXTENSION = ".xml";
78
79 bool hasExtension(const std::string& filename, const std::string& extension)
80 {
81     _D("Looking for extension %s in %s", extension.c_str(), filename.c_str());
82     size_t fileLen = filename.length();
83     size_t extLen = extension.length();
84     if (fileLen < extLen) {
85         _E("Filename %s is shorter than extension %s", filename.c_str(), extension.c_str());
86         return false;
87     }
88     return (0 == filename.compare(fileLen - extLen, extLen, extension));
89 }
90 } // namespace anonymous
91
92 namespace Jobs {
93 namespace WidgetInstall {
94
95 TaskConfiguration::TaskConfiguration(InstallerContext& context) :
96     DPL::TaskDecl<TaskConfiguration>(this),
97     m_context(context)
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     m_widgetConfig = getWidgetDataFromXML( //TODO: make one parsing of config.xml
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 ConfigParserData TaskConfiguration::getWidgetDataFromXML(
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     ConfigParserData configInfo;
487     Try
488     {
489         if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
490             parser.Parse(widgetSource,
491                          ElementParserPtr(
492                              new RootParser<WidgetParser>(configInfo,
493                                                           DPL::FromUTF32String(
494                                                               L"widget"))));
495         } else {
496             std::string configFile;
497             configFile = tempPath + "/" + CONFIG_XML;
498             if (!WrtUtilFileExists(configFile)) {
499                 configFile = tempPath + "/" + WITH_OSP_XML;
500             }
501
502             if (isReinstall) {
503                 // checking RDS data directory
504                 if (access(configFile.c_str(), F_OK) != 0) {
505                     std::string tzAppId =
506                         widgetSource.substr(widgetSource.find_last_of("/")+1);
507                     WidgetDAOReadOnly dao(WidgetDAOReadOnly::getTzAppId(DPL::FromUTF8String(tzAppId)));
508                     configFile = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
509                     configFile += "/";
510                     configFile += WITH_OSP_XML;
511                 }
512             }
513
514             if(!DPL::Utils::Path(configFile).Exists())
515             {
516                 ThrowMsg(Exceptions::MissingConfig, "Config file not exists");
517             }
518
519 #ifdef SCHEMA_VALIDATION_ENABLED
520             if(!parser.Validate(configFilePath, WRT_WIDGETS_XML_SCHEMA))
521             {
522                 _E("Invalid configuration file - schema validation failed");
523                 ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Failed to parse config.xml file");
524             }
525 #endif
526             parser.Parse(configFile,
527                     ElementParserPtr(
528                         new RootParser<WidgetParser>(configInfo,
529                             DPL::
530                             FromUTF32String(
531                                 L"widget"))));
532         }
533     }
534     Catch(ElementParser::Exception::ParseError)
535     {
536         _E("Failed to parse config.xml file");
537         ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Parser exeption");
538     }
539     Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
540     {
541         _E("Failed to find installed widget - give proper tizenId");
542         ThrowMsg(Exceptions::RDSDeltaFailure, "WidgetNotExist");
543     }
544     Catch(Exceptions::WidgetConfigFileNotFound){
545         _E("Failed to find config.xml");
546         ThrowMsg(Exceptions::MissingConfig, "Parser exeption");
547     }
548
549     return configInfo;
550 }
551
552 WidgetUpdateInfo TaskConfiguration::detectWidgetUpdate(
553     const ConfigParserData &configInfo,
554     const WrtDB::TizenAppId &tizenId)
555 {
556     _D("Checking up widget package for config.xml...");
557     OptionalWidgetVersion incomingVersion;
558
559     if (!configInfo.version.IsNull()) {
560         incomingVersion =
561             DPL::Optional<WidgetVersion>(
562                 WidgetVersion(*configInfo.version));
563     }
564
565     WidgetDAOReadOnly dao(tizenId);
566
567     OptionalWidgetVersion optVersion;
568     DPL::OptionalString version = dao.getVersion();
569     if (!version.IsNull()) {
570         optVersion = OptionalWidgetVersion(WidgetVersion(*version));
571     }
572
573     return WidgetUpdateInfo(
574         dao.getTzAppId(),
575         optVersion,
576         incomingVersion);
577 }
578
579 void TaskConfiguration::CheckPackageTypeStep()
580 {
581     if (hasExtension(m_context.requestedPath, XML_EXTENSION)) {
582         _D("Hosted app installation");
583         m_context.widgetConfig.packagingType = PKG_TYPE_HOSTED_WEB_APP;
584         return;
585     }
586
587     std::string configFile = m_tempDir + "/" + OSP_MANIFEST_XML;
588     if (WrtUtilFileExists(configFile)) {
589         m_context.widgetConfig.packagingType = PKG_TYPE_HYBRID_WEB_APP;
590         return;
591     }
592
593     m_context.widgetConfig.packagingType = PKG_TYPE_NOMAL_WEB_APP;
594 }
595
596 void TaskConfiguration::ApplicationTypeStep() //TODO: is this really needed as WAC is not supported?
597 {
598     AppType widgetAppType = APP_TYPE_UNKNOWN;
599     FOREACH(iterator, m_widgetConfig.nameSpaces) {
600         _D("namespace = [%ls]", (*iterator).c_str());
601
602         if (*iterator == ConfigurationNamespace::TizenWebAppNamespaceName) {
603             widgetAppType = APP_TYPE_TIZENWEBAPP;
604             break;
605         }
606     }
607
608     m_context.widgetConfig.webAppType = widgetAppType;
609
610     _D("type = [%s]", m_context.widgetConfig.webAppType.getApptypeToString().c_str());
611 }
612
613 void TaskConfiguration::ResourceEncryptionStep()
614 {    
615     m_context.needEncryption = false;
616     FOREACH(it, m_widgetConfig.settingsList)
617     {
618         if (it->m_name == SETTING_VALUE_ENCRYPTION &&
619             it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE)
620         {
621             _D("resource need encryption");
622             m_context.needEncryption = true;
623         }
624     }
625 }
626
627 void TaskConfiguration::InstallationFSLocationStep()
628 {
629     m_context.locationType = INSTALL_LOCATION_TYPE_NOMAL;
630     if (m_context.mode.installTime != InstallMode::InstallTime::PRELOAD) {
631         FOREACH(it, m_widgetConfig.settingsList) {
632             if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME &&
633                 it->m_value ==
634                 SETTING_VALUE_INSTALLTOEXT_PREPER_EXT)
635             {
636                 _D("This widget will be installed to sd card");
637                 m_context.locationType =
638                     INSTALL_LOCATION_TYPE_EXTERNAL;
639             }
640         }
641     }
642 }
643
644 bool TaskConfiguration::checkSupportRDSUpdate(const WrtDB::ConfigParserData
645         &configInfo)
646 {
647     if (m_context.mode.command ==
648             InstallMode::Command::REINSTALL)
649     {
650         DPL::String configValue = SETTING_VALUE_ENCRYPTION_DISABLE;
651         DPL::String dbValue = SETTING_VALUE_ENCRYPTION_DISABLE;
652
653         WidgetDAOReadOnly dao(m_context.widgetConfig.tzAppid);
654         WrtDB::WidgetSettings widgetSettings;
655         dao.getWidgetSettings(widgetSettings);
656
657         FOREACH(it, widgetSettings) {
658             if (it->settingName == SETTING_VALUE_ENCRYPTION) {
659                 dbValue = it->settingValue;
660             }
661         }
662
663         FOREACH(data, configInfo.settingsList)
664         {
665             if (data->m_name == SETTING_VALUE_ENCRYPTION)
666             {
667                 configValue = data->m_value;
668             }
669         }
670         if (configValue != dbValue) {
671             _E("Not Support RDS mode because of encryption setting");
672             return false;
673         }
674     }
675
676     return true;
677 }
678
679 }
680 }