Since: API level 25
public class

DexManager

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.dex.DexManager

Class Overview

This class provides APIs to control the Dex mode. API functions include disabling and enabling Dex mode, making configurations, and querying the current status of Dex mode

Since
API level 25
KNOX 3.1

Summary

Constants
int DEX_APP_ALREADY_SET_POLICY Flag to indicate that API failed because of already set the policy.
int DEX_APP_NOT_INSTALLED Flag to Dex application API failed because of application is not installed.
int DEX_APP_NOT_SET_POLICY Flag to indicate that API failed because this application has not set a policy.
int DEX_POLICY_FAIL Flag to Dex application API failed because any exception.
int DEX_POLICY_SUCCESS Flag to Dex application API success.
Public Methods
int addPackageToDisableList(String packageName)
Deprecated in API level 33
int addShortcut(int x, int y, ComponentName component)
This method adds an application shortcut to the Dex launcher at the specified position.
int addURLShortcut(int x, int y, String title, String url, String imgName, ComponentName component, ParcelFileDescriptor imgFD)
This method adds a new browser shortcut linking the specific url with customized icon to the DeX launcher.
int addURLShortcut(int x, int y, String title, String url, ComponentName component)
This method adds a new browser shortcut linking the specific url to the DeX launcher.
int allowAutoOpenLastApp(int state)
This method allows/disallows the DeX AutoOpenLastApp that opens the last app you were using automatically when you start or exit Samsung Dex.
boolean allowScreenTimeoutChange(boolean allow)
API to allow or disallow the user changing the screen time out for Dex mode.
int clearLoadingLogo()
This method clears the logo that is displayed when the phone is starting Dex and restores the default logo.
boolean enforceEthernetOnly(boolean enforced)
API to enforce or release the ethernet only mode.
boolean enforceVirtualMacAddress(boolean use)
Deprecated in API level 33
NOTE: This API is not available since Android 11.
List<String> getForegroundModePackageList()
This method gets a package whitelist of foreground mode from dex.
int getHDMIAutoEnterState()
This method gets the DeX HDMIAutoEnter's state.
int getHomeAlignment()
This method gets the DeX alignment mode.
List<String> getPackagesFromDisableList()
API to get the list of disabled application package names for Dex mode.
int getScreenTimeout()
This method gets the Dex mode screen timeout in seconds.
int getShowIMEWithHardKeyboard()
This method gets the ShowIMEWithHardKeyboard's state.
String getVirtualMacAddress()
Deprecated in API level 33
NOTE: This API is not available since Android 11.
int isAutoOpenLastAppAllowed()
This method gets the DeX AutoOpenLastApp's state.
boolean isDexActivated()
API to check whether Dex mode is activated.
boolean isDexDisabled()
API to check whether Dex mode is enabled.
boolean isEthernetOnlyEnforced()
API to check whether ethernet only mode is enforced.
boolean isScreenTimeoutChangeAllowed()
API to check whether the user is allowed to change the screen time out for Dex mode.
boolean isVirtualMacAddressEnforced()
Deprecated in API level 33
NOTE: This API is not available since Android 11.
int removePackageFromDisableList(String packageName)
Deprecated in API level 33
int removeShortcut(ComponentName component)
This method removes an application shortcut from the Dex launcher.
int removeURLShortcut(String url, ComponentName component)
This method removes the given shortcut from the DeX launcher.
boolean setDexDisabled(boolean disabled)
API to enable or disable the Dex mode

int setForegroundModePackageList(int state, List<String> pkgList)
This method adds, removes, clears a package whitelist for Dex foreground mode.
int setHDMIAutoEnterState(int state)
This method sets the DeX HDMIAutoEnter that starts Dex mode automatically when HDMI cable is connected.
int setHomeAlignment(int mode)
This method sets the DeX alignment mode.
int setLoadingLogo(ParcelFileDescriptor logoFD)
This method sets the logo that is displayed when the phone is starting Dex.
int setScreenTimeout(int timeout)
This method sets the Dex mode screen timeout to the specified number of seconds.
int setShowIMEWithHardKeyboard(int state)
This method shows/hides the on-screen keyboard while a physical keyboard is being used.
int setWallpaper(Context context, InputStream bitmapData, Rect visibleCropHint, boolean allowBackup, int which)
This method allows the caller to specify which of the supported wallpaper categories to set.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int DEX_APP_ALREADY_SET_POLICY

