Remote Desktop Module provides means by which the admin capture the device screen content. More...
#include <RemoteDesktop.h>
Public Member Functions | |
virtual bool | init ()=0 |
API to initialize remote desktop session. | |
virtual void | getScreenInfo (int *width, int *height, int *bytesPerPixel, int *pixelFormat)=0 |
API to get Frame Buffer's Resolution/PixelFormat information. | |
virtual bool | getFrameBufInfo (int *fd, FDType *fdType)=0 |
API to get Frame Buffer Information. | |
virtual bool | setListener (IRemoteDesktopListener *listener)=0 |
API to register Screen Event listener. | |
virtual bool | captureScreen (DirtyRegion ®ion)=0 |
API to capture the screen. | |
virtual void | getScreenPixelFormatInfo (PixelFormatDetail &formatDetail)=0 |
API to get screen pixel format information. | |
virtual bool | setScreenInfo (int prefW, int prefH, int prefFormat)=0 |
API to set the framebuffer's width, height and format preferred by the admin. | |
virtual void | getDefaultScreenInfo (int *hwwidth, int *hwheight, int *hwbytesPerPixel, int *hwpixelFormat)=0 |
API to get the default screen information. | |
virtual int | getDefaultDexScreenInfo (int *hwwidth, int *hwheight, int *hwbytesPerPixel)=0 |
API to get the default Dex screen information. | |
virtual bool | setDexScreenInfo (int prefW, int prefH)=0 |
API to set Dex screen framebuffer's width and height by the admin. | |
virtual void | getDexBufInfo (int *fdDex)=0 |
API to get Dex screen Frame Buffer Information. | |
virtual void | getDexScreenInfo (int *width, int *height, int *bytesPerPixel)=0 |
API to get Dex screen Frame Buffer's Resolution. | |
Static Public Member Functions | |
static IRemoteDesktop * | getInstance () |
Returns an instance of a RemoteDesktop client. |
Remote Desktop Module provides means by which the admin capture the device screen content.
It provides the following features for EDM client
(Note: Surface Flinger is android's composition engine that composes the
UI content and updates to the display
( This prevents the EDM client from having to poll the screen content continuously
to check for changes. The notifications shall be received for both approaches fb0
and surface flinger.)
The decision to use framebuffer device (fb0) or Surface Flinger mechanism is made based on the
following aspects
(Eg: - Only Surface Flinger approach works in some devices as the frame buffer
device is not accessible/available),
(Eg: - FB0 misses some overlay content. Lets say, Wallpaper is present in one
layer, Status Bar present in one layer, remaining UIs present in another layer).
Note: This decision is done for every device at build time.
The EDM client can register a listener to receive notifications when the screen changes.
On occurrence of screen change, the Remote Desktop module sends a screenChanged callback and
waits for the capture request from the client.
(Note: Subsequent screen changes are detected, but they are not notified to the client until
the capture request for the outstanding callback is received.)
In case of Remote Desktop session
1) If Remote Desktop Session is started at owner space
a) It can capture owner space screens
b) It can capture Android guest user's screens
2) If Remote Desktop Session is started at Android guest user
a) It can't capture owner space screens
b) It can capture its own user space screens
Events injected by Remote Injection are not injected into user space where Remote Desktop
is disabled.
"com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission
which has a protection level of signature.
virtual bool knoxremotedesktop::IRemoteDesktop::captureScreen | ( | DirtyRegion & | region | ) | [pure virtual] |
API to capture the screen.
Admin can use this API to capture the screen. Remote Desktop
module returns the changed region or dirty region in response
to this request. (This API updates the screen contents to shared memory
if fdType == FD_SHARED_MEM.)
[NOTE] It is recommended to follow the following sequence:
Step 1 : Call IRemoteDesktop::getInstance() to get an instance of IRemoteDesktop
Step 2 : Call IRemoteDesktop::getDefaultScreenInfo(&hwwidth,&hwheight,&hwbytesPerPixel,&hwpixelFormat) to get the hardware width,height,pixel size and format
Step 3 : Call IRemoteDesktop::setScreenInfo (prefW, prefH, prefFormat) to set the desired screen width,height and pixel format
Step 4 : Call IRemoteDesktop::init()
Step 5 : Call IRemoteDesktop::getFrameBufInfo() to get file descriptor and type of it
Step 6 : Call mmap() to map file descriptor to memory
Step 7 : Set screen update listener
Step 8 : Call IRemoteDesktop::captureScreen() to get dirty regions after screenChanged() callback is called
Example client call:
class RemoteDesktopListener : public IRemoteDesktopListener {
RemoteDesktopListener() {}
virtual void screenChanged() {
LOGI("RemoteDesktopListener :: screenChanged()");
// Capture Screen Request code
DirtyRegion dirtyRegion;
bool err = remoteDesktop->captureScreen(dirtyRegion);
if(err == false) {
// failure code
} else {
// success code
}
}
}
....
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance();
int w = 360, h = 640, format = PF_RGBA_8888;
//Only in case, when user is in Landscape mode and facing problem in starting the Remote Session in Android 10 device int w = 640, h = 360, format = PF_RGBA_8888;
int mFD;
FDType mFDType;
bool ret;
int hwwidth, hwheight, hwpixelFormat, hwbytesPerPixel;
remotedesktop->getDefaultScreenInfo(&hwwidth, &hwheight, &hwbytesPerPixel, &hwpixelFormat);
ret = remoteDesktop->setScreenInfo(w,h,format);
if(ret == false){
// failure code
}
ret = remoteDesktop->init();
if(ret == false){
// failure code
}
ret = remoteDesktop->getFrameBufInfo(&mFD, &mFDType);
if(ret == false){
// failure code
}
if (mFDType == FD_DEV_FB0) {
struct fb_var_screeninfo vinfo;
if(ioctl(mFD, FBIOGET_VSCREENINFO, &vinfo) < 0) return false;
int offset = vinfo.xoffset * mBytesPerPixel + vinfo.xres * vinfo.yoffset * mBytesPerPixel;
mFrame = (unsigned short *) mmap(0, mFrameBufferSize, PROT_READ, MAP_PRIVATE, mFD, offset);
} else if (mFDType == FD_SHARED_MEM) {
mFrame = (unsigned short *) mmap(0, mFrameBufferSize, PROT_READ, MAP_SHARED, mFD, 0);
} else {
LOGE("mapFrameBuffer Failed");
return false;
}
IRemoteDesktopListener *remoteDesktoplistener = new RemoteDesktopListener();
remoteDesktop->setListener(remoteDesktoplistener);
"com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level
of signature.
region | Dirty Region Information |
true
if captured successfully, else false
.virtual int knoxremotedesktop::IRemoteDesktop::getDefaultDexScreenInfo | ( | int * | hwwidth, |
int * | hwheight, | ||
int * | hwbytesPerPixel | ||
) | [pure virtual] |
API to get the default Dex screen information.
Admin can use this API to get the default hardware screen dimensions and pixel byte size of Dex sreen. This new API is introduced for devices that support samsung Dex mode.
Example client call:
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance(); bool ret = remoteDesktop->init(); if(ret == false) { // failure code } else { // success code // Dex state change callback received int hwwidth, hwheight, hwbytesPerPixel; int res = remotedesktop->getDefaultDexScreenInfo(&hwwidth, &hwheight, &hwbytesPerPixel); }
hwwidth | Hardware Screen Width of Dex screen. |
hwHeight | Hardware Screen Height of Dex screen. |
hwbytesPerPixel | Hardware Pixel Size in Bytes of Dex screen. |
API level 35
Knox 3.8
virtual void knoxremotedesktop::IRemoteDesktop::getDefaultScreenInfo | ( | int * | hwwidth, |
int * | hwheight, | ||
int * | hwbytesPerPixel, | ||
int * | hwpixelFormat | ||
) | [pure virtual] |
API to get the default screen information.
Admin can use this API to get the default hardware screen dimensions, pixel formats and
pixel byte size. This new API is introduced as getScreenInfo need not return the default screen
information as it returns the selected framebuffer information based on the preferences
set by the admin
Example client call:
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance();
bool ret = remoteDesktop->init();
if(ret == false) {
// failure code
} else {
// success code
int hwwidth, hwheight, hwpixelFormat, hwbytesPerPixel;
remotedesktop->getDefaultScreenInfo(&hwwidth, &hwheight, &hwbytesPerPixel, &hwpixelFormat);
}
"com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level
of signature.
hwwidth | Hardware Screen Width |
hwHeight | Hardware Screen Height |
hwbytesPerPixel | Hardware Pixel Size in Bytes |
hwpixelFormat | Hardware Pixel Format. |
virtual void knoxremotedesktop::IRemoteDesktop::getDexBufInfo | ( | int * | fdDex | ) | [pure virtual] |
API to get Dex screen Frame Buffer Information.
Admin can use this API to get File Descriptor of Dex screen Shared memory.
[Note] For Dex screen file descriptor type (FDType) is always Shared Memory.
Example client call:
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance(); bool ret = remoteDesktop->init(); if(ret == false) { // failure code } else { // success code // Dex state change callback received int mFDdex; int w = 640, h = 360; bool ret = remoteDesktop->setDexScreenInfo(w,h); remoteDesktop->getDexBufInfo(&mFDdex); if(mFDdex == -1) { // failure code } else { // success code } }
fd | File Descriptor for Dex screen buffer |
API level 35
Knox 3.8
virtual void knoxremotedesktop::IRemoteDesktop::getDexScreenInfo | ( | int * | width, |
int * | height, | ||
int * | bytesPerPixel | ||
) | [pure virtual] |
API to get Dex screen Frame Buffer's Resolution.
Admin can use this API to get Dex screen framebuffer dimensions and pixel byte size.
Note: Client should use same pixel format info for Dex screen buffer that is returned for device screen buffer.
Example client call:
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance(); bool ret = remoteDesktop->init(); if(ret == false) { // failure code } else { // success code // Dex state change callback received int w = 640, h = 360; bool ret = remoteDesktop->setDexScreenInfo(w,h); int width, height, bytesPerPixel; remoteDesktop->getDexScreenInfo(&width, &height, &bytesPerPixel); }
width | Screen Width |
height | Screen Height |
bytesPerPixel | Pixel Size in Bytes |
API level 35
Knox 3.8
virtual bool knoxremotedesktop::IRemoteDesktop::getFrameBufInfo | ( | int * | fd, |
FDType * | fdType | ||
) | [pure virtual] |
API to get Frame Buffer Information.
Admin can use this API to get File Descriptor to
framebuffer device or Shared memory.
Example client call:
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance();
bool ret = remoteDesktop->init();
if(ret == false) {
// failure code
} else {
// success code
int mFD;
FDType mFDType;
bool err = remoteDesktop->getFrameBufInfo(&mFD, &mFDType);
if(err == false) {
// failure code
} else {
// success code
}
}
"com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level
of signature.
fd | File Descriptor |
fdType | File Descriptor Type (Shared Memory or Frame Buffer) |
true
if frame buffer information successfully retrieved, else false
.static IRemoteDesktop* knoxremotedesktop::IRemoteDesktop::getInstance | ( | ) | [static] |
Returns an instance of a RemoteDesktop client.
Admin can use this API to initialize the remote desktop session
establishing the connection to the underneath capture mechanism.
Example client call:
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance();
bool ret = remoteDesktop->init();
if(ret == false) { // failure due to either permission
// denied or other initialization failures
// failure code
} else {
// success code
}
null
.virtual void knoxremotedesktop::IRemoteDesktop::getScreenInfo | ( | int * | width, |
int * | height, | ||
int * | bytesPerPixel, | ||
int * | pixelFormat | ||
) | [pure virtual] |
API to get Frame Buffer's Resolution/PixelFormat information.
Admin can use this API to get the framebuffer dimensions, pixel formats and
pixel byte size.
Note: PixelFormat returned by this API is not reliable. It will not give accurate information
on the exact position details of each pixel. Also for FB0 FDType, the pixel format may also be returned
as PF_UNKNOWN. It is recommended that client always rely on the API getScreenPixelFormatInfo().
Example client call:
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance();
bool ret = remoteDesktop->init();
if(ret == false) {
// failure code
} else {
// success code
int width, height, pixelFormat, bytesPerPixel;
remoteDesktop->getScreenInfo(&width, &height, &bytesPerPixel, &pixelFormat);
}
"com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level
of signature.
width | Screen Width |
height | Screen Height |
bytesPerPixel | Pixel Size in Bytes |
pixelFormat | Pixel Format. |
true
if screen information successfully retrieved, else false
.virtual void knoxremotedesktop::IRemoteDesktop::getScreenPixelFormatInfo | ( | PixelFormatDetail & | formatDetail | ) | [pure virtual] |
API to get screen pixel format information.
Admin can use this API to get the pixel format detailed information.
Example client call:
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance();
bool ret = remoteDesktop->init();
if(ret == false) {
// failure code
} else {
// success code
PixelFormatDetail formatDetail;
remoteDesktop->getScreenPixelFormatInfo(formatDetail);
}
"com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level
of signature.
formatDetail | Pixel Format Detail |
virtual bool knoxremotedesktop::IRemoteDesktop::init | ( | ) | [pure virtual] |
API to initialize remote desktop session.
Admin can use this API to initialize the remote desktop session
establishing the connection to the underneath capture mechanism.
Example client call:
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance();
bool ret = remoteDesktop->init();
if(ret == false) { // failure due to either permission
// denied or other initialization failures
// failure code
} else {
// success code
}
"com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level
of signature.
true
if successfully initialised, else false
.virtual bool knoxremotedesktop::IRemoteDesktop::setDexScreenInfo | ( | int | prefW, |
int | prefH | ||
) | [pure virtual] |
API to set Dex screen framebuffer's width and height by the admin.
Admin can use this API to set the preference for the remote capture of Dex screen dimensions considering the different factors like network bandwidth usage and performance. This may or may not be honoured based on the platform support. This API creates a separate frame buffer for Dex screen capture.
Example client call:
int w = 640, h = 360; IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance(); bool ret = remoteDesktop->init(); // Dex state change callback received int hwwidth, hwheight, hwbytesPerPixel; int res = remotedesktop->getDefaultDexScreenInfo(&hwwidth, &hwheight, &hwbytesPerPixel); ret = remoteDesktop->setDexScreenInfo(w,h);
prefW | Preferred Screen Width of Dex screen |
prefH | Preferred Screen Height of Dex screen. |
true
if intended operation is successful false
multiple cases like Dex is not connected, invalid parameter value, permission denied, remote session not started or unable to create buffer for Dex screen. API level 35
Knox 3.8
virtual bool knoxremotedesktop::IRemoteDesktop::setListener | ( | IRemoteDesktopListener * | listener | ) | [pure virtual] |
API to register Screen Event listener.
Admin can use this API to get Screen Changed Event Callbacks
from remote desktop module.
Example client call:
class RemoteDesktopListener : public IRemoteDesktopListener {
RemoteDesktopListener() {}
virtual void screenChanged() {
LOGI("RemoteDesktopListener :: screenChanged()");
// Capture Screen Request code
}
}
....
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance();
bool ret = remoteDesktop->init();
if(ret == false) {
// failure code
} else {
// success code
IRemoteDesktopListener *remoteDesktoplistener = new RemoteDesktopListener();
bool err = remoteDesktop->setListener(remoteDesktoplistener);
if(err == false) {
// failure code
} else {
// success code
}
}
"com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level
of signature.
listener | Screen Change Event Listener |
true
if listener is successfully set, else false
.virtual bool knoxremotedesktop::IRemoteDesktop::setScreenInfo | ( | int | prefW, |
int | prefH, | ||
int | prefFormat | ||
) | [pure virtual] |
API to set the framebuffer's width, height and format preferred by the admin.
Admin can use this API to set the preference for the remote screen dimensions considering the
different factors like network bandwidth usage and performance. This may or may not be honoured based
on the platform support. Mostly in case of FB0, this will not be honoured.
Example client call:
Note: If user faces problem in starting Remote Session in Landscape mode, then he/she should call and refer getDefaultScreenInfo(&hwwidth,&hwheight,&hwbytesPerPixel,&hwpixelFormat) API about hardware width and hardware height before calling setScreenInfo(prefW, prefH, prefFormat) API.
int w = 360, h = 640, format = PF_RGB_565;
//Only in case, when user is in Landscape mode and facing problem in starting the Remote Session in Android 10 device int w = 640, h = 360, format = PF_RGB_565;
IRemoteDesktop *remoteDesktop = RemoteDesktop::getInstance();
int hwwidth, hwheight, hwpixelFormat, hwbytesPerPixel;
remotedesktop->getDefaultScreenInfo(&hwwidth, &hwheight, &hwbytesPerPixel, &hwpixelFormat);
bool ret = remoteDesktop->setScreenInfo(w,h,format);
if(ret == false) { // failure due to either permission
// denied or other initialization failures
// failure code
} else {
// success code
}
"com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level
of signature.
prefW | Preferred Screen Width |
prefH | Preferred Screen Height |
prefFormat | Preferred Pixel Format |
true
if success, else false
.