From 16ee8ec88214d1529cee7eff07cde0cddba0d5bd Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Thu, 10 Oct 2019 08:40:04 +0530 Subject: [PATCH] Fix app uninstall issue for Android --- .../core/impl/SubscriptionManagerImpl.java | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index 484b9e4add..40428d4a7a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -686,6 +686,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { return MDMAndroidOperationUtil.createInstallAppOperation(app); } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { app.setType(mobileAppType); + app.setAppIdentifier(application.getPackageName()); return MDMAndroidOperationUtil.createAppUninstallOperation(app); } else { String msg = "Invalid Action is found. Action: " + action; @@ -706,6 +707,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { app.setProperties(properties); return MDMIOSOperationUtil.createInstallAppOperation(app); } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { + app.setType(mobileAppType); + app.setAppIdentifier(application.getPackageName()); return MDMIOSOperationUtil.createAppUninstallOperation(app); } else { String msg = "Invalid Action is found. Action: " + action; @@ -713,35 +716,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { throw new ApplicationManagementException(msg); } } else { - if (ApplicationType.CUSTOM.toString().equalsIgnoreCase(application.getType())) { - if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { - ProfileOperation operation = new ProfileOperation(); - operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_INSTALL_APPLICATION); - operation.setType(Operation.Type.PROFILE); - CustomApplication customApplication = new CustomApplication(); - customApplication.setType(application.getType()); - customApplication.setUrl(application.getApplicationReleases().get(0).getInstallerPath()); - operation.setPayLoad(customApplication.toJSON()); - return operation; - } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { - ProfileOperation operation = new ProfileOperation(); - operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_UNINSTALL_APPLICATION); - operation.setType(Operation.Type.PROFILE); - CustomApplication customApplication = new CustomApplication(); - customApplication.setType(application.getType()); - //todo get application package name and set - operation.setPayLoad(customApplication.toJSON()); - return MDMAndroidOperationUtil.createAppUninstallOperation(app); - } else { - String msg = "Invalid Action is found. Action: " + action; - log.error(msg); - throw new ApplicationManagementException(msg); - } - } else { - String msg = "Invalid device type is found. Device Type: " + deviceType; - log.error(msg); - throw new ApplicationManagementException(msg); - } + String msg = "Invalid device type is found. Device Type: " + deviceType; + log.error(msg); + throw new ApplicationManagementException(msg); } } } catch (UnknownApplicationTypeException e) {