Since: API level 25

Flag to indicate that API failed because of already set the policy.

Since
API level 25
KNOX 3.1
Constant Value: 3 (0x00000003)

public static final int DEX_APP_NOT_INSTALLED

Since: API level 25

Flag to Dex application API failed because of application is not installed.

Since
API level 25
KNOX 3.1
Constant Value: 2 (0x00000002)

public static final int DEX_APP_NOT_SET_POLICY

Since: API level 25

Flag to indicate that API failed because this application has not set a policy.

Since
API level 25
KNOX 3.1
Constant Value: 4 (0x00000004)

public static final int DEX_POLICY_FAIL

Since: API level 25

Flag to Dex application API failed because any exception.

Since
API level 25
KNOX 3.1
Constant Value: 1 (0x00000001)

public static final int DEX_POLICY_SUCCESS

Since: API level 25

Flag to Dex application API success.

Since
API level 25
KNOX 3.1
Constant Value: 0 (0x00000000)

Public Methods

public int addPackageToDisableList (String packageName)

Since: API level 25

Deprecated in API level 33

API to add a application package name to Dex mode disable list.

Parameters
packageName The application package name to be added to disable list for Dex mode.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to add application package names to Dex mode disable list.

NOTE: This API works only for owner (User 0) space applications.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 DexManager dexMgr = edm.getDexManager();
 try {
     int status = dexMgr.addPackageToDisableList("com.test.app");
     // status is operation result
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 

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

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public int addShortcut (int x, int y, ComponentName component)

Since: API level 25

This method adds an application shortcut to the Dex launcher at the specified position.

Parameters
x The x position of the shortcut and it starts from 0.
y The y position of the shortcut and it starts from 0.
component The component name of the required shortcut.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
An administrator can use this API to add an application shortcut to the Dex launcher at the specified position. This API only supports CUSTOM_GRID. ALPHABETIC_GRID and TYPE_GRID are not supported.
 try {
     CustomDeviceManager cdm = CustomDeviceManager.getInstance();
     DexManager dexmanager = cdm.getDexManager();
     ComponentName component = new ComponentName("com.android.chrome", com.google.android.apps.chrome.Main");
     dexmanager.addShortcut(0, 0, component);
 } catch(SecurityException e) {
     Log.w(TAG, "SecurityException:" + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public int addURLShortcut (int x, int y, String title, String url, String imgName, ComponentName component, ParcelFileDescriptor imgFD)

Since: API level 26

This method adds a new browser shortcut linking the specific url with customized icon to the DeX launcher.

Parameters
x The x position of the URL shortcut.
y The y position of the URL shortcut.
title The Title of the URL shortcut.
url The URL address of the URL shortcut.
imgName The File name of the icon image.
component The specific component to launch the URL shortcut.
imgFD The File descriptor of the icon image.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 try {
     CustomDeviceManager cdm = CustomDeviceManager.getInstance();
     DexManager dexmanager = cdm.getDexManager();
     String url = "http://www.naver.com";
     String imgName = "Firefox.bmp";
     ComponentName component = new ComponentName("com.android.chrome", "com.google.android.apps.chrome.Main");
     ParcelFileDescriptor imgFD = ParcelFileDescriptor.open(new File(logoFile), ParcelFileDescriptor.MODE_READ_ONLY);
     dexmanager.addURLShortcut( 0, 0, "shortcut", url, imgName, component, imgFD);
 } catch(SecurityException e) {
     Log.w(TAG, "SecurityException:" + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 26
KNOX 3.2
Multiuser Environment
Global Scope

public int addURLShortcut (int x, int y, String title, String url, ComponentName component)

Since: API level 26

This method adds a new browser shortcut linking the specific url to the DeX launcher.

Parameters
x The x position of the URL shortcut.
y The y position of the URL shortcut.
title The Title of the URL shortcut.
url The URL address of the URL shortcut.
component The specific component to launch the URL shortcut.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 try {
     CustomDeviceManager cdm = CustomDeviceManager.getInstance();
     DexManager dexmanager = cdm.getDexManager();
     String url = "http://www.naver.com";
     ComponentName component = new ComponentName("com.android.chrome", "com.google.android.apps.chrome.Main");
     dexmanager.addURLShortcut( 0, 0, "shortcut", url, component);
 } catch(SecurityException e) {
     Log.w(TAG, "SecurityException:" + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 26
KNOX 3.2
Multiuser Environment
Global Scope

public int allowAutoOpenLastApp (int state)

Since: API level 28

This method allows/disallows the DeX AutoOpenLastApp that opens the last app you were using automatically when you start or exit Samsung Dex.

Parameters
state ALLOW This is a ALLOW for Dex AutoOpenLastApp.
DISALLOW This is a DISALLOW which turns off and blocking for Dex AutoOpenLastApp.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 int state = CustomDeviceManager.ALLOW;
 dexmanager.allowAutoOpenLastApp(state);
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 28
KNOX 3.3
Multiuser Environment
Global Scope

public boolean allowScreenTimeoutChange (boolean allow)

Since: API level 25

API to allow or disallow the user changing the screen time out for Dex mode.

Parameters
allow true to allow, false to disallow
Returns
  • true if operation is successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to allow or disallow the user changing the screen time out for Dex mode. If not allowed, the user cannot change the screen time out.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 DexManager dexMgr = edm.getDexManager();
 // disable
 try {
     if (dexMgr.allowScreenTimeoutChange(false)) {
         // Screen time out change is not allowed.
     } else {
         // failure restricting Dex mode.
     }
     // enable
     if (dexMgr.allowScreenTimeoutChange(true)) {
         // Screen time out change is allowed.
     } else {
         // failure removing restriction of Dex mode.
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 

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

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope
See Also

public int clearLoadingLogo ()

Since: API level 25

This method clears the logo that is displayed when the phone is starting Dex and restores the default logo.

Returns
  • SUCCESS The Dex loading logo was successfully restored.
Throws
SecurityException The calling application does not have the required permission.
Usage
 try {
     CustomDeviceManager cdm = CustomDeviceManager.getInstance();
     DexManager dexmanager = cdm.getDexManager();
     dexmanager.clearLoadingLogo();
 } catch(SecurityException e) {
     Log.w(TAG, "SecurityException:" + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public boolean enforceEthernetOnly (boolean enforced)

Since: API level 25

API to enforce or release the ethernet only mode.

Parameters
enforced true to enforce, false to release.
Returns
  • true if operation is successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to enable ethernet only mode without user interaction. Cellular data / wifi / tetherings(wifi, bluetooth, usb) are restricted in Dex mode.

NOTE: setCellularData(), setWifiState(), setWifiTethering(), setUsbTethering(), setBluetoothTethering() will return false when device is in Dex mode under ethernet only mode

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 DexManager dexMgr = edm.getDexManager();
 // enforce
 try {
     if (dexMgr.enforceEthernetOnly(true)) {
         // Ethernet only mode is enabled.
     } else {
         // failure restricting ethernet only mode.
     }
     // release
     if (dexMgr.enforceEthernetOnly(false)) {
         // Ethernet only mode is disabled.
     } else {
         // failure removing restriction of ethernet only mode.
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 

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

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public boolean enforceVirtualMacAddress (boolean use)

Since: API level 25

Deprecated in API level 33
NOTE: This API is not available since Android 11.

API to set use virtual MAC address for Dex mode.

Returns
  • true if operation is successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to use the virtual MAC address for Dex mode.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 DexManager dexMgr = edm.getDexManager();
 // disable
 try {
     if (dexMgr.enforceVirtualMacAddress(false)) {
         // Use phone MAC address
     }
     
     if (dexMgr.enforceVirtualMacAddress(true)) {
         // Use virtual MAC addres
     } 
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 

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

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public List<String> getForegroundModePackageList ()

Since: API level 26

This method gets a package whitelist of foreground mode from dex.

Returns
  • The List of the packages.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 List foregroundModepackageList = dexmanager.getForegroundModePackageList();
 
Since
API level 26
KNOX 3.2
Multiuser Environment
Global Scope

public int getHDMIAutoEnterState ()

Since: API level 28

This method gets the DeX HDMIAutoEnter's state.

Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 dexmanager.getHDMIAutoEnterState();
 
Since
API level 28
KNOX 3.3
Multiuser Environment
Global Scope

public int getHomeAlignment ()

Since: API level 26

This method gets the DeX alignment mode.

Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 int alignment = dexmanager.getHomeAlignment();
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 26
KNOX 3.2
Multiuser Environment
Global Scope

public List<String> getPackagesFromDisableList ()

Since: API level 25

API to get the list of disabled application package names for Dex mode.

Returns
  • List of the disabled application package names for Dex mode if it succeeds, else null
Usage
An administrator can use this API to get the list of application package names that are disabled from Dex mode disable list.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 DexManager dexMgr = edm.getDexManager();
 List blacklist = dexMgr.getPackagesFromDisableList();
 
Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public int getScreenTimeout ()

Since: API level 25

This method gets the Dex mode screen timeout in seconds.

Returns
  • The screen timeout in seconds.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 int screenTimeout = dexmanager.getScreenTimeout();
 
Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public int getShowIMEWithHardKeyboard ()

Since: API level 28

This method gets the ShowIMEWithHardKeyboard's state.

Returns
  • ON This is a ON of ShowIMEWithHardKeyboard that shows soft keyboard.
    OFF This is a OFF of ShowIMEWithHardKeyboard that does not show soft keyboard.
Throws
SecurityException The calling application does not have the required permission.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 dexmanager.getShowIMEWithHardKeyboard();
 
Since
API level 28
KNOX 3.3
Multiuser Environment
Global Scope

public String getVirtualMacAddress ()

Since: API level 25

Deprecated in API level 33
NOTE: This API is not available since Android 11.

API to get virtual MAC Address

Returns
  • Virtual MAC address
Usage
An administrator can use this API to get virtual MAC Address

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public int isAutoOpenLastAppAllowed ()

Since: API level 28

This method gets the DeX AutoOpenLastApp's state.

Returns
  • ALLOW The current state of Dex AutoOpenLastApp is a ALLOW.
    DISALLOW The current state of Dex AutoOpenLastApp is a DISALLOW.
Throws
SecurityException The calling application does not have the required permission.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 dexmanager.isAutoOpenLastAppAllowed();
 
Since
API level 28
KNOX 3.3
Multiuser Environment
Global Scope

public boolean isDexActivated ()

Since: API level 25

API to check whether Dex mode is activated.

Returns
  • true if activated, false if deactivated
Usage
An administrator can use this API to check whether the Dex mode is activated or not.

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public boolean isDexDisabled ()

Since: API level 25

API to check whether Dex mode is enabled.

Returns
  • true if enabled, false if disabled
Usage
An administrator can use this API to check whether the Dex mode is enabled or not.

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public boolean isEthernetOnlyEnforced ()

Since: API level 25

API to check whether ethernet only mode is enforced.

Returns
  • true if enforced, false if released
Usage
An administrator can use this API to check whether the ethernet only mode is enforced or not.

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public boolean isScreenTimeoutChangeAllowed ()

Since: API level 25

API to check whether the user is allowed to change the screen time out for Dex mode.

Returns
  • true if enabled, false if disabled
Usage
An administrator can use this API check whether the user is allowed to change the screen time out. If not allowed, the user cannot change the screen time out.

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public boolean isVirtualMacAddressEnforced ()

Since: API level 25

Deprecated in API level 33
NOTE: This API is not available since Android 11.

API to check enforced use of the virtual MAC address for Dex mode.

Returns
  • true if use virtual MAC address, false if use phone MAC address.
Usage
An administrator can use this API to check whether the virtual MAC address is used in Dex mode.

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public int removePackageFromDisableList (String packageName)

Since: API level 25

Deprecated in API level 33

API to remove the application package name from Dex mode disable list.

Parameters
packageName The application package name to be remove from disable list for Dex mode.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remove disabled application package name from Dex mode disable list.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 DexManager dexMgr = edm.getDexManager();
 try {
     int status = dexMgr.removePackageFromDisableList("com.test.app");
     // status is operation result
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 

Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_DEX" permission which has a protection level of signature.
Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public int removeShortcut (ComponentName component)

Since: API level 25

This method removes an application shortcut from the Dex launcher.
NOTE: This method will remove all shortcuts for the specified package.

Parameters
component The component name of the shortcut to be removed.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 try {
     CustomDeviceManager cdm = CustomDeviceManager.getInstance();
     DexManager dexmanager = cdm.getDexManager();
     ComponentName component = new ComponentName("com.android.chrome", com.google.android.apps.chrome.Main");
     dexmanager.removeShortcut(component);
 } catch(SecurityException e) {
     Log.w(TAG, "SecurityException:" + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public int removeURLShortcut (String url, ComponentName component)

Since: API level 26

This method removes the given shortcut from the DeX launcher.

Parameters
url The URL address of the URL shortcut.
component The component name of the shortcut to be removed.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 try {
     CustomDeviceManager cdm = CustomDeviceManager.getInstance();
     DexManager dexmanager = cdm.getDexManager();
     ComponentName component = new ComponentName("com.android.chrome", "com.google.android.apps.chrome.Main");
     dexmanager.removeURLShortcut( "http://www.naver.com", component)
 } catch(SecurityException e) {
     Log.w(TAG, "SecurityException:" + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 26
KNOX 3.2
Multiuser Environment
Global Scope

public boolean setDexDisabled (boolean disabled)

Since: API level 25

API to enable or disable the Dex mode

Parameters
disabled true to disable dex, false to enable dex
Returns
  • true if operation is successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to disable Dex mode without user interaction.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 DexManager dexMgr = edm.getDexManager();
 // disable
 try {
     if (dexMgr.setDexDisabled(false)) {
         // Dex mode is disabled.
     } else {
         // failure restricting Dex mode.
     }
     // enable
     if (dexMgr.setDexDisabled(true)) {
         // Dex mode is enabled.
     } else {
         // failure removing restriction of Dex mode.
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 

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

Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope
See Also

public int setForegroundModePackageList (int state, List<String> pkgList)

Since: API level 26

This method adds, removes, clears a package whitelist for Dex foreground mode.

Parameters
state ADD Specify the package to run as foreground when DeX mode starts.
REMOVE Remove the package from the current specificed list.
CLEAR Clear the current speficied list.
pkgList Specific package list. If the package name is wrong or not installed, it will be ignored.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
This API adds, removes, or clears a package whitelist for the DeX foreground mode. An app that is in the foreground will be automatically launched after the device is connected to a monitor.

NOTE:

This API only works for owner (User 0) space applications.

To implement this method properly, the should be called in Samsung Dex single view mode.

 try {
     CustomDeviceManager cdm = CustomDeviceManager.getInstance();
     DexManager dexmanager = cdm.getDexManager();
     List pkgList = new List<>{"com.android.chrome"};
     dexmanager.setForegroundModePackageList( CustomDeviceManager.ADD, pkgList);
 } catch(SecurityException e) {
     Log.w(TAG, "SecurityException:" + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 26
KNOX 3.2
Multiuser Environment
Global Scope

public int setHDMIAutoEnterState (int state)

Since: API level 28

This method sets the DeX HDMIAutoEnter that starts Dex mode automatically when HDMI cable is connected. This is an "Auto start when HDMI is connected" option in DeX settings in tablets.

Parameters
state HDMI_AUTO_ENTER_RESTORE This is to go back to user's eariler setting.
HDMI_AUTO_ENTER_ON This is a ON of Dex HDMIAutoEnterState.
HDMI_AUTO_ENTER_RESET This is to go back to initial setting.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 int state = CustomDeviceManager.HDMI_AUTO_ENTER_RESTORE;
 dexmanager.setHDMIAutoEnterState(state);
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 28
KNOX 3.3
Multiuser Environment
Global Scope
See Also
  • #getDexHDMIAutoEnterState()

public int setHomeAlignment (int mode)

Since: API level 26

This method sets the DeX alignment mode.

Parameters
mode CUSTOM_GRID This is the Custom Grid mode for Dex launcher.
ALPHABETIC_GRID This is the Alphabetic Grid mode for Dex launcher.
TYPE_GRID This is the Type Grid mode for Dex launcher.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 int mode = CustomDeviceManager.ALPHABETIC_GRID;
 dexmanager.setHomeAlignment(mode);
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 26
KNOX 3.2
Multiuser Environment
Global Scope

public int setLoadingLogo (ParcelFileDescriptor logoFD)

Since: API level 25

This method sets the logo that is displayed when the phone is starting Dex.

Parameters
logoFD The descriptor of the file to be used as the logo. The logo file must be a png image.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 try {
     CustomDeviceManager cdm = CustomDeviceManager.getInstance();
     DexManager dexmanager = cdm.getDexManager();
     ParcelFileDescriptor logoFD = ParcelFileDescriptor.open(new File(logoFile), ParcelFileDescriptor.MODE_READ_ONLY);
     dexmanager.setLoadingLogo(logoFD);
 } catch(SecurityException e) {
     Log.w(TAG, "SecurityException:" + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public int setScreenTimeout (int timeout)

Since: API level 25

This method sets the Dex mode screen timeout to the specified number of seconds. Samsung DeX supports 2 modes: Dual View mode and Standalone Mode For 'StandAlone mode',screen timeout for DeX should be set to the Device settings' value. For 'DualView mode', screen timeout for DeX sholuld be set to SettingsProvider for DeX only, not Settings.

Parameters
timeout The new Dex mode screen timeout in seconds.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 try {
     CustomDeviceManager cdm = CustomDeviceManager.getInstance();
     DexManager dexmanager = cdm.getDexManager();
     dexmanager.setScreenTimeout(1200);
 } catch(SecurityException e) {
     Log.w(TAG, "SecurityException:" + e);
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_DEX" permission.
Since
API level 25
KNOX 3.1
Multiuser Environment
Global Scope

public int setShowIMEWithHardKeyboard (int state)

Since: API level 28

This method shows/hides the on-screen keyboard while a physical keyboard is being used.

Parameters
state ON This is a ON of ShowIMEWithHardKeyboard that shows soft keyboard.
OFF This is a OFF of ShowIMEWithHardKeyboard that does not show soft keyboard.
Returns
Throws
SecurityException The calling application does not have the required permission.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 int state = CustomDeviceManager.ON;
 dexmanager.setShowIMEWithHardKeyboard(state);
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
Since
API level 28
KNOX 3.3
Multiuser Environment
Global Scope

public int setWallpaper (Context context, InputStream bitmapData, Rect visibleCropHint, boolean allowBackup, int which)

Since: API level 28

This method allows the caller to specify which of the supported wallpaper categories to set.

Parameters
context A caller's context to retrieve a instance associated with the given Context.
bitmapData A stream containing the raw data to install as a wallpaper.
This data can be in any format handled by BitmapRegionDecoder.
visibleCropHint The rectangular subregion of the streamed image that should be displayed as wallpaper.
Passing null for this parameter means that the full image should be displayed if possible given the image's and device's aspect ratios, etc.
allowBackup if the OS is permitted to back up this wallpaper image for restore to a future device; false otherwise.
which Flags indicating which wallpaper(s) to configure with the new imagery.
FLAG_LOCK_DEX Flag: set or retrieve the lock-screen-specific wallpaper on Dex.
FLAG_SYSTEM_DEX Flag: set or retrieve the general system wallpaper on Dex.
Returns
  • An integer ID assigned to the newly active wallpaper; or zero on failure.
Throws
SecurityException The calling application does not have the required permission.
IllegalArgumentException If the visibleCropHint rectangle is empty or invalid.
If an error occurs when attempting to set the wallpaper based on the provided image data.
Usage
 CustomDeviceManager cdm = CustomDeviceManager.getInstance();
 DexManager dexmanager = cdm.getDexManager();
 dexmanager.setWallpaper(context, bitmapData, visibleCropHint, allowBackup, which);
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_CUSTOM_DEX" permission.
The use of this API requires the caller to have the "android.Manifest.permission.SET_WALLPAPER" permission.
Since
API level 28
KNOX 3.3
Multiuser Environment
Global Scope