Menu

Remote Control (RC) for Samsung DeX

From Knox 3.4.1 onwards, it is possible to use Remote Control (RC) with Samsung DeX (For devices running Android 10(Q) or higher). This allows users to use RC for—

  1. Device screen,
  2. DeX screen, and
  3. Device and DeX screens collectively.

The new feature uses two ‘shared buffers’ compared to a single ‘shared buffer’ used earlier. This enables the use of dual screen or dual DeX.

Generate a Knox license

To use the remote support features, your app needs the permission com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL.

Once you have your KPE Premium license with this permission, activate the license.

Then, update your Android Manifest file to declare the permission:

<?xml version="1.0" encoding="utf-8"?>
<manifest
	xmlns:android="http://schemas.android.com/apk/res/android" package="com.my.mtdapp">
	<application>
		<!-- Enable selective Knox permissions(optional)-->
		<meta-data android:name="com.samsung.knoxlicense.permissions" android:value="true"/>
	</application>
</manifest>

APIs to capture DeX Screen

API Description of API
getDefaultDexScreenInfo Get default hardware screen dimensions by pixels
setDexScreenInfo Set DeX framebuffer’s preferred dimensions
getDexScreenInfo Get DeX framebuffer’s actual dimensions by pixel
getDexBufInfo Get DeX screen framebuffer file descriptor (FD)
dexStateChanged Get DeX state status (if connected or not)
injectPointerEventDex Inject a pointer event to DeX screen
injectKeyEventDex Inject a key event to DeX screen
NOTE – For DeX, FD is always Shared Memory.
NOTE – dexStateChanged callback is necessary even when RC starts when DeX is active.

Procedure for capturing DeX screen

Initially, dexStateChanged callback notifies the user that DeX mode is on.

When DeX mode is on use existing APIs (mentioned in Remote viewing) to capture device screen. To capture DeX screen use DeX remote capture APIs following these steps—

  1. Call IRemoteDesktop::getDefaultDexScreenInfo() to get default hardware screen dimensions of DeX screen.
  2. Call IRemoteDesktop::setDexScreenInfo() to set the desired DeX screen dimensions
  3. Call IRemoteDesktop::getDexScreenInfo() to get DeX framebuffer size.
  4. Call IRemoteDesktop::getDexBufInfo() to get file descriptor (FD) of DeX buffer.
  5. Call mmap() to map DeX file descriptor to memory.

Now, on calling captureScreen(), user can capture DeX screen using file descriptor.

Procedure for controlling DeX screen

To inject touch event, use injectPointerEventDex API and to inject a key event, use injectKeyEventDex API. To inject these events to device screen, use the method described in Remote injection.

NOTE– Currently, Trackball is not supported for injection into DeX.
NOTE– Some key injection events are only injected in device screen (for example—power key)

Operation Sequence

Look at this diagram to get a better idea of the sequence of operations–