From 948b1829aba80028de02dcbaf4cd047a3c995fe5 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 17 Apr 2020 17:06:10 +0900 Subject: [PATCH] Add WgtInstallerFactory and HybridInstallerFactory Now wgt-backend uses installer-runner to run the installer Change-Id: I801c452dcaababf77527de54876957689d48974f Signed-off-by: Ilho Kim --- src/hybrid/hybrid_installer_factory.cc | 37 ++++++++++++++++++++++++++++++++++ src/hybrid/hybrid_installer_factory.h | 27 +++++++++++++++++++++++++ src/wgt/wgt_installer_factory.cc | 37 ++++++++++++++++++++++++++++++++++ src/wgt/wgt_installer_factory.h | 27 +++++++++++++++++++++++++ src/wgt_backend/wgt_backend.cc | 27 +++++++++++++++++++++---- 5 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 src/hybrid/hybrid_installer_factory.cc create mode 100644 src/hybrid/hybrid_installer_factory.h create mode 100644 src/wgt/wgt_installer_factory.cc create mode 100644 src/wgt/wgt_installer_factory.h diff --git a/src/hybrid/hybrid_installer_factory.cc b/src/hybrid/hybrid_installer_factory.cc new file mode 100644 index 0000000..52c5395 --- /dev/null +++ b/src/hybrid/hybrid_installer_factory.cc @@ -0,0 +1,37 @@ +// Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#include "hybrid/hybrid_installer_factory.h" + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "common/pkgmgr_interface.h" +#include "common/pkgmgr_query.h" + +namespace ci = common_installer; + +namespace hybrid { + +std::unique_ptr HybridInstallerFactory::CreateInstaller( + ci::PkgMgrPtr pkgmgr, int idx) { + std::unique_ptr installer; + wgt::WgtAppQueryInterface* wgt_aqi = new wgt::WgtAppQueryInterface(); + + pkgmgr->AddAppQueryInterface(idx, wgt_aqi); + installer.reset(new hybrid::HybridInstaller(pkgmgr)); + installer->SetIndex(idx); + + return installer; +} + +} // namespace hybrid diff --git a/src/hybrid/hybrid_installer_factory.h b/src/hybrid/hybrid_installer_factory.h new file mode 100644 index 0000000..f93bb76 --- /dev/null +++ b/src/hybrid/hybrid_installer_factory.h @@ -0,0 +1,27 @@ +// Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#ifndef HYBRID_HYBRID_INSTALLER_FACTORY_H_ +#define HYBRID_HYBRID_INSTALLER_FACTORY_H_ + +#include +#include + +#include + +namespace ci = common_installer; + +namespace hybrid { + +class AppInstaller; + +class HybridInstallerFactory : public ci::InstallerFactory { + public: + std::unique_ptr CreateInstaller( + ci::PkgMgrPtr pkgmgr, int idx); +}; + +} // namespace hybrid + +#endif // HYBRID_HYBRID_INSTALLER_FACTORY_H_ diff --git a/src/wgt/wgt_installer_factory.cc b/src/wgt/wgt_installer_factory.cc new file mode 100644 index 0000000..e826ee2 --- /dev/null +++ b/src/wgt/wgt_installer_factory.cc @@ -0,0 +1,37 @@ +// Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#include "wgt/wgt_installer_factory.h" + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "common/pkgmgr_interface.h" +#include "common/pkgmgr_query.h" + +namespace ci = common_installer; + +namespace wgt { + +std::unique_ptr WgtInstallerFactory::CreateInstaller( + ci::PkgMgrPtr pkgmgr, int idx) { + std::unique_ptr installer; + WgtAppQueryInterface* wgt_aqi = new WgtAppQueryInterface(); + + pkgmgr->AddAppQueryInterface(idx, wgt_aqi); + installer.reset(new wgt::WgtInstaller(pkgmgr)); + installer->SetIndex(idx); + + return installer; +} + +} // namespace wgt diff --git a/src/wgt/wgt_installer_factory.h b/src/wgt/wgt_installer_factory.h new file mode 100644 index 0000000..dd1ff4f --- /dev/null +++ b/src/wgt/wgt_installer_factory.h @@ -0,0 +1,27 @@ +// Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#ifndef WGT_WGT_INSTALLER_FACTORY_H_ +#define WGT_WGT_INSTALLER_FACTORY_H_ + +#include +#include + +#include + +namespace ci = common_installer; + +namespace wgt { + +class AppInstaller; + +class WgtInstallerFactory : public ci::InstallerFactory { + public: + std::unique_ptr CreateInstaller( + ci::PkgMgrPtr pkgmgr, int idx); +}; + +} // namespace wgt + +#endif // WGT_WGT_INSTALLER_FACTORY_H_ diff --git a/src/wgt_backend/wgt_backend.cc b/src/wgt_backend/wgt_backend.cc index 9f003e3..c72e135 100644 --- a/src/wgt_backend/wgt_backend.cc +++ b/src/wgt_backend/wgt_backend.cc @@ -3,34 +3,53 @@ // Use of this source code is governed by a apache 2.0 license that can be // found in the LICENSE file. +#include #include #include #include "hybrid/hybrid_installer.h" +#include "hybrid/hybrid_installer_factory.h" #include "wgt/utils/wgt_app_query_interface.h" #include "wgt/wgt_installer.h" +#include "wgt/wgt_installer_factory.h" namespace ci = common_installer; +#if __cplusplus < 201300L +namespace { + +template +std::unique_ptr make_unique(Args&&... args) { + return std::unique_ptr(new T(std::forward(args)...)); +} + +} // namespace +#endif + int main(int argc, char** argv) { ci::PkgmgrInstaller pkgmgr_installer; wgt::WgtAppQueryInterface query_interface; auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &pkgmgr_installer, &query_interface); + std::unique_ptr installer_factory; if (!pkgmgr) { LOG(ERROR) << "Options of pkgmgr installer cannot be parsed"; return EINVAL; } +#if __cplusplus >= 201300L + using std; +#endif // This is workaround for hybrid apps as they requires much different flow // but installer does not branch at all in current design if (query_interface.IsHybridApplication( pkgmgr->GetRequestInfo(), pkgmgr->GetUid())) { LOG(INFO) << "Hybrid package detected"; - hybrid::HybridInstaller installer(pkgmgr); - return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1; + ci::InstallerRunner runner( + make_unique(), pkgmgr); + return (runner.Run() == ci::AppInstaller::Result::OK) ? 0 : 1; } else { - wgt::WgtInstaller installer(pkgmgr); - return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1; + ci::InstallerRunner runner(make_unique(), pkgmgr); + return (runner.Run() == ci::AppInstaller::Result::OK) ? 0 : 1; } } -- 2.7.4