Merge pull request #19 from morphis/activity-launch-bounds
Allow clients to specify the launch bounds of a new activity
This commit is contained in:
commit
aa23c349a1
9 changed files with 43 additions and 12 deletions
|
|
@ -28,6 +28,7 @@
|
|||
#include <binder/IServiceManager.h>
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace {
|
||||
std::map<std::string,std::string> common_env = {
|
||||
|
|
@ -48,9 +49,9 @@ void AndroidApiSkeleton::wait_for_process(core::posix::ChildProcess &process,
|
|||
const auto result = process.wait_for(core::posix::wait::Flags::untraced);
|
||||
if (result.status != core::posix::wait::Result::Status::exited ||
|
||||
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
|
||||
// info the response here.
|
||||
// info to the response here.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -76,6 +77,16 @@ void AndroidApiSkeleton::launch_application(anbox::protobuf::bridge::LaunchAppli
|
|||
"--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()) {
|
||||
argv.push_back("-a");
|
||||
argv.push_back(intent.action());
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#define ANBOX_APPLICATION_MANAGER_H_
|
||||
|
||||
#include "anbox/android/intent.h"
|
||||
#include "anbox/graphics/rect.h"
|
||||
#include "anbox/do_not_copy_or_move.h"
|
||||
|
||||
#include <string>
|
||||
|
|
@ -26,7 +27,7 @@
|
|||
namespace anbox {
|
||||
class ApplicationManager : public DoNotCopyOrMove {
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ void AndroidApiStub::ensure_rpc_channel() {
|
|||
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();
|
||||
|
||||
auto c = std::make_shared<Request<protobuf::rpc::Void>>();
|
||||
|
|
@ -56,6 +57,14 @@ void AndroidApiStub::launch(const android::Intent &intent) {
|
|||
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();
|
||||
|
||||
if (!intent.action.empty()) launch_intent->set_action(intent.action);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class AndroidApiStub : public anbox::ApplicationManager {
|
|||
void set_rpc_channel(const std::shared_ptr<rpc::Channel> &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 remove_task(const std::int32_t &id);
|
||||
|
|
@ -71,6 +71,7 @@ class AndroidApiStub : public anbox::ApplicationManager {
|
|||
common::WaitHandle set_focused_task_handle_;
|
||||
common::WaitHandle remove_task_handle_;
|
||||
common::WaitHandle resize_task_handle_;
|
||||
graphics::Rect launch_bounds_ = graphics::Rect::Invalid;
|
||||
};
|
||||
} // namespace bridge
|
||||
} // namespace anbox
|
||||
|
|
|
|||
|
|
@ -40,10 +40,17 @@ ApplicationManager::ApplicationManager(
|
|||
reader >> intent.package;
|
||||
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;
|
||||
|
||||
try {
|
||||
launch(intent);
|
||||
launch(intent, launch_bounds);
|
||||
reply = core::dbus::Message::make_method_return(msg);
|
||||
} catch (std::exception const &err) {
|
||||
reply = core::dbus::Message::make_error(msg, "org.anbox.Error.Failed",
|
||||
|
|
@ -56,8 +63,8 @@ ApplicationManager::ApplicationManager(
|
|||
|
||||
ApplicationManager::~ApplicationManager() {}
|
||||
|
||||
void ApplicationManager::launch(const android::Intent &intent) {
|
||||
impl_->launch(intent);
|
||||
void ApplicationManager::launch(const android::Intent &intent, const graphics::Rect &launch_bounds) {
|
||||
impl_->launch(intent, launch_bounds);
|
||||
}
|
||||
} // namespace skeleton
|
||||
} // namespace dbus
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class ApplicationManager : public anbox::ApplicationManager {
|
|||
const std::shared_ptr<anbox::ApplicationManager> &impl);
|
||||
~ApplicationManager();
|
||||
|
||||
void launch(const android::Intent &intent) override;
|
||||
void launch(const android::Intent &intent, const graphics::Rect &launch_bounds = graphics::Rect::Invalid) override;
|
||||
|
||||
private:
|
||||
core::dbus::Bus::Ptr bus_;
|
||||
|
|
|
|||
|
|
@ -38,12 +38,13 @@ ApplicationManager::ApplicationManager(const core::dbus::Bus::Ptr &bus,
|
|||
|
||||
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<
|
||||
anbox::dbus::interface::ApplicationManager::Methods::Launch,
|
||||
anbox::dbus::interface::ApplicationManager::Methods::Launch::ResultType>(
|
||||
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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class ApplicationManager : public anbox::ApplicationManager {
|
|||
const core::dbus::Object::Ptr &object);
|
||||
~ApplicationManager();
|
||||
|
||||
void launch(const android::Intent &intent) override;
|
||||
void launch(const android::Intent &intent, const graphics::Rect &launch_bounds = graphics::Rect::Invalid) override;
|
||||
|
||||
private:
|
||||
core::dbus::Bus::Ptr bus_;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ message Notification {
|
|||
|
||||
message LaunchApplication {
|
||||
required Intent intent = 1;
|
||||
optional Rect launch_bounds = 2;
|
||||
}
|
||||
|
||||
message SetFocusedTask {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue