Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
d7c73bf7
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,发现更多精彩内容 >>
提交
d7c73bf7
编写于
6月 28, 2016
作者:
S
Simon Fels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement RPC commands on the Android side
上级
ed23744a
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
94 addition
and
5 deletion
+94
-5
Android.mk
Android.mk
+7
-2
android/CMakeLists.txt
android/CMakeLists.txt
+5
-0
android/service/server.cpp
android/service/server.cpp
+52
-2
android/service/server.h
android/service/server.h
+5
-0
external/process-cpp-minimal/include/core/posix/child_process.h
...al/process-cpp-minimal/include/core/posix/child_process.h
+2
-0
external/process-cpp-minimal/src/core/posix/child_process.cpp
...rnal/process-cpp-minimal/src/core/posix/child_process.cpp
+19
-1
external/process-cpp-minimal/src/core/posix/fork.cpp
external/process-cpp-minimal/src/core/posix/fork.cpp
+4
-0
未找到文件。
Android.mk
浏览文件 @
d7c73bf7
...
...
@@ -9,8 +9,12 @@ LOCAL_SRC_FILES := \
external/process-cpp-minimal/src/core/posix/signal.cpp
\
external/process-cpp-minimal/src/core/posix/signalable.cpp
\
external/process-cpp-minimal/src/core/posix/standard_stream.cpp
\
external/process-cpp-minimal/src/core/posix/wait.cpp
external/process-cpp-minimal/src/core/posix/wait.cpp
\
external/process-cpp-minimal/src/core/posix/fork.cpp
\
external/process-cpp-minimal/src/core/posix/exec.cpp
\
external/process-cpp-minimal/src/core/posix/child_process.cpp
LOCAL_CFLAGS
:=
\
-DANDROID
\
-fexceptions
LOCAL_C_INCLUDES
+=
\
$(LOCAL_PATH)
/external/process-cpp-minimal/include
...
...
@@ -26,11 +30,12 @@ LOCAL_SRC_FILES := \
android/service/host_connector.cpp
\
android/service/local_socket_connection.cpp
\
android/service/message_processor.cpp
\
android/service/server.cpp
\
src/anbox/common/fd.cpp
\
src/anbox/bridge/message_processor.cpp
\
src/anbox/bridge/pending_call_cache.cpp
\
src/anbox/bridge/rpc_channel.cpp
\
src/anbox/protobuf/bridge.proto
src/anbox/protobuf/
anbox_
bridge.proto
proto_header_dir
:=
$(
call
local-generated-sources-dir
)
/proto/
$(LOCAL_PATH)
/src/anbox/protobuf
LOCAL_C_INCLUDES
+=
\
$(proto_header_dir)
\
...
...
android/CMakeLists.txt
浏览文件 @
d7c73bf7
...
...
@@ -19,3 +19,8 @@ target_link_libraries(anboxd
pthread
process-cpp
anbox-protobuf
)
# As we're adding Android specific bits in this project we can't
# build this safely within default build anymore. We keep this
# for easy integration into used IDEs.
set_target_properties
(
anboxd
PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1
)
android/service/server.cpp
浏览文件 @
d7c73bf7
...
...
@@ -19,6 +19,16 @@
#include "anbox_bridge.pb.h"
#include <core/posix/exec.h>
#include <core/posix/child_process.h>
namespace
{
std
::
map
<
std
::
string
,
std
::
string
>
common_env
=
{
{
"ANDROID_DATA"
,
"/data"
},
{
"ANDROID_ROOT"
,
"/system"
},
};
}
namespace
anbox
{
namespace
android
{
Server
::
Server
()
{
...
...
@@ -30,20 +40,60 @@ Server::~Server() {
void
Server
::
install_application
(
anbox
::
protobuf
::
bridge
::
InstallApplication
const
*
request
,
anbox
::
protobuf
::
bridge
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
{
(
void
)
request
;
(
void
)
response
;
std
::
vector
<
std
::
string
>
argv
=
{
"/system/bin/pm"
,
"install"
,
request
->
path
(),
};
auto
process
=
core
::
posix
::
exec
(
"/system/bin/sh"
,
argv
,
common_env
,
core
::
posix
::
StandardStream
::
empty
);
process
.
wait_for
(
core
::
posix
::
wait
::
Flags
::
untraced
);
done
->
Run
();
}
void
Server
::
launch_application
(
anbox
::
protobuf
::
bridge
::
LaunchApplication
const
*
request
,
anbox
::
protobuf
::
bridge
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
{
(
void
)
request
;
(
void
)
response
;
std
::
string
intent
=
request
->
package_name
();
intent
+=
"/"
;
intent
+=
request
->
activity
();
std
::
vector
<
std
::
string
>
argv
=
{
"/system/bin/am"
,
"start"
,
intent
,
};
auto
process
=
core
::
posix
::
exec
(
"/system/bin/sh"
,
argv
,
common_env
,
core
::
posix
::
StandardStream
::
empty
);
process
.
wait_for
(
core
::
posix
::
wait
::
Flags
::
untraced
);
done
->
Run
();
}
void
Server
::
set_dns_servers
(
anbox
::
protobuf
::
bridge
::
SetDnsServers
const
*
request
,
anbox
::
protobuf
::
bridge
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
)
{
(
void
)
response
;
std
::
vector
<
std
::
string
>
argv
=
{
"resolver"
,
"setnetdns"
,
"0"
,
request
->
domain
(),
};
for
(
int
n
=
0
;
n
<
request
->
servers_size
();
n
++
)
argv
.
push_back
(
request
->
servers
(
n
).
address
());
auto
process
=
core
::
posix
::
exec
(
"/system/bin/ndc"
,
argv
,
common_env
,
core
::
posix
::
StandardStream
::
empty
);
process
.
wait_for
(
core
::
posix
::
wait
::
Flags
::
untraced
);
done
->
Run
();
}
}
// namespace anbox
}
// namespace network
android/service/server.h
浏览文件 @
d7c73bf7
...
...
@@ -29,6 +29,7 @@ namespace protobuf {
namespace
bridge
{
class
InstallApplication
;
class
LaunchApplication
;
class
SetDnsServers
;
class
Void
;
}
// namespace bridge
}
// namespace protobuf
...
...
@@ -45,6 +46,10 @@ public:
void
launch_application
(
anbox
::
protobuf
::
bridge
::
LaunchApplication
const
*
request
,
anbox
::
protobuf
::
bridge
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
);
void
set_dns_servers
(
anbox
::
protobuf
::
bridge
::
SetDnsServers
const
*
request
,
anbox
::
protobuf
::
bridge
::
Void
*
response
,
google
::
protobuf
::
Closure
*
done
);
};
}
// namespace android
}
// namespace anbox
...
...
external/process-cpp-minimal/include/core/posix/child_process.h
浏览文件 @
d7c73bf7
...
...
@@ -114,6 +114,7 @@ public:
*/
wait
::
Result
wait_for
(
const
wait
::
Flags
&
flags
);
#ifndef ANDROID
/**
* @brief Access this process's stderr.
*/
...
...
@@ -128,6 +129,7 @@ public:
* @brief Access this process's stdout.
*/
std
::
istream
&
cout
();
#endif
private:
friend
ChildProcess
fork
(
const
std
::
function
<
posix
::
exit
::
Status
()
>&
,
const
StandardStream
&
);
...
...
external/process-cpp-minimal/src/core/posix/child_process.cpp
浏览文件 @
d7c73bf7
...
...
@@ -18,8 +18,10 @@
#include <core/posix/child_process.h>
#ifndef ANDROID
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#endif
#include <atomic>
#include <fstream>
...
...
@@ -33,7 +35,13 @@
#include <sys/eventfd.h>
#include <sys/signalfd.h>
#include <assert.h>
#include <sys/wait.h>
#ifndef ANDROID
namespace
io
=
boost
::
iostreams
;
#endif
namespace
{
...
...
@@ -279,12 +287,14 @@ struct ChildProcess::Private
const
ChildProcess
::
Pipe
&
stdin
,
const
ChildProcess
::
Pipe
&
stdout
)
:
pipes
{
stderr
,
stdin
,
stdout
},
#ifndef ANDROID
serr
(
pipes
.
stderr
.
read_fd
(),
io
::
never_close_handle
),
sin
(
pipes
.
stdin
.
write_fd
(),
io
::
never_close_handle
),
sout
(
pipes
.
stdout
.
read_fd
(),
io
::
never_close_handle
),
cerr
(
&
serr
),
cin
(
&
sin
),
cout
(
&
sout
),
#endif
original_parent_pid
(
::
getpid
()),
original_child_pid
(
pid
)
{
...
...
@@ -308,12 +318,15 @@ struct ChildProcess::Private
ChildProcess
::
Pipe
stdout
;
ChildProcess
::
Pipe
stderr
;
}
pipes
;
#ifndef ANDROID
io
::
stream_buffer
<
io
::
file_descriptor_source
>
serr
;
io
::
stream_buffer
<
io
::
file_descriptor_sink
>
sin
;
io
::
stream_buffer
<
io
::
file_descriptor_source
>
sout
;
std
::
istream
cerr
;
std
::
ostream
cin
;
std
::
istream
cout
;
#endif
// We need to store the original parent pid as we might have been forked
// and with our automatic cleanup in place, it might happen that the d'tor
...
...
@@ -371,14 +384,18 @@ wait::Result ChildProcess::wait_for(const wait::Flags& flags)
{
result
.
status
=
wait
::
Result
::
Status
::
stopped
;
result
.
detail
.
if_stopped
.
signal
=
static_cast
<
Signal
>
(
WSTOPSIG
(
status
));
}
else
if
(
WIFCONTINUED
(
status
))
}
#ifndef ANDROID
else
if
(
WIFCONTINUED
(
status
))
{
result
.
status
=
wait
::
Result
::
Status
::
continued
;
}
#endif
return
result
;
}
#ifndef ANDROID
std
::
istream
&
ChildProcess
::
cerr
()
{
return
d
->
cerr
;
...
...
@@ -393,5 +410,6 @@ std::istream& ChildProcess::cout()
{
return
d
->
cout
;
}
#endif
}
}
external/process-cpp-minimal/src/core/posix/fork.cpp
浏览文件 @
d7c73bf7
...
...
@@ -19,7 +19,9 @@
#include <core/posix/exit.h>
#include <core/posix/fork.h>
#ifndef ANDROID
#include "backtrace.h"
#endif
#include <iomanip>
#include <iostream>
...
...
@@ -38,12 +40,14 @@ void redirect_stream_to_fd(int fd, int stream)
void
print_backtrace
(
std
::
ostream
&
out
,
const
std
::
string
&
line_prefix
)
{
#ifndef ANDROID
core
::
posix
::
backtrace
::
visit_with_handler
([
&
out
,
line_prefix
](
const
core
::
posix
::
backtrace
::
Frame
&
frame
)
{
out
<<
line_prefix
<<
std
::
dec
<<
std
::
setw
(
2
)
<<
frame
.
depth
()
<<
"@"
<<
std
::
hex
<<
std
::
setw
(
14
)
<<
frame
.
frame_pointer
()
<<
": "
<<
(
frame
.
symbol
().
is_cxx
()
?
frame
.
symbol
().
demangled
()
:
frame
.
symbol
().
raw
())
<<
std
::
endl
;
return
true
;
});
#endif
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录