提交 79b598be 编写于 作者: S Simon Fels 提交者: GitHub

Merge pull request #346 from morphis/f/allow-use-of-system-dbus

Allow the use of the system dbus service
...@@ -77,6 +77,9 @@ anbox::cmds::Launch::Launch() ...@@ -77,6 +77,9 @@ anbox::cmds::Launch::Launch()
flag(cli::make_flag(cli::Name{"stack"}, flag(cli::make_flag(cli::Name{"stack"},
cli::Description{"Which window stack the activity should be started on. Possible: default, fullscreen, freeform"}, cli::Description{"Which window stack the activity should be started on. Possible: default, fullscreen, freeform"},
stack_)); stack_));
flag(cli::make_flag(cli::Name{"use-system-dbus"},
cli::Description{"Use system instead of session DBus"},
use_system_dbus_));
action([this](const cli::Command::Context&) { action([this](const cli::Command::Context&) {
if (!intent_.valid()) { if (!intent_.valid()) {
...@@ -92,7 +95,11 @@ anbox::cmds::Launch::Launch() ...@@ -92,7 +95,11 @@ anbox::cmds::Launch::Launch()
auto rt = Runtime::create(); auto rt = Runtime::create();
auto bus = std::make_shared<core::dbus::Bus>(core::dbus::WellKnownBus::session); auto bus_type = core::dbus::WellKnownBus::session;
if (use_system_dbus_)
bus_type = core::dbus::WellKnownBus::system;
auto bus = std::make_shared<core::dbus::Bus>(bus_type);
bus->install_executor(core::dbus::asio::make_executor(bus, rt->service())); bus->install_executor(core::dbus::asio::make_executor(bus, rt->service()));
const auto snap_path = utils::get_env_value("SNAP"); const auto snap_path = utils::get_env_value("SNAP");
......
...@@ -38,6 +38,7 @@ class Launch : public cli::CommandWithFlagsAndAction { ...@@ -38,6 +38,7 @@ class Launch : public cli::CommandWithFlagsAndAction {
android::Intent intent_; android::Intent intent_;
wm::Stack::Id stack_; wm::Stack::Id stack_;
bool use_system_dbus_ = false;
}; };
} // namespace cmds } // namespace cmds
} // namespace anbox } // namespace anbox
......
...@@ -85,16 +85,9 @@ std::istream& operator>>(std::istream& in, anbox::graphics::GLRendererServer::Co ...@@ -85,16 +85,9 @@ std::istream& operator>>(std::istream& in, anbox::graphics::GLRendererServer::Co
} }
} }
anbox::cmds::SessionManager::BusFactory anbox::cmds::SessionManager::session_bus_factory() { anbox::cmds::SessionManager::SessionManager()
return []() {
return std::make_shared<core::dbus::Bus>(core::dbus::WellKnownBus::session);
};
}
anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
: CommandWithFlagsAndAction{cli::Name{"session-manager"}, cli::Usage{"session-manager"}, : CommandWithFlagsAndAction{cli::Name{"session-manager"}, cli::Usage{"session-manager"},
cli::Description{"Run the the anbox session manager"}}, cli::Description{"Run the the anbox session manager"}},
bus_factory_(bus_factory),
window_size_(default_single_window_size) { window_size_(default_single_window_size) {
// Just for the purpose to allow QtMir (or unity8) to find this on our // Just for the purpose to allow QtMir (or unity8) to find this on our
// /proc/*/cmdline // /proc/*/cmdline
...@@ -117,6 +110,9 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) ...@@ -117,6 +110,9 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
flag(cli::make_flag(cli::Name{"experimental"}, flag(cli::make_flag(cli::Name{"experimental"},
cli::Description{"Allows users to use experimental features"}, cli::Description{"Allows users to use experimental features"},
experimental_)); experimental_));
flag(cli::make_flag(cli::Name{"use-system-dbus"},
cli::Description{"Use system instead of session DBus"},
use_system_dbus_));
action([this](const cli::Command::Context &) { action([this](const cli::Command::Context &) {
auto trap = core::posix::trap_signals_for_process( auto trap = core::posix::trap_signals_for_process(
...@@ -251,7 +247,11 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) ...@@ -251,7 +247,11 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
dispatcher->dispatch([&]() { container_->start(container_configuration); }); dispatcher->dispatch([&]() { container_->start(container_configuration); });
} }
auto bus = bus_factory_(); auto bus_type = core::dbus::WellKnownBus::session;
if (use_system_dbus_)
bus_type = core::dbus::WellKnownBus::system;
auto bus = std::make_shared<core::dbus::Bus>(bus_type);
bus->install_executor(core::dbus::asio::make_executor(bus, rt->service())); bus->install_executor(core::dbus::asio::make_executor(bus, rt->service()));
auto skeleton = anbox::dbus::skeleton::Service::create_for_bus(bus, app_manager); auto skeleton = anbox::dbus::skeleton::Service::create_for_bus(bus, app_manager);
......
...@@ -36,21 +36,17 @@ class Client; ...@@ -36,21 +36,17 @@ class Client;
namespace cmds { namespace cmds {
class SessionManager : public cli::CommandWithFlagsAndAction { class SessionManager : public cli::CommandWithFlagsAndAction {
public: public:
typedef std::function<core::dbus::Bus::Ptr()> BusFactory; SessionManager();
static BusFactory session_bus_factory();
SessionManager(const BusFactory& bus_factory = session_bus_factory());
private: private:
std::shared_ptr<container::Client> container_; std::shared_ptr<container::Client> container_;
BusFactory bus_factory_;
std::string desktop_file_hint_; std::string desktop_file_hint_;
graphics::GLRendererServer::Config::Driver gles_driver_; graphics::GLRendererServer::Config::Driver gles_driver_;
bool single_window_ = false; bool single_window_ = false;
graphics::Rect window_size_; graphics::Rect window_size_;
bool standalone_ = false; bool standalone_ = false;
bool experimental_ = false; bool experimental_ = false;
bool use_system_dbus_ = false;
}; };
} // namespace cmds } // namespace cmds
} // namespace anbox } // namespace anbox
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册