2 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "anbox/cmds/install.h"
19 #include "anbox/dbus/stub/application_manager.h"
21 #include <core/dbus/asio/executor.h>
23 #include <boost/filesystem.hpp>
25 namespace fs = boost::filesystem;
27 anbox::cmds::Install::Install()
28 : CommandWithFlagsAndAction{
29 cli::Name{"install"}, cli::Usage{"install"},
31 "Install specified application in the Android container"}} {
32 flag(cli::make_flag(cli::Name{"apk"},
33 cli::Description{"Path to APK to install"}, apk_));
34 action([this](const cli::Command::Context&) {
35 if (apk_.length() == 0)
36 BOOST_THROW_EXCEPTION(std::runtime_error("No APK to install specified"));
38 if (!fs::is_regular_file(apk_))
39 BOOST_THROW_EXCEPTION(
40 std::runtime_error("Specified APK file does not exist"));
43 std::make_shared<core::dbus::Bus>(core::dbus::WellKnownBus::session);
44 bus->install_executor(core::dbus::asio::make_executor(bus));
45 auto stub = dbus::stub::ApplicationManager::create_for_bus(bus);