Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
0f500649
A
anbox
项目概览
openeuler
/
anbox
通知
24
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
anbox
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0f500649
编写于
11月 15, 2016
作者:
S
Simon Fels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement RPC for window state synchronization
上级
f7820e1f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
89 addition
and
78 deletion
+89
-78
android/service/platform_api_stub.cpp
android/service/platform_api_stub.cpp
+2
-28
android/service/platform_api_stub.h
android/service/platform_api_stub.h
+5
-4
android/service/platform_service.cpp
android/service/platform_service.cpp
+47
-5
android/service/platform_service.h
android/service/platform_service.h
+9
-2
android/service/platform_service_interface.cpp
android/service/platform_service_interface.cpp
+2
-11
android/service/platform_service_interface.h
android/service/platform_service_interface.h
+3
-5
src/anbox/bridge/platform_api_skeleton.h
src/anbox/bridge/platform_api_skeleton.h
+2
-5
src/anbox/bridge/platform_message_processor.cpp
src/anbox/bridge/platform_message_processor.cpp
+0
-2
src/anbox/protobuf/anbox_bridge.proto
src/anbox/protobuf/anbox_bridge.proto
+16
-0
src/anbox/ubuntu/platform_api_skeleton.cpp
src/anbox/ubuntu/platform_api_skeleton.cpp
+1
-11
src/anbox/ubuntu/platform_api_skeleton.h
src/anbox/ubuntu/platform_api_skeleton.h
+2
-5
未找到文件。
android/service/platform_api_stub.cpp
浏览文件 @
0f500649
...
...
@@ -55,7 +55,7 @@ void PlatformApiStub::handle_boot_finished_response(Request<protobuf::rpc::Void>
boot_finished_wait_handle_
.
result_received
();
}
void
PlatformApiStub
::
update_window_state
()
{
void
PlatformApiStub
::
update_window_state
(
const
anbox
::
protobuf
::
bridge
::
WindowStateUpdate
&
window_state
)
{
auto
c
=
std
::
make_shared
<
Request
<
protobuf
::
rpc
::
Void
>>
();
ALOGI
(
"Updating window state"
);
...
...
@@ -65,11 +65,9 @@ void PlatformApiStub::update_window_state() {
update_window_state_wait_handle_
.
expect_result
();
}
protobuf
::
rpc
::
Void
message
;
rpc_channel_
->
call_method
(
"update_window_state"
,
&
messag
e
,
c
->
response
.
get
(),
&
window_stat
e
,
c
->
response
.
get
(),
google
::
protobuf
::
NewCallback
(
this
,
&
PlatformApiStub
::
handle_update_window_state_response
,
c
.
get
()));
update_window_state_wait_handle_
.
wait_for_all
();
...
...
@@ -78,28 +76,4 @@ void PlatformApiStub::update_window_state() {
void
PlatformApiStub
::
handle_update_window_state_response
(
Request
<
protobuf
::
rpc
::
Void
>
*
request
)
{
update_window_state_wait_handle_
.
result_received
();
}
void
PlatformApiStub
::
remove_window
()
{
auto
c
=
std
::
make_shared
<
Request
<
protobuf
::
rpc
::
Void
>>
();
ALOGI
(
"Remove window"
);
{
std
::
lock_guard
<
decltype
(
mutex_
)
>
lock
(
mutex_
);
remove_window_wait_handle_
.
expect_result
();
}
protobuf
::
rpc
::
Void
message
;
rpc_channel_
->
call_method
(
"remove_window"
,
&
message
,
c
->
response
.
get
(),
google
::
protobuf
::
NewCallback
(
this
,
&
PlatformApiStub
::
handle_remove_window_response
,
c
.
get
()));
remove_window_wait_handle_
.
wait_for_all
();
}
void
PlatformApiStub
::
handle_remove_window_response
(
Request
<
protobuf
::
rpc
::
Void
>
*
request
)
{
update_window_state_wait_handle_
.
result_received
();
}
}
// namespace anbox
android/service/platform_api_stub.h
浏览文件 @
0f500649
...
...
@@ -26,7 +26,11 @@ namespace anbox {
namespace
protobuf
{
namespace
rpc
{
class
Void
;
class
WindowStateUpdate
;
}
// namespace rpc
namespace
bridge
{
class
WindowStateUpdate
;
}
// namespace bridge
}
// namespace protobuf
namespace
rpc
{
class
Channel
;
...
...
@@ -36,8 +40,7 @@ public:
PlatformApiStub
(
const
std
::
shared_ptr
<
rpc
::
Channel
>
&
rpc_channel
);
void
boot_finished
();
void
update_window_state
();
void
remove_window
();
void
update_window_state
(
const
anbox
::
protobuf
::
bridge
::
WindowStateUpdate
&
window_state
);
private:
template
<
typename
Response
>
...
...
@@ -49,12 +52,10 @@ private:
void
handle_boot_finished_response
(
Request
<
protobuf
::
rpc
::
Void
>
*
request
);
void
handle_update_window_state_response
(
Request
<
protobuf
::
rpc
::
Void
>
*
request
);
void
handle_remove_window_response
(
Request
<
protobuf
::
rpc
::
Void
>
*
request
);
mutable
std
::
mutex
mutex_
;
common
::
WaitHandle
boot_finished_wait_handle_
;
common
::
WaitHandle
update_window_state_wait_handle_
;
common
::
WaitHandle
remove_window_wait_handle_
;
std
::
shared_ptr
<
rpc
::
Channel
>
rpc_channel_
;
};
...
...
android/service/platform_service.cpp
浏览文件 @
0f500649
...
...
@@ -19,9 +19,14 @@
#include "android/service/platform_api_stub.h"
#include "anbox/rpc/channel.h"
#include "anbox_rpc.pb.h"
#include "anbox_bridge.pb.h"
#define LOG_TAG "Anboxd"
#include <cutils/log.h>
#include <utils/String8.h>
using
namespace
android
;
namespace
android
{
...
...
@@ -34,13 +39,50 @@ status_t PlatformService::boot_finished() {
return
OK
;
}
status_t
PlatformService
::
update_window_state
()
{
platform_api_stub_
->
update_window_state
();
return
OK
;
void
PlatformService
::
unpack_window_state
(
anbox
::
protobuf
::
bridge
::
WindowStateUpdate_WindowState
*
window
,
const
Parcel
&
data
)
{
window
->
set_has_surface
(
data
.
readByte
()
!=
0
);
String8
package_name
(
data
.
readString16
());
auto
frame_left
=
data
.
readInt32
();
auto
frame_top
=
data
.
readInt32
();
auto
frame_right
=
data
.
readInt32
();
auto
frame_bottom
=
data
.
readInt32
();
auto
task_id
=
data
.
readInt32
();
auto
stack_id
=
data
.
readInt32
();
window
->
set_package_name
(
package_name
.
string
());
window
->
set_frame_left
(
frame_left
);
window
->
set_frame_top
(
frame_top
);
window
->
set_frame_right
(
frame_right
);
window
->
set_frame_bottom
(
frame_bottom
);
window
->
set_task_id
(
task_id
);
window
->
set_stack_id
(
stack_id
);
}
status_t
PlatformService
::
remove_window
()
{
platform_api_stub_
->
remove_window
();
status_t
PlatformService
::
update_window_state
(
const
Parcel
&
data
)
{
anbox
::
protobuf
::
bridge
::
WindowStateUpdate
window_state
;
const
auto
num_displays
=
data
.
readInt32
();
for
(
auto
n
=
0
;
n
<
num_displays
;
n
++
)
{
const
auto
display_id
=
data
.
readInt32
();
for
(
auto
m
=
0
;
m
<
num_windows
;
m
++
)
{
auto
window
=
window_state
.
add_windows
();
window
->
set_display_id
(
display_id
);
unpack_window_state
(
window
,
data
);
}
}
const
auto
num_removed_windows
=
data
.
readInt32
();
for
(
auto
n
=
0
;
n
<
num_removed_windows
;
n
++
)
{
auto
window
=
window_state
.
add_removed_windows
();
window
->
set_display_id
(
0
);
unpack_window_state
(
window
,
data
);
}
platform_api_stub_
->
update_window_state
(
window_state
);
return
OK
;
}
}
// namespace android
android/service/platform_service.h
浏览文件 @
0f500649
...
...
@@ -20,10 +20,17 @@
#include "android/service/platform_service_interface.h"
#include <binder/Parcel.h>
#include <memory>
namespace
anbox
{
class
PlatformApiStub
;
namespace
protobuf
{
namespace
bridge
{
class
WindowStateUpdate_WindowState
;
}
// namespace bridge
}
// namespace protobuf
}
// namespace anbox
namespace
android
{
...
...
@@ -34,10 +41,10 @@ public:
PlatformService
(
const
std
::
shared_ptr
<
anbox
::
PlatformApiStub
>
&
platform_api_stub
);
status_t
boot_finished
()
override
;
status_t
update_window_state
()
override
;
status_t
remove_window
()
override
;
status_t
update_window_state
(
const
Parcel
&
data
)
override
;
private:
void
unpack_window_state
(
anbox
::
protobuf
::
bridge
::
WindowStateUpdate_WindowState
*
window
,
const
Parcel
&
data
);
std
::
shared_ptr
<
anbox
::
PlatformApiStub
>
platform_api_stub_
;
};
}
// namespace android
...
...
android/service/platform_service_interface.cpp
浏览文件 @
0f500649
...
...
@@ -28,18 +28,12 @@ status_t BpPlatformService::boot_finished() {
return
remote
()
->
transact
(
IPlatformService
::
BOOT_FINISHED
,
data
,
&
reply
);
}
status_t
BpPlatformService
::
update_window_state
()
{
status_t
BpPlatformService
::
update_window_state
(
const
Parcel
&
)
{
Parcel
data
,
reply
;
data
.
writeInterfaceToken
(
IPlatformService
::
getInterfaceDescriptor
());
return
remote
()
->
transact
(
IPlatformService
::
UPDATE_WINDOW_STATE
,
data
,
&
reply
);
}
status_t
BpPlatformService
::
remove_window
()
{
Parcel
data
,
reply
;
data
.
writeInterfaceToken
(
IPlatformService
::
getInterfaceDescriptor
());
return
remote
()
->
transact
(
IPlatformService
::
REMOVE_WINDOW
,
data
,
&
reply
);
}
IMPLEMENT_META_INTERFACE
(
PlatformService
,
"org.anbox.IPlatformService"
);
status_t
BnPlatformService
::
onTransact
(
uint32_t
code
,
const
Parcel
&
data
,
...
...
@@ -50,10 +44,7 @@ status_t BnPlatformService::onTransact(uint32_t code, const Parcel &data,
return
boot_finished
();
case
UPDATE_WINDOW_STATE
:
CHECK_INTERFACE
(
IPlatformService
,
data
,
reply
);
return
update_window_state
();
case
REMOVE_WINDOW
:
CHECK_INTERFACE
(
IPlatformService
,
data
,
reply
);
return
remove_window
();
return
update_window_state
(
data
);
default:
break
;
}
...
...
android/service/platform_service_interface.h
浏览文件 @
0f500649
...
...
@@ -33,14 +33,13 @@ public:
DECLARE_META_INTERFACE
(
PlatformService
);
enum
{
// Keep this synchronized with frameworks/base/services/java/com/android/server/wm/AnboxPlatformServiceProxy.java
BOOT_FINISHED
=
IBinder
::
FIRST_CALL_TRANSACTION
,
UPDATE_WINDOW_STATE
=
IBinder
::
FIRST_CALL_TRANSACTION
+
1
,
REMOVE_WINDOW
=
IBinder
::
FIRST_CALL_TRANSACTION
+
2
,
};
virtual
status_t
boot_finished
()
=
0
;
virtual
status_t
update_window_state
()
=
0
;
virtual
status_t
remove_window
()
=
0
;
virtual
status_t
update_window_state
(
const
Parcel
&
data
)
=
0
;
};
class
BpPlatformService
:
public
BpInterface
<
IPlatformService
>
{
...
...
@@ -48,8 +47,7 @@ public:
BpPlatformService
(
const
sp
<
IBinder
>
&
binder
);
status_t
boot_finished
()
override
;
status_t
update_window_state
()
override
;
status_t
remove_window
()
override
;
status_t
update_window_state
(
const
Parcel
&
data
)
override
;
};
class
BnPlatformService
:
public
BnInterface
<
IPlatformService
>
{
...
...
src/anbox/bridge/platform_api_skeleton.h
浏览文件 @
0f500649
...
...
@@ -33,6 +33,7 @@ class Void;
}
// namespace rpc
namespace
bridge
{
class
Notification
;
class
WindowStateUpdate
;
}
// namespace bridge
}
// namespace protobuf
namespace
rpc
{
...
...
@@ -48,14 +49,10 @@ public:
anbox
::
protobuf
::
rpc
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
=
0
;
virtual
void
update_window_state
(
anbox
::
protobuf
::
rpc
::
Void
const
*
request
,
virtual
void
update_window_state
(
anbox
::
protobuf
::
bridge
::
WindowStateUpdate
const
*
request
,
anbox
::
protobuf
::
rpc
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
=
0
;
virtual
void
remove_window
(
anbox
::
protobuf
::
rpc
::
Void
const
*
request
,
anbox
::
protobuf
::
rpc
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
=
0
;
private:
std
::
shared_ptr
<
rpc
::
PendingCallCache
>
pending_calls_
;
};
...
...
src/anbox/bridge/platform_message_processor.cpp
浏览文件 @
0f500649
...
...
@@ -38,8 +38,6 @@ void PlatformMessageProcessor::dispatch(rpc::Invocation const& invocation) {
invoke
(
this
,
server_
.
get
(),
&
PlatformApiSkeleton
::
boot_finished
,
invocation
);
else
if
(
invocation
.
method_name
()
==
"update_window_state"
)
invoke
(
this
,
server_
.
get
(),
&
PlatformApiSkeleton
::
update_window_state
,
invocation
);
else
if
(
invocation
.
method_name
()
==
"remove_window"
)
invoke
(
this
,
server_
.
get
(),
&
PlatformApiSkeleton
::
remove_window
,
invocation
);
}
void
PlatformMessageProcessor
::
process_event_sequence
(
const
std
::
string
&
)
{
...
...
src/anbox/protobuf/anbox_bridge.proto
浏览文件 @
0f500649
...
...
@@ -26,3 +26,19 @@ message SetDnsServers {
}
repeated
Server
servers
=
2
;
}
message
WindowStateUpdate
{
message
WindowState
{
required
int32
display_id
=
1
;
required
bool
has_surface
=
2
;
required
string
package_name
=
3
;
required
int32
frame_left
=
4
;
required
int32
frame_top
=
5
;
required
int32
frame_right
=
6
;
required
int32
frame_bottom
=
7
;
required
int32
task_id
=
8
;
required
int32
stack_id
=
9
;
}
repeated
WindowState
windows
=
1
;
repeated
WindowState
removed_windows
=
2
;
}
src/anbox/ubuntu/platform_api_skeleton.cpp
浏览文件 @
0f500649
...
...
@@ -45,7 +45,7 @@ void PlatformApiSekeleton::boot_finished(anbox::protobuf::rpc::Void const *reque
done
->
Run
();
}
void
PlatformApiSekeleton
::
update_window_state
(
anbox
::
protobuf
::
rpc
::
Void
const
*
request
,
void
PlatformApiSekeleton
::
update_window_state
(
anbox
::
protobuf
::
bridge
::
WindowStateUpdate
const
*
request
,
anbox
::
protobuf
::
rpc
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
{
(
void
)
request
;
...
...
@@ -53,16 +53,6 @@ void PlatformApiSekeleton::update_window_state(anbox::protobuf::rpc::Void const
DEBUG
(
""
);
done
->
Run
();
}
void
PlatformApiSekeleton
::
remove_window
(
anbox
::
protobuf
::
rpc
::
Void
const
*
request
,
anbox
::
protobuf
::
rpc
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
{
(
void
)
request
;
(
void
)
response
;
DEBUG
(
""
);
done
->
Run
();
}
...
...
src/anbox/ubuntu/platform_api_skeleton.h
浏览文件 @
0f500649
...
...
@@ -26,6 +26,7 @@ class Dispatcher;
}
// namespace common
namespace
bridge
{
class
AndroidApiStub
;
class
WindowStateUpdate
;
}
// namespace bridge
namespace
rpc
{
class
PendingCallCache
;
...
...
@@ -40,14 +41,10 @@ public:
anbox
::
protobuf
::
rpc
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
override
;
void
update_window_state
(
anbox
::
protobuf
::
rpc
::
Void
const
*
request
,
void
update_window_state
(
anbox
::
protobuf
::
bridge
::
WindowStateUpdate
const
*
request
,
anbox
::
protobuf
::
rpc
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
override
;
void
remove_window
(
anbox
::
protobuf
::
rpc
::
Void
const
*
request
,
anbox
::
protobuf
::
rpc
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
override
;
void
on_boot_finished
(
const
std
::
function
<
void
()
>
&
action
);
private:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录