Since: API level 1
public class

ExchangeAccountPolicy

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.accounts.ExchangeAccountPolicy

Deprecated in API level 27

Class Overview

This class provides APIs to configure Microsoft Exchange ActiveSync account-related settings and to create and delete Microsoft Exchange ActiveSync accounts. Some configuration value has dependency on Microsoft Exchange ActiveSync protocol version.

Since
API level 1
MDM 1.0

Summary

Constants
String ACTION_CBA_INSTALL_STATUS Broadcast action: To notify user of certificate installation status for certificate-based authentication (CBA).
String ACTION_ENFORCE_SMIME_ALIAS_RESULT Broadcast Action: To notify an administrator about smime certificate alias enforcement status which will be sent after calling setForceSMIMECertificateAlias(long, String, int) or setForceSMIMECertificateAlias(long, String, String, int).
String ACTION_EXCHANGE_ACCOUNT_ADD_RESULT Broadcast Action: To notify an administrator about account create/update operations status which will be sent after accounts setting validation.This intent can be sent several times for one account; an example is when settings validation failed because the user initially entered the wrong password and later retried by entering the correct value..
String ACTION_EXCHANGE_ACCOUNT_DELETE_RESULT Broadcast Action: To notify administrator about account delete operations status.
int ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT SMIME certificate alias enforcement operation type for Encryption.
int ENFORCE_SMIME_ALIAS_TYPE_SIGN SMIME certificate alias enforcement operation type for Signing.
int ERROR_SET_SMIME_CERTIFICATE_NONE Flag indicating force SMIME certificate operation was successful.
int ERROR_SET_SMIME_CERTIFICATE_NOT_FOUND Flag indicating if certificate alias could not be found at keystore (in case either setForceSMIMECertificateAlias(long, String, int) or setForceSMIMECertificateAlias(long, String, String, int) was called) on forcing SMIME certificate.
int ERROR_SET_SMIME_CERTIFICATE_UNKNOWN Flag indicating an unknown error on forcing SMIME certificate.
String EXTRA_ACCOUNT_ID The lookup key for long object.
String EXTRA_EMAIL_ADDRESS The lookup key for String object.
String EXTRA_ENFORCE_SMIME_ALIAS_TYPE The lookup key for integer object.
String EXTRA_RESULT The lookup key for integer object.
String EXTRA_SERVER_ADDRESS The lookup key for String object.
String EXTRA_SMIME_RESULT The lookup key for integer object.
String EXTRA_STATUS The lookup key for an object.
Public Methods
long addNewAccount(ExchangeAccount account)
Deprecated in API level 27
boolean allowInComingAttachments(boolean enable, long accId)
Deprecated in API level 27
boolean deleteAccount(long accId)
Deprecated in API level 27
Account getAccountDetails(long accId)
Deprecated in API level 27
long getAccountId(String easDomain, String easUser, String activeSyncHost)
Deprecated in API level 27
Account[] getAllEASAccounts()
Deprecated in API level 27
String getDeviceId()
Deprecated in API level 27
int getIncomingAttachmentsSize(long accId)
Deprecated in API level 27
int getMaxCalendarAgeFilter(long accId)
Deprecated in API level 27
int getMaxEmailAgeFilter(long accId)
Deprecated in API level 27
int getMaxEmailBodyTruncationSize(long accId)
Deprecated in API level 27
int getMaxEmailHTMLBodyTruncationSize(long accId)
Deprecated in API level 27
boolean getRequireEncryptedSMIMEMessages(long accId)
Deprecated in API level 27
boolean getRequireSignedSMIMEMessages(long accId)
Deprecated in API level 27
String getSMIMECertificateAlias(long accId, int type)
Deprecated in API level 27
boolean isIncomingAttachmentsAllowed(long accId)
Deprecated in API level 27
void removePendingAccount(String emailAddress, String easUser, String easDomain, String serverAddress)
Deprecated in API level 27
void sendAccountsChangedBroadcast()
Deprecated in API level 27
boolean setAcceptAllCertificates(boolean acceptAllCertificates, long accId)
Deprecated in API level 27
boolean setAccountName(String accountName, long accId)
Deprecated in API level 27
boolean setAlwaysVibrateOnEmailNotification(boolean enable, long accId)
Deprecated in API level 27
boolean setAsDefaultAccount(long accId)
Deprecated in API level 27
void setClientAuthCert(byte[] certData, String password, long accId)
Deprecated in API level 27
boolean setDataSyncs(boolean syncCalendar, boolean syncContacts, boolean syncTasks, boolean syncNotes, long accId)
Deprecated in API level 27
boolean setForceSMIMECertificateAlias(long accId, String alias, int type)
Deprecated in API level 27
boolean setForceSMIMECertificateAlias(long accId, String storageName, String alias, int type)
Deprecated in API level 27
boolean setIncomingAttachmentsSize(int size, long accId)
Deprecated in API level 27
boolean setMaxCalendarAgeFilter(int maxage, long accId)
Deprecated in API level 27
boolean setMaxEmailAgeFilter(int maxage, long accId)
Deprecated in API level 27
boolean setMaxEmailBodyTruncationSize(int size, long accId)
Deprecated in API level 27
boolean setMaxEmailHTMLBodyTruncationSize(int size, long accId)
Deprecated in API level 27
boolean setPassword(String password, long accId)
Deprecated in API level 27
boolean setPastDaysToSync(int pastDaysToSync, long accId)
Deprecated in API level 27
boolean setRequireEncryptedSMIMEMessages(long accId, boolean enable)
Deprecated in API level 27
boolean setRequireSignedSMIMEMessages(long accId, boolean enable)
Deprecated in API level 27
boolean setSSL(boolean enableSSL, long accId)
Deprecated in API level 27
boolean setSignature(String signature, long accId)
Deprecated in API level 27
boolean setSyncPeakTimings(int peakDays, int peakStartMinute, int peakEndMinute, long accId)
Deprecated in API level 27
boolean setSyncSchedules(int peakSyncSchedule, int offPeakSyncSchedule, int roamingSyncSchedule, long accId)
Deprecated in API level 27
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_CBA_INSTALL_STATUS

Since: API level 2

Broadcast action: To notify user of certificate installation status for certificate-based authentication (CBA). The intent has the following extra values:

The parcelable extra EXTRA_STATUS is also contained in this intent, which identifies the status of the certificate installation initiated using API setClientAuthCert(byte[], String, long)

Since
API level 2
MDM 2.0
Constant Value: "com.samsung.android.knox.intent.action.CBA_INSTALL_STATUS"

public static final String ACTION_ENFORCE_SMIME_ALIAS_RESULT

Since: API level 15

