Set focus to current active window

This commit is contained in:
Simon Fels 2016-11-26 13:04:50 +01:00
commit 84b3fa430b
15 changed files with 189 additions and 41 deletions

View file

@ -15,6 +15,8 @@
*
*/
#define LOG_TAG "Anboxd"
#include "android/service/android_api_skeleton.h"
#include "anbox_rpc.pb.h"
@ -23,6 +25,8 @@
#include <core/posix/exec.h>
#include <core/posix/child_process.h>
#include <binder/IServiceManager.h>
namespace {
std::map<std::string,std::string> common_env = {
{"ANDROID_DATA", "/data"},
@ -48,6 +52,14 @@ void AndroidApiSkeleton::wait_for_process(core::posix::ChildProcess &process,
}
}
void AndroidApiSkeleton::connect_services() {
if (!activity_manager_.get()) {
auto am = android::defaultServiceManager()->getService(android::String16("activity"));
if (am.get())
activity_manager_ = new android::BpActivityManager(am);
}
}
void AndroidApiSkeleton::install_application(anbox::protobuf::bridge::InstallApplication const *request,
anbox::protobuf::rpc::Void *response,
google::protobuf::Closure *done) {
@ -106,4 +118,19 @@ void AndroidApiSkeleton::set_dns_servers(anbox::protobuf::bridge::SetDnsServers
done->Run();
}
void AndroidApiSkeleton::set_focused_task(anbox::protobuf::bridge::SetFocusedTask const *request,
anbox::protobuf::rpc::Void *response,
google::protobuf::Closure *done) {
(void) response;
connect_services();
if (activity_manager_.get())
activity_manager_->setFocusedTask(request->id());
else
response->set_error("ActivityManager is not available");
done->Run();
}
} // namespace anbox