Since: Knox API Level 6
public class

EnterpriseLicenseManager

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.license.EnterpriseLicenseManager

Class Overview

This class provides APIs to activate Enterprise license on device

Since
API level 6
MDM 4.0

Summary

Constants
String ACTION_LICENSE_STATUS Broadcast Action : Sent to inform administrator about result of License activation or validation result.
int ERROR_INTERNAL Internal error.
int ERROR_INTERNAL_SERVER Internal server error.
int ERROR_INVALID_LICENSE Invalid license.
int ERROR_INVALID_PACKAGE_NAME Invalid package name.
int ERROR_LICENSE_TERMINATED License terminated.
int ERROR_NETWORK_DISCONNECTED Network disconnected.
int ERROR_NETWORK_GENERAL General network error.
int ERROR_NONE Success.
int ERROR_NOT_CURRENT_DATE Not current date.
int ERROR_NULL_PARAMS null parameter.
int ERROR_SIGNATURE_MISMATCH Caller package signature mismatch.
int ERROR_UNKNOWN Unknown error.
int ERROR_USER_DISAGREES_LICENSE_AGREEMENT User disagrees License agreement.
int ERROR_VERSION_CODE_MISMATCH Caller package version code mismatch.
String EXTRA_LICENSE_ATTESTATION_STATUS This constant is deprecated. in API level 29
String EXTRA_LICENSE_ERROR_CODE Used as an integer extra field with ACTION_LICENSE_STATUS.
String EXTRA_LICENSE_GRANTED_PERMISSIONS Used as StringArrayList extra field with ACTION_LICENSE_STATUS.
String EXTRA_LICENSE_RESULT_TYPE Used as integer extra field with ACTION_LICENSE_STATUS.
String EXTRA_LICENSE_STATUS This constant is deprecated. Not supported since KNOX 3.2. Use EXTRA_LICENSE_ERROR_CODE to check status.
String LICENSE_LOG_API The lookup key for log data in JSON array returned by getApiCallDataByAdmin(String)
String LICENSE_LOG_DATE The lookup key for log date in JSON array returned by getApiCallDataByAdmin(String)
int LICENSE_RESULT_TYPE_ACTIVATION Result Activation.
int LICENSE_RESULT_TYPE_VALIDATION Result Validation.
int STATUS_ATTESTED This constant is deprecated. in API level 29
int STATUS_DEVICE_NOT_SUPPORTED This constant is deprecated. in API level 29
int STATUS_NOT_ATTESTED This constant is deprecated. in API level 29
int STATUS_UNKNOWN_ERROR This constant is deprecated. in API level 29
Public Methods
void activateLicense(String licenseKey)
API to activate enterprise license.
void activateLicense(String licenseKey, String pkgName)
API to activate enterprise license.
JSONArray getApiCallDataByAdmin(String packageName)
API to retrieve API call data for the given packagename on device.
static EnterpriseLicenseManager getInstance(Context context)
API to create an instance of EnterpriseLicenseManager class.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_LICENSE_STATUS

Since: Knox API Level 6

Broadcast Action : Sent to inform administrator about result of License activation or validation result. This targeted broadcast is sent only to the administrator who calls the activateLicense(String) API. Also system does periodic validation of Enterprise license, administrator continuously needs to listen for this intent after activation. The intent will have the following extra value:

EXTRA_LICENSE_STATUS:
"success", "fail".

EXTRA_LICENSE_ERROR_CODE:
ERROR_NONE
ERROR_NULL_PARAMS
ERROR_UNKNOWN
ERROR_INVALID_LICENSE
ERROR_LICENSE_TERMINATED
ERROR_INTERNAL
ERROR_INTERNAL_SERVER
ERROR_NETWORK_DISCONNECTED
ERROR_NETWORK_GENERAL
ERROR_USER_DISAGREES_LICENSE_AGREEMENT
ERROR_INVALID_PACKAGE_NAME
ERROR_NOT_CURRENT_DATE

EXTRA_LICENSE_RESULT_TYPE:
LICENSE_RESULT_TYPE_ACTIVATION
LICENSE_RESULT_TYPE_VALIDATION

EXTRA_LICENSE_GRANTED_PERMISSIONS

EXTRA_LICENSE_ATTESTATION_STATUS:
STATUS_ATTESTED
STATUS_NOT_ATTESTED
STATUS_DEVICE_NOT_SUPPORTED
STATUS_UNKNOWN_ERROR

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

