--- /dev/null
+// 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 <unzip.h>
+
+#include <manifest_parser/utils/logging.h>
+#include <hybrid/hybrid_installer.h>
+#include <wgt/utils/wgt_app_query_interface.h>
+#include <wgt/wgt_installer.h>
+
+#include <map>
+#include <memory>
+#include <string>
+
+#include "common/pkgmgr_interface.h"
+#include "common/pkgmgr_query.h"
+
+namespace ci = common_installer;
+
+namespace hybrid {
+
+std::unique_ptr<ci::AppInstaller> HybridInstallerFactory::CreateInstaller(
+ ci::PkgMgrPtr pkgmgr, int idx) {
+ std::unique_ptr<ci::AppInstaller> 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
--- /dev/null
+// 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 <common/installer_factory.h>
+#include <common/pkgmgr_interface.h>
+
+#include <memory>
+
+namespace ci = common_installer;
+
+namespace hybrid {
+
+class AppInstaller;
+
+class HybridInstallerFactory : public ci::InstallerFactory {
+ public:
+ std::unique_ptr<ci::AppInstaller> CreateInstaller(
+ ci::PkgMgrPtr pkgmgr, int idx);
+};
+
+} // namespace hybrid
+
+#endif // HYBRID_HYBRID_INSTALLER_FACTORY_H_
--- /dev/null
+// 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 <unzip.h>
+
+#include <manifest_parser/utils/logging.h>
+#include <hybrid/hybrid_installer.h>
+#include <wgt/utils/wgt_app_query_interface.h>
+#include <wgt/wgt_installer.h>
+
+#include <map>
+#include <memory>
+#include <string>
+
+#include "common/pkgmgr_interface.h"
+#include "common/pkgmgr_query.h"
+
+namespace ci = common_installer;
+
+namespace wgt {
+
+std::unique_ptr<ci::AppInstaller> WgtInstallerFactory::CreateInstaller(
+ ci::PkgMgrPtr pkgmgr, int idx) {
+ std::unique_ptr<ci::AppInstaller> installer;
+ WgtAppQueryInterface* wgt_aqi = new WgtAppQueryInterface();
+
+ pkgmgr->AddAppQueryInterface(idx, wgt_aqi);
+ installer.reset(new wgt::WgtInstaller(pkgmgr));
+ installer->SetIndex(idx);
+
+ return installer;
+}
+
+} // namespace wgt
--- /dev/null
+// 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 <common/installer_factory.h>
+#include <common/pkgmgr_interface.h>
+
+#include <memory>
+
+namespace ci = common_installer;
+
+namespace wgt {
+
+class AppInstaller;
+
+class WgtInstallerFactory : public ci::InstallerFactory {
+ public:
+ std::unique_ptr<ci::AppInstaller> CreateInstaller(
+ ci::PkgMgrPtr pkgmgr, int idx);
+};
+
+} // namespace wgt
+
+#endif // WGT_WGT_INSTALLER_FACTORY_H_
// Use of this source code is governed by a apache 2.0 license that can be
// found in the LICENSE file.
+#include <common/installer_runner.h>
#include <common/pkgmgr_interface.h>
#include <cerrno>
#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<typename T, typename... Args>
+std::unique_ptr<T> make_unique(Args&&... args) {
+ return std::unique_ptr<T>(new T(std::forward<Args>(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<ci::InstallerFactory> 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<hybrid::HybridInstallerFactory>(), 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<wgt::WgtInstallerFactory>(), pkgmgr);
+ return (runner.Run() == ci::AppInstaller::Result::OK) ? 0 : 1;
}
}