Since: Knox API Level 3
public class

RemoteInjection

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.remotecontrol.RemoteInjection

Class Overview

This class provides APIs to support remote injection of key, pointer, and trackball events into the device UI.

Since
API level 3
MDM 2.1

Summary

Public Methods
boolean injectKeyEvent(KeyEvent ev, boolean sync)
API to inject a key event into the device UI.
boolean injectKeyEventDex(KeyEvent ev, boolean sync)
API to inject a key event into the Dex screen UI.
boolean injectPointerEvent(MotionEvent ev, boolean sync)
API to inject a pointer (touch) event into the device UI.
boolean injectPointerEventDex(MotionEvent ev, boolean sync)
API to inject a pointer (touch) event into the Dex screen UI.
boolean injectTrackballEvent(MotionEvent ev, boolean sync)
API to inject a track ball (navigation device) event into the device UI.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean injectKeyEvent (KeyEvent ev, boolean sync)

Since: Knox API Level 3

API to inject a key event into the device UI.

Parameters
ev Key event describing the keystroke action.
sync If true, waits for the event to be completed before returning to the caller. Otherwise, returns immediately without blocking.
Returns
  • true if event was dispatched, false if it was dropped for any reason.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to inject key events into the device remotely. Setting sync to false causes the method to block while waiting for a current input event to be dispatched.

Example client call:


  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

  RemoteInjection remoteInjection = edm.getRemoteInjection();



  try {

      int keycode = KeyEvent.KEYCODE_0;

      remoteInjection.injectKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keycode), true);

  } catch (SecurityException se) {

      Log.w(TAG,"Exception: " + se);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level of signature.
Since
API level 3
MDM 2.1

public boolean injectKeyEventDex (KeyEvent ev, boolean sync)

Since: Knox API Level 30

API to inject a key event into the Dex screen UI.

Parameters
ev Key event describing the keystroke action.
sync If true, waits for the event to be completed before returning to the caller. Otherwise, returns immediately without blocking.
Returns
  • true if event was dispatched, false if it was dropped for any reason.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to inject key events into the Dex screen of device remotely when Dex mode is ON. Setting sync to false causes the method to block while waiting for a current input event to be dispatched. Note : Some key injection events can only be injected in device screen (like power key).

Example client call:


  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

  RemoteInjection remoteInjection = edm.getRemoteInjection();



  try {

      int keycode = KeyEvent.KEYCODE_0;

      remoteInjection.injectKeyEventDex(new KeyEvent(KeyEvent.ACTION_DOWN, keycode), true);

  } catch (SecurityException se) {

      Log.w(TAG,"Exception: " + se);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_ADVANCED_RESTRICTION" permission which has a protection level of signature.
Since
API level 30
KNOX 3.4.1

public boolean injectPointerEvent (MotionEvent ev, boolean sync)

Since: Knox API Level 3

API to inject a pointer (touch) event into the device UI.

Parameters
ev Motion event describing the pointer (touch) action.
sync If true, waits for the event to be completed before returning to the caller. Otherwise, returns immediately without blocking.
Returns
  • Returns true if event was dispatched, false if it was dropped for any reason.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to inject a pointer event into the device remotely. Setting sync to false causes the method to block while waiting for the current input event to be dispatched.

Example client call:


  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

  RemoteInjection remoteInjection = edm.getRemoteInjection();



  try {

      int x = 100, y = 200,flags = 0;

      remoteInjection.injectPointerEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),

              SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x, y, flags), true);

  } catch (SecurityException se) {

      Log.w(TAG,"Exception: " + se);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level of signature.
Since
API level 3
MDM 2.1

public boolean injectPointerEventDex (MotionEvent ev, boolean sync)

Since: Knox API Level 30

API to inject a pointer (touch) event into the Dex screen UI.

Parameters
ev Motion event describing the pointer (touch) action.
sync If true, waits for the event to be completed before returning to the caller. Otherwise, returns immediately without blocking.
Returns
  • Returns true if event was dispatched, false if it was dropped for any reason.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to inject a pointer event into Dex screen of device remotely when Dex mode is ON. Setting sync to false causes the method to block while waiting for the current input event to be dispatched.

Example client call:


  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

  RemoteInjection remoteInjection = edm.getRemoteInjection();



  try {

      int x = 100, y = 200,flags = 0;

      remoteInjection.injectPointerEventDex(MotionEvent.obtain(SystemClock.uptimeMillis(),

              SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x, y, flags), true);

  } catch (SecurityException se) {

      Log.w(TAG,"Exception: " + se);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_ADVANCED_RESTRICTION" permission which has a protection level of signature.
Since
API level 30
KNOX 3.4.1

public boolean injectTrackballEvent (MotionEvent ev, boolean sync)

Since: Knox API Level 3

API to inject a track ball (navigation device) event into the device UI.

Parameters
ev Trackball event describing the trackball action.
sync If true, waits for the event to be completed before returning to the caller. Otherwise, returns immediately without blocking.
Returns
  • Returns true if event was dispatched, false if it was dropped for any reason.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to inject a trackball event into the device remotely. Setting sync to false causes the method to block while waiting for the current input event to be dispatched.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

  RemoteInjection remoteInjection = edm.getRemoteInjection();



  try {

      int x = 100, y = 200, flags = 0;

      remoteInjection.injectTrackballEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),

              SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x, y, flags), true);

  } catch (SecurityException se) {

      Log.w(TAG,"Exception: " + se);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_REMOTE_CONTROL" permission which has a protection level of signature.
Since
API level 3
MDM 2.1