Since: API level 34
public class

PeripheralManager

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.ex.peripheral.PeripheralManager

Deprecated in API level 37

Class Overview

Public interface to manage peripheral service

Since
API level 34
Knox 3.7.1

Summary

Constants
int RESULT_CODE_FAIL_PERMISSION_ERROR Deprecated in API level 37
int RESULT_CODE_FAIL_SERVICE_UNAVAILABLE Deprecated in API level 37
int RESULT_CODE_FAIL_WRONG_ARGUMENT Deprecated in API level 37
int RESULT_CODE_INVALID Deprecated in API level 37
int RESULT_CODE_SUCCESS Deprecated in API level 37
Public Methods
int beep(String peripheralId, int milliseconds, Bundle option, PeripheralResultListener listener)
Deprecated in API level 37
int clearMemory(String peripheralId, String clearOption, PeripheralResultListener listener)
Deprecated in API level 37
int connectPeripheral(BluetoothDevice peripheral, PeripheralResultListener listener)
Deprecated in API level 37
int disable()
Deprecated in API level 37
int disconnectPeripheral(String peripheralId, PeripheralResultListener listener)
Deprecated in API level 37
int displayText(String peripheralId, String text, int milliseconds, Bundle option, PeripheralResultListener listener)
Deprecated in API level 37
int enable(Bundle profile)
Deprecated in API level 37
int getAvailablePeripherals(PeripheralResultListener listener)
Deprecated in API level 37
int getBluetoothPeripherals(String option, PeripheralResultListener listener)
Deprecated in API level 37
int getConfiguration(String peripheralId, List<String> keyList, PeripheralResultListener listener)
Deprecated in API level 37
int getConnectionProfile(String peripheralId, PeripheralResultListener listener)
Deprecated in API level 37
int getInformation(PeripheralResultListener listener)
Deprecated in API level 37
static PeripheralManager getInstance(Context context)
Deprecated in API level 37
int getPairingBarcodeData(String peripheralId, PeripheralResultListener listener)
Deprecated in API level 37
int getStoredData(String peripheralId, PeripheralResultListener listener)
Deprecated in API level 37
int getSupportedPeripherals(PeripheralResultListener listener)
Deprecated in API level 37
boolean isEnabled()
Deprecated in API level 37
boolean isStarted()
Deprecated in API level 37
int registerDataListener(PeripheralDataListener listener)
Deprecated in API level 37
int registerInfoListener(PeripheralInfoListener listener)
Deprecated in API level 37
int registerStateListener(PeripheralStateListener listener)
Deprecated in API level 37
int resetPeripheral(String peripheralId, String resetOption, PeripheralResultListener listener)
Deprecated in API level 37
int setConfiguration(String peripheralId, Bundle data, PeripheralResultListener listener)
Deprecated in API level 37
int setConnectionProfile(String peripheralId, String connectionProfile, PeripheralResultListener listener)
Deprecated in API level 37
int start(PeripheralResultListener listener)
Deprecated in API level 37
int startAutoTriggerMode(String peripheralId, PeripheralResultListener listener)
Deprecated in API level 37
int startBarcodeScan(String peripheralId, PeripheralResultListener listener)
Deprecated in API level 37
int stop(PeripheralResultListener listener)
Deprecated in API level 37
int stopAutoTriggerMode(String peripheralId, PeripheralResultListener listener)
Deprecated in API level 37
int stopPairingPeripheral(PeripheralResultListener listener)
Deprecated in API level 37
int unregisterDataListener(PeripheralDataListener listener)
Deprecated in API level 37
int unregisterInfoListener(PeripheralInfoListener listener)
Deprecated in API level 37
int unregisterStateListener(PeripheralStateListener listener)
Deprecated in API level 37
int vibrate(String peripheralId, int milliseconds, Bundle option, PeripheralResultListener listener)
Deprecated in API level 37
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int RESULT_CODE_FAIL_PERMISSION_ERROR

Since: API level 34

Deprecated in API level 37

Indicates that callee doesn't have permission

Since
API level 34
KNOX 3.7.1
Constant Value: 3 (0x00000003)

public static final int RESULT_CODE_FAIL_SERVICE_UNAVAILABLE

Since: API level 34

Deprecated in API level 37

Indicates that peripheral service is not available

Since
API level 34
KNOX 3.7.1
Constant Value: 1 (0x00000001)

public static final int RESULT_CODE_FAIL_WRONG_ARGUMENT

Since: API level 34

Deprecated in API level 37

Indicates that argument is wrong

Since
API level 34
KNOX 3.7.1
Constant Value: 2 (0x00000002)

public static final int RESULT_CODE_INVALID

Since: API level 34

Deprecated in API level 37

Indicates that plugin is not available

Since
API level 34
KNOX 3.7.1
Constant Value: -1 (0xffffffff)

public static final int RESULT_CODE_SUCCESS

Since: API level 34

Deprecated in API level 37

Indicates success

Since
API level 34
KNOX 3.7.1
Constant Value: 0 (0x00000000)

Public Methods

