/* Copyright 2015 Samsung Electronics, license APACHE-2.0, see LICENSE file */
+#include <common/installer_runner.h>
#include <common/pkgmgr_interface.h>
#include <manifest_parser/utils/logging.h>
#include <TTraceWrapper.h>
#include "tpk/tpk_app_query_interface.h"
-#include "tpk/tpk_installer.h"
+#include "tpk/tpk_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(const int argc, char* argv[]) {
TTRACE(TTRACE_TAG_APP, "TPK_BACKEND");
return -1;
}
- tpk::TpkInstaller t(pkgmgr);
- if (t.Run() != ci::AppInstaller::Result::OK) {
- LOG(ERROR) << "TpkInstaller run failure";
- return -1;
- }
- return 0;
+#if __cplusplus >= 201300L
+ using std;
+#endif
+ ci::InstallerRunner runner(
+ make_unique<tpk::TpkInstallerFactory>(), pkgmgr);
+ ci::AppInstaller::Result result = runner.Run();
+
+ return (result == ci::AppInstaller::Result::OK) ? 0 : 1;
}
--- /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 "tpk/tpk_installer_factory.h"
+
+#include <unzip.h>
+
+#include <manifest_parser/utils/logging.h>
+#include <tpk/tpk_app_query_interface.h>
+#include <tpk/tpk_installer.h>
+
+#include <map>
+#include <memory>
+#include <string>
+
+#include "common/pkgmgr_interface.h"
+#include "common/pkgmgr_query.h"
+
+namespace ci = common_installer;
+
+namespace tpk {
+
+std::unique_ptr<ci::AppInstaller> TpkInstallerFactory::CreateInstaller(
+ ci::PkgMgrPtr pkgmgr, int idx) {
+ std::unique_ptr<ci::AppInstaller> installer;
+ TpkAppQueryInterface* tpk_aqi = new TpkAppQueryInterface();
+
+ pkgmgr->AddAppQueryInterface(idx, tpk_aqi);
+ installer.reset(new TpkInstaller(pkgmgr));
+
+ installer->SetIndex(idx);
+
+ return installer;
+}
+
+} // namespace tpk
--- /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 TPK_TPK_INSTALLER_FACTORY_H_
+#define TPK_TPK_INSTALLER_FACTORY_H_
+
+#include <common/installer_factory.h>
+#include <common/pkgmgr_interface.h>
+
+#include <memory>
+
+namespace ci = common_installer;
+
+namespace tpk {
+
+class AppInstaller;
+
+class TpkInstallerFactory : public ci::InstallerFactory {
+ public:
+ std::unique_ptr<ci::AppInstaller> CreateInstaller(
+ ci::PkgMgrPtr pkgmgr, int idx);
+};
+
+} // namespace tpk
+
+#endif // TPK_TPK_INSTALLER_FACTORY_H_