2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file ConfigurationManager.cpp
19 * @brief This is the implementation file for %ConfigurationManager class.
25 #include <unique_ptr.h>
27 #include <pkgmgr_parser.h>
28 #include <pkgmgr_installer.h>
30 #include <FBaseUtilStringUtil.h>
32 #include <FIoDirectory.h>
33 #include <FSecCertX509CertificatePath.h>
35 #include <FAppPkg_PackageInfoImpl.h>
36 #include <FAppPkg_PackageManagerImpl.h>
37 #include <FBase_StringConverter.h>
39 #include "ConfigurationManager.h"
40 #include "ManifestGenerator.h"
41 #include "InstallerUtil.h"
43 using namespace Tizen::Base;
44 using namespace Tizen::Base::Collection;
45 using namespace Tizen::Base::Utility;
46 using namespace Tizen::Security::Cert;
47 using namespace Tizen::App;
48 using namespace Tizen::App::Package;
49 using namespace Tizen::Io;
51 ConfigurationManager::ConfigurationManager(void)
55 ConfigurationManager::~ConfigurationManager(void)
60 ConfigurationManager::CreateFile(InstallationContext* pContext)
63 const char* pBinaryPath = null;
65 char* pXmlPath = null;
67 bool hybridService = pContext->IsHybridService();
68 ArrayList* pContentDataList = null;
70 _PackageInfoImpl *pPackageInfoImpl = null;
71 pPackageInfoImpl = pContext->GetPackageInfoImpl();
72 TryReturn(pPackageInfoImpl, false, "[osp-installer] pPackageInfoImpl is null.");
75 rootPath = pPackageInfoImpl->GetAppRootPath();
78 apiVersion = pPackageInfoImpl->GetAppApiVersion();
79 String versionInfoFile;
80 versionInfoFile.Format(1024, L"%ls%ls", rootPath.GetPointer(), VERSION_INFO_FILE);
81 CreateInfoFile(versionInfoFile, &apiVersion);
83 String webServicePrivilege(TIZEN_PRIVILEGE_WEB_SERVICE);
84 if (FindPrivilege(pContext, webServicePrivilege) == true)
86 AppLogTag(OSP_INSTALLER, "WEB_SERVICE privilege is detected. rootPath=[%ls]", rootPath.GetPointer());
88 String webServiceInfoFile;
89 webServiceInfoFile.Format(1024, L"%ls%ls", rootPath.GetPointer(), WEBSERVICE_INFO_FILE);
90 CreateInfoFile(webServiceInfoFile, null);
93 _PackageAppInfoImpl* pAppInfoImpl = null;
94 ArrayList* pAppList = null;
95 pAppList = pPackageInfoImpl->GetAppInfoList();
96 for (int i = 0 ; i < pAppList->GetCount(); i++)
98 pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
101 result r = E_SUCCESS;
104 appName = pAppInfoImpl->GetName();
107 appType = pAppInfoImpl->GetType();
110 packageName = pAppInfoImpl->GetPackageName();
113 binaryPath.Format(1024, L"%ls%ls/%ls", rootPath.GetPointer(), DIR_BIN, appName.GetPointer());
115 String tempBinaryPath;
116 tempBinaryPath.Format(1024, L"%ls%ls/.%ls", rootPath.GetPointer(), DIR_BIN, appName.GetPointer());
118 pBinaryPath = _StringConverter::CopyToCharArrayN(binaryPath);
119 TryCatch(pBinaryPath, res = false, "[osp-installer] pBinaryPath is null");
121 if (File::IsFileExist(binaryPath) == true)
123 InstallerUtil::Remove(binaryPath);
126 if (appType == L"UiApp")
128 //err = symlink(UIAPP_LOADER_PATH, pBinaryPath);
130 r = File::Copy(UIAPP_LOADER_PATH, pBinaryPath, false);
131 TryCatch(!IsFailed(r), res = false, "[osp-installer] File::Copy() failed, filePath=[%s]", pBinaryPath);
133 InstallerUtil::Copy(UIAPP_LOADER_PATH, tempBinaryPath);
135 ArrayList* pFeatureList = pAppInfoImpl->GetAppFeatureList();
136 TryCatch(pFeatureList, res = false, "[osp-installer] pFeatureList is null");
138 String coordinateSystem;
139 String baseScreenSize;
140 String logicalCoordinate;
142 for (int j = 0; j < pFeatureList->GetCount(); j++)
144 _AppFeatureInfoImpl* pAppFeature = dynamic_cast<_AppFeatureInfoImpl*>(pFeatureList->GetAt(j));
146 if (pAppFeature != null)
148 if (pAppFeature->GetName() == L"CoordinateSystem")
150 coordinateSystem = pAppFeature->GetValue();
153 if (pAppFeature->GetName() == L"BaseScreenSize")
155 baseScreenSize = pAppFeature->GetValue();
158 if (pAppFeature->GetName() == L"LogicalCoordinate")
160 logicalCoordinate = pAppFeature->GetValue();
165 String uiScalability;
166 uiScalability.Format(1024, UISCALABILITY_INFO, coordinateSystem.GetPointer(), baseScreenSize.GetPointer(), logicalCoordinate.GetPointer());
168 String uiScalabilityInfoFile;
169 uiScalabilityInfoFile.Format(1024, L"%ls%ls", rootPath.GetPointer(), UISCALABILITY_INFO_FILE);
171 CreateInfoFile(uiScalabilityInfoFile, &uiScalability);
173 int categoryType = pAppInfoImpl->GetAppFeature();
174 if (categoryType != CATEGORY_TYPE_NONE)
176 String category = InstallerUtil::GetCategory(categoryType);
177 category.ToLowerCase();
179 int type = _Aul::GetAppType(category);
181 if (category == L"ime")
183 CreateImeSymlink(binaryPath, packageName);
187 typeInfo.Format(1024, L"%d", type);
190 typeInfoFile.Format(1024, L"%ls%ls", rootPath.GetPointer(), TYPE_INFO_FILE);
192 CreateInfoFile(typeInfoFile, &typeInfo);
195 else if (appType == L"ServiceApp")
197 if (pContext->IsPreloaded() == false)
199 //err = symlink(SERVICEAPP_LOADER_PATH, pBinaryPath);
201 InstallerUtil::Copy(SERVICEAPP_LOADER_PATH, tempBinaryPath);
203 r = File::Copy(SERVICEAPP_LOADER_PATH, pBinaryPath, false);
204 TryCatch(!IsFailed(r), res = false, "[osp-installer] File::Copy() failed, filePath=[%s]", pBinaryPath);
208 //err = symlink(SYSTEMAPP_LOADER_PATH, pBinaryPath);
210 InstallerUtil::Copy(SYSTEMAPP_LOADER_PATH, tempBinaryPath);
212 r = File::Copy(SYSTEMAPP_LOADER_PATH, pBinaryPath, false);
213 TryCatch(!IsFailed(r), res = false, "[osp-installer] File::Copy() failed, filePath=[%s]", pBinaryPath);
217 InstallerUtil::ChangeMode(pBinaryPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
219 delete[] pBinaryPath;
224 pContentDataList = pContext->GetContentDataList();
225 if (pContentDataList)
227 int contentCount = pContentDataList->GetCount();
228 for (int i = 0 ; i < contentCount; i++)
230 ContentData* pContentData = static_cast<ContentData*>(pContentDataList->GetAt(i));
233 String contentId = pContentData->GetContentId();
234 String oldPath = rootPath + DIR_CONTENTS + L"/" + contentId;
236 if (File::IsFileExist(SLP_FONT_PATH) == false)
238 Directory::Create(SLP_FONT_PATH, false);
239 InstallerUtil::ChangeMode(SLP_FONT_PATH, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
242 String newPath = SLP_FONT_PATH;
243 newPath += L"/" + pContext->GetId();
244 Directory::Create(newPath, false);
245 InstallerUtil::ChangeMode(newPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
248 newPath += contentId;
249 InstallerUtil::CreateSymlink(oldPath, newPath);
254 //if (pContext->IsPreloaded() == true)
256 // xmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, pContext->GetId().GetPointer());
260 xmlPath.Format(1024, DIR_RW_PACKAGE_SYSTEM_MANIFEST, pContext->GetId().GetPointer());
263 pXmlPath = _StringConverter::CopyToCharArrayN(xmlPath);
264 TryCatch(pXmlPath != null, res = false, "[osp-installer] pXmlPath is null");
266 if (hybridService == true)
268 String webXmlPath = pXmlPath;
269 webXmlPath += L".wgt";
270 InstallerUtil::Copy(pXmlPath, webXmlPath);
272 pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath, null);
273 CreateSystemXmlFile(pContext);
275 String serviceXmlPath = pXmlPath;
276 serviceXmlPath += L".tpk";
277 InstallerUtil::Copy(pXmlPath, serviceXmlPath);
278 InstallerUtil::Remove(pXmlPath);
280 MergeToSystemXmlFile(pXmlPath, webXmlPath, serviceXmlPath);
281 InstallerUtil::Remove(webXmlPath);
282 InstallerUtil::Remove(serviceXmlPath);
286 pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath, null);
287 CreateSystemXmlFile(pContext);
290 AppLogTag(OSP_INSTALLER, "------------------------------------------");
291 AppLogTag(OSP_INSTALLER, "sync() - START");
293 AppLogTag(OSP_INSTALLER, "sync() - END");
294 AppLogTag(OSP_INSTALLER, "------------------------------------------");
296 AppLogTag(OSP_INSTALLER, "------------------------------------------");
297 AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() - START");
298 err = pkgmgr_parser_parse_manifest_for_installation(pXmlPath, null);
301 AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() is failed. error = [%d][%s]", err, pXmlPath);
302 fprintf(stderr, "pkgmgr_parser_parse_manifest_for_installation is failed. error = [%d][%s]\n", err, pXmlPath);
304 AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() - END");
305 AppLogTag(OSP_INSTALLER, "------------------------------------------");
310 delete[] pBinaryPath;
317 ConfigurationManager::RemoveFile(InstallationContext* pContext)
320 char* pXmlPath = null;
321 _PackageInfoImpl *pPackageInfoImpl = null;
322 _PackageAppInfoImpl* pAppInfoImpl = null;
323 ArrayList* pAppList = null;
325 //if (pContext->IsPreloaded() == true)
327 // xmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, pContext->GetId().GetPointer());
331 xmlPath.Format(1024, DIR_RW_PACKAGE_SYSTEM_MANIFEST, pContext->GetId().GetPointer());
334 pXmlPath = _StringConverter::CopyToCharArrayN(xmlPath);
335 TryCatch(pXmlPath != null, , "[osp-installer] pXmlPath is null");
337 if (pContext->IsHybridService() == true)
339 AppLogTag(OSP_INSTALLER, "Uninstallation for HybridService - skip");
344 AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() START");
345 if (pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath, null) != 0)
347 AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() is failed.[%s]", pXmlPath);
349 AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() END");
351 InstallerUtil::Remove(xmlPath);
354 pPackageInfoImpl = pContext->GetPackageInfoImpl();
355 TryCatch(pPackageInfoImpl, , "[osp-installer] pPackageInfoImpl is null.");
357 pAppList = pPackageInfoImpl->GetAppInfoList();
359 for (int i = 0 ; i < pAppList->GetCount(); i++)
361 pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
364 String packageName = pAppInfoImpl->GetPackageName();
366 char dest[772] = {0};
368 destPath.Format(1024, L"%ls/%ls", SLP_APP_PATH, packageName.GetPointer());
369 sprintf(dest, "%ls", destPath.GetPointer());
381 ConfigurationManager::RegisterCertInfo(InstallationContext* pContext) const
383 AppLogTag(OSP_INSTALLER, "------------------------------------------");
384 AppLogTag(OSP_INSTALLER, "RegisterCertInfo - START");
388 pkgmgr_instcertinfo_h handle = null;
389 String appId = pContext->GetId();
390 X509CertificatePath* pAuthorCertPath = pContext->GetAuthorCertPath();
391 X509CertificatePath* pDistributorCertPath = pContext->GetDistributorCertPath();
393 char* pAppId = _StringConverter::CopyToCharArrayN(appId);
394 TryCatch(pAppId, result = false, "[osp-installer] pAppId is null");
396 res = pkgmgr_installer_create_certinfo_set_handle(&handle);
397 TryCatch(res == 0, result = false, "[osp-installer] pkgmgr_installer_create_certinfo_set_handle() failed.[%d]", res);
401 AppLogTag(OSP_INSTALLER, "[AuthorCert]");
402 result = SetCertHashValue(handle, pAuthorCertPath, PM_SET_AUTHOR_SIGNER_CERT);
403 TryCatch(result == true, , "[osp-installer] RegisterCertHashValue() failed. [pAuthorCertPath]");
406 if (pDistributorCertPath)
408 AppLogTag(OSP_INSTALLER, "[DistributorCert]");
409 result = SetCertHashValue(handle, pDistributorCertPath, PM_SET_DISTRIBUTOR_SIGNER_CERT);
410 TryCatch(result == true, , "[osp-installer] RegisterCertHashValue() failed. [pDistributorCertPath]");
413 res = pkgmgr_installer_save_certinfo(pAppId, handle);
414 TryCatch(res == 0, result = false, "[osp-installer] pkgmgr_installer_save_certinfo(%s) failed.[%d]", pAppId, res);
416 AppLogTag(OSP_INSTALLER, "RegisterCertInfo - END");
417 AppLogTag(OSP_INSTALLER, "------------------------------------------");
422 pkgmgr_installer_destroy_certinfo_set_handle(handle);
430 ConfigurationManager::SetCertHashValue(void* pHandle, X509CertificatePath* pCertPath, int certType) const
432 TryReturn(pCertPath, false, "[osp-installer] pCertPath is null.");
436 ICertificate* pCert = null;
437 char* pCertValue = null;
439 for (int i = 0; i < pCertPath->GetLength(); i++)
441 pCert = pCertPath->GetCertificateN(i);
442 TryCatch(pCert, result = false, "[osp-installer] pCert is null.[%i]", i);
444 pCertValue = GetCertValueN(pCert);
445 TryCatch(pCertValue, result = false, "[osp-installer] pCertValue is null.[%i]", i);
447 AppLogTag(OSP_INSTALLER, "------------------------------------------");
448 AppLogTag(OSP_INSTALLER, "CertValue(%d), certType[%d]", i, certType);
449 AppLogTag(OSP_INSTALLER, "[%s]", pCertValue);
451 res = pkgmgr_installer_set_cert_value(pHandle, (pkgmgr_instcert_type)certType, pCertValue);
452 TryCatch(res == 0, result = false, "[osp-installer] pkgmgr_installer_set_cert_value(%d) failed.[%d]", i, res);
470 ConfigurationManager::GetCertValueN(ICertificate* pCert) const
472 result r = E_SUCCESS;
473 ByteBuffer* pEncodedData = null;
475 char* pEncodedValue = null;
477 pEncodedData = pCert->GetEncodedDataN();
478 TryCatch(pEncodedData, , "[osp-installer] pEncodedData is null.");
480 r = StringUtil::EncodeToBase64String(*pEncodedData, base64Value);
481 TryCatch(!IsFailed(r), , "[osp-installer] StringUtil::EncodeToBase64String is failed.");
483 pEncodedValue = _StringConverter::CopyToCharArrayN(base64Value);
484 TryCatch(pEncodedValue, , "[osp-installer] pEncodedValue is null");
489 return pEncodedValue;
493 ConfigurationManager::UnregisterCertInfo(InstallationContext* pContext) const
495 AppLogTag(OSP_INSTALLER, "------------------------------------------");
496 AppLogTag(OSP_INSTALLER, "UnregisterCertInfo - START");
499 String appId = pContext->GetId();
501 char* pAppId = _StringConverter::CopyToCharArrayN(appId);
502 TryCatch(pAppId, result = false, "[osp-installer] pAppId is null");
504 res = pkgmgr_installer_delete_certinfo(pAppId);
505 TryCatch(res == 0, result = false, "[osp-installer] pkgmgr_installer_delete_certinfo(%s) failed.[%d]", pAppId, res);
507 AppLogTag(OSP_INSTALLER, "UnregisterCertInfo - END");
508 AppLogTag(OSP_INSTALLER, "------------------------------------------");
516 ConfigurationManager::PostInstall(InstallationContext* pContext, bool error) const
518 app2ext_handle* pHandle = pContext->GetApp2ExtHandle();
521 String appId = pContext->GetId();
522 std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
523 TryReturn(pAppId, false, "[osp-installer] pAppId is null");
527 pHandle->interface.post_install(pAppId.get(), APP2EXT_STATUS_FAILED);
528 AppLogTag(OSP_INSTALLER, "[app2sd] post_install(%s, APP2EXT_STATUS_FAILED)", pAppId.get());
532 pHandle->interface.post_install(pAppId.get(), APP2EXT_STATUS_SUCCESS);
533 AppLogTag(OSP_INSTALLER, "[app2sd] post_install(%s, APP2EXT_STATUS_SUCCESS)", pAppId.get());
536 app2ext_deinit(pHandle);
543 ConfigurationManager::PostUninstall(InstallationContext* pContext) const
545 app2ext_handle* pHandle = pContext->GetApp2ExtHandle();
548 String appId = pContext->GetId();
549 std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
550 TryReturn(pAppId, false, "[osp-installer] pAppId is null");
552 pHandle->interface.post_uninstall(pAppId.get());
553 AppLogTag(OSP_INSTALLER, "[app2sd] post_uninstall(%s)", pAppId.get());
555 app2ext_deinit(pHandle);
562 ConfigurationManager::CreateSystemXmlFile(InstallationContext* pContext)
564 AppLogTag(OSP_INSTALLER, "------------------------------------------");
565 AppLogTag(OSP_INSTALLER, "CreateSystemXmlFile() - START");
568 ManifestGenerator manifestGenerator;
569 manifestGenerator.Construct(pContext);
570 ret = manifestGenerator.Write();
574 fprintf(stderr, "manifestGenerator.Write() is failed.\n");
575 AppLogTag(OSP_INSTALLER, "manifestGenerator.Write() is failed.");
577 AppLogTag(OSP_INSTALLER, "CreateSystemXmlFile() - END");
578 AppLogTag(OSP_INSTALLER, "------------------------------------------");
584 //ConfigurationManager::CreateHybridServiceDesktopFile(InstallationContext* pContext)
586 // AppLogTag(OSP_INSTALLER, "HybridServiceDesktopFile - START");
589 // _PackageInfoImpl *pPackageInfoImpl = pContext->GetPackageInfoImpl();
590 // _PackageAppInfoImpl* pAppInfoImpl = null;
591 // ArrayList* pAppList = null;
592 // pAppList = pPackageInfoImpl->GetAppInfoList();
594 // for (int i = 0 ; i < pAppList->GetCount(); i++)
596 // pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
601 // name.Format(1024, L"%ls", pPackageInfoImpl->GetAppName().GetPointer());
603 // String binaryPath;
604 // binaryPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_BIN, pAppInfoImpl->GetName().GetPointer());
607 // iconPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_ICONS, pAppInfoImpl->GetMainmenuIcon().GetPointer());
610 // version.Format(1024, L"%ls", pPackageInfoImpl->GetAppVersion().GetPointer());
613 // desktop.Format(1024, L"[Desktop Entry]\n"
615 // "Name[en_GB]=%ls\n"
616 // "Type=Application\n"
620 // "NoDisplay=true\n"
621 // "X-TIZEN-TaskManage=False\n"
622 // "X-TIZEN-PackageType=tpk\n",
623 // name.GetPointer(), name.GetPointer(), binaryPath.GetPointer(), iconPath.GetPointer(), version.GetPointer());
625 // String desktopPath;
626 // desktopPath.Format(1024, L"/opt/share/applications/%ls.desktop", pAppInfoImpl->GetPackageName().GetPointer());
628 // if (File::IsFileExist(desktopPath) == true)
630 // AppLogTag(OSP_INSTALLER, "removing desktop filePath=[%ls]", desktopPath.GetPointer());
631 // InstallerUtil::Remove(desktopPath);
634 // CreateInfoFile(desktopPath, &desktop);
638 // AppLogTag(OSP_INSTALLER, "HybridServiceDesktopFile - END");
644 ConfigurationManager::MergeToSystemXmlFile(const String& systemXmlPath, const String& webXmlPath, const String& serviceXmlPath)
646 result r = E_SUCCESS;
648 FileAttributes webXmlAttr;
649 r = File::GetAttributes(webXmlPath, webXmlAttr);
650 TryReturn(!IsFailed(r), false, "[osp-installer] File::GetAttributes() failed, webXmlPath=%ls", webXmlPath.GetPointer());
652 FileAttributes serviceAttr;
653 r = File::GetAttributes(serviceXmlPath, serviceAttr);
654 TryReturn(!IsFailed(r), false, "[osp-installer] File::GetAttributes() failed, serviceXmlPath=%ls", serviceXmlPath.GetPointer());
656 long long webXmlFileSize = webXmlAttr.GetFileSize();
657 long long serviceXmlFileSize = serviceAttr.GetFileSize();
658 long long mergedSize = webXmlFileSize + serviceXmlFileSize;
661 r = webXml.Construct(webXmlPath, L"r");
662 TryReturn(!IsFailed(r), false, "[osp-installer] webXmlPath.Construct is failed");
664 std::unique_ptr<char[]> pMergedBuf(new (std::nothrow) char[mergedSize + 1]);
665 TryReturn(pMergedBuf, false, "[osp-installer] pMergedBuf is null");
666 memset(pMergedBuf.get(), 0, mergedSize + 1);
668 int readBytes = webXml.Read(pMergedBuf.get(), webXmlFileSize);
669 TryReturn(readBytes >= 0, false, "[osp-installer] webXml.Read is failed");
672 r = serviceXml.Construct(serviceXmlPath, L"r");
673 TryReturn(!IsFailed(r), false, "[osp-installer] serviceXmlPath.Construct is failed");
675 std::unique_ptr<char[]> pServiceBuf(new (std::nothrow) char[serviceXmlFileSize + 1]);
676 TryReturn(pServiceBuf, false, "[osp-installer] pServiceBuf is null");
677 memset(pServiceBuf.get(), 0, serviceXmlFileSize + 1);
679 readBytes = serviceXml.Read(pServiceBuf.get(), serviceXmlFileSize);
680 TryReturn(readBytes >= 0, false, "[osp-installer] serviceXml.Read is failed");
682 char* pManifestTag = strcasestr(pMergedBuf.get(), "</manifest>");
683 TryReturn(pManifestTag, false, "[osp-installer] pManifestTag is null");
685 char* pAppTagStart = strcasestr(pServiceBuf.get(), "<ui-application");
686 TryReturn(pAppTagStart, false, "[osp-installer] pAppTagStart is null");
688 char* pAppTagEnd = strcasestr(pServiceBuf.get(), "</ui-application>");
689 TryReturn(pAppTagEnd, false, "[osp-installer] pAppTagEnd is null");
691 int serviceAppLen = pAppTagEnd - pAppTagStart + strlen("</ui-application>");
693 memcpy(pManifestTag, pAppTagStart, serviceAppLen);
695 char* pManifestEndTag = pManifestTag + serviceAppLen;
696 strcpy(pManifestEndTag, "\n</manifest>");
698 int fileSize = pManifestEndTag - pMergedBuf.get() + strlen("\n</manifest>");
701 r = systemXml.Construct(systemXmlPath, L"w");
702 TryReturn(!IsFailed(r), false, "[osp-installer] systemXmlPath.Construct is failed");
704 systemXml.Write(pMergedBuf.get(), fileSize);
706 AppLogTag(OSP_INSTALLER, "pMergedBuf.get()=0x%0x, length=%d", pMergedBuf.get(), fileSize);
707 InstallerUtil::DumpLogData(pMergedBuf.get(), fileSize);
713 ConfigurationManager::CreateInfoFile(const String& filePath, const String* pContext)
715 result r = E_SUCCESS;
718 r = file.Construct(filePath, "w");
719 TryReturn(!IsFailed(r), false, "[osp-installer] file.Construct() failed, filePath=[%ls]", filePath.GetPointer());
721 AppLogTag(OSP_INSTALLER, "------------------------------------------");
722 AppLogTag(OSP_INSTALLER, "CreateInfoFile(), filePath = [%ls]", filePath.GetPointer());
726 r = file.Write(*pContext);
727 TryReturn(!IsFailed(r), false, "[osp-installer] file.Write() failed, filePath=[%ls]", filePath.GetPointer());
728 AppLogTag(OSP_INSTALLER, "string = [%ls]", pContext->GetPointer());
730 AppLogTag(OSP_INSTALLER, "------------------------------------------");
736 ConfigurationManager::CreateImeSymlink(const String& binaryPath, const String& packageName)
740 const char* pExePath = null;
741 const char* pSymlinkPath = null;
743 Directory::Create(IME_PATH, true);
746 exePath.Format(1024, L"%ls.exe", binaryPath.GetPointer());
749 symlinkPath.Format(1024, L"%s/%ls.so", IME_PATH, packageName.GetPointer());
751 pExePath = _StringConverter::CopyToCharArrayN(exePath);
752 TryCatch(pExePath, res = false, "[osp-installer] pExePath is null");
754 pSymlinkPath = _StringConverter::CopyToCharArrayN(symlinkPath);
755 TryCatch(pSymlinkPath, res = false, "[osp-installer] pSymlinkPath is null");
757 err = symlink(pExePath, pSymlinkPath);
759 AppLogTag(OSP_INSTALLER, "[%s] -> [%s]", pSymlinkPath, pExePath);
763 delete[] pSymlinkPath;
769 ConfigurationManager::FindPrivilege(InstallationContext* pContext, const String& privilege) const
771 TryReturn(pContext, false, "[osp-installer] pContext is null.");
774 const ArrayList* pPrivilegeList = pContext->GetPrivilegeList();
778 if (pPrivilegeList->Contains(privilege) == true)
780 AppLogTag(OSP_INSTALLER, "Privilege = [%ls]", privilege.GetPointer());