Broadcast Action: To notify an administrator about smime certificate alias enforcement status which will be sent after calling setForceSMIMECertificateAlias(long, String, int) or setForceSMIMECertificateAlias(long, String, String, int).

The intent will have the following extra values:

EXTRA_ENFORCE_SMIME_ALIAS_TYPE

EXTRA_ACCOUNT_ID

EXTRA_SMIME_RESULT

Permission
The use of this intent requires the user to have the "com.samsung.android.knox.permission.KNOX_EXCHANGE" permission which has a protection level of signature.
Since
API level 15
MDM 5.4
Constant Value: "com.samsung.android.knox.intent.action.ENFORCE_SMIME_ALIAS_RESULT"

public static final String ACTION_EXCHANGE_ACCOUNT_ADD_RESULT

Since: API level 6

Broadcast Action: To notify an administrator about account create/update operations status which will be sent after accounts setting validation.This intent can be sent several times for one account; an example is when settings validation failed because the user initially entered the wrong password and later retried by entering the correct value..

The intent has the following extra values:

EXTRA_RESULT

EXTRA_EMAIL_ADDRESS

EXTRA_SERVER_ADDRESS

EXTRA_ACCOUNT_ID

Permission
The use of this intent requires the user to have the "com.samsung.android.knox.permission.KNOX_EXCHANGE" permission which has a protection level of signature.
Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.action.EXCHANGE_ACCOUNT_ADD_RESULT"

public static final String ACTION_EXCHANGE_ACCOUNT_DELETE_RESULT

Since: API level 6

Broadcast Action: To notify administrator about account delete operations status.

The intent has the following extra values:

EXTRA_RESULT

EXTRA_EMAIL_ADDRESS

EXTRA_SERVER_ADDRESS

EXTRA_ACCOUNT_ID

Permission
The use of this intent requires the user to have the "com.samsung.android.knox.permission.KNOX_EXCHANGE" permission which has a protection level of signature.
Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.action.EXCHANGE_ACCOUNT_DELETE_RESULT"

public static final int ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT

Since: API level 15

SMIME certificate alias enforcement operation type for Encryption.

Since
API level 15
MDM 5.4
Constant Value: 0 (0x00000000)

public static final int ENFORCE_SMIME_ALIAS_TYPE_SIGN

Since: API level 15

SMIME certificate alias enforcement operation type for Signing.

Since
API level 15
MDM 5.4
Constant Value: 1 (0x00000001)

public static final int ERROR_SET_SMIME_CERTIFICATE_NONE

Since: API level 6

Flag indicating force SMIME certificate operation was successful.

Since
API level 6
MDM 4.0
Constant Value: -1 (0xffffffff)

public static final int ERROR_SET_SMIME_CERTIFICATE_NOT_FOUND

Since: API level 6

Flag indicating if certificate alias could not be found at keystore (in case either setForceSMIMECertificateAlias(long, String, int) or setForceSMIMECertificateAlias(long, String, String, int) was called) on forcing SMIME certificate.

Since
API level 6
MDM 4.0
Constant Value: 1 (0x00000001)

public static final int ERROR_SET_SMIME_CERTIFICATE_UNKNOWN

Since: API level 6

Flag indicating an unknown error on forcing SMIME certificate.

Since
API level 6
MDM 4.0
Constant Value: 0 (0x00000000)

public static final String EXTRA_ACCOUNT_ID

Since: API level 6

The lookup key for long object. Retrieve with getLongExtra(String, long). Account Id in email database or -1 in case account creation, account update, and deletion of nonvalidating accounts.

Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.extra.ACCOUNT_ID"

public static final String EXTRA_EMAIL_ADDRESS

Since: API level 6

The lookup key for String object. Retrieve with getStringExtra(String). Account email address used to identify account.

Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.extra.EMAIL_ADDRESS"

public static final String EXTRA_ENFORCE_SMIME_ALIAS_TYPE

Since: API level 15

The lookup key for integer object. Retrieve with getIntExtra(String, int). SMIME certificate alias enforcement operation type.

Since
API level 15
MDM 5.4
Constant Value: "com.samsung.android.knox.intent.extra.ENFORCE_SMIME_ALIAS_TYPE"

public static final String EXTRA_RESULT

Since: API level 6

The lookup key for integer object. Retrieve with getIntExtra(String, int). Status for account creation/update/delete

  • Value 0 - Success
  • Value 1 - Activation error for setup result intent or fail for delete result intent
  • Value 2 - Authentication error
  • Value 3 - I/O error
  • Value 4 - Security policy unsupported
  • Value 5 - Protocol version unsupported
  • Value 6 - General security error
  • Value 7 - Error when saving account to database
  • Value 8 - Other errors

Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.extra.RESULT"

public static final String EXTRA_SERVER_ADDRESS

Since: API level 6

The lookup key for String object. Retrieve with getStringExtra(String). Account exchange server host address used to identify account.

Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.extra.SERVER_ADDRESS"

public static final String EXTRA_SMIME_RESULT

Since: API level 15

The lookup key for integer object. Retrieve with getIntExtra(String, int). Status for SMIME Certificate enforcement.

Since
API level 15
MDM 5.4
Constant Value: "com.samsung.android.knox.intent.extra.SMIME_RESULT"

public static final String EXTRA_STATUS

Since: API level 2

The lookup key for an object. Retrieve with getIntExtra(String, int). If successfully installed, status is "0", and on any failure, status is "1".

Since
API level 2
MDM 2.0
Constant Value: "com.samsung.android.knox.intent.extra.STATUS"

Public Methods

public long addNewAccount (ExchangeAccount account)

Since: API level 11

Deprecated in API level 27

API to add a new Microsoft Exchange account with base parameters.

Parameters
account Exchange account class of the account

NOTE : All other settings values are set to default.

Returns
  • On success, valid account Id if Android version is less than 4.0 else 0 for Android version 4.0 onward. On failure, -1.
Throws
SecurityException If caller does not have required permissions
Usage

An administrator can use this API to remotely configure a Microsoft Exchange ActiveSync account on the user's device without user interaction. Most of these settings can be changed by the user except 'domain' and 'username'.

Exchange account base parameters: Exchange Account class.

The administrator can register ACTION_EXCHANGE_ACCOUNT_ADD_RESULT intent to receive account creation status and account Id.

The administrator can use removePendingAccount(String, String, String, String) to delete nonvalidated pending accounts.

NOTE:

