Since: API level 2
public class

DeviceInventory

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.deviceinfo.DeviceInventory

Class Overview

This class provides APIs to retrieve information on the device inventory.

Since
API level 2
MDM 2.0

Summary

Constants
String ACTION_SIM_CARD_CHANGED Deprecated in API level 37
String EXTRA_SIM_CHANGE_INFO The lookup key for a SimChangeInfo object.
Public Methods
long getAvailableCapacityExternal()
Deprecated in API level 35
long getAvailableCapacityInternal()
Deprecated in API level 35
String getDeviceOS()
Deprecated in API level 35
String getDeviceOSVersion()
Deprecated in API level 35
int getDroppedCallsCount()
API to retrieve the number of dropped calls.
String getKnoxServiceId()
API to get Knox Service ID.
SimChangeInfo getLastSimChangeInfo()
Deprecated in API level 35
int getMissedCallsCount()
API to retrieve the number of missed calls.
String getSalesCode()
API to get the Samsung CSC Code.
String getSerialNumber()
Deprecated in API level 30
NOTE: This API is not available since Android 11.
int getSuccessCallsCount()
API to retrieve the number of calls completed successfully.
long getTotalCapacityExternal()
Deprecated in API level 35
long getTotalCapacityInternal()
Deprecated in API level 35
boolean isDeviceLocked()
Deprecated in API level 30
boolean isDeviceSecure()
Deprecated in API level 30
boolean resetCallsCount()
API to reset the counters that tally call counts.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_SIM_CARD_CHANGED

Since: API level 2

Deprecated in API level 37

Broadcast Action: The sim card has changed. The intent will have the following extra values:

The parcelable extra EXTRA_SIM_CHANGE_INFO is also contained in this intent which identifies the type of sim change operation, the time of change and old and new sim card data.

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

public static final String EXTRA_SIM_CHANGE_INFO

Since: API level 2

The lookup key for a SimChangeInfo object.

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

Public Methods

public long getAvailableCapacityExternal ()

Since: API level 2

Deprecated in API level 35

API to retrieve the available capacity in bytes of the external SD card.

Returns
  • Available capacity in bytes. Returns -1 if the SD card is unavailable or any other error occurs.
Usage
An administrator can use this API to get the available capacity of the external SD card.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory  deviceInventoryPolicy = edm.getDeviceInventory();
  long  bytes =  deviceInventoryPolicy.getAvailableCapacityExternal();
  
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope

public long getAvailableCapacityInternal ()

Since: API level 2

Deprecated in API level 35

API to retrieve the available capacity in bytes of the internal SD card and phone memory.

Returns
  • Available capacity in bytes. Returns -1 if SD card is unavailable or if any other error occurs.
Usage
An administrator can use this API to get the available capacity of the internal SD card and phone memory.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory  deviceInventoryPolicy = edm.getDeviceInventory();
  long  bytes =  deviceInventoryPolicy.getAvailableCapacityInternal();
 
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope

public String getDeviceOS ()

Since: API level 2

Deprecated in API level 35

API to retrieve the operating system.

Returns
  • If device operating system is set it is returned, else null.
Usage
An administrator can use this API to determine the operating system.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory  deviceInventoryPolicy = edm.getDeviceInventory();
  String  deviceOS =  deviceInventoryPolicy.getDeviceOS();
  if(null != deviceOS)
  {
      //if device operating system  is set it is returned else null.
  }
  // Sample Output
  // Linux
 
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope

public String getDeviceOSVersion ()

Since: API level 2

Deprecated in API level 35

API to retrieve the operating system version of the device.

Returns
  • If device operating system version is set it is returned, else null.
Usage
An administrator can use this API to get the operating system version of the device.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory  deviceInventoryPolicy = edm.getDeviceInventory();
  String  deviceOSVersion =  deviceInventoryPolicy.getDeviceOSVersion();
  if(null != deviceOSVersion)
  {
      //if device operating system version  is set it is returned
      //else null.
  }
  // Sample Output
  // 2.6.35.7
 
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope
See Also

