From c5944f6602066e3734edf96f75c1e9cd02042538 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Thu, 7 Nov 2019 19:45:49 +0530 Subject: [PATCH] Fix app installing issue if uninstall operation trigger twice at same time --- .../core/impl/SubscriptionManagerImpl.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 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 ec5c5324750..dee1b7a6d16 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 @@ -637,15 +637,21 @@ public class SubscriptionManagerImpl implements SubscriptionManager { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); DeviceSubscriptionDTO deviceSubscriptionDTO = deviceSubscriptions.get(device.getId()); if (deviceSubscriptionDTO != null) { - if (!deviceSubscriptionDTO.isUnsubscribed() && Operation.Status.COMPLETED.toString() - .equals(deviceSubscriptionDTO.getStatus())) { - subscribingDeviceIdHolder.getAppInstalledDevices().put(deviceIdentifier, device.getId()); - } else if (deviceSubscriptionDTO.isUnsubscribed() && !Operation.Status.COMPLETED.toString() - .equals(deviceSubscriptionDTO.getStatus())) { - subscribingDeviceIdHolder.getAppReUnInstallableDevices().put(deviceIdentifier, device.getId()); - } else if (Operation.Status.PENDING.toString().equals(deviceSubscriptionDTO.getStatus()) + if (Operation.Status.PENDING.toString().equals(deviceSubscriptionDTO.getStatus()) || Operation.Status.IN_PROGRESS.toString().equals(deviceSubscriptionDTO.getStatus())) { subscribingDeviceIdHolder.getSkippedDevices().put(deviceIdentifier, device.getId()); + } else if (deviceSubscriptionDTO.isUnsubscribed()) { + if (Operation.Status.COMPLETED.toString().equals(deviceSubscriptionDTO.getStatus())) { + subscribingDeviceIdHolder.getAppReInstallableDevices().put(deviceIdentifier, device.getId()); + } else { + /*We can't ensure whether app is uninstalled successfully or not hence allow to perform both + install and uninstall operations*/ + subscribingDeviceIdHolder.getAppReUnInstallableDevices().put(deviceIdentifier, device.getId()); + subscribingDeviceIdHolder.getAppReInstallableDevices().put(deviceIdentifier, device.getId()); + } + } else if (!deviceSubscriptionDTO.isUnsubscribed() && Operation.Status.COMPLETED.toString() + .equals(deviceSubscriptionDTO.getStatus())) { + subscribingDeviceIdHolder.getAppInstalledDevices().put(deviceIdentifier, device.getId()); } else { subscribingDeviceIdHolder.getAppReInstallableDevices().put(deviceIdentifier, device.getId()); }