Using a Client Application to Communicate with Workstation Connect

Using a Client Application to Communicate with Workstation Connect

Any third-party application that attempts to configure Workstation Connect must bind to an AIDL interface exposed by Workstation Connect.
package com.zebra.valueadd; //AIDL interface to provide to third-party applications interface IZVAService { /** * Method that receives the JSON string from the third-party application as input * If the data is valid, returns success, otherwise returns failure as an output. * The caller should call this API just after binding to the service. */ String processZVARequest(in String json); }
This interface is protected by a custom permission that must be declared in the manifest of the third-party application.
<uses-permission android:name="com.zebra.workstationconnect.ACCESS_CONFIGURATION_SERVICE"/>
To successfully configure Workstation Connect from a third-party application, the third-party application must declare in its manifest the intention to bind to and configure Workstation Connect through a custom permission. To correctly perform this configuration, Workstation Connect must be installed before the third-party application to ensure that the custom permission is defined before the third-party application attempts to use it.
The permission is not defined If the third-party application was installed before Workstation Connect, and the third-party application does not have permission. As a result, the application cannot bind to the AIDL interface and the third-party application cannot configure Workstation Connect successfully.
In this case, the third-party application must be uninstalled and re-installed while Workstation Connect is on the device. At that point, the third-party application can receive the requisite permission and configure Workstation Connect.
A third-party application binds to the AIDL interface exposed by Workstation Connect by sending a bindService intent that specifies the package name and service name of Workstation Connect.
/** * Option 1: Bind to service through intent */ private void bindToZVAServiceThroughIntent() { Intent intent = new Intent(); intent.setClassName(getAppPackageName(), "com.zebra.workstationconnect.DeviceManagementService"); bindService(intent, this, BIND_AUTO_CREATE); } /** * Option 2: Bind to service through component */ private void bindToZVAServiceThroughComponent() { Intent intent = new Intent(); intent.setComponent(new ComponentName(getAppPackageName(), "com.zebra.workstationconnect.DeviceManagementService")); bindService(intent, this, BIND_AUTO_CREATE); }
Strings setComponent and setClassname are both supported for binding the service identifier.
Any third-party application can declare the custom permission in its manifest; it does not provide sufficient security over which applications can configure Workstation Connect. Declaring the custom permission in its manifest allows a third-party application to bind to Workstation Connect and to attempt to submit JSON to configure Workstation Connect. However, unless the administrator explicitly grants the third-party application permission to configure Workstation Connect, the attempt to submit a JSON string fails due to a security exception.
The administrator must use XML sent to the AccessMgr CSP (for example, through StageNow) or Managed Configurations sent to OemConfig, to grant third-party applications the right to submit the configuration to Workstation Connect as JSON strings.
Access Manager must be invoked to grant the needed permission. To invoke Access Manager, provide the Service Access Action, Service Identifier, Caller Package Name, and the Caller Signature. Go to techdocs.zebra.com/mx/accessmgr/ for additional information on using Access Manager to enable configurations.
  • Service Access Action - select
    Allow Caller to Call Service
    from the dropdown.
  • Service Identifier - the Zebra Value Add service name you intend to interface, enter: delegation-zebra-workstationconnect-api-access-configuration-service
  • Caller Package Name - the application's
    applicationId
    found in the module Build.gradle file under the defaultConfig section; for example, com.zebra.wsc-sample-app
  • Caller Signature - the application signature in DER format, provided in a .CRT file. Extract the application signature to obtain the certificate.
Ensure the application you plan to authorize is installed.
Go to techdocs.zebra.com/emdk-for-android/latest/samples/sigtools/ for instructions on extracting the application signature.
If a third-party application successfully binds to Workstation Connect, it receives and saves an IBinder object used to access the methods of that service using a callback.
public ServiceConnection myConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder binder) { //cast the IBinder and get LocalService instance } }
If an administrator successfully grants the third-party application permission to configure Workstation Connect, it can submit a JSON string to configure Workstation Connect using a previously saved IBinder:
String configJson = “some JSON text”; String resultJson = myService.processZVARequest(configJson);
Coordinate with the administrator to understand roles and relevant use cases.