Introduction
Each device has its unique serial number. The number is preloaded on the media player persistence storage and should match the printer on the label at the bottom of the case. It can be a unique identifier for a custom application. You are advised to follow the instructions below to obtain the serial number.
Prerequisite
Please visit Enable Enterprise customer development page to obtain the Apollo SDK file. With the SDK file, you can import the included AAR and AIDL library files to build your own APP
Assuming that the latest AIDL library was imported to your Android project.
You are suggested to create a DeviceClient Class to communicate with the corresponding service.
Here's an example :
DeviceClient.java
package tv.amino.testplay;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.util.Log;
import com.aminocom.device.IDeviceRemoteService;
public class DeviceClient {
private static final String TAG = DeviceClient.class.getSimpleName();
private static final String DEVICE_REMOTE_SERVICE_PACKAGE = "com.aminocom.device";
private static final String DEVICE_REMOTE_SERVICE_CLASS = DEVICE_REMOTE_SERVICE_PACKAGE + ".DeviceRemoteService";
private static IDeviceRemoteService mService;
private static DeviceRemoteServiceConnection mConnection;
private Context mContext;
public DeviceClient(Context context, DeviceRemoteServiceConnection connection) {
mContext = context;
mConnection = connection;
}
// ----------------------------------------------------------------------
// Code showing how to deal with remote service.
// ----------------------------------------------------------------------
public static class DeviceRemoteServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
Log.d(TAG, "onServiceConnected(): className=" + className);
// This is called when the connection with the service has been
// established, giving us the service object we can use to
// interact with the service. We are communicating with our
// service through an IDL interface, so get a client-side
// representation of that from the raw service object.
mService = IDeviceRemoteService.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName className) {
Log.d(TAG, "onServiceDisconnected(): className=" + className);
// This is called when the connection with the service has been
// unexpectedly disconnected -- that is, its process crashed.
mService = null;
}
}
public static IDeviceRemoteService getService() {
return mService;
}
public static int getVersion() {
return IDeviceRemoteService.VERSION;
}
public void connect() throws Exception {
// Bind remote service on setUp()
Intent intent = new Intent();
intent.setComponent(new ComponentName(DEVICE_REMOTE_SERVICE_PACKAGE, DEVICE_REMOTE_SERVICE_CLASS));
mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}
public void disconnect() throws Exception {
// Unbind remote service on tearDown()
mContext.unbindService(mConnection);
}
public String getDeviceParameter(final String key, final String def) throws Exception {
return mService.getDeviceParameter(key, def);
}
public String getApplicationParameter(final String key, final String def) throws Exception {
return mService.getApplicationParameter(key, def);
}
public boolean setApplicationParameter(final String key, final String value) throws Exception {
return mService.setApplicationParameter(key, value);
}
public byte[] getEthernetMacAddress() throws Exception {
return mService.getEthernetMacAddress();
}
public String getDeviceSerialNumber() throws Exception {
return mService.getDeviceSerialNumber();
}
public String getDeviceHardwareModel() throws Exception {
return mService.getDeviceHardwareModel();
}
}
Example
Below is an example to obtain the serial number of the H-Series device.
AndroidManifest.xml
Your Manifest file is required to allow special user permission. Please add :
<uses-permission android:name="com.aminocom.device.permission.MANAGE_DEVICE" />
<uses-permission android:name="com.aminocom.device.permission.READ_DEVICE_CONFIG" />
MainActivity.java
At your MainActivity, you are suggested to define the client, connection class and then make a service connection call under oncreate().
Here's an example :
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
//Definition for Device Client connection
private DeviceClient mClient;
private DeviceClient.DeviceRemoteServiceConnection mConnection = new DeviceClient.DeviceRemoteServiceConnection();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Create Device Client Connection
mClient = new DeviceClient(getApplicationContext(), mConnection);
try {
mClient.connect();
Log.e("start_deviceClient ","starting");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Sample Method to get the Serial number :
private String getDeviceSerialNumber() {
try {
return mClient.getDeviceSerialNumber();
} catch (Exception e) {
return "";
}
}
After the client connect is called (you may need a callback to notify your application), obtain the serial number with the following call:
String SN=getDeviceSerialNumber();
Log.e("Serial Number = ",SN);
Expected output :
2022-07-29 15:39:33.017 6247-6247/? E/Serial Number =: 107-10587981
References
None