Merge branch 'application-mgt-new' into 'application-mgt-new'

Improve APPM device subs updating method

See merge request entgra/carbon-device-mgt-plugins!55
revert-dabc3590
Dharmakeerthi Lasantha 6 years ago
commit dcb6bf2806

@ -239,11 +239,15 @@ public class AndroidDeviceUtils {
} }
} else if (AndroidConstants.OperationCodes.INSTALL_APPLICATION.equals(operation.getCode())) { } else if (AndroidConstants.OperationCodes.INSTALL_APPLICATION.equals(operation.getCode())) {
try { 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) { } catch (org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException e) {
String msg = "Error occurred while updating the app subscription for device."; String msg = "Error occurred while updating the app subscription for device.";
log.error(msg); log.error(msg);
throw new OperationManagementException(msg, e); 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); AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation);
@ -303,13 +307,14 @@ public class AndroidDeviceUtils {
informationManager.addDeviceLocation(deviceLocation); informationManager.addDeviceLocation(deviceLocation);
} }
private static void updateAppSubStatus(int operationId, String status) private static void updateAppSubStatus(DeviceIdentifier deviceIdentifier, int operationId, String status)
throws org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException { throws org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException,
DeviceManagementException {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ApplicationManager applicationManager = ApplicationManager applicationManager =
(ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null); (ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null);
Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
applicationManager.updateSubsStatus(operationId, status); applicationManager.updateSubsStatus(device.getId(), operationId, status);
} }
private static void updateDeviceInfo(DeviceIdentifier deviceId, DeviceInfo deviceInfo) private static void updateDeviceInfo(DeviceIdentifier deviceId, DeviceInfo deviceInfo)

Loading…
Cancel
Save