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

Merge pull request #19 from morphis/activity-launch-bounds

Allow clients to specify the launch bounds of a new activity
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <binder/IServiceManager.h> #include <binder/IServiceManager.h>
#include <string> #include <string>
#include <sstream>
namespace { namespace {
std::map<std::string,std::string> common_env = { std::map<std::string,std::string> common_env = {
...@@ -48,9 +49,9 @@ void AndroidApiSkeleton::wait_for_process(core::posix::ChildProcess &process, ...@@ -48,9 +49,9 @@ void AndroidApiSkeleton::wait_for_process(core::posix::ChildProcess &process,
const auto result = process.wait_for(core::posix::wait::Flags::untraced); const auto result = process.wait_for(core::posix::wait::Flags::untraced);
if (result.status != core::posix::wait::Result::Status::exited || if (result.status != core::posix::wait::Result::Status::exited ||
result.detail.if_exited.status != core::posix::exit::Status::success) { result.detail.if_exited.status != core::posix::exit::Status::success) {
response->set_error("Failed to install application"); response->set_error("Failed to execute process");
// FIXME once we add proper error codes/domains we need to add structured error // FIXME once we add proper error codes/domains we need to add structured error
// info the response here. // info to the response here.
} }
} }
...@@ -76,6 +77,16 @@ void AndroidApiSkeleton::launch_application(anbox::protobuf::bridge::LaunchAppli ...@@ -76,6 +77,16 @@ void AndroidApiSkeleton::launch_application(anbox::protobuf::bridge::LaunchAppli
"--stack", "2", "--stack", "2",
}; };
if (request->has_launch_bounds()) {
argv.push_back("--launch-bounds");
std::stringstream launch_bounds;
launch_bounds << request->launch_bounds().left() << " "
<< request->launch_bounds().top() << " "
<< request->launch_bounds().right() << " "
<< request->launch_bounds().bottom();
argv.push_back(launch_bounds.str());
}
if (intent.has_action()) { if (intent.has_action()) {
argv.push_back("-a"); argv.push_back("-a");
argv.push_back(intent.action()); argv.push_back(intent.action());
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#define ANBOX_APPLICATION_MANAGER_H_ #define ANBOX_APPLICATION_MANAGER_H_
#include "anbox/android/intent.h" #include "anbox/android/intent.h"
#include "anbox/graphics/rect.h"
#include "anbox/do_not_copy_or_move.h" #include "anbox/do_not_copy_or_move.h"
#include <string> #include <string>
...@@ -26,7 +27,7 @@ ...@@ -26,7 +27,7 @@
namespace anbox { namespace anbox {
class ApplicationManager : public DoNotCopyOrMove { class ApplicationManager : public DoNotCopyOrMove {
public: public:
virtual void launch(const android::Intent &intent) = 0; virtual void launch(const android::Intent &intent, const graphics::Rect &launch_bounds = graphics::Rect::Invalid) = 0;
}; };
} // namespace anbox } // namespace anbox
......
...@@ -45,7 +45,8 @@ void AndroidApiStub::ensure_rpc_channel() { ...@@ -45,7 +45,8 @@ void AndroidApiStub::ensure_rpc_channel() {
if (!channel_) throw std::runtime_error("No remote client connected"); if (!channel_) throw std::runtime_error("No remote client connected");
} }
void AndroidApiStub::launch(const android::Intent &intent) { void AndroidApiStub::launch(const android::Intent &intent,
const graphics::Rect &launch_bounds) {
ensure_rpc_channel(); ensure_rpc_channel();
auto c = std::make_shared<Request<protobuf::rpc::Void>>(); auto c = std::make_shared<Request<protobuf::rpc::Void>>();
...@@ -56,6 +57,14 @@ void AndroidApiStub::launch(const android::Intent &intent) { ...@@ -56,6 +57,14 @@ void AndroidApiStub::launch(const android::Intent &intent) {
launch_wait_handle_.expect_result(); launch_wait_handle_.expect_result();
} }
if (launch_bounds != graphics::Rect::Invalid) {
auto rect = message.mutable_launch_bounds();
rect->set_left(launch_bounds_.left());
rect->set_top(launch_bounds_.top());
rect->set_right(launch_bounds_.right());
rect->set_bottom(launch_bounds_.bottom());
}
auto launch_intent = message.mutable_intent(); auto launch_intent = message.mutable_intent();
if (!intent.action.empty()) launch_intent->set_action(intent.action); if (!intent.action.empty()) launch_intent->set_action(intent.action);
......
...@@ -43,7 +43,7 @@ class AndroidApiStub : public anbox::ApplicationManager { ...@@ -43,7 +43,7 @@ class AndroidApiStub : public anbox::ApplicationManager {
void set_rpc_channel(const std::shared_ptr<rpc::Channel> &channel); void set_rpc_channel(const std::shared_ptr<rpc::Channel> &channel);
void reset_rpc_channel(); void reset_rpc_channel();
void launch(const android::Intent &intent) override; void launch(const android::Intent &intent, const graphics::Rect &launch_bounds = graphics::Rect::Invalid) override;
void set_focused_task(const std::int32_t &id); void set_focused_task(const std::int32_t &id);
void remove_task(const std::int32_t &id); void remove_task(const std::int32_t &id);
...@@ -71,6 +71,7 @@ class AndroidApiStub : public anbox::ApplicationManager { ...@@ -71,6 +71,7 @@ class AndroidApiStub : public anbox::ApplicationManager {
common::WaitHandle set_focused_task_handle_; common::WaitHandle set_focused_task_handle_;
common::WaitHandle remove_task_handle_; common::WaitHandle remove_task_handle_;
common::WaitHandle resize_task_handle_; common::WaitHandle resize_task_handle_;
graphics::Rect launch_bounds_ = graphics::Rect::Invalid;
}; };
} // namespace bridge } // namespace bridge
} // namespace anbox } // namespace anbox
......
...@@ -40,10 +40,17 @@ ApplicationManager::ApplicationManager( ...@@ -40,10 +40,17 @@ ApplicationManager::ApplicationManager(
reader >> intent.package; reader >> intent.package;
reader >> intent.component; reader >> intent.component;
std::int32_t left, top, right, bottom;
reader >> left;
reader >> top;
reader >> right;
reader >> bottom;
graphics::Rect launch_bounds{left,top,right,bottom};
core::dbus::Message::Ptr reply; core::dbus::Message::Ptr reply;
try { try {
launch(intent); launch(intent, launch_bounds);
reply = core::dbus::Message::make_method_return(msg); reply = core::dbus::Message::make_method_return(msg);
} catch (std::exception const &err) { } catch (std::exception const &err) {
reply = core::dbus::Message::make_error(msg, "org.anbox.Error.Failed", reply = core::dbus::Message::make_error(msg, "org.anbox.Error.Failed",
...@@ -56,8 +63,8 @@ ApplicationManager::ApplicationManager( ...@@ -56,8 +63,8 @@ ApplicationManager::ApplicationManager(
ApplicationManager::~ApplicationManager() {} ApplicationManager::~ApplicationManager() {}
void ApplicationManager::launch(const android::Intent &intent) { void ApplicationManager::launch(const android::Intent &intent, const graphics::Rect &launch_bounds) {
impl_->launch(intent); impl_->launch(intent, launch_bounds);
} }
} // namespace skeleton } // namespace skeleton
} // namespace dbus } // namespace dbus
......
...@@ -34,7 +34,7 @@ class ApplicationManager : public anbox::ApplicationManager { ...@@ -34,7 +34,7 @@ class ApplicationManager : public anbox::ApplicationManager {
const std::shared_ptr<anbox::ApplicationManager> &impl); const std::shared_ptr<anbox::ApplicationManager> &impl);
~ApplicationManager(); ~ApplicationManager();
void launch(const android::Intent &intent) override; void launch(const android::Intent &intent, const graphics::Rect &launch_bounds = graphics::Rect::Invalid) override;
private: private:
core::dbus::Bus::Ptr bus_; core::dbus::Bus::Ptr bus_;
......
...@@ -38,12 +38,13 @@ ApplicationManager::ApplicationManager(const core::dbus::Bus::Ptr &bus, ...@@ -38,12 +38,13 @@ ApplicationManager::ApplicationManager(const core::dbus::Bus::Ptr &bus,
ApplicationManager::~ApplicationManager() {} ApplicationManager::~ApplicationManager() {}
void ApplicationManager::launch(const android::Intent &intent) { void ApplicationManager::launch(const android::Intent &intent, const graphics::Rect &launch_bounds) {
auto result = object_->invoke_method_synchronously< auto result = object_->invoke_method_synchronously<
anbox::dbus::interface::ApplicationManager::Methods::Launch, anbox::dbus::interface::ApplicationManager::Methods::Launch,
anbox::dbus::interface::ApplicationManager::Methods::Launch::ResultType>( anbox::dbus::interface::ApplicationManager::Methods::Launch::ResultType>(
intent.action, intent.uri, intent.type, intent.flags, intent.package, intent.action, intent.uri, intent.type, intent.flags, intent.package,
intent.component); intent.component, launch_bounds.left(), launch_bounds.top(),
launch_bounds.right(), launch_bounds.bottom());
if (result.is_error()) throw std::runtime_error(result.error().print()); if (result.is_error()) throw std::runtime_error(result.error().print());
} }
......
...@@ -37,7 +37,7 @@ class ApplicationManager : public anbox::ApplicationManager { ...@@ -37,7 +37,7 @@ class ApplicationManager : public anbox::ApplicationManager {
const core::dbus::Object::Ptr &object); const core::dbus::Object::Ptr &object);
~ApplicationManager(); ~ApplicationManager();
void launch(const android::Intent &intent) override; void launch(const android::Intent &intent, const graphics::Rect &launch_bounds = graphics::Rect::Invalid) override;
private: private:
core::dbus::Bus::Ptr bus_; core::dbus::Bus::Ptr bus_;
......
...@@ -33,6 +33,7 @@ message Notification { ...@@ -33,6 +33,7 @@ message Notification {
message LaunchApplication { message LaunchApplication {
required Intent intent = 1; required Intent intent = 1;
optional Rect launch_bounds = 2;
} }
message SetFocusedTask { message SetFocusedTask {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册