Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
5c7b0adf
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,发现更多精彩内容 >>
提交
5c7b0adf
编写于
1月 06, 2017
作者:
S
Simon Fels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Synchronize application icons with the host
上级
8caaa1f3
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
106 addition
and
44 deletion
+106
-44
android/appmgr/src/org/anbox/appmgr/PlatformService.java
android/appmgr/src/org/anbox/appmgr/PlatformService.java
+49
-18
android/service/platform_api_stub.cpp
android/service/platform_api_stub.cpp
+2
-0
android/service/platform_api_stub.h
android/service/platform_api_stub.h
+1
-0
android/service/platform_service.cpp
android/service/platform_service.cpp
+21
-21
src/anbox/application/launcher_storage.cpp
src/anbox/application/launcher_storage.cpp
+14
-3
src/anbox/application/launcher_storage.h
src/anbox/application/launcher_storage.h
+4
-1
src/anbox/bridge/platform_api_skeleton.cpp
src/anbox/bridge/platform_api_skeleton.cpp
+5
-0
src/anbox/cmds/run.cpp
src/anbox/cmds/run.cpp
+2
-1
src/anbox/protobuf/anbox_bridge.proto
src/anbox/protobuf/anbox_bridge.proto
+1
-0
src/anbox/utils.cpp
src/anbox/utils.cpp
+5
-0
src/anbox/utils.h
src/anbox/utils.h
+2
-0
未找到文件。
android/appmgr/src/org/anbox/appmgr/PlatformService.java
浏览文件 @
5c7b0adf
...
...
@@ -27,8 +27,14 @@ import android.content.Context;
import
android.content.pm.PackageManager
;
import
android.content.pm.ApplicationInfo
;
import
android.net.Uri
;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap.Config
;
import
android.graphics.Canvas
;
import
java.util.List
;
import
java.io.ByteArrayOutputStream
;
public
final
class
PlatformService
{
private
static
final
String
TAG
=
"AnboxAppMgr"
;
...
...
@@ -69,12 +75,25 @@ public final class PlatformService {
data
.
writeInt
(
apps
.
size
());
for
(
int
n
=
0
;
n
<
apps
.
size
();
n
++)
{
ApplicationInfo
appInfo
=
apps
.
get
(
n
);
Intent
launchIntent
=
mPm
.
getLaunchIntentForPackage
(
appInfo
.
packageName
);
if
(
launchIntent
==
null
)
continue
;
Drawable
icon
=
null
;
try
{
icon
=
mPm
.
getApplicationIcon
(
appInfo
.
packageName
);
}
catch
(
PackageManager
.
NameNotFoundException
ex
)
{
continue
;
}
if
(
icon
==
null
)
continue
;
data
.
writeString
(
appInfo
.
name
);
data
.
writeString
(
appInfo
.
packageName
);
Intent
launchIntent
=
mPm
.
getLaunchIntentForPackage
(
appInfo
.
packageName
);
if
(
launchIntent
!=
null
)
{
data
.
writeInt
(
1
);
data
.
writeString
(
launchIntent
.
getAction
());
if
(
launchIntent
.
getData
()
!=
null
)
data
.
writeString
(
launchIntent
.
getData
().
toString
());
...
...
@@ -86,11 +105,11 @@ public final class PlatformService {
data
.
writeInt
(
launchIntent
.
getCategories
().
size
());
for
(
String
category
:
launchIntent
.
getCategories
())
data
.
writeString
(
category
);
}
else
{
data
.
writeInt
(
0
);
}
// FIXME add icon, flags, ...
Bitmap
iconBitmap
=
drawableToBitmap
(
icon
);
ByteArrayOutputStream
outStream
=
new
ByteArrayOutputStream
();
iconBitmap
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
90
,
outStream
);
data
.
writeByteArray
(
outStream
.
toByteArray
());
}
Parcel
reply
=
Parcel
.
obtain
();
...
...
@@ -107,4 +126,16 @@ public final class PlatformService {
public
void
notifyPackageRemoved
(
Intent
intent
)
{
}
private
Bitmap
drawableToBitmap
(
Drawable
drawable
)
{
if
(
drawable
instanceof
BitmapDrawable
)
return
((
BitmapDrawable
)
drawable
).
getBitmap
();
Bitmap
bitmap
=
Bitmap
.
createBitmap
(
drawable
.
getIntrinsicWidth
(),
drawable
.
getIntrinsicHeight
(),
Config
.
ARGB_8888
);
Canvas
canvas
=
new
Canvas
(
bitmap
);
drawable
.
setBounds
(
0
,
0
,
canvas
.
getWidth
(),
canvas
.
getHeight
());
drawable
.
draw
(
canvas
);
return
bitmap
;
}
}
android/service/platform_api_stub.cpp
浏览文件 @
5c7b0adf
...
...
@@ -81,6 +81,8 @@ void PlatformApiStub::update_application_list(const ApplicationListUpdate &updat
auto
c
=
launch_intent
->
add_categories
();
*
c
=
category
;
}
app
->
set_icon
(
a
.
icon
.
data
(),
a
.
icon
.
size
());
}
rpc_channel_
->
send_event
(
seq
);
...
...
android/service/platform_api_stub.h
浏览文件 @
5c7b0adf
...
...
@@ -73,6 +73,7 @@ public:
std
::
vector
<
std
::
string
>
categories
;
};
Intent
launch_intent
;
std
::
vector
<
int8_t
>
icon
;
};
std
::
vector
<
Application
>
applications
;
};
...
...
android/service/platform_service.cpp
浏览文件 @
5c7b0adf
...
...
@@ -97,7 +97,6 @@ status_t PlatformService::update_application_list(const Parcel &data) {
package_name
.
string
(),
};
if
(
data
.
readInt32
()
==
1
)
{
String8
action
(
data
.
readString16
());
String8
uri
(
data
.
readString16
());
String8
type
(
data
.
readString16
());
...
...
@@ -116,8 +115,9 @@ status_t PlatformService::update_application_list(const Parcel &data) {
p
.
launch_intent
.
component
=
component_class
;
p
.
launch_intent
.
categories
=
categories
;
data
.
readByteVector
(
&
p
.
icon
);
update
.
applications
.
push_back
(
p
);
};
}
platform_api_stub_
->
update_application_list
(
update
);
...
...
src/anbox/application/launcher_storage.cpp
浏览文件 @
5c7b0adf
...
...
@@ -17,6 +17,7 @@
#include "anbox/application/launcher_storage.h"
#include "anbox/utils.h"
#include "anbox/logger.h"
#include <algorithm>
#include <fstream>
...
...
@@ -26,19 +27,25 @@ namespace fs = boost::filesystem;
namespace
anbox
{
namespace
application
{
LauncherStorage
::
LauncherStorage
(
const
fs
::
path
&
path
)
:
path_
(
path
)
{}
LauncherStorage
::
LauncherStorage
(
const
fs
::
path
&
path
,
const
boost
::
filesystem
::
path
&
icon_path
)
:
path_
(
path
),
icon_path_
(
icon_path
)
{
}
LauncherStorage
::~
LauncherStorage
()
{}
void
LauncherStorage
::
add
(
const
Item
&
item
)
{
if
(
!
fs
::
exists
(
path_
))
fs
::
create_directories
(
path_
);
if
(
!
fs
::
exists
(
icon_path_
))
fs
::
create_directories
(
icon_path_
);
auto
package_name
=
item
.
package
;
std
::
replace
(
package_name
.
begin
(),
package_name
.
end
(),
'.'
,
'-'
);
const
auto
item_path
=
path_
/
utils
::
string_format
(
"anbox-%s.desktop"
,
package_name
);
std
::
string
exec
=
"anbox launch "
;
const
auto
item_icon_path
=
icon_path_
/
utils
::
string_format
(
"anbox-%s.png"
,
package_name
);
std
::
string
exec
=
utils
::
string_format
(
"%s launch "
,
utils
::
process_get_exe_path
(
getpid
()));
if
(
!
item
.
launch_intent
.
action
.
empty
())
exec
+=
utils
::
string_format
(
"--action=%s "
,
item
.
launch_intent
.
action
);
...
...
@@ -62,7 +69,11 @@ void LauncherStorage::add(const Item &item) {
<<
"Exec="
<<
exec
<<
std
::
endl
<<
"Terminal=false"
<<
std
::
endl
<<
"Type=Application"
<<
std
::
endl
<<
"Encoding=UTF-8"
<<
std
::
endl
;
<<
"Icon="
<<
item_icon_path
.
string
()
<<
std
::
endl
;
f
.
close
();
f
=
std
::
ofstream
(
item_icon_path
.
string
());
f
.
write
(
item
.
icon
.
data
(),
item
.
icon
.
size
());
f
.
close
();
}
}
// namespace application
...
...
src/anbox/application/launcher_storage.h
浏览文件 @
5c7b0adf
...
...
@@ -29,19 +29,22 @@ namespace anbox {
namespace
application
{
class
LauncherStorage
{
public:
LauncherStorage
(
const
boost
::
filesystem
::
path
&
path
);
LauncherStorage
(
const
boost
::
filesystem
::
path
&
path
,
const
boost
::
filesystem
::
path
&
icon_path
);
~
LauncherStorage
();
struct
Item
{
std
::
string
name
;
std
::
string
package
;
android
::
Intent
launch_intent
;
std
::
vector
<
char
>
icon
;
};
void
add
(
const
Item
&
item
);
private:
boost
::
filesystem
::
path
path_
;
boost
::
filesystem
::
path
icon_path_
;
};
}
// namespace application
}
// namespace anbox
...
...
src/anbox/bridge/platform_api_skeleton.cpp
浏览文件 @
5c7b0adf
...
...
@@ -89,6 +89,11 @@ void PlatformApiSkeleton::handle_application_list_update_event(
for
(
int
m
=
0
;
m
<
li
.
categories_size
();
m
++
)
item
.
launch_intent
.
categories
.
push_back
(
li
.
categories
(
m
));
item
.
icon
=
std
::
vector
<
char
>
(
app
.
icon
().
begin
(),
app
.
icon
().
end
());
if
(
item
.
package
.
empty
())
continue
;
// If the item is already stored it will be updated
launcher_storage_
->
add
(
item
);
}
...
...
src/anbox/cmds/run.cpp
浏览文件 @
5c7b0adf
...
...
@@ -114,7 +114,8 @@ anbox::cmds::Run::Run(const BusFactory &bus_factory)
auto
window_manager
=
std
::
make_shared
<
wm
::
Manager
>
(
policy
);
auto
launcher_storage
=
std
::
make_shared
<
application
::
LauncherStorage
>
(
xdg
::
data
().
home
()
/
"applications"
);
xdg
::
data
().
home
()
/
"applications"
/
"anbox"
,
xdg
::
data
().
home
()
/
"anbox"
/
"icons"
);
auto
gl_server
=
std
::
make_shared
<
graphics
::
GLRendererServer
>
(
window_manager
);
...
...
src/anbox/protobuf/anbox_bridge.proto
浏览文件 @
5c7b0adf
...
...
@@ -74,6 +74,7 @@ message ApplicationListUpdateEvent {
required
string
name
=
1
;
required
string
package
=
2
;
optional
Intent
launch_intent
=
3
;
optional
bytes
icon
=
4
;
}
repeated
Application
applications
=
1
;
}
...
...
src/anbox/utils.cpp
浏览文件 @
5c7b0adf
...
...
@@ -158,5 +158,10 @@ std::string prefix_dir_from_env(const std::string &path,
return
result
;
}
std
::
string
process_get_exe_path
(
const
pid_t
&
pid
)
{
auto
exe_path
=
string_format
(
"/proc/%d/exe"
,
pid
);
return
boost
::
filesystem
::
read_symlink
(
exe_path
).
string
();
}
}
// namespace utils
}
// namespace anbox
src/anbox/utils.h
浏览文件 @
5c7b0adf
...
...
@@ -48,6 +48,8 @@ void ensure_paths(const std::vector<std::string> &paths);
std
::
string
prefix_dir_from_env
(
const
std
::
string
&
path
,
const
std
::
string
&
env_var
);
std
::
string
process_get_exe_path
(
const
pid_t
&
pid
);
template
<
typename
...
Types
>
static
std
::
string
string_format
(
const
std
::
string
&
fmt_str
,
Types
&&
...
args
);
}
// namespace utils
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录