Implementing Dual Screen Display Functionality on Rockchip Platform (Based on Android 13)

Implementing Dual Screen Display Functionality on Rockchip Platform (Based on Android 13)

Implementing Dual Screen Display Functionality on Rockchip Platform (Based on Android 13)

1. Display Implementation Solutions

The Rockchip SDK platform supports two different display solutions: Android Presentation and Android Activity screen specification.

Using the Android Presentation solution, it is necessary to call the corresponding interface in APP development to display the specified view (the Presentation view is a special type of dialog view) on the secondary screen.

In contrast, using the Android Activity screen specification solution, the APP can directly display on the corresponding screen using the display id parameter when launching the activity, allowing third-party application activities to be projected onto the secondary screen without source code through command line or system interface.

The main differences between these two solutions are:

  1. 1. The Android Presentation solution requires independent development of the activity and projecting the content to be displayed onto the secondary screen, while the Android Activity specification solution does not require source code; it can project third-party application activities onto the secondary screen through command line or system interface.

  2. 2. The Android Presentation solution has only one activity at the top level, displaying the specified content on the secondary screen through a special dialog, while the Android Activity specification solution has two activities displayed separately on the main screen and secondary screen.

1.1 Presentation

The SDK has provided a demo related to this interface. Please enter the development/samples/ApiDemos directory and use mm to compile the corresponding apk. After installing the apk, click App->Activity->Presentation option to enter the Presentation call interface. In this interface, you need to check the secondary screen checkbox option to display the corresponding image on the secondary screen.

The specific code is located at the following path:development/samples/ApiDemos/src/com/example/android/apis/app/PresentationActivity.java.

Implementing Dual Screen Display Functionality on Rockchip Platform (Based on Android 13)

1.2 Android Activity Screen Specification

Set the specified screen’s display id in the startActivity interface parameters to directly launch the Activity on the specified screen.

The multi-display support for Activity requires the device to support <feature name="android.software.activities_on_secondary_displays" />. Additionally, the application or Activity needs to support split-screen properties, which means setting the new attribute android:resizeableActivity="true" under the <application> or <activity> tags. This attribute defaults to true when the target version is Android N or higher.

ActivityOptions provides two new functions to support multiple displays:

  • setLaunchDisplayId(): Specifies which display the Activity should be shown on after launching.

  • getLaunchDisplayId(): Returns the display on which the operation component is currently launched.

Example of usage: In this example, the MediaRouter interface is used to obtain the secondary screen’s display id. Similarly, the DisplayManager interface can also be used to obtain the corresponding display id. It should be noted that only activities from other packages can be opened here; otherwise, it will prompt: “App does not support launch on secondary displays”.

private void showSecondByActivity(Context context) {
    ActivityOptions options = ActivityOptions.makeBasic();
    MediaRouter mediaRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
    MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);
    if (route != null) {
        Display presentationDisplay = route.getPresentationDisplay();
        options.setLaunchDisplayId(presentationDisplay.getDisplayId());
        //options.
        Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent, options.toBundle());
    }
}

At the same time, adb shell has also been extended to support multiple displays. The shell start command can now be used to launch operation components and specify the target display:

adb shell am start --display &lt;display_id&gt; &lt;activity_name&gt;

For example: adb shell am start --display 1 com.android.settings/.Settings (launches the Settings interface on the specified secondary screen).

2. Secondary Screen Orientation Configuration

The RK3568 has scenarios for dual and triple screens. In the dual-screen scenario, the secondary screen can adjust different orientations by setting the property persist.sys.rotation.einit-1 (property values are 0,1,2,3). For example, the setting command setprop persist.sys.rotation.einit-1 1 can rotate the secondary screen 90 degrees. After setting, the machine needs to be restarted to take effect.

In the triple-screen scenario, there is one screen as the main screen, and the other two screens as secondary screens. According to the following dumpsys input information, the three displays correspond to the viewport as follows:

  • • Viewport INTERNAL: displayId=0, uniqueId=local:0, port=0, orientation=0, logicalFrame=[0, 0, 1080, 1920], physicalFrame=[0, 0, 1080, 1920], deviceSize=[1080, 1920], isActive=[1]

  • • Viewport EXTERNAL: displayId=0, uniqueId=local:1, port=1, orientation=1, logicalFrame=[0, 0, 1080, 1920], physicalFrame=[0, 0, 720, 1280], deviceSize=[720, 1280], isActive=[1]

  • • Viewport EXTERNAL: displayId=0, uniqueId=local:2, port=2, orientation=0, logicalFrame=[0, 0, 1080, 1920], physicalFrame=[0, 0, 1440, 900], deviceSize=[1440, 900], isActive=[1]

The two secondary screens need to set the properties persist.sys.rotation.einit-1 and persist.sys.rotation.einit-2 (property values are 0,1,2,3) to control the orientation of the corresponding screens. (These two properties correspond to port1 and port2 for the two secondary screens).

Additionally, for chips such as RK3288, RK3399, PX30, and RK3326, the orientation of the secondary screen can be adjusted by setting the property persist.sys.rotation.einit (property values are 0,1,2,3). For example, the setting command setprop persist.sys.rotation.einit 1 can rotate the secondary screen 90 degrees. After setting, the machine also needs to be restarted to take effect.

3. Other Configurations

3.1 Supporting Input Method Display on Secondary Screen

Set the corresponding screen shouldShowIme to true in device/rockchip/common/display_settings.xml, as follows:

&lt;?xml version='1.0' encoding='utf-8' standalone='yes' ?&gt;
&lt;display-settings&gt;
    &lt;config identifier="0" /&gt;
    &lt;display
        name="local:1"
        shouldShowIme="true"
        forcedDensity="240"/&gt;
&lt;/display-settings&gt;

3.2 Secondary Screen DPI Settings

Set the forcedDensity in device/rockchip/common/display_settings.xml, for example:

&lt;?xml version='1.0' encoding='utf-8' standalone='yes' ?&gt;
&lt;display-settings&gt;
    &lt;config identifier="0" /&gt;
    &lt;display
        name="local:1"
        shouldShowIme="true"
        forcedDensity="240"/&gt;
&lt;/display-settings&gt;

3.3 Mouse Switching Display Between Main and Secondary Screens

Set sys.mouse.presentation to 1 to enable this feature. In the display state, the mouse defaults to show on the main screen when powered on. When the mouse moves to the edge of the screen, it will automatically switch to display at the center position of the secondary screen.

Leave a Comment

×