X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fcmds%2Finstall.cpp;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fcmds%2Finstall.cpp;h=ff3c4af5c7994a0bc6b8811ad9a1713eadafa53f;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.cpp new file mode 100644 index 0000000..ff3c4af --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/cmds/install.h" +#include "anbox/dbus/stub/application_manager.h" + +#include + +#include + +namespace fs = boost::filesystem; + +anbox::cmds::Install::Install() + : CommandWithFlagsAndAction{ + cli::Name{"install"}, cli::Usage{"install"}, + cli::Description{ + "Install specified application in the Android container"}} { + flag(cli::make_flag(cli::Name{"apk"}, + cli::Description{"Path to APK to install"}, apk_)); + action([this](const cli::Command::Context&) { + if (apk_.length() == 0) + BOOST_THROW_EXCEPTION(std::runtime_error("No APK to install specified")); + + if (!fs::is_regular_file(apk_)) + BOOST_THROW_EXCEPTION( + std::runtime_error("Specified APK file does not exist")); + + auto bus = + std::make_shared(core::dbus::WellKnownBus::session); + bus->install_executor(core::dbus::asio::make_executor(bus)); + auto stub = dbus::stub::ApplicationManager::create_for_bus(bus); + + stub->install(apk_); + + return EXIT_SUCCESS; + }); +}