On Android version 4.0 onwards:

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.
                         getExchangeAccountPolicy();
  try {
     accountId =  exchangeAccountPolicy.addNewAccount(new ExchangeAccount(
                 "testeasid@easserver.com", "testeasid","easDomain", "easserver.com",
                 "Password@123"));
     if(accountId >= 0){
         Log.d(TAG,"Add a new exchange account with base parameters succeeded!");
         // Administrator needs to call sendAccountsChangedBroadcast() API
         // to notify about the Microsoft Exchange account addition.
         exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG," Add a new exchange account with base parameters failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.
                         getExchangeAccountPolicy();
  try {
     accountId =  exchangeAccountPolicy.addNewAccount(new ExchangeAccount(
                 "testeasid@easserver.com", "testeasid","easDomain", "easserver.com",
                 "Password@123"));
     if(accountId >= 0){
         Log.d(TAG,"Add a new exchange account with base parameters succeeded!");
         // Administrator needs to call sendAccountsChangedBroadcast() API
         // to notify about the Microsoft Exchange account addition.
         exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG," Add a new exchange account with base parameters failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.

Depending on the Credential Storage type identified by certificateStorageName attribute, a new permission will also be enforced. System Credential Storages will check for 'com.samsung.android.knox.permission.KNOX_UCM_ESE_MGMT' permission, while non-system ones check for 'com.samsung.android.knox.permission.KNOX_UCM_OTHER_MGMT' permission. Please refer to Universal Credential Manager (UCM) DEV guide in order to have more details of how to get these new permissions.
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public boolean allowInComingAttachments (boolean enable, long accId)

Since: API level 11

Deprecated in API level 27

API to enable or disable incoming attachments for Exchange accounts.

Parameters
enable true to enable attachment
accId The exchange account id to enable attachment
Returns
  • true if successful, false otherwise
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to enable or disable incoming attachments for Exchange accounts.
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.allowInComingAttachments(false,accId);
      if (true == enable) {
          // administrator has disabled Incoming attachments for Exchange accounts.
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
  // When you create container successfully, containerID will be returned via intent.
  // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.allowInComingAttachments(false, accId);
      if (true == enable) {
          // administrator has disabled Incoming attachments for Exchange accounts.
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public boolean deleteAccount (long accId)

Since: API level 1

Deprecated in API level 27

API to delete an account.

Parameters
accId Id of account to be deleted
Returns
  • true if account deleted successfully, else false.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely delete a Microsoft Exchange ActiveSync account and all related data without user interaction. The key to using this API is the enterprise Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String).

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean result  = exchangeAccountPolicy.deleteAccount(
         accountId);
      if(result){
          Log.d(TAG,"deleting account succeede!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account deletion.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG,"deleting account failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean result  = exchangeAccountPolicy.deleteAccount(
         accountId);
      if(result){
          Log.d(TAG,"deleting account succeede!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account deletion.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG,"deleting account failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public Account getAccountDetails (long accId)

Since: API level 1

Deprecated in API level 27

API to get account details.

Parameters
accId Id of account containing the details to be queried
Returns
  • Account object filled with all account details if successful, else null.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this utility API to obtain the details of a particular Microsoft Exchange ActiveSync account. The key to using this API is the enterprise Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String).

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      Account  mAccnt  = exchangeAccountPolicy.getAccountDetails(
                  accountId);
      if(mAccnt != null){
          Log.d(TAG," return account details are not null (account exists)!");
      }else{
          Log.d(TAG," return account details are null (account does not exist).");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      Account  mAccnt  = exchangeAccountPolicy.getAccountDetails(
                  accountId);
      if(mAccnt != null){
          Log.d(TAG," return account details are not null (account exists)!");
      }else{
          Log.d(TAG," return account details are null (account does not exist).");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public long getAccountId (String easDomain, String easUser, String activeSyncHost)

Since: API level 1

Deprecated in API level 27

API to get the Id of an account with given details.

Parameters
easDomain Domain name of the account
easUser User name of the account
activeSyncHost Server address of the account
Returns
  • Account Id if success, else -1.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this utility API to obtain the account Id of a particular Microsoft Exchange ActiveSync account. A Microsoft Exchange ActiveSync account is uniquely represented by a combination of the 'domain name', 'user name', and 'ActiveSync host'. All parameters for this API are case sensitive.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId  = exchangeAccountPolicy.getAccountId("easDomain",
                  "testeasid","easserver.com");
      if(accountId >0){
          Log.d(TAG," get account Id is valid/successful!");
      }else{
          Log.d(TAG," get account Id is invalid/failure.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId  = exchangeAccountPolicy.getAccountId("easDomain",
                  "testeasid","easserver.com");
      if(accountId >0){
          Log.d(TAG," get account Id is valid/successful!");
      }else{
          Log.d(TAG," get account Id is invalid/failure.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public Account[] getAllEASAccounts ()

Since: API level 2

Deprecated in API level 27

API to get all Microsoft Exchange ActiveSync account information as a list.

Returns
  • Account object array filled with all account details if successful, else null.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get information on all existing Microsoft Exchange accounts on the device.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      Account[] accounts = exchangeAccountPolicy.getAllEASAccounts() ;
      if(accounts!= null){
          Log.d(TAG,"Retrieving Microsoft Exchange account detail succeeded! One or more accounts exist.");
      }else{
          Log.d(TAG," No Microsoft Exchange accounts exist.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      Account[] accounts = exchangeAccountPolicy.getAllEASAccounts() ;
      if(accounts!= null){
          Log.d(TAG,"Retrieving Microsoft Exchange account detail succeeded! One or more accounts exist.");
      }else{
          Log.d(TAG," No Microsoft Exchange accounts exist.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public String getDeviceId ()

Since: API level 2

Deprecated in API level 27

API to get the unique device Id generated by the Microsoft Exchange ActiveSync protocol.

Returns
  • unique device id if successful, else null.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get the unique device Id generated by the Microsoft Exchange ActiveSync protocol. This task is a long running operation. The API should be called from a worker thread rather than the main UI thread to ensure the best UI performance. You can use AsyncTask or Handler to communicate with the main UI thread.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  String  deviceId = exchangeAccountPolicy.getDeviceId();
  if(deviceId != null){
      Log.d(TAG," Device Id:" +deviceId);
  }else{
      Log.d(TAG," Device Id is null" );
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  String  deviceId = exchangeAccountPolicy.getDeviceId();
  if(deviceId != null){
      Log.d(TAG," Device Id:" +deviceId);
  }else{
      Log.d(TAG," Device Id is null" );
  }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EXCHANGE" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public int getIncomingAttachmentsSize (long accId)

Since: API level 11

Deprecated in API level 27

API to get maximum attachment size allowed for Exchange accounts. (byte)

Parameters
accId The exchange account id to get maximum attachment size.
Returns
  • maximum attachment size of Exchange accounts. ( 0 : no limit )
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get maximum attachment size allowed for Exchange accounts. (byte)
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      int value = exchangeAccountPolicy.getIncomingAttachmentsSize(accId);
      // Incoming attachments of Exchange accounts is enable.
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
  // When you create container successfully, containerID will be returned via intent.
  // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      int value = exchangeAccountPolicy.getIncomingAttachmentsSize(accId);
      // Incoming attachments of Exchange accounts is enable.
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public int getMaxCalendarAgeFilter (long accId)

Since: API level 11

Deprecated in API level 27

API to get maximum calendar age of Exchange accounts.

Parameters
accId The exchange account id to get maximum Calendar sync period.
Returns
  • maximum calendar age of Exchange accounts.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get maximum calendar age of Exchange accounts.
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      int value = exchangeAccountPolicy.getMaxCalendarAgeFilter(accId);
      //  All(value 0), 2 weeks(value 1), 1 months(value 2), 3 months(value 3), 6 months (value 4)
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
  // When you create container successfully, containerID will be returned via intent.
  // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      int value = exchangeAccountPolicy.getMaxCalendarAgeFilter(accId);
      //  All(value 0), 2 weeks(value 1), 1 months(value 2), 3 months(value 3), 6 months (value 4)
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public int getMaxEmailAgeFilter (long accId)

Since: API level 11

Deprecated in API level 27

API to get maximum Email age of Exchange accounts.

Parameters
accId The exchange account id to get maximum Email sync period.
Returns
  • maximum Email age of Exchange accounts.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get maximum Email age of Exchange accounts.
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      int value = exchangeAccountPolicy.getMaxEmailAgeFilter(accId);
      //  All(value 0), 2 weeks(value 1), 1 months(value 2), 3 months(value 3), 6 months (value 4)
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      int value = exchangeAccountPolicy.getMaxEmailAgeFilter(accId);
      //  All(value 0), 2 weeks(value 1), 1 months(value 2), 3 months(value 3), 6 months (value 4)
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public int getMaxEmailBodyTruncationSize (long accId)

Since: API level 11

Deprecated in API level 27

API to get maximum Email Body Truncation size of Exchange accounts. (kbyte)

Parameters
accId The exchange account id to get maximum Email Body Truncation Size.
Returns
  • maximum Email Body Truncation size of Exchange accounts. (kbyte)
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get maximum Email Body Truncation size of Exchange accounts. (kbyte)
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      int value = exchangeAccountPolicy.getMaxEmailBodyTruncationSize(accId);

  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      int value = exchangeAccountPolicy.getMaxEmailBodyTruncationSize(accId);

  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public int getMaxEmailHTMLBodyTruncationSize (long accId)

Since: API level 11

Deprecated in API level 27

API to get maximum Email HTML Body Truncation size of Exchange accounts. (kbyte)

Parameters
accId The exchange account id to get maximum Email HTML Body Truncation Size.
Returns
  • maximum Email HTML Body Truncation size of Exchange accounts. (kbyte)
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get maximum Email HTML Body Truncation size of Exchange accounts. (kbyte)
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      int value = exchangeAccountPolicy.getMaxEmailHTMLBodyTruncationSize(accId);

  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      int value = exchangeAccountPolicy.getMaxEmailHTMLBodyTruncationSize(accId);

  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public boolean getRequireEncryptedSMIMEMessages (long accId)

Since: API level 6

Deprecated in API level 27

API to determine whether encrypted S/MIME messages are required for an exchange account.

Parameters
accId The exchange account id.
Returns
  • true if encrypted S/MIME messages are required, false otherwise.
Usage
An administrator can use this API to get status of the S/MIME encryption requirement for an exchange account.*
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.getRequireEncryptedSMIMEMessages(accId);
      if (true == enable) {
          // encrypted S/MIME messages are required for this account
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
  // When you create container successfully, containerID will be returned via intent.
  // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.getRequireEncryptedSMIMEMessages(accId);
      if (true == enable) {
          // encrypted S/MIME messages are required for this account
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
Since
API level 6
MDM 4.0
Multiuser Environment
User Scope

public boolean getRequireSignedSMIMEMessages (long accId)

Since: API level 6

Deprecated in API level 27

API to determine whether using S/MIME certificate is required to sign messages. for the given exchange account.

Parameters
accId The exchange account id.
Returns
  • true if signed S/MIME messages are required, false otherwise.
Usage
An administrator can use this API to get status of S/MIME signing requirement for an exchange account.
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.getRequireSignedSMIMEMessages(accId);
      if (true == enable) {
          // signed S/MIME messages are required for this account
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.getRequireSignedSMIMEMessages(accId);
      if (true == enable) {
          // signed S/MIME messages are required for this account
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
Since
API level 6
MDM 4.0
Multiuser Environment
User Scope

public String getSMIMECertificateAlias (long accId, int type)

Since: API level 15

Deprecated in API level 27

API to retrieve the certificate alias used for S/MIME messages for specific Exchange account.

Parameters
accId Exchange account Id
type Operation type either ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT or ENFORCE_SMIME_ALIAS_TYPE_SIGN
Returns
  • Enforced certificate alias for the given account id if some is set, or null otherwise. In case certificate has been enforced with setForceSMIMECertificateAlias(long, String, String, int) API, the alias will be returned in an URI format, which contains the storage name information.
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  int type = 1; // ExchangeAccountPolicy.ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT;
  try {
      String alias = exchangeAccountPolicy.getSMIMECertificateAlias(accId, type);
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  int type = 1; // ExchangeAccountPolicy.ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT;
  try {
      String alias = exchangeAccountPolicy.getSMIMECertificateAlias(accId, type);
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
Since
API level 15
MDM 5.4
Multiuser Environment
User Scope

public boolean isIncomingAttachmentsAllowed (long accId)

Since: API level 11

Deprecated in API level 27

API to check whether incoming attachments of Exchange accounts are allowed.

Parameters
accId The exchange account id to get state of attachemnt enable
Returns
  • true if Incoming attachments of Exchange are enabled, false otherwise.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to check whether incoming attachments of Exchange accounts are allowed.
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.isIncomingAttachmentsAllowed(accId);
      if (true == enable) {
          // Incoming attachments of Exchange accounts are enable.
      }
      else{
          // Incoming attachments of Exchange accounts are disable.
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
  // When you create container successfully, containerID will be returned via intent.
  // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.isIncomingAttachmentsAllowed(accId);
      if (true == enable) {
          // Incoming attachments of Exchange accounts are enable.
      }
      else{
          // Incoming attachments of Exchange accounts are disable.
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public void removePendingAccount (String emailAddress, String easUser, String easDomain, String serverAddress)

Since: API level 6

Deprecated in API level 27

API to remove account which is still pending creation.

Parameters
emailAddress Email Address of the exchange account
easUser User name of the exchange account
easDomain Domain name of the exchange account
serverAddress Address of the exchange server e.g "mail.xyz.com"
Throws
SecurityException If caller does not have required permissions
Usage
Administrator can use this API to remove pending Exchange account from the device.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
 try {
         exchangeAccountPolicy.removePendingAccount("testeasid@easserver.com",
                           "testeasid", "easserver.com", "mail.easserver.com");
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
 try {
         exchangeAccountPolicy.removePendingAccount("testeasid@easserver.com",
                           "testeasid", "easserver.com", "mail.easserver.com");
 } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 6
MDM 4.0
Multiuser Environment
User Scope

public void sendAccountsChangedBroadcast ()

Since: API level 1

Deprecated in API level 27

API to be called to notify other applications after changes are made to an account.

Throws
SecurityException If caller does not have required permissions
Usage
This API is to be called whenever any changes are made to an account. The API enables all other applications that depend on the account to be informed if any changes are made to account parameters.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean result  = exchangeAccountPolicy.deleteAccount(
         accountId);
      if(result){
          Log.d(TAG,"deleting account succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account deletion.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG,"deleting account failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean result  = exchangeAccountPolicy.deleteAccount(
         accountId);
      if(result){
          Log.d(TAG,"deleting account succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account deletion.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG,"deleting account failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public boolean setAcceptAllCertificates (boolean acceptAllCertificates, long accId)

Since: API level 1

Deprecated in API level 27

API to enable or disable the Microsoft Exchange account setting for accepting all certificates.

Parameters
acceptAllCertificates true to enable, false to disable
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure whether Secure Sockets Layer (SSL) transport should accept all certificates sent from the server when connecting to it. The key to using this API is the enterprise Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setAcceptAllCertificates(
              true, accountId);
      if(result){
          Log.d(TAG,"setAcceptAllCertificates succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG," setAcceptAllCertificates failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setAcceptAllCertificates(
              true, accountId);
      if(result){
          Log.d(TAG,"setAcceptAllCertificates succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG," setAcceptAllCertificates failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public boolean setAccountName (String accountName, long accId)

Since: API level 1

Deprecated in API level 27

API to change the account name displayed for the Microsoft Exchange account.

Parameters
accountName Account name String
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the user-readable name associated with a Microsoft Exchange ActiveSync account. The key to using this API is the enterprise Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setAccountName(
          "MytestAccount",accountId);
      if(result){
          Log.d(TAG,"setAccountName succeeded!");
          // Administrator needs to call sendAccountsChangedBroadcast() API
          // to notify about the Microsoft Exchange account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
     }else{
          Log.d(TAG,"setAccountName failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setAccountName(
          "MytestAccount",accountId);
      if(result){
          Log.d(TAG,"setAccountName succeeded!");
          // Administrator needs to call sendAccountsChangedBroadcast() API
          // to notify about the Microsoft Exchange account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
     }else{
          Log.d(TAG,"setAccountName failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public boolean setAlwaysVibrateOnEmailNotification (boolean enable, long accId)

Since: API level 1

Deprecated in API level 27

API to enable or disable the Microsoft Exchange account setting 'Always Vibrate On Email Notification'.

Parameters
enable true to enable, false to disable
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administration can use this API to remotely configure whether the device should always vibrate when a new email is received. The key to using this API is the enterprise Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.
             setAlwaysVibrateOnEmailNotification(true, accountId);
      if(result){
          Log.d(TAG,"setAlwaysVibrateOnEmailNotification succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG,"setAlwaysVibrateOnEmailNotification failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.
             setAlwaysVibrateOnEmailNotification(true, accountId);
      if(result){
          Log.d(TAG,"setAlwaysVibrateOnEmailNotification succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG,"setAlwaysVibrateOnEmailNotification failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public boolean setAsDefaultAccount (long accId)

Since: API level 2

Deprecated in API level 27

API to set a given account as the default.

Parameters
accId Id of account to be set as default
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to set a particular account as the default account. The key to using this API is the enterprise Microsoft Exchange ActiveSync a ccount Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setAsDefaultAccount(
                     accountId);
      if(result){
          Log.d(TAG,"setAsDefaultAccount succeeded!");
      }else{
          Log.d(TAG,"setAsDefaultAccount failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }

 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setAsDefaultAccount(
                     accountId);
      if(result){
          Log.d(TAG,"setAsDefaultAccount succeeded!");
      }else{
          Log.d(TAG,"setAsDefaultAccount failed.");
      }
  } 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_EXCHANGE" permission which has protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public void setClientAuthCert (byte[] certData, String password, long accId)

Since: API level 1

Deprecated in API level 27

API to set the certificate for an account.

Parameters
certData Certificate binary
password Certificate password to extract information
accId Account to be set
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely install the authentication certificate for a Microsoft Exchange ActiveSync account to be used by the client during Secure Sockets Layer (SSL) client authentication. The key to using this API is the enterprise Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String). A user cannot change this parameter. The administrator can determine the status of certificate installation by using the intent ACTION_CBA_INSTALL_STATUS.

  byte[] read2array(String fileName) throws IOException {
      File file = new File(fileName);
      FileInputStream is = null;
      byte[] bytes = null;
      try {
      is = new FileInputStream(file);
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      }
      if (null != is) {
          // Get the size of the file
          long length = file.length();
          if (length > Integer.MAX_VALUE) {
              throw new IOException("The file is too big");
          }
          // Create the byte array to hold the data
          bytes = new byte[(int) length];
          // Read in the bytes
          int offset = 0;
          int numRead = 0;
          while (offset < bytes.length
              && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
              offset += numRead;
          }
          // Ensure all the bytes have been read in
          if (offset < bytes.length) {
              throw new IOException("The file was not completely read: " + file.getName());
          }
          // Close the input stream, all file contents are in the bytes variable
          is.close();
      }
      return bytes;
  }

 void setAccountCertificate() {
      long accountId = -1;
      byte[] certData = null;
      try {
          certData = read2array(certificatePath);
      } catch (IOException e) {
          e.printStackTrace();
      }

      EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
      ExchangeAccountPolicy  exchangeAccountPolicy = edm.
          getExchangeAccountPolicy();

      try {
          accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
          exchangeAccountPolicy.setClientAuthCert(certData, "password245",
             accountId);
      } catch(SecurityException e) {
          Log.w(TAG,"SecurityException: "+e);
      }
  }
 
For Container:
  byte[] read2array(String fileName) throws IOException {
      File file = new File(fileName);
      FileInputStream is = null;
      byte[] bytes = null;
      try {
      is = new FileInputStream(file);
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      }
      if (null != is) {
          // Get the size of the file
          long length = file.length();
          if (length > Integer.MAX_VALUE) {
              throw new IOException("The file is too big");
          }
          // Create the byte array to hold the data
          bytes = new byte[(int) length];
          // Read in the bytes
          int offset = 0;
          int numRead = 0;
          while (offset < bytes.length
              && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
              offset += numRead;
          }
          // Ensure all the bytes have been read in
          if (offset < bytes.length) {
              throw new IOException("The file was not completely read: " + file.getName());
          }
          // Close the input stream, all file contents are in the bytes variable
          is.close();
      }
      return bytes;
  }

 void setAccountCertificate() {
      long accountId = -1;
      byte[] certData = null;
      try {
          certData = read2array(certificatePath);
      } catch (IOException e) {
          e.printStackTrace();
      }

      // When you create container successfully, containerID will be returned via intent.
      // Use this containerID in below API.
      EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
      KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
      ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();

      try {
          accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
          exchangeAccountPolicy.setClientAuthCert(certData, "password245",
             accountId);
      } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public boolean setDataSyncs (boolean syncCalendar, boolean syncContacts, boolean syncTasks, boolean syncNotes, long accId)

Since: API level 2

Deprecated in API level 27

API to select the types of personal information management (PIM) items (contacts, calendar, tasks, notes) to sync on the account.

Parameters
syncCalendar syncCalendar = true, account syncs calendar information syncCalendar = false, account does not sync calendar information
syncContacts syncContacts = true, account syncs contact information syncContacts = false, account does not sync contact information
syncTasks syncTasks = true, account syncs tasks information syncTasks = false, account does not sync tasks information
syncNotes syncNotes = true, account syncs notes information syncNotes = false, account does not sync notes information NOTE: Notes syncing is not supported yet.
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the items that need to be synced for the Microsoft Exchange ActiveSync account. The key to using this API is the managed Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");

      boolean result = exchangeAccountPolicy.setDataSyncs(true, true,false,
           false,accountId);
      if(result){
          Log.d(TAG,"setDataSyncs succeeded!");
      }else{
          Log.d(TAG," setDataSyncs failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");

      boolean result = exchangeAccountPolicy.setDataSyncs(true, true,false,
           false,accountId);
      if(result){
          Log.d(TAG,"setDataSyncs succeeded!");
      }else{
          Log.d(TAG," setDataSyncs failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setForceSMIMECertificateAlias (long accId, String alias, int type)

Since: API level 15

Deprecated in API level 27

API to enforce or reset a certificate alias used for S/MIME messages for specific Exchange account. The user is not allowed to use another certificate alias for that Exchange account.

Note: Only the administrator owner of S/MIME policies is allowed to make changes.

Parameters
accId Exchange account Id
alias Certificate alias to set, null to reset
type Operation type either ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT or ENFORCE_SMIME_ALIAS_TYPE_SIGN
Returns
Throws
SecurityException If caller does not have required permissions
Usage
Administrator can use this API to enforce or reset (if a certificate alias has already been enforced by administrator) a certificate alias used for S/MIME messages for specific Exchange account, either for Signature or Encryption operations. MDM framework will broadcast intent with action ACTION_ENFORCE_SMIME_ALIAS_RESULT with EXTRA_ENFORCE_SMIME_ALIAS_TYPE, EXTRA_ACCOUNT_ID and EXTRA_SMIME_RESULT as extras upon calling this API.

NOTE 1: S/MIME certificate must be installed either in Client Certificate Manager (CCM) keystore or KEYSTORE_FOR_VPN_AND_APPS before calling this API. Please refer either to CCM APIs (KNOX Premium SDK) or installCertificateToKeystore(String, byte[], String, String, int) for further details on how to install a certificate to those keystores, respectively. In case same alias is present on both keystores, the certificate at CCM will be enforced, taking precedence over the one installed at VPN and APPS keystore.

NOTE 2: In MDM 5.4, certificates from CCM keystore only is supported by this API. Certificates from VPN and APPS keystore are also supported by this API from MDM 5.4.1.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  String alias = "test";
  int type = 1; // ExchangeAccountPolicy.ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT;
  try {
      boolean ret = exchangeAccountPolicy.setForceSMIMECertificateAlias(accId, alias, type);
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  String alias = "test";
  int type = 1; // ExchangeAccountPolicy.ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT;
  try {
      boolean ret = exchangeAccountPolicy.setForceSMIMECertificateAlias(accId, alias, type);
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 15
MDM 5.4
Multiuser Environment
User Scope

public boolean setForceSMIMECertificateAlias (long accId, String storageName, String alias, int type)

Since: API level 19

Deprecated in API level 27

API to enforce or reset a certificate alias used for S/MIME messages for specific Exchange account. The user is not allowed to use another certificate alias for that Exchange account.

Note: Only the administrator owner of S/MIME policies is allowed to make changes.

Parameters
accId Exchange account Id
storageName Credential storage name. Passing null or an empty String value will behave same as calling setForceSMIMECertificateAlias(long, String, int)
alias Certificate alias to set, null to reset
type Operation type either ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT or ENFORCE_SMIME_ALIAS_TYPE_SIGN
Returns
Throws
SecurityException If caller does not have required permissions
Usage
Administrator can use this API to enforce or reset (if a certificate alias has already been enforced by administrator) a certificate alias used for S/MIME messages for specific Exchange account, either for Signature or Encryption operations. MDM framework will broadcast intent with action ACTION_ENFORCE_SMIME_ALIAS_RESULT with EXTRA_ENFORCE_SMIME_ALIAS_TYPE, EXTRA_ACCOUNT_ID and EXTRA_SMIME_RESULT as extras upon calling this API.

S/MIME certificate must be installed in the storage passed as parameter in storageName. In order to see how to install certificates in such credential storage, please refer to Universal Credential Manager (UCM) DEV guide.

Passing null or an empty String value at storageName parameter will behave the same as calling setForceSMIMECertificateAlias(long, String, int). In this case, please refer to notes at that API on which keystore will be used to retrieve alias.
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  String alias = "test";
  int type = 1; // ExchangeAccountPolicy.ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT;
  try {
      // Please refer to UCM DEV guide to see how to retrieve storageName parameter
      boolean ret = exchangeAccountPolicy.setForceSMIMECertificateAlias(accId, storageName, alias, type);
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  String alias = "test";
  int type = 1; // ExchangeAccountPolicy.ENFORCE_SMIME_ALIAS_TYPE_ENCRYPT;
  try {
      // Please refer to UCM DEV guide to see how to retrieve storageName parameter
      boolean ret = exchangeAccountPolicy.setForceSMIMECertificateAlias(accId, storageName, alias, type);
  } 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_EXCHANGE" permission which has a protection level of signature.

Depending on the Credential Storage type identified by certificateStorageName parameter, a new permission will also be enforced. System Credential Storages will check for 'com.samsung.android.knox.permission.KNOX_UCM_ESE_MGMT' permission, while non-system ones check for 'com.samsung.android.knox.permission.KNOX_UCM_OTHER_MGMT' permission. Please refer to Universal Credential Manager (UCM) DEV guide in order to have more details of how to get these new permissions.
Since
API level 19
MDM 5.6
Multiuser Environment
User Scope

public boolean setIncomingAttachmentsSize (int size, long accId)

Since: API level 11

Deprecated in API level 27

API to set maximum attachment size allowed for Exchange accounts. (byte)

Parameters
size vale to set maximum attachment size of Exchange accounts.
accId The exchange account id to set maximum attachment size.
Returns
  • true if successful, false otherwise
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to set maximum attachment size allowed for Exchange accounts. (byte)
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.setIncomingAttachmentsSize(1000,accId);
      if (true == enable) {
          // administrator set maximum attachment size of Exchange accounts as 1000 byte.
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
  // When you create container successfully, containerID will be returned via intent.
  // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.setIncomingAttachmentsSize(1000,accId);
      if (true == enable) {
          // administrator set maximum attachment size of Exchange accounts as 1000 byte.
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public boolean setMaxCalendarAgeFilter (int maxage, long accId)

Since: API level 11

Deprecated in API level 27

API to set maximum calendar age allowed for Exchange accounts.

Parameters
maxage All(value 0), 2 weeks(value 4), 1 months(value 5), 3 months(value 6), 6 months (value 7)
accId The exchange account id to set maximum Calendar sync period.
Returns
  • true if successful, false otherwise
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to set maximum calendar age allowed for Exchange accounts.
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.setMaxCalendarAgeFilter(4,accId);
      if (true == enable) {
          // administrator set maximum calendar age of Exchange accounts as 6 months.
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
  // When you create container successfully, containerID will be returned via intent.
  // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.setMaxCalendarAgeFilter(4,accId);
      if (true == enable) {
          // administrator set maximum calendar age of Exchange accounts as 6 months.
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public boolean setMaxEmailAgeFilter (int maxage, long accId)

Since: API level 11

Deprecated in API level 27

API to set maximum Email age of Exchange accounts.

Parameters
maxage All(int value 0), 1 day (int value 1), 3 day(int value 2), 1 week (int value 3), 2 weeks(int value 4), 1 months(int value 5).
accId The exchange account id to set maximum Email sync period.
Returns
  • true if successful, false otherwise
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to set maximum Email age of Exchange accounts.
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.setMaxEmailAgeFilter(4,accId);
      if (true == enable) {
          // administrator set maximum Email age of Exchange accounts as 2 weeks.
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
  // When you create container successfully, containerID will be returned via intent.
  // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      boolean enable = exchangeAccountPolicy.setMaxEmailAgeFilter(4,accId);
      if (true == enable) {
          // administrator set maximum Email age of Exchange accounts as 2 weeks.
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public boolean setMaxEmailBodyTruncationSize (int size, long accId)

Since: API level 11

Deprecated in API level 27

API to set maximum Email Body Truncation size of Exchange accounts. (kbyte)

Parameters
size value to set maximum Email Body Truncation size of Exchange accounts. (kbyte)
accId The exchange account id to set maximum Email Body Truncation Size.
Returns
  • true if successful, false otherwise
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to set maximum Email Body Truncation size of Exchange accounts. (kbyte)
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.setMaxEmailBodyTruncationSize(20,accId);
      if (true == enable) {
          // administrator set maximum Email Body Truncation size of Exchange accounts as 20 kb.
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      boolean enable = exchangeAccountPolicy.setMaxEmailBodyTruncationSize(20,accId);
      if (true == enable) {
          // administrator set maximum Email Body Truncation size of Exchange accounts as 20 kb.
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public boolean setMaxEmailHTMLBodyTruncationSize (int size, long accId)

Since: API level 11

Deprecated in API level 27

API to set maximum Email HTML Body Truncation size of Exchange accounts. (kbyte)

Parameters
size value to set maximum Email HTML Body Truncation size of Exchange accounts. (kbyte)
accId The exchange account id to set maximum Email HTML Body Truncation Size.
Returns
  • true if successful, false otherwise
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to set maximum Email HTML Body Truncation size of Exchange accounts. (kbyte)
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.setMaxEmailBodyTruncationSize(20,accId);
      if (true == enable) {
          // administrator set maximum Email HTML Body Truncation size of Exchange accounts as 20 kb.
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean enable = exchangeAccountPolicy.setMaxEmailBodyTruncationSize(20,accId);
      if (true == enable) {
          // administrator set maximum Email HTML Body Truncation size of Exchange accounts as 20 kb.
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public boolean setPassword (String password, long accId)

Since: API level 1

Deprecated in API level 27

API to change the password of the Microsoft Exchange account.

Parameters
password Password String
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the password of the Microsoft Exchange ActiveSync account. The key to using this API is the enterprise Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setPassword("password@123",
                           accountId);
      if(result){
          Log.d(TAG,"setPassword succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
     }else{
          Log.d(TAG,"setPassword failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setPassword("password@123",
                           accountId);
      if(result){
          Log.d(TAG,"setPassword succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
     }else{
          Log.d(TAG,"setPassword failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public boolean setPastDaysToSync (int pastDaysToSync, long accId)

Since: API level 1

Deprecated in API level 27

API to change the number of previous days to sync email in a Microsoft Exchange account.

Parameters
pastDaysToSync 1 day (int value 1), 3 days(int value 2), 1 week (int value 3), 2 weeks (int value 4), 1 month (int value 5)
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the number of previous days that email should be synced for a Microsoft Exchange ActiveSync account. The key to using this API is the managed Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setPastDaysToSync(2,
                      accountId);
      if(result){
          Log.d(TAG,"setPastDaysToSync succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
     }else{
          Log.d(TAG,"setPastDaysToSync failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setPastDaysToSync(2,
                      accountId);
      if(result){
          Log.d(TAG,"setPastDaysToSync succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
     }else{
          Log.d(TAG,"setPastDaysToSync failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public boolean setRequireEncryptedSMIMEMessages (long accId, boolean enable)

Since: API level 6

Deprecated in API level 27

API to require S/MIME certificate to encrypt messages for a specific exchange account.

Note: Only the administrator owner of S/MIME policies is allowed to make changes.

Parameters
accId The exchange account id.
enable true to enable encrypted S/MIME messages for the given account, false to disable encrypted S/MIME messages.
Returns
  • true on success, false on failure.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to require encrypted S/MIME messages for an exchange account.
  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean result = exchangeAccountPolicy.setRequireEncryptedSMIMEMessages(accId, true);
      if (true == result) {
          // encrypted S/MIME messages are now required for this account
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
  // When you create container successfully, containerID will be returned via intent.
  // Use this containerID in below API.
  EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
  KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  long accId = 1;
  try {
      boolean result = exchangeAccountPolicy.setRequireEncryptedSMIMEMessages(accId, true);
      if (true == result) {
          // encrypted S/MIME messages are now required for this account
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 6
MDM 4.0
Multiuser Environment
User Scope

public boolean setRequireSignedSMIMEMessages (long accId, boolean enable)

Since: API level 6

Deprecated in API level 27

API to set whether S/MIME certificate is required for signing messages for an specified account.

Note: Only the administrator owner of S/MIME policies is allowed to make changes.

Parameters
accId The exchange account id to be configured.
enable true to enable signed S/MIME messages for the given account. false to disable signed S/MIME messages.
Returns
  • true on success, false on failure.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to require signed S/MIME messages for an exchange account.
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      boolean result = exchangeAccountPolicy.setRequireSignedSMIMEMessages(accId, true);
      if (true == result) {
          // signed S/MIME messages are now required for this account
      }
  } catch (SecurityException e) {
      Log.w(TAG,"SecurityException: " + e);
  }
 
For Container:
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      boolean result = exchangeAccountPolicy.setRequireSignedSMIMEMessages(accId, true);
      if (true == result) {
          // signed S/MIME messages are now required for this account
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 6
MDM 4.0
Multiuser Environment
User Scope

public boolean setSSL (boolean enableSSL, long accId)

Since: API level 1

Deprecated in API level 27

API to enable or disable the Secure Sockets Layer (SSL) setting of the Microsoft Exchange account.

Parameters
enableSSL true to enable, false to disable
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure whether SSL transport should be used when connecting with the server. The key to using this API is the managed Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");

      boolean  result = exchangeAccountPolicy.setSSL(true,
                      accountId);
      if(result){
          Log.d(TAG,"setSSL succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG,"setSSL failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");

      boolean  result = exchangeAccountPolicy.setSSL(true,
                      accountId);
      if(result){
          Log.d(TAG,"setSSL succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG,"setSSL failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public boolean setSignature (String signature, long accId)

Since: API level 1

Deprecated in API level 27

API to change the user signature in the Microsoft Exchange account.

Parameters
signature Signature String
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the user signature, which appears at the bottom of every outgoing email, in a Microsoft Exchange ActiveSync account. The key to using this API is the enterprise Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setSignature(
                  "myTestSignature",accountId);
      if(result){
          Log.d(TAG,"setSignature succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
     }else{
          Log.d(TAG,"setSignature failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean  result  = exchangeAccountPolicy.setSignature(
                  "myTestSignature",accountId);
      if(result){
          Log.d(TAG,"setSignature succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
     }else{
          Log.d(TAG,"setSignature failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 1
MDM 1.0
Multiuser Environment
User Scope

public boolean setSyncPeakTimings (int peakDays, int peakStartMinute, int peakEndMinute, long accId)

Since: API level 2

Deprecated in API level 27

API to set the sync interval peak days and peak timings of the account.

Parameters
peakDays Peak days for sync schedule, put decimal number after calculating binary number. Sequence of binary number - SAT,FRI,THU,WED,TUE,MON,SUN eg: 62 (0x3e) for Fri|Thu|Wed|Tue|Mon (0111110) 73 (0x49) for Sat|Wed|Sun (1001001) 66 (0x42) for Sat|Mon (1000010)
peakStartMinute Peak start time in minutes. For example: 8AM 8hr x 60 = 480 9AM 9hr x 60 = 540
peakEndMinute Peak end time in minutes. For example: 5PM 17hr x 60 = 1020 6PM 18hr x 60 = 1080
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the sync interval peak timings for the Microsoft Exchange ActiveSync account. The key to using this API is the enterprise Microsoft Exchange ActiveSync account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean result = exchangeAccountPolicy.setSyncPeakTimings(62, 480,
              1020, accountId);
      if(result){
          Log.d(TAG,"setSyncPeakTimings succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG," setSyncPeakTimings failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean result = exchangeAccountPolicy.setSyncPeakTimings(62, 480,
              1020, accountId);
      if(result){
          Log.d(TAG,"setSyncPeakTimings succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG," setSyncPeakTimings failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setSyncSchedules (int peakSyncSchedule, int offPeakSyncSchedule, int roamingSyncSchedule, long accId)

Since: API level 2

Deprecated in API level 27

API to change the number of previous days to sync the account.

Parameters
peakSyncSchedule Frequency to sync email during peak time
  • Value -2 - Automatic push
  • Value -1 - Never
  • Value 5 - 5 minutes
  • Value 10 - 10 minutes
  • Value 15 - 15 minutes
  • Value 30 - 30 minutes
  • Value 60 - 1 hour
  • Value 240 - 4 hours
  • Value 720 - 12 hours
offPeakSyncSchedule Frequency to sync email during off-peak time
  • Value -2 - Automatic push
  • Value -1 - Never
  • Value 5 - 5 minutes
  • Value 10 - 10 minutes
  • Value 15 - 15 minutes
  • Value 30 - 30 minutes
  • Value 60 - 1 hour
  • Value 240 - 4 hours
  • Value 720 - 12 hours
roamingSyncSchedule 0 - Manual 1 - Use sync settings
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the advanced sync schedule of the Microsoft Exchange ActiveSync account. The key to using this API is the enterprise Microsoft Exchange ActiveSyncaccount Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

 long  accountId = -1;
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean result = exchangeAccountPolicy.setSyncSchedules(-2, 60, 0,
                  accountId);
      if(result){
          Log.d(TAG,"setSyncSchedules succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG," setSyncSchedules failed.");
      }
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
 
For Container:
 long  accountId = -1;
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
  ExchangeAccountPolicy  exchangeAccountPolicy = kcm.getExchangeAccountPolicy();
  try {
      accountId = exchangeAccountPolicy.getAccountId("easDomain",
             "testeasid","easserver.com");
      boolean result = exchangeAccountPolicy.setSyncSchedules(-2, 60, 0,
                  accountId);
      if(result){
          Log.d(TAG,"setSyncSchedules succeeded!");
          // Administrator need to call sendAccountsChangedBroadcast() API
          // to notify the  exchange(EAS) account changes.
          exchangeAccountPolicy.sendAccountsChangedBroadcast();
      }else{
          Log.d(TAG," setSyncSchedules failed.");
      }
  } 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_EXCHANGE" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope