From 3aff323f4d871a9ebb330fdc4dc316fdc5b8ba88 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Thu, 27 Jun 2019 23:38:00 +0530 Subject: [PATCH] Improve APPM device subs updating method --- .../services/android/util/AndroidDeviceUtils.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java index d720aca40..590bf0e55 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java @@ -239,11 +239,15 @@ public class AndroidDeviceUtils { } } else if (AndroidConstants.OperationCodes.INSTALL_APPLICATION.equals(operation.getCode())) { try { - updateAppSubStatus(operation.getId(), operation.getStatus().toString()); + updateAppSubStatus(deviceIdentifier, operation.getId(), operation.getStatus().toString()); } catch (org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException e) { String msg = "Error occurred while updating the app subscription for device."; log.error(msg); throw new OperationManagementException(msg, e); + } catch (DeviceManagementException e) { + String msg = "Error occurred while getting device data for device identifier."; + log.error(msg); + throw new OperationManagementException(msg, e); } } AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation); @@ -303,13 +307,14 @@ public class AndroidDeviceUtils { informationManager.addDeviceLocation(deviceLocation); } - private static void updateAppSubStatus(int operationId, String status) - throws org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException { + private static void updateAppSubStatus(DeviceIdentifier deviceIdentifier, int operationId, String status) + throws org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException, + DeviceManagementException { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); ApplicationManager applicationManager = (ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null); - - applicationManager.updateSubsStatus(operationId, status); + Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); + applicationManager.updateSubsStatus(device.getId(), operationId, status); } private static void updateDeviceInfo(DeviceIdentifier deviceId, DeviceInfo deviceInfo)