public int getDroppedCallsCount ()

Since: API level 2

API to retrieve the number of dropped calls.

Returns
  • The number of dropped calls if successful, else -1.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get the number of dropped calls.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory deviceInventoryPolicy = edm.getDeviceInventory();
  
  int droppedCallsCount = deviceInventoryPolicy.getDroppedCallsCount();
  if(0 <= droppedCallsCount)
  {
      //print dropped call count
  }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_INVENTORY" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope

public String getKnoxServiceId ()

Since: API level 33

API to get Knox Service ID.

Returns
  • If Knox Service ID is set, then it is returned, else null or an empty String
Usage
An app can use this API to get Knox service ID defined by Knox Cloud Services. To use this API, the app must be registered in allowed list by the Knox Cloud Services.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 DeviceInventory deviceInventoryPolicy = edm.getDeviceInventory();

 String id = deviceInventoryPolicy.getKnoxServiceId();
 if (!TextUtils.isEmpty(id)) {
     // Knox Service ID is set
 }
 
Since
API level 33
Multiuser Environment
Global Scope

public SimChangeInfo getLastSimChangeInfo ()

Since: API level 2

Deprecated in API level 35

API to get SIM card information regarding the last time that the card was changed.

Returns
  • Information regarding the last SIM card change operation if successful, else null.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to detect SIM card-related changes including removal and insertion and take appropriate action based on enterprise policy.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory devInv = edm.getDeviceInventory();
  try {
      SimChangeInfo sci = devInv.getLastSimChangeInfo();
      //print SIM change Info
      Log.d(TAG,"changeTime : " + sci.changeTime);
      Log.d(TAG,"previousSimInfo.countryIso : " +sci.previousSimInfo.countryIso);
      Log.d(TAG,"previousSimInfo.operator : " + sci.previousSimInfo.operator);
      Log.d(TAG,"previousSimInfo.operatorName : " + sci.previousSimInfo.operatorName);
      Log.d(TAG,"previousSimInfo.phoneNumber : " + sci.previousSimInfo.phoneNumber);
      Log.d(TAG,"previousSimInfo.serialNumber :" + sci.previousSimInfo.serialNumber);
      Log.d(TAG,"currentSimInfo.countryIso : " + sci.currentSimInfo.countryIso);
      Log.d(TAG,"currentSimInfo.operator : " + sci.currentSimInfo.operator);
      Log.d(TAG,"currentSimInfo.operatorName : " + sci.currentSimInfo.operatorName);
      Log.d(TAG,"currentSimInfo.phoneNumber : " + sci.currentSimInfo.phoneNumber);
      Log.d(TAG,"currentSimInfo.serialNumber :" + sci.currentSimInfo.serialNumber);
  } catch(SecurityException e) {
      Log.w(TAG,"SecurityException: "+e);
  }
  // Sample Output:
  // changeTime                   :1322738274410
  // previousSimInfo.countryIso   :in
  // previousSimInfo.operator     :40471
  // previousSimInfo.operatorName :BSNL MOBILE
  // previousSimInfo.serialNumber :89917110359178254573
  // currentSimInfo.countryIso    :in
  // currentSimInfo.operator      :40471
  // previousSimInfo.operatorName :BSNL MOBILE
  // currentSimInfo.phoneNumbe    :8088548602
  // currentSimInfo.serialNumber  :89917110349178255375

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_INVENTORY" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope

public int getMissedCallsCount ()

Since: API level 2

API to retrieve the number of missed calls.

Returns
  • The number of missed calls if successful, else -1.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get the number of missed calls.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory deviceInventoryPolicy = edm.getDeviceInventory();
  
  int missedCallsCount = deviceInventoryPolicy.getMissedCallsCount();
  if(0 <= missedCallsCount)
  {
      //print missed call count
  }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_INVENTORY" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope

public String getSalesCode ()

Since: API level 20

API to get the Samsung CSC Code.

Returns
  • String Sales Code
Usage