public int beep (String peripheralId, int milliseconds, Bundle option, PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API for making beep sound in the peripheral. (only for peripherals which support this functionality)

Parameters
peripheralId peripheral id to update firmware.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
milliseconds duration to make beep sound (milliseconds)
option Bundle data (optional)
if option has key 'PeripheralConstants.BeepSoundEffect.REPEAT_INT', peripheral makes beep sound multiple time as value of this key,
otherwise, makes beep sound only once.
'PeripheralConstants.BeepSoundEffect.INTERVAL_INT' is need to config interval time (milliseconds)
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 Bundle option = new Bundle(); // optional
 option.putInt(PeripheralConstants.BeepSoundEffect.INTERVAL_INT, 500); // optional
 option.putInt(PeripheralConstants.BeepSoundEffect.REPEAT_INT, 3); // optional
 // option is 'repeat 3 times, interval is 500 milliseconds

 PeripheralManager.getInstance(context).beep(mPeripheralId, milliseconds, option,
     new PeripheralResultListener() {

         public void onSuccess(Bundle data) {
             // invoked when 'beep' function succeeds
         }

         public void onFail(int errorCode, String description) {
             // invoked when 'beep' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public int clearMemory (String peripheralId, String clearOption, PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to clear memory of peripheral device

Parameters
peripheralId peripheral id to clear memory.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
clearOption Clear option. PeripheralConstants.DataClearOption
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 PeripheralManager.getInstance(context).clearMemory(peripheralId, clearOption
    new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'clearMemory' function succeeds
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'clearMemory' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int connectPeripheral (BluetoothDevice peripheral, PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API for connecting specified bluetooth peripheral.
This could be used when peripheral is disconnected unexpectedly for following reasons (ex. out of range, battery off..).
getBluetoothPeripherals(String, PeripheralResultListener) retrieves Bluetooth peripheral list have paired before.

Parameters
peripheral BluetoothDevice to connect.
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 mPeripheralManager.connectPeripheral(device,
    new PeripheralResultListener() {

         public void onSuccess(Bundle data) {
             // invoked when 'connectPeripheral' function succeeds
         }

         public void onFail(int errorCode, String description) {
             // invoked when 'connectPeripheral' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public int disable ()

Since: API level 34

Deprecated in API level 37

API to disable PeripheralService.

Returns
Throws
SecurityException If caller does not have required permissions
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope
See Also

public int disconnectPeripheral (String peripheralId, PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API for disconnecting specified peripheral.

Parameters
peripheralId peripheral id to update firmware.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 mPeripheralManager.disconnectPeripheral(peripheralId,
    new PeripheralResultListener() {

         public void onSuccess(Bundle data) {
             // invoked when 'disconnectPeripheral' function succeeds
         }

         public void onFail(int errorCode, String description) {
             // invoked when 'disconnectPeripheral' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public int displayText (String peripheralId, String text, int milliseconds, Bundle option, PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API for showing specified text on the display of the peripheral. (only for peripherals which support this functionality)

Parameters
peripheralId peripheral id to update firmware.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
text text message to show in peripheral screen
milliseconds time to show text message (milliseconds)
option Bundle data (optional)
if option has key 'PeripheralConstants.DisplayText.CLEAR_DISPLAY_BOOL' and the value is 'false',
peripheral display doesn't clear screen and appends test message.
otherwise (option is null or empty or 'PeripheralConstants.DisplayText.CLEAR_DISPLAY_BOOL' is true),
peripheral clears screen(display) and shows text message.
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 Bundle option = new Bundle(); // optional
 option.putBoolean(PeripheralConstants.DisplayText.CLEAR_DISPLAY_BOOL, false); // optional

 PeripheralManager.getInstance(context).displayText(mPeripheralId, text, milliseconds, option,
     new PeripheralResultListener() {

         public void onSuccess(Bundle data) {
             // invoked when 'displayText' function succeeds
         }

         public void onFail(int errorCode, String description) {
             // invoked when 'displayText' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public int enable (Bundle profile)

Since: API level 34

Deprecated in API level 37

API to enable PeripheralService by using Profile.
This API applies profile to PeripheralService.
Once PeripheralService is enabled with wrong profile, you should disable PeripheralService by disable() and enable PeripheralService with new profile.

Profile hierarchy

    Profile
       + Plugin
             + Peripheral
                + Connectivity

    Profile has list of Plugin
    Plugins have list of Peripheral
    Peripherals have list of Connectivity


Profile Example
    Profile
       + Profile name : test_profile_2021-01-11
       + Plugin
          + Plugin Name : plugin_name
          + Plugin package name : com.test.test_plugin
          + Plugin service name : com.test.test_plugin.plugin_service
             + Peripheral
                + Peripheral Name : test_peripheral
                + Connectivity
                   + Connectivity Type : USB
                   + Identifier : SPP:1111/3333,HID:2222/3333
                   + Barcode Data Process Mode : WEDGE
                   + Prefix : test_prefix
                   + Suffix : test_suffix
                   + Enable Timestamp : true
                   + Enable Beep Sound : true
                + Connectivity
                   + Connectivity Type (Bluetooth)
                   + Enable Beep sound : false
                     ....
             + Peripheral
                + Peripheral Name : POS_abc
                   + ...
                + Connectivity
                   ...
       + Plugin
          + ....
       + Plugin
          + ....

Key Fields of profile

Parameters
profile peripheral profile
Returns
Throws
SecurityException If caller does not have required permissions
Usage
Belows are just temporary sample code. usage may be changed
 // if peripheralService is enabled, disable peripheralService to change profile.
 if (PeripheralManager.getInstance(context).isEnabled()) {
     PeripheralManager.getInstance(context).disable();
 }
 PeripheralManager.getInstance(context).enable(getProfile());

 private Bundle getProfile() {
   Bundle bundle = new Bundle();
   bundle.putString(KEY_PROFILE_NAME_STR, "test_profile_2021-01-11");
   Bundle pluginBundle = getPlugin();
   ArrayList pluginList = new ArrayList<>();
   pluginList.add(pluginBundle);
   bundle.putParcelableArrayList(KEY_PLUGIN_BUNDLE_LIST, pluginList);
   return bundle;
 }

 private Bundle getPlugin() {
   Bundle bundle = new Bundle();
   bundle.putString(KEY_PLUGIN_NAME_STR, "plugin_name");
   bundle.putString(KEY_PLUGIN_PACKAGE_NAME_STR, "com.test.test_plugin");
   bundle.putString(KEY_PLUGIN_SERVICE_NAME_STR, "com.test.test_plugin.plugin_service");
   Bundle peripheralBundle = getPeripheral();
   ArrayList peripheralList = new ArrayList<>();
   peripheralList.add(peripheralBundle);
   bundle.putParcelableArrayList(KEY_PERIPHERAL_BUNDLE_LIST, peripheralList);
   return bundle;
 }

 private Bundle getPeripheral() {
   Bundle bundle = new Bundle();
   bundle.putString(KEY_PERIPHERAL_NAME_STR, "test_peripheral");
   Bundle connectivityBundle = getConnectivity();
   ArrayList connectivityList = new ArrayList<>();
   connectivityList.add(connectivityBundle);
   bundle.putParcelableArrayList(KEY_PERIPHERAL_CONNECTIVITY_BUNDLE_LIST, connectivityList);
   return bundle;
 }

 private Bundle getConnectivity() {
   Bundle bundle = new Bundle();
   bundle.putString(KEY_PERIPHERAL_CONNECTIVITY_TYPE_STR,
           PeripheralConstants.ConnectivityType.USB);
   bundle.putString(KEY_PERIPHERAL_CONNECTIVITY_IDENTIFIER_STR,"SPP:1111/3333,HID:2222/3333");
   bundle.putString(KEY_PERIPHERAL_BARCODE_DATA_PROCESS_MODE_STR,
           PeripheralConstants.BarcodeDataProcessMode.WEDGE);
   bundle.putString(KEY_PERIPHERAL_PREFIX_STR, "test_prefix");
   bundle.putString(KEY_PERIPHERAL_SUFFIX_STR, "test_suffix");
   bundle.putBoolean(KEY_PERIPHERAL_BARCODE_ENABLE_TIMESTAMP_BOOL, true);
   bundle.putBoolean(KEY_PERIPHERAL_ENABLE_BEEP_SOUND_BOOL, true);
   ArrayList symbolList = new ArrayList<>();
   symbolList.add(PeripheralBarcodeConstants.Symbology.CODABAR);
   symbolList.add(PeripheralBarcodeConstants.Symbology.CODE11);
   symbolList.add(PeripheralBarcodeConstants.Symbology.CODE32);
   symbolList.add(PeripheralBarcodeConstants.Symbology.EAN13);
   bundle.putStringArrayList(KEY_PERIPHERAL_BARCODE_ENABLED_SYMBOLOGY_LIST, symbolList);
   return bundle;
 }
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope
See Also

public int getAvailablePeripherals (PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to get connected peripheral devices from all plugins

Parameters
listener listener to which result is to be delivered.
Returns
Usage
 public void getAvailablePeripheral(Context context) {
     PeripheralManager peripheralManager = PeripheralManager.getInstance(context);
     peripheralManager.getAvailablePeripherals(new PeripheralResultListener() {
         public void onSuccess(Bundle bundle) {
             getPeripheralList(bundle);
         }
         public void onFail(int errorCode, String description) {
             // invoked if fail to call getAvailablePeripheral.
         }
     });
 }
 private List getPeripheralList(Bundle bundle) {
     ArrayList pluginList = new ArrayList<>();
     ArrayList pluginBundleList = bundle.getParcelableArrayList(KEY_PLUGIN_BUNDLE_LIST);

     if (pluginBundleList == null) return pluginList;
     for (Bundle plugin : pluginBundleList) {
         ArrayList peripherals =
                 plugin.getParcelableArrayList(KEY_PERIPHERAL_BUNDLE_LIST);
         if (peripherals == null) continue;
         for (Bundle peripheral : peripherals) {
             String peripheralId = peripheral.getString(KEY_PERIPHERAL_ID_STR);
             pluginList.add(peripheralId);
         }
     }
     return pluginList;
 }
 
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int getBluetoothPeripherals (String option, PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API for getting all paired bluetooth peripherals.

Parameters
option option for getting bluetooth peripheral.
ALL : retrieves all paired bluetooth devices.
RECENT : retrieves latest paired bluetooth devices.
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 mPeripheralManager.getBluetoothPeripherals(PeripheralConstants.BtPeripheralListOption.ALL,
    new PeripheralResultListener() {

         public void onSuccess(Bundle data) {
             // invoked when 'getBluetoothPeripherals' function succeeds
             ArrayList btList = bundle.getParcelableArrayList(PeripheralConstants.KEY_RESULT_BLUETOOTH_PERIPHERAL_LIST);
         }

         public void onFail(int errorCode, String description) {
             // invoked when 'getBluetoothPeripherals' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public int getConfiguration (String peripheralId, List<String> keyList, PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to get configuration of specified peripheral
PeripheralResultListener.onResult retrieves data which is listed in param List<String> keyList from specified peripheral (param peripheralId).

supported keys

Parameters
peripheralId peripheral id to get configuration from.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
keyList list of keys. PeripheralResultListener.onSuccess retrieves values of these keys
listener listener to which result is to be delivered.
Returns
Usage
Belows are just temporary sample code. usage may be changed
 private void getConfiguration(Context context, String peripheralId) {
   ArrayList list = new ArrayList<>();
   list.add(KEY_PERIPHERAL_BARCODE_DATA_PROCESS_MODE_STR);
   list.add(KEY_PERIPHERAL_PREFIX_STR);
   list.add(KEY_PERIPHERAL_SUFFIX_STR);
   list.add(KEY_PERIPHERAL_BARCODE_ENABLE_TIMESTAMP_BOOL);
   list.add(KEY_PERIPHERAL_ENABLE_BEEP_SOUND_BOOL);
   list.add(KEY_PERIPHERAL_ENABLE_CHECK_DUPLICATED_BARCODE_BOOL);
   list.add(KEY_PERIPHERAL_BARCODE_ENABLED_SYMBOLOGY_LIST);
   list.add(KEY_PERIPHERAL_BARCODE_SUPPORTED_SYMBOLOGY_LIST);
   list.add(KEY_PERIPHERAL_BATTERY_LEVEL_STR);
   list.add(KEY_PERIPHERAL_CONNECTIVITY_TYPE_STR);
   list.add(KEY_PERIPHERAL_FIRMWARE_STR);
   list.add(KEY_PERIPHERAL_MANUFACTURER_STR);
   list.add(KEY_PERIPHERAL_NAME_STR);
   list.add(KEY_PERIPHERAL_SERIAL_NUMBER_STR);
   list.add(KEY_PERIPHERAL_STORED_DATA_COUNT_INT);
   list.add(KEY_PERIPHERAL_TYPE_STR);
   list.add(KEY_PLUGIN_VENDOR_STR);
   list.add(KEY_PLUGIN_VERSION_STR);
   list.add(KEY_PLUGIN_PACKAGE_NAME_STR);
   list.add(KEY_PLUGIN_SERVICE_NAME_STR);
   // getConfiguration doesn't support below fields. please find them by using getInformation()
   //list.add(KEY_RESULT_CURRENT_CONNECTIVITY_TYPE_STR);
   //list.add(KEY_RESULT_CURRENT_CONNECTIVITY_VERSION_STR);
   PeripheralManager.getInstance(context).
      getConfiguration(peripheralId, list,
           new PeripheralResultListener(){
               public void onSuccess(Bundle bundle) {
                   onGetConfiguration(bundle);
               }
               public void onFail(int errorCode, String description) {
                   // invoked if fail to call setConfiguration.
               }
           });
 }

 private void onGetConfiguration(Bundle bundle) {

   ArrayList peripheralList = bundle.getParcelableArrayList(KEY_PERIPHERAL_BUNDLE_LIST);

   for (Bundle peripheral : peripheralList) {
       // barcodeDataProcessMode is matched PeripheralConstants.BarcodeDataProcessMode
       String barcodeDataProcessMode
                     = peripheral.getString(KEY_PERIPHERAL_BARCODE_DATA_PROCESS_MODE_STR);
       boolean enableTimestamp =
                     peripheral.getBoolean(KEY_PERIPHERAL_BARCODE_ENABLE_TIMESTAMP_BOOL);
       String batteryLevel = peripheral.getString(KEY_PERIPHERAL_BATTERY_LEVEL_STR);
       // connectivityType is matched with PeripheralConstants.ConnectivityType
       String connectivityType = peripheral.getString(KEY_PERIPHERAL_CONNECTIVITY_TYPE_STR);
       boolean enableBeepSound = peripheral.getBoolean(KEY_PERIPHERAL_ENABLE_BEEP_SOUND_BOOL);
       String firmware = peripheral.getString(KEY_PERIPHERAL_FIRMWARE_STR);
       String manufacturer = peripheral.getString(KEY_PERIPHERAL_MANUFACTURER_STR);
       String peripheralName = peripheral.getString(KEY_PERIPHERAL_NAME_STR);
       String prefix = peripheral.getString(KEY_PERIPHERAL_PREFIX_STR);
       String suffix = peripheral.getString(KEY_PERIPHERAL_SUFFIX_STR);
       String serialNumber = peripheral.getString(KEY_PERIPHERAL_SERIAL_NUMBER_STR);
       String vendor = peripheral.getString(KEY_PLUGIN_VENDOR_STR);
       String version = peripheral.getString(KEY_PLUGIN_VERSION_STR);
       int storedCount = peripheral.getInt(KEY_PERIPHERAL_STORED_DATA_COUNT_INT);
       String peripheralType = peripheral.getString(KEY_PERIPHERAL_TYPE_STR);
       String pluginPackageName = peripheral.getString(KEY_PLUGIN_PACKAGE_NAME_STR);
       String pluginServiceName = peripheral.getString(KEY_PLUGIN_SERVICE_NAME_STR);

       // symbology is matched with PeripheralBarcodeConstants.Symbology
       ArrayList enabledSymbologyList =
               peripheral.getStringArrayList(KEY_PERIPHERAL_BARCODE_ENABLED_SYMBOLOGY_LIST);
       ArrayList supportedSymbologyList =
               peripheral.getStringArrayList(KEY_PERIPHERAL_BARCODE_SUPPORTED_SYMBOLOGY_LIST);
   }
 }
 
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int getConnectionProfile (String peripheralId, PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to get Connection Profile. Connection Profile means profile of BLUETOOTH, class of USB

Parameters
peripheralId peripheral id to update firmware.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 PeripheralManager.getInstance(context).getConnectionProfile(peripheralId,
    new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'getConnectionProfile' function succeeds
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'getConnectionProfile' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int getInformation (PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to get information of all peripherals and plugins

Parameters
listener listener to which result is to be delivered.
Returns
Usage
Belows are just temporary sample code. usage may be changed
 PeripheralManager.getInstance(context).getInformation(
     new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'getInformation' function succeeds
             PeripheralHelperInfo info = new PeripheralHelperInfo(bundle);
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'getInformation' function failed
         }
 });

 public class PeripheralHelperInfo {
   List mPluginList = new ArrayList<>();

   public PeripheralHelperInfo(Bundle bundle) {
     ArrayList pluginList = bundle.getParcelableArrayList(KEY_PLUGIN_BUNDLE_LIST);
     if (pluginList != null) {
         for (Bundle pluginBundle : pluginList) {
             mPluginList.add(new Plugin(pluginBundle));
         }
     }
   }

   public static class Plugin {
     String mName;
     String mVendor;
     String mVersion;
     String mPackageName;
     String mServiceName;
     List mPeripheralList = new ArrayList<>();

     public Plugin(Bundle bundle) {
         mName = bundle.getString(KEY_PLUGIN_NAME_STR);
         mVendor = bundle.getString(KEY_PLUGIN_VENDOR_STR);
         mVersion = bundle.getString(KEY_PLUGIN_VERSION_STR);
         mPackageName = bundle.getString(KEY_PLUGIN_PACKAGE_NAME_STR);
         mServiceName = bundle.getString(KEY_PLUGIN_SERVICE_NAME_STR);
         ArrayList bundleList = bundle.getParcelableArrayList(KEY_PERIPHERAL_BUNDLE_LIST);
         if (bundleList != null) {
             for (Bundle peripheralBundle : bundleList) {
                 mPeripheralList.add(new Peripheral(peripheralBundle));
             }
         }
     }
   }
   public static class Peripheral {
     String mName;
     String mModelName;
     String mManufacturer;
     String mState;
     String mPeripheralType;
     String mCurrentConnectivityType;
     String mCurrentConnectivityVersion;
     String mConnectionState;
     String mBatteryLevel;
     int mUsageCount;
     String mSerialNumber;
     String mFirmware;
     String mDisconnectedReason;
     List mConnectivityList = new ArrayList<>();

     public Peripheral(Bundle bundle) {
         mName = bundle.getString(KEY_PERIPHERAL_NAME_STR);
         mModelName = bundle.getString(KEY_PERIPHERAL_MODEL_NAME_STR);
         mManufacturer = bundle.getString(KEY_PERIPHERAL_MANUFACTURER_STR);
         mState = bundle.getString(KEY_PERIPHERAL_STATE_STR);
         mPeripheralType = bundle.getString(KEY_PERIPHERAL_TYPE_STR);
         mCurrentConnectivityType = bundle.getString(KEY_RESULT_CURRENT_CONNECTIVITY_TYPE_STR);
         mCurrentConnectivityVersion = bundle.getString(KEY_RESULT_CURRENT_CONNECTIVITY_VERSION_STR);
         mConnectionState = bundle.getString(KEY_PERIPHERAL_CONNECTION_STATE_STR);
         mBatteryLevel = bundle.getString(KEY_PERIPHERAL_BATTERY_LEVEL_STR);
         mUsageCount = bundle.getInt(KEY_PERIPHERAL_USAGE_COUNT_INT, -1);
         mSerialNumber = bundle.getString(KEY_PERIPHERAL_SERIAL_NUMBER_STR);
         mFirmware = bundle.getString(KEY_PERIPHERAL_FIRMWARE_STR);
         mDisconnectedReason = bundle.getString(KEY_PERIPHERAL_DISCONNECTED_REASON_STR);
         ArrayList bundleList = bundle.getParcelableArrayList(KEY_PERIPHERAL_CONNECTIVITY_BUNDLE_LIST);
         if (bundleList != null) {
             for (Bundle connectivityBundle : bundleList) {
                 mConnectivityList.add(new Connectivity(connectivityBundle));
             }
         }
    }

   public static class Connectivity {
     String mConnectivityType;
     String mBarcodeDataProcessMode;
     List mEnabledSymbologyList = new ArrayList<>();

     public Connectivity(Bundle bundle) {
         mConnectivityType = bundle.getString(KEY_PERIPHERAL_CONNECTIVITY_TYPE_STR);
         mBarcodeDataProcessMode = bundle.getString(KEY_PERIPHERAL_BARCODE_DATA_PROCESS_MODE_STR);
         mEnabledSymbologyList = bundle.getStringArrayList(KEY_PERIPHERAL_BARCODE_ENABLED_SYMBOLOGY_LIST);
     }
   }
 }
 
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope
See Also

public static PeripheralManager getInstance (Context context)

Since: API level 34

Deprecated in API level 37

API to create an instance of PeripheralManager class.

Parameters
context context of the application or service using this class
Returns
  • Returns the PeripheralManager object
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int getPairingBarcodeData (String peripheralId, PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API for getting barcode data required for discovery and pairing of bluetooth peripheral.
device discovers Bluetooth peripheral before time-out DISCOVER_TIMEOUT
or calling stopPairingPeripheral(PeripheralResultListener)

Parameters
peripheralId peripheral id to update firmware.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 mPeripheralManager.getPairingBarcodeData(peripheralId,
    new PeripheralResultListener() {

         public void onSuccess(Bundle data) {
             // invoked when 'getPairingBarcodeData' function succeeds
             String barcode = bundle.getString(PeripheralConstants.KEY_RESULT_BARCODE_DATA_STR);
         }

         public void onFail(int errorCode, String description) {
             // invoked when 'getPairingBarcodeData' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public int getStoredData (String peripheralId, PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to get stored data. barcode data is stored in peripheral, if data process mode is STORE

Parameters
peripheralId peripheral id to get stored data.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
listener listener to deliver result.
NOTE : listener notifies 'get stored data is started'.
doesn't retrieve stored barcode data.
PeripheralDataListener.onReceive(), which is registered by registerDataListener retrieves barcode data.
Returns
Usage
 PeripheralManager.getInstance(context).getStoredData(peripheralId,
    new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'getStoredData' function succeeds
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'getStoredData' function failed
         }
 });
 
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int getSupportedPeripherals (PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API for getting all supported peripheral list from all plugins, regardless of current connection status.

Parameters
listener listener to which result is to be delivered.
Returns
Usage
 public void getSupportedPeripherals(Context context) {
     PeripheralManager peripheralManager = PeripheralManager.getInstance(context);
     peripheralManager.getSupportedPeripherals(new PeripheralResultListener() {
         public void onSuccess(Bundle bundle) {
             getPeripheralList(bundle);
         }
         public void onFail(int errorCode, String description) {
             // invoked if fail to call getSupportedPeripherals.
         }
     });
 }
 private List getPeripheralList(Bundle bundle) {
     ArrayList pluginList = new ArrayList<>();
     ArrayList pluginBundleList = bundle.getParcelableArrayList(KEY_PLUGIN_BUNDLE_LIST);

     if (pluginBundleList == null) return pluginList;
     for (Bundle plugin : pluginBundleList) {
         ArrayList peripherals =
                 plugin.getParcelableArrayList(KEY_PERIPHERAL_BUNDLE_LIST);
         if (peripherals == null) continue;
         for (Bundle peripheral : peripherals) {
             String peripheralId = peripheral.getString(KEY_PERIPHERAL_ID_STR);
             pluginList.add(peripheralId);
         }
     }
     return pluginList;
 }
 
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public boolean isEnabled ()

Since: API level 34

Deprecated in API level 37

API to check whether PeripheralService is enabled or not.

Returns
  • Returns true if service is enabled, false otherwise.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope
See Also

public boolean isStarted ()

Since: API level 34

Deprecated in API level 37

API to check whether PeripheralService is started or not.

Returns
  • Returns true if service is started, false otherwise.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int registerDataListener (PeripheralDataListener listener)

Since: API level 34

Deprecated in API level 37

API to register listener which retrieves barcode data

Parameters
listener listener to which barcode data is to be delivered.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
Belows are just temporary sample code. usage may be changed
 PeripheralManager.getInstance(context).registerDataListener(
     new PeripheralDataListener() {
         public void onSuccess() {
             // invoked when 'registerDataListener' function succeeds
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'registerDataListener' function failed
         }
         public void onReceive(int eventType, Bundle data) {
             PeripheralHelperData barcodeData = new PeripheralHelperData(data);
         }
 });
 public class PeripheralHelperData {
     String mPeripheralId;
     String mName;
     String mModel;
     String mSerialNumber;
     String mDataType;
     List mBarcodeDataList = new ArrayList<>();

     public PeripheralHelperData(Bundle bundle) {
         mPeripheralId = bundle.getString(KEY_PERIPHERAL_ID_STR);
         mName = bundle.getString(KEY_PERIPHERAL_NAME_STR);
         mModel = bundle.getString(KEY_PERIPHERAL_MODEL_NAME_STR);
         mSerialNumber = bundle.getString(KEY_PERIPHERAL_SERIAL_NUMBER_STR);
         mDataType = bundle.getString(KEY_RESULT_DATA_TYPE_STR);
         List bundleList = bundle.getParcelableArrayList(KEY_RESULT_BARCODE_DATA_LIST);
         if (bundleList != null) {
             for (Bundle barcodeBundle : bundleList) {
                 mBarcodeDataList.add(new BarcodeData(barcodeBundle));
             }
         }
     }

     public static class BarcodeData {
         String mBarcodeData;
         String mSymbology;
         long mTimeStamp;
         String mDataProcessMode;
         String mFailReason;
         String mBarcodeRawData;

         public BarcodeData(Bundle bundle) {
             mBarcodeData = bundle.getString(KEY_RESULT_BARCODE_DATA_STR);
             mSymbology = bundle.getString(KEY_PERIPHERAL_BARCODE_ENABLED_SYMBOLOGY_STR);
             mTimeStamp = bundle.getLong(KEY_PERIPHERAL_TIMESTAMP_LONG);
             mDataProcessMode = bundle.getString(KEY_PERIPHERAL_BARCODE_DATA_PROCESS_MODE_STR);
             mFailReason = bundle.getString(KEY_PERIPHERAL_FAIL_REASON_STR);
             mBarcodeRawData = bundle.getString(KEY_RESULT_BARCODE_RAW_DATA_STR);
         }
     }
 }
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int registerInfoListener (PeripheralInfoListener listener)

Since: API level 34

Deprecated in API level 37

API to register listener which retrieves information of all peripherals and plugins

Parameters
listener listener to which information is to be delivered.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 PeripheralManager.getInstance(context).registerInfoListener(
     new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'registerInfoListener' function succeeds
             // same bundle data is retrieved getInformation(PeripheralResultListener)
             PeripheralHelperInfo info = new PeripheralHelperInfo(bundle);
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'registerInfoListener' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int registerStateListener (PeripheralStateListener listener)

Since: API level 34

Deprecated in API level 37

API to register listener which retrieves state change from peripherals

Parameters
listener listener to which state is to be delivered.
Returns
Throws
SecurityException If caller does not have required permissions
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Usage
Belows are just temporary sample code. usage may be changed
 PeripheralManager.getInstance(context).registerStateListener(
     new PeripheralStateListener() {
         public void onSuccess() {
             // invoked when 'registerStateListener' function succeeds
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'registerStateListener' function failed
         }
         public void onStateChange(final int eventType, final Bundle bundle) {
            // invoked when receiving state event
            if (eventType == PeripheralConstants.EventType.CONNECTION_CHANGED) {
                PeripheralHelperConnectionState state = new PeripheralHelperConnectionState(bundle);
            } else if (eventType == PeripheralConstants.EventType.ERROR_RECEIVED) {
                PeripheralHelperErrorState state = new PeripheralHelperErrorState(bundle);
            }
         }
 });

 public class PeripheralHelperConnectionState {
     List mPeripheralList = new ArrayList<>();

     public PeripheralHelperConnectionState(Bundle bundle) {
         ArrayList bundleList = bundle.getParcelableArrayList(KEY_PERIPHERAL_BUNDLE_LIST);
         if (bundleList != null) {
             for (Bundle peripheralBundle : bundleList) {
                 mPeripheralList.add(new Peripheral(peripheralBundle));
             }
         }
     }

     public static class Peripheral {
         String mId;
         String mName;
         String mModel;
         String mSerialNumber;
         String mPeripheralType;
         String mConnectionState;
         String mCurrentConnectivityType;
         String mCurrentConnectivityVersion;

         public Peripheral(Bundle bundle) {
             mId = bundle.getString(KEY_PERIPHERAL_ID_STR);
             mName = bundle.getString(KEY_PERIPHERAL_NAME_STR);
             mModel = bundle.getString(KEY_PERIPHERAL_MODEL_NAME_STR);
             mSerialNumber = bundle.getString(KEY_PERIPHERAL_SERIAL_NUMBER_STR);
             mPeripheralType = bundle.getString(KEY_PERIPHERAL_TYPE_STR);
             mConnectionState = bundle.getString(KEY_PERIPHERAL_CONNECTION_STATE_STR);
             mCurrentConnectivityType = bundle.getString(KEY_RESULT_CURRENT_CONNECTIVITY_TYPE_STR);
             mCurrentConnectivityVersion = bundle.getString(KEY_RESULT_CURRENT_CONNECTIVITY_VERSION_STR);
         }
     }
 }
 public class PeripheralHelperErrorState implements PeripheralHelperState {
     int mErrorCode;
     List mPluginList= new ArrayList<>();

     public PeripheralHelperErrorState(Bundle bundle) {
         mErrorCode = bundle.getInt(KEY_RESULT_ERROR_CODE_INT);
         if (mErrorCode == ERROR_PLUGIN_NOT_FOUND) {
             mPluginList = bundle.getStringArrayList(KEY_RESULT_PLUGIN_PACKAGE_NAME_LIST);
         }
     }
 }
 
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int resetPeripheral (String peripheralId, String resetOption, PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API to reset peripheral configuration

Parameters
peripheralId peripheral id to reset peripheral configuration.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
resetOption peripheral reset option. Please find PeripheralConstants.DataResetOption
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 PeripheralManager.getInstance(context).resetPeripheral(peripheralId, resetOption
    new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'resetPeripheral' function succeeds
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'resetPeripheral' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public int setConfiguration (String peripheralId, Bundle data, PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to set configuration of specified peripheral.

supported keys

Parameters
peripheralId peripheral id to set configuration.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
data key and value to set configuration
listener listener to which result is to be delivered.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
Belows are just temporary sample code. usage may be changed
 public void setConfiguration(Context context, String peripheralId) {
   Bundle bundle = new Bundle();
   bundle.putString(KEY_PERIPHERAL_BARCODE_DATA_PROCESS_MODE_STR,
           PeripheralConstants.BarcodeDataProcessMode.WEDGE);
   bundle.putString(KEY_PERIPHERAL_PREFIX_STR, "test_prefix");
   bundle.putString(KEY_PERIPHERAL_SUFFIX_STR, "test_suffix");
   bundle.putBoolean(KEY_PERIPHERAL_BARCODE_ENABLE_TIMESTAMP_BOOL, true);
   bundle.putBoolean(KEY_PERIPHERAL_ENABLE_BEEP_SOUND_BOOL, true);
   // symbology list
   ArrayList symbolList = new ArrayList<>();
   symbolList.add(PeripheralBarcodeConstants.Symbology.CODABAR);
   symbolList.add(PeripheralBarcodeConstants.Symbology.CODE11);
   symbolList.add(PeripheralBarcodeConstants.Symbology.CODE32);
   symbolList.add(PeripheralBarcodeConstants.Symbology.EAN13);
   bundle.putStringArrayList(KEY_PERIPHERAL_BARCODE_ENABLED_SYMBOLOGY_LIST, symbolList);
   PeripheralManager peripheralManager = PeripheralManager.getInstance(context);

   PeripheralManager.getInstance(context).
       setConfiguration(peripheralId, bundle,
           new PeripheralResultListener(){
               public void onSuccess(Bundle bundle) {
                   // success
               }
               public void onFail(int errorCode, String description) {
                   // invoked if fail to call setConfiguration.
               }
           });
 }
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int setConnectionProfile (String peripheralId, String connectionProfile, PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to change Connection Profile. (ex. SPP -> HID) Connection Profile means profile of BLUETOOTH, class of USB

Parameters
peripheralId peripheral id to update firmware.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
connectionProfile Connection profile. Please find PeripheralConstants.ConnectionProfile
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 PeripheralManager.getInstance(context).setConnectionProfile(peripheralId, mode
    new PeripheralResultListener() {

         public void onSuccess(Bundle data) {
             // invoked when 'setConnectionProfile' function succeeds
         }

         public void onFail(int errorCode, String description) {
             // invoked when 'setConnectionProfile' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int start (PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to start PeripheralService.
Note : listener.onSuccess() doesn't guarantee profile validity.
PeripheralService broadcasts intent ACTION_SERVICE_START to notify result of profile validation since Knox3.8(API level 35)

Parameters
listener listener to which result is to be delivered.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 PeripheralManager.getInstance(context).start(profile,
     new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'start' function succeeds
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'start' function failed
         }
 });

 // broadcastReceiver. register this receiver with intentFilter(PeripheralConstants.ACTION_SERVICE_START)
 .... new BroadcastReceiver() {
     public void onReceive(Context context, Intent intent) {
         if (intent.getAction().equals(PeripheralConstants.ACTION_SERVICE_START)) {
             int errorCode = intent.getIntExtra(PeripheralConstants.EXTRA_SERVICE_START_RESULT, PeripheralConstants.ErrorCode.ERROR_FRAMEWORK_UNKNOWN);
             String desc = intent.getStringExtra(PeripheralConstants.EXTRA_SERVICE_START_DESCRIPTION);
             if (errorCode == PeripheralConstants.ErrorCode.ERROR_NONE) {
                  // profile is valid
             } else {
                  // profile it not valid
                 Log.e(TAG, "profile is invalid : " + desc);
             }
         }
     }
 }
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int startAutoTriggerMode (String peripheralId, PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API to enable auto trigger mode

Parameters
peripheralId peripheral id to enable auto trigger mode.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 PeripheralManager.getInstance(context).startAutoTriggerMode(peripheralId, clearOption
    new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'startAutoTriggerMode' function succeeds
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'startAutoTriggerMode' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public int startBarcodeScan (String peripheralId, PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to start barcode scan

Parameters
peripheralId peripheral id to start barcode scan.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
listener listener to deliver result.
NOTE : listener notifies 'barcode scan is started'. doesn't retrieve barcode data. PeripheralDataListener.onReceive(), which is registered by registerDataListener retrieves barcode data.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
Belows are just temporary sample code. usage may be changed
 PeripheralManager.getInstance(context).startBarcodeScan(peripheralId,
    new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'startBarcodeScan' function succeeds
             // this function doesn't retrieve barcode data
             // barcode data is notified by PeripheralDataListener
             // please find registerDataListener(PeripheralDataListener)
         }

         public void onFail(int errorCode, String description) {
             // invoked when 'startBarcodeScan' function failed
         }
 });
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope
See Also
  • #stopBarcodeScan(String, PeripheralResultListener)

public int stop (PeripheralResultListener listener)

Since: API level 34

Deprecated in API level 37

API to stop PeripheralService.

Parameters
listener listener to which result is to be delivered.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 PeripheralManager.getInstance(context).stop(
     new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'stop' function succeeds
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'stop' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int stopAutoTriggerMode (String peripheralId, PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API to disable auto trigger mode

Parameters
peripheralId peripheral id to disable auto trigger mode.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 PeripheralManager.getInstance(context).stopAutoTriggerMode(peripheralId, clearOption
    new PeripheralResultListener() {
         public void onSuccess(Bundle data) {
             // invoked when 'stopAutoTriggerMode' function succeeds
         }
         public void onFail(int errorCode, String description) {
             // invoked when 'stopAutoTriggerMode' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public int stopPairingPeripheral (PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API for stopping ongoing discovery and pairing of bluetooth peripheral.
getPairingBarcodeData(String, PeripheralResultListener) starts discovering Bluetooth peripherals.

Parameters
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 mPeripheralManager.stopPairingPeripheral(
    new PeripheralResultListener() {

         public void onSuccess(Bundle data) {
             // invoked when 'stopPairingPeripheral' function succeeds
         }

         public void onFail(int errorCode, String description) {
             // invoked when 'stopPairingPeripheral' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope

public int unregisterDataListener (PeripheralDataListener listener)

Since: API level 34

Deprecated in API level 37

API to unregister listener which retrieves barcode data

Parameters
listener listener to which barcode data is to be delivered.
Returns
Throws
SecurityException If caller does not have required permissions
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int unregisterInfoListener (PeripheralInfoListener listener)

Since: API level 34

Deprecated in API level 37

API to unregister listener which retrieves information of all peripherals and plugins

Parameters
listener listener to which information is to be delivered.
Returns
Throws
SecurityException If caller does not have required permissions
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int unregisterStateListener (PeripheralStateListener listener)

Since: API level 34

Deprecated in API level 37

API to unregister listener which retrieves state change from peripherals

Parameters
listener listener to which state is to be delivered.
Returns
Throws
SecurityException If caller does not have required permissions
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 34
KNOX 3.7.1
Multiuser Environment
Global Scope

public int vibrate (String peripheralId, int milliseconds, Bundle option, PeripheralResultListener listener)

Since: API level 35

Deprecated in API level 37

API for making vibration in the peripheral. (only for peripherals which support this functionality)

Parameters
peripheralId peripheral id to update firmware.
getAvailablePeripherals(PeripheralResultListener) retrieves list of available peripheralId.
milliseconds duration to make vibration (milliseconds)
option Bundle data (optional)
if option has key 'PeripheralConstants.VibrationEffect.REPEAT_INT', peripheral makes vibration multiple time as value of this key,
otherwise, makes vibration only once.
'PeripheralConstants.VibrationEffect.INTERVAL_INT' is need to config interval time (milliseconds)
listener listener to deliver result.
Returns
Throws
SecurityException If caller does not have required permissions
Usage
 Bundle option = new Bundle(); // optional
 option.putInt(PeripheralConstants.VibrationEffect.INTERVAL_INT, 500); // optional
 option.putInt(PeripheralConstants.VibrationEffect.REPEAT_INT, 3); // optional
 // option is 'repeat 3 times, interval is 500 milliseconds

 PeripheralManager.getInstance(context).vibrate(mPeripheralId, milliseconds, option,
     new PeripheralResultListener() {

         public void onSuccess(Bundle data) {
             // invoked when 'vibrate' function succeeds
         }

         public void onFail(int errorCode, String description) {
             // invoked when 'vibrate' function failed
         }
 });
 
Permission
The use of this feature requires the caller to have the "com.samsung.android.knox.permission.KNOX_NDA_PERIPHERAL_RT" permission.
Since
API level 35
KNOX 3.8
Multiuser Environment
Global Scope