福州瑞芯微电子有限公司
密级状态:绝密( ) 秘密( ) 内部( ) 公开( √ )
[RK3188&3288_Android4.4&5.1-SDK]双屏双显
使用说明
(第一系统产品部)
文件状态:
当前版本:
V1.3
[ ] 正在修改
作 者:
SZC, SZY, ZY
[√] 正式发布
完成日期:
2016-11-08
审 核:
ZY, ZXZ
完成日期:
2016-11-16
福州瑞芯微电子有限公司
Fuzhou Rockchips Semiconductor Co . , Ltd
(版本所有,翻版必究)
福州瑞芯微电子有限公司
版 本 历 史
版本号
作者
修改日期
修改说明
备注
V1.0
SZC
2016-10-20
添加系统 API
V1.1
SZY
2016-10-21
添加补丁与配置
V1.2
V1.3
ZY
ZY
2016-11-07
整理格式,补充配置说明
2016-11-08
增加双屏触摸简单说明
福州瑞芯微电子有限公司
目目 录录
1 简介 ............................................................................................................. 2
2 系统 API ....................................................................................................... 2
2.1 ANDROID PRESENTATION ............................................................................... 2
2.1.1 API 介绍 ............................................................................................ 2
2.1.2
Presentation 示例 ............................................................................... 5
2.2 RK DUALSCREEN ........................................................................................ 8
2.2.1 API 介绍 ............................................................................................ 8
2.2.2 RockChip DualScreen 接口使用示例 ........................................................ 9
3 补丁与配置 ................................................................................................... 11
3.1 ANDROID .................................................................................................11
3.1.1 RK3288 Android 5.1 ..........................................................................11
3.1.2 RK3288 Android 4.4 ..........................................................................12
3.1.3 RK3188 Android 5.1 ..........................................................................12
3.1.4 RK3188 Android 4.4 ..........................................................................12
3.2 KERNEL DRIVER .........................................................................................12
3.2.1 RK3288 Android 5.1 ..........................................................................12
3.2.2 RK3288 Android 4.4 ..........................................................................14
4 双屏触摸 ..................................................................................................... 14
4.1 原理说明 .................................................................................................14
4.2 补丁 ......................................................................................................15
1
福州瑞芯微电子有限公司
1 简介
本文主要介绍了 RockChip(以下简称 RK) SDK 平台上支持的异显方案,包括系统 API、
补丁、内核配置方法等,适用于以下 SDK 平台:
RK3188 Android4.4
RK3188 Android5.1
RK3288 Android4.4
RK3288 Android5.1
2 系统 API
RK 双屏异显方案有两种方式:Android Presentation 和 RK dualscreen。Android
Presentation 是 Google 提供的双屏方案,实现了 View 级别的 VOP 派发,逻辑均在同一个 APP
上进行控制;RK dualscreen 则是实现了 APP 级别的 VOP 派发,异显的两部分分别是不同的 APP。
Presentation 比较适用于对自身需求进行深入定制的方案,RK dualscreen 在满足深入定制方
案下,也支持,快速集成多方 APP,进行功能整合。两者各有优缺点,也能够进行互补。
2.1
Android Presentation
2.1.1 API 介绍
官方 API 以及示例说明文档:
https://developer.android.com/reference/android/app/Presentation.html
Presentation 是 google 官方提供的一个特殊的 dialog 类型,用来将特定内容显示到其他非
主屏显示器上。它在创建时,需要绑定显示屏,并根据这个目标显示屏以及其大小来配置 context
和 resource。目前系统提供了两种方式来与目标显示屏进行绑定。
1. 通过 MediaRouter 接口获取并绑定:
2
福州瑞芯微电子有限公司
MediaRouter mediaRouter =(MediaRouter)
context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute();
if(route !=null){
Display presentationDisplay = route.getPresentationDisplay();
if(presentationDisplay !=null){
Presentation presentation =newMyPresentation(context, presentationDisplay);
presentation.show();
}
}
2. 通过 DisplayManager 接口获取并绑定:
DisplayManager displayManager =(DisplayManager)
context.getSystemService(Context.DISPLAY_SERVICE);
Display[] presentationDisplays =
displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
if(presentationDisplays.length >0){
// If there is more than one suitable presentation display, then we could consider
// giving the user a choice. For this example, we simply choose the first display
// which is the one the system recommends as the preferred presentation display.
Display display = presentationDisplays[0];
Presentation presentation =new MyPresentation(context, presentationDisplay);
presentation.show();
}
MediaRouter 和 DisplayManager 接口不在此处详细介绍。
Presentation 的接口使用简单,功能明确,主要接口如下:
1. 构造接口
(1) Presentation(Context outerContext,Display display)
接口说明:
实例一个使用默认主题,绑定到目标 display 上的 Presentation 对象。
参数说明:
outerContext:application 的 context 对象;
display:要绑定的目标 display,可以通过上述介绍的 MediaRouter 和 DisplayManager
接口获取。
3
福州瑞芯微电子有限公司
(2) Presentation(Context outerContext, Display display, int theme)
接口说明:
实例一个使用特定主题,并绑定到目标 display 上的 Presentation 对象。
参数说明:
outerContext:application 的 context 对象;
display:要绑定的目标 display,可通过上述介绍的 MediaRouter 和 DisplayManager 接
口获取;
theme:窗口使用的主题资源。
2. 方法接口
(1) Display getDisplay()
接口说明:
获取当前 presentation 显示所在的目标屏。
(2) Resources getResources()
接口说明:
获取用于当前 presentation 的 Resources 对象。
(3) void onDisplayChanged()
接口说明:
当 presentation 绑定的 display 发生变化(如大小、方向等)时,系统会回调此接口,并且
系统将自动调用 cancel()接口,关闭此 presentation。
(4) void onDisplayRemoved()
接口说明:
当 presentation 绑定的 display 被移除时,系统会回调此接口,并在此之后,系统会自动调
用 cancel()接口,关闭此 presentation。
(5) void show()
接口说明:
4
福州瑞芯微电子有限公司
用 于 显 示 此 presentation , 如 果 显 示 设 备 无 法 找 到 , 调 用 此 接 口 , 将 抛 出
WindowManager.InvalidDisplayException 异常。
(6) void onStart()
接口说明:
当此 presentation 启动后,会调用此接口,类似 activity 的 onStart。
(7) void onStop()
接口说明:
当此 presentation 正在走 stop 流程时,将会调用到此接口,类似 activity 的 onStop。
2.1.2 Presentation 示例
谷歌官方提供了 ApiDemo,用来展示各个 API 的使用,presentation 在源码中的范例路径
为:
development/samples/ApiDemos/./src/com/example/android/apis/app/Presentation
Activity.java。
关键代码(红色字体)介绍如下:
1. 获取目标显示设备:
public void updateContents() {
clear();
String displayCategory = getDisplayCategory();
Display[] displays = mDisplayManager.getDisplays(displayCategory);
addAll(displays);
Log.d(TAG, "There are currently " + displays.length + " displays connected.");
for (Display display : displays) {
Log.d(TAG, "" + display);
}
}
private String getDisplayCategory() {
return mShowAllDisplaysCheckbox.isChecked() ? null :
DisplayManager.DISPLAY_CATEGORY_PRESENTATION;
}
通过 DisplayManager 接口获取 PRESENTATION 类型的显示设备,添加到队列当中并绑定
5
福州瑞芯微电子有限公司
到各个 View 当中。
2. 点击 CheckItem,创建 Presentation,并显示:
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView == mShowAllDisplaysCheckbox) {
// Show all displays checkbox was toggled.
mDisplayListAdapter.updateContents();
} else {
//Display item checkbox was toggled.
final Display display = (Display)buttonView.getTag();
if (isChecked) {
PresentationContents contents = new PresentationContents(getNextPhoto());
showPresentation(display, contents);
} else {
hidePresentation(display);
}
}
}
通过 View 的 setTag 绑定对象的方法,将 display 对象绑定到具体 View 当中,并在需要时,
通过 getTag 获取对应的 display 对象。
private void showPresentation(Display display, PresentationContents contents) {
final int displayId = display.getDisplayId();
if (mActivePresentations.get(displayId) != null) {
return;
}
Log.d(TAG, "Showing presentation photo #" + contents.photo + " on display #" + displayId +
".");
DemoPresentation presentation = new DemoPresentation(this, display, contents);
presentation.show();
presentation.setOnDismissListener(mOnDismissListener);
mActivePresentations.put(displayId, presentation);
}
在范例中自定义了一个 Presentation 类,此处通过调用自定义的 Presentation,并显式调
用 show 方法,将此 Presentation 显示到对应的 display 上。
此处的 PresentationContents 只是自定义了一个数据的封装方式,传给 Presentation,实
际使用当中,可以根据项目需要,或者通过其他方式给显示的数据即可,不需要也创建这类对象。
3. 自定义 Presentation 类:
6