An administrator can use this API to get the Samsung CSC(Consumer Software Customization) code

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 DeviceInventory devInv = edm.getDeviceInventory();
 String result = devInv.getSalesCode();
 if(result != null && result.equals("SKT"){
   // SKT device 
 }else if(result != null && result.equals("SPR"){
   // Sprint device
 }
 
Since
API level 20
MDM 5.7
Multiuser Environment
Global Scope

public String getSerialNumber ()

Since: API level 2

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

API to retrieve the device serial number.

Returns
  • If serial number is set then actual serial number is returned, else null.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get the device serial number, which is embedded in the hardware.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory deviceInventoryPolicy = edm.getDeviceInventory();
  String serialNumber = deviceInventoryPolicy.getSerialNumber();
  if(null != serialNumber)
  {
      //if serial number is set it is returned.
  }
  // Sample Output
  // 1234567890
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_INVENTORY" permission which has a protection level of signature. (Since Knox API level 26)
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public int getSuccessCallsCount ()

Since: API level 2

API to retrieve the number of calls completed successfully.

Returns
  • The number of calls completed successfully if successful, else -1.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get the number of calls completed successfully.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory deviceInventoryPolicy = edm.getDeviceInventory();
  
  int successCallsCount = deviceInventoryPolicy.getSuccessCallsCount();
  if(0 <= successCallsCount)
  {
      //print successful call count
  }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_INVENTORY" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope

public long getTotalCapacityExternal ()

Since: API level 2

Deprecated in API level 35

API to retrieve the total capacity in bytes of the external SD card.

Returns
  • Total capacity of external SD card in bytes or -1 if the SD card is unavailable or any other error occurs
Usage
An administrator can use this API to get the total capacity of the external SD card.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory  deviceInventoryPolicy = edm.getDeviceInventory();
  long  bytes =  deviceInventoryPolicy.getTotalCapacityExternal();
  
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope

public long getTotalCapacityInternal ()

Since: API level 2

Deprecated in API level 35

API to retrieve the total capacity in bytes of the internal SD card and phone memory.

Returns
  • Total capacity in bytes. Returns -1 if the SD card is unavailable or any other error occurs.
Usage
An administrator can use this API to get the total capacity of the internal SD card and phone memory.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory  deviceInventoryPolicy = edm.getDeviceInventory();
  long  bytes =  deviceInventoryPolicy.getTotalCapacityInternal();
 
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope

public boolean isDeviceLocked ()

Since: API level 2

Deprecated in API level 30

API to check whether device is currently locked.

Returns
  • true if device is locked, false if device is unlocked
Usage
An administrator can use this API to check whether the device is currently locked.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory  deviceInventoryPolicy = edm.getDeviceInventory();
  boolean  result =  deviceInventoryPolicy.isDeviceLocked();
  if(true == result)
  {
      //device is locked
  }
  
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope
See Also

public boolean isDeviceSecure ()

Since: API level 2

Deprecated in API level 30

API to check whether a device is secured by a password, PIN, or pattern.

Returns
  • true if device is protected, false if device is not protected
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to check whether the device is secure. To secure the device, the administrator can silently set the password, PIN, or pattern.

  EnterpriseDeviceManager edm = (EnterpriseDeviceManager)getSystemService(
                  EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE);
  DeviceInventory  deviceInventoryPolicy = edm.getDeviceInventory();
  boolean  result =  deviceInventoryPolicy.isDeviceSecure();
  if(true == result)
  {
      //device is secure
  }

  
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_INVENTORY" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope
See Also

public boolean resetCallsCount ()

Since: API level 2

API to reset the counters that tally call counts.

Returns
  • true if call count reset successfully, else false.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to reset the counters that tally calls count.

  EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
  DeviceInventory deviceInventoryPolicy = edm.getDeviceInventory();
  
  boolean result = deviceInventoryPolicy.resetCallsCount();
  if(true == result)
  {
      //call log reset
  }
 

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

Since
API level 2
MDM 2.0
Multiuser Environment
Global Scope