public static final int ERROR_INTERNAL

Since: Knox API Level 6

Internal error.

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

public static final int ERROR_INTERNAL_SERVER

Since: Knox API Level 6

Internal server error.

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

public static final int ERROR_INVALID_LICENSE

Since: Knox API Level 6

Invalid license.

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

public static final int ERROR_INVALID_PACKAGE_NAME

Since: Knox API Level 9

Invalid package name.

Since
API level 9
MDM 4.1
Constant Value: 204 (0x000000cc)

public static final int ERROR_LICENSE_TERMINATED

Since: Knox API Level 6

License terminated.

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

public static final int ERROR_NETWORK_DISCONNECTED

Since: Knox API Level 6

Network disconnected.

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

public static final int ERROR_NETWORK_GENERAL

Since: Knox API Level 6

General network error.

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

public static final int ERROR_NONE

Since: Knox API Level 6

Success.

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

public static final int ERROR_NOT_CURRENT_DATE

Since: Knox API Level 9

Not current date.

Since
API level 9
MDM 4.1
Constant Value: 205 (0x000000cd)

public static final int ERROR_NULL_PARAMS

Since: Knox API Level 6

null parameter.

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

public static final int ERROR_SIGNATURE_MISMATCH

Since: Knox API Level 20

Caller package signature mismatch.

Since
API level 20
MDM 5.7
Constant Value: 206 (0x000000ce)

public static final int ERROR_UNKNOWN

Since: Knox API Level 6

Unknown error.

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

public static final int ERROR_USER_DISAGREES_LICENSE_AGREEMENT

Since: Knox API Level 6

User disagrees License agreement.

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

public static final int ERROR_VERSION_CODE_MISMATCH

Since: Knox API Level 20

Caller package version code mismatch.

Since
API level 20
MDM 5.7
Constant Value: 207 (0x000000cf)

public static final String EXTRA_LICENSE_ATTESTATION_STATUS

Since: Knox API Level 20

This constant is deprecated.
in API level 29

Used as integer extra field with ACTION_LICENSE_STATUS. Contains the Remote Attestation status during license activation.

Since
API level 20
MDM 5.7
Constant Value: "com.samsung.android.knox.intent.extra.LICENSE_ATTESTATION_STATUS"

public static final String EXTRA_LICENSE_ERROR_CODE

Since: Knox API Level 6

Used as an integer extra field with ACTION_LICENSE_STATUS. Contains the error code of license activation or validation result. In case of success, this extra will contain ERROR_NONE.

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

public static final String EXTRA_LICENSE_GRANTED_PERMISSIONS

Since: Knox API Level 30

Used as StringArrayList extra field with ACTION_LICENSE_STATUS. Contains the list of permissions given after an activation or validation.

Since
API level 30
KNOX 3.4.1
Constant Value: "com.samsung.android.knox.intent.extra.LICENSE_GRANTED_PERMISSIONS"

public static final String EXTRA_LICENSE_RESULT_TYPE

Since: Knox API Level 9

Used as integer extra field with ACTION_LICENSE_STATUS. This will tell whether this is activation or validation result.

Since
API level 9
MDM 4.1
Constant Value: "com.samsung.android.knox.intent.extra.LICENSE_RESULT_TYPE"

public static final String EXTRA_LICENSE_STATUS

Since: Knox API Level 6

This constant is deprecated.
Not supported since KNOX 3.2. Use EXTRA_LICENSE_ERROR_CODE to check status.

Used as string extra field with ACTION_LICENSE_STATUS. Contains the result of the license activation or validation result.

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

public static final String LICENSE_LOG_API

Since: Knox API Level 6

The lookup key for log data in JSON array returned by getApiCallDataByAdmin(String)

Since
API level 6
MDM 4.0
Constant Value: "api_call"

public static final String LICENSE_LOG_DATE

Since: Knox API Level 6

The lookup key for log date in JSON array returned by getApiCallDataByAdmin(String)

Since
API level 6
MDM 4.0
Constant Value: "log_date"

public static final int LICENSE_RESULT_TYPE_ACTIVATION

Since: Knox API Level 9

Result Activation.

Since
API level 9
MDM 4.1
Constant Value: 800 (0x00000320)

public static final int LICENSE_RESULT_TYPE_VALIDATION

