This documentation is for WSO2 Enterprise Mobility Manager 2.2.0. View documentation for the latest release.
Invoking the Firmware Upgrade API - Enterprise Mobility Manager 2.2.0 - WSO2 Documentation
Skip to end of metadata
Go to start of metadata

The Android system service application provides an API for the external applications to know the device firmware upgrade package status, download progress and to check if a new firmware upgrade is available. To invoke these APIs, external applications should invoke the service exposed by the system service application and implement a BroadcastReceiver to receive results.

Guidelines to invoke the API

Follows the points given below as guidelines:

  • Use the org.wso2.emm.system.service.START_SERVICE service name to invoke the API.
  • Use the org.wso2.emm.system.service.MESSAGE_PROCESSED action name to call and receive the output from the API.
  • Use the FIRMWARE_UPGRADE_PACKAGE_STATUS operation code when invoking the status/availability check API.
  • Use the FIRMWARE_UPGRADE_DOWNLOAD_PROGRESS operation code when invoking the API to chek the progress of the downloading package.
  • Define the intent result parameters as follows:
    • Define 200 as the status codes to denote success and 400 to denote failure. 
    • Define the payload as a result payload. 

    • The service will return the JSON output as the payload for status/availability check API.

         "size":"UPGRADE PACKAGE SIZE",
         "release":"UPGRADE PACKAGE RELEASE CODE",
         "version":"UPGRADE PACKAGE VERSION CODE",
    • The service will return a JSON output as the payload when using the API to check the download status of the package.



Invoking the API

Follow the steps given below to invoke the API by starting the exposed service.

  1. Configure the BroadcastReceiver.

    public class UpgradeServiceResponseReceiver extends BroadcastReceiver {
       public void onReceive(Context context, Intent intent) {
             String code = intent.getStringExtra(“code”);
             String status = intent.getStringExtra(“status”);
             JSONObject result = new JSONObject(intent.getStringExtra(“payload”));
             //Your result manipulation code goes here
  2. Register a receiver to listen to the service results. 

    Context context = getApplicationContext();
    IntentFilter filter = new IntentFilter(“org.wso2.emm.system.service.MESSAGE_PROCESSED”);
    UpgradeServiceResponseReceiver receiver = new UpgradeServiceResponseReceiver();
    registerReceiver(receiver, filter);
  3. Call the service. 

    This should always happen after registering the receiver.

    Intent intent =  new Intent(“org.wso2.emm.system.service.START_SERVICE”);
    Intent explicitIntent = createExplicitFromImplicitIntent(context, intent);
    if (explicitIntent != null) {
      intent = explicitIntent;
    intent.putExtra("code", “FIRMWARE_UPGRADE_PACKAGE_STATUS”);
  4. Create an explicit intent method.

    public static Intent createExplicitFromImplicitIntent(Context context, Intent implicitIntent) {
      //Retrieve all services that can match the given intent
      PackageManager pm = context.getPackageManager();
      List<ResolveInfo> resolveInfo = pm.queryIntentServices(implicitIntent, 0);
      //Make sure only one match was found
      if (resolveInfo == null || resolveInfo.size() != 1) {
         return null;
      //Get component info and create ComponentName
      ResolveInfo serviceInfo = resolveInfo.get(0);
      String packageName = serviceInfo.serviceInfo.packageName;
      String className =;
      ComponentName component = new ComponentName(packageName, className);
      //Create a new intent. Use the old one for extras and such reuse
      Intent explicitIntent = new Intent(implicitIntent);
      //Set the component to be explicit
      return explicitIntent;

What's next

For more information, see Upgrading Firmware of an Android Device.

  • No labels