Since: Knox API Level 9

Result Validation.

Since
API level 9
MDM 4.1
Constant Value: 801 (0x00000321)

public static final int STATUS_ATTESTED

Since: Knox API Level 20

This constant is deprecated.
in API level 29

Device is attested.

Since
API level 20
MDM 5.7
Constant Value: 0 (0x00000000)

public static final int STATUS_DEVICE_NOT_SUPPORTED

Since: Knox API Level 20

This constant is deprecated.
in API level 29

Device does not support Attestation

Since
API level 20
MDM 5.7
Constant Value: 2 (0x00000002)

public static final int STATUS_NOT_ATTESTED

Since: Knox API Level 20

This constant is deprecated.
in API level 29

Device is not attested.

Since
API level 20
MDM 5.7
Constant Value: 1 (0x00000001)

public static final int STATUS_UNKNOWN_ERROR

Since: Knox API Level 20

This constant is deprecated.
in API level 29

Attestation unknown error

Since
API level 20
MDM 5.7
Constant Value: 3 (0x00000003)

Public Methods

public void activateLicense (String licenseKey)

Since: Knox API Level 6

API to activate enterprise license.

Parameters
licenseKey provided by the MDM admin
Usage
Administrator can use this API to activate Enterprise license on device for accessing MDM APIs. MDM will broadcast intent with action ACTION_LICENSE_STATUS with string EXTRA_LICENSE_STATUS, integer EXTRA_LICENSE_ERROR_CODE, integer EXTRA_LICENSE_RESULT_TYPE and integer EXTRA_LICENSE_ATTESTATION_STATUS as extras in intent upon calling this API. This is a targeted broadcast intent, sent only to the administrator calling the activateLicense(String).

NOTE:

Administrator must be active before calling this API.

Since
API level 6
MDM 4.0

public void activateLicense (String licenseKey, String pkgName)

Since: Knox API Level 11

API to activate enterprise license.

Parameters
licenseKey provided by the caller application
pkgName package name of the caller application calling this API.
Usage
Administrator can use this API to activate Enterprise license on device for accessing MDM APIs. MDM will broadcast intent with action ACTION_LICENSE_STATUS with string EXTRA_LICENSE_STATUS, integer EXTRA_LICENSE_ERROR_CODE, integer EXTRA_LICENSE_RESULT_TYPE and integer EXTRA_LICENSE_ATTESTATION_STATUS as extras in intent upon calling this API. This is a targeted broadcast intent, sent only to the administrator calling the activateLicense(String, String).

NOTE:

Active/non-active administrator or any other application can call this API.

Since
API level 11
MDM 5.0

public JSONArray getApiCallDataByAdmin (String packageName)

Since: Knox API Level 6

API to retrieve API call data for the given packagename on device.

Parameters
packageName Packagename for which api data to be retrieved
Returns
  • the API Call Data in the form of a JSONObject array corresponding to the given packageName, else null, if no logs exist for that packageName
Usage
Used to get API call data in JSONArray in below key value format.
[{
"log_date" :"DATE1" ,
"api_call" : {"API_1" : "CALLS_VALUE" , ... , "API_n" : "CALLS_VALUE"}
"log_date" :"DATE2" ,
"api_call" : {"API_1" : "CALLS_VALUE" , ... , "API_n" : "CALLS_VALUE"}
}]

 EnterpriseLicenseManager mgr = EnterpriseLicenseManager.getInstance(context);
 String pkgName = "com.xyz.testadmin";
 JSONArray arr = mgr.getApiCallDataByAdmin(pkgName);
 if (arr == null){
    Log.w("EnterpriseLicenseManager.getApiCallDataByAdmin() failed");
    return;
 }
 String result = arr.toString();
 Log.w("EnterpriseLicenseManager.getApiCallDataByAdmin() result = " + result);
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_LICENSE_LOG" permission which has a protection level of signature.
Since
API level 6
MDM 4.0

public static EnterpriseLicenseManager getInstance (Context context)

Since: Knox API Level 6

API to create an instance of EnterpriseLicenseManager class.

Parameters
context context of the application or service using this class
Returns
Usage
Used to get access to EnterpriseLicenseManager object

 EnterpriseLicenseManager mgr = EnterpriseLicenseManager.getInstance(context);
 
Since
API level 6
MDM 4.0