mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
uninstall related fix
This commit is contained in:
parent
a09638e79b
commit
54c2de4230
@ -57,6 +57,8 @@ import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
|
|||||||
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
|
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
|
||||||
import org.wso2.carbon.context.CarbonContext;
|
import org.wso2.carbon.context.CarbonContext;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.SubAction;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.SubscriptionType;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
@ -100,6 +102,7 @@ import javax.validation.ConstraintViolation;
|
|||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -284,13 +287,14 @@ public class AndroidDeviceUtils {
|
|||||||
|
|
||||||
List<? extends Operation> operations;
|
List<? extends Operation> operations;
|
||||||
operations = AndroidAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier);
|
operations = AndroidAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier);
|
||||||
if (handleGoogleAps) {
|
if (operations != null && handleGoogleAps) {
|
||||||
handleEnrollmentGoogleApps(operations, deviceIdentifier);
|
handleEnrollmentGoogleApps(operations, deviceIdentifier);
|
||||||
}
|
}
|
||||||
return operations;
|
return operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleEnrollmentGoogleApps(List<? extends Operation> operations, DeviceIdentifier deviceIdentifier) {
|
private static void handleEnrollmentGoogleApps(List<? extends Operation> operations, DeviceIdentifier
|
||||||
|
deviceIdentifier) {
|
||||||
boolean containsGoogleAppPolicy = false;
|
boolean containsGoogleAppPolicy = false;
|
||||||
for (int x = 0; x < operations.size() && !containsGoogleAppPolicy; x++) {
|
for (int x = 0; x < operations.size() && !containsGoogleAppPolicy; x++) {
|
||||||
Operation operation = operations.get(x);
|
Operation operation = operations.get(x);
|
||||||
@ -317,9 +321,17 @@ public class AndroidDeviceUtils {
|
|||||||
for (JsonElement appElement : appListArray) {
|
for (JsonElement appElement : appListArray) {
|
||||||
JsonElement googlePolicyPayload = appElement.getAsJsonObject().
|
JsonElement googlePolicyPayload = appElement.getAsJsonObject().
|
||||||
get(AndroidConstants.ApplicationInstall.GOOGLE_POLICY_PAYLOAD);
|
get(AndroidConstants.ApplicationInstall.GOOGLE_POLICY_PAYLOAD);
|
||||||
|
|
||||||
if (googlePolicyPayload != null) {
|
if (googlePolicyPayload != null) {
|
||||||
containsGoogleAppPolicy = true;
|
String uuid = appElement.getAsJsonObject().get("uuid").toString();
|
||||||
sendPayloadToGoogle(payload, deviceIdentifier);
|
containsGoogleAppPolicy = true;// breaking out of outer for loop
|
||||||
|
try {
|
||||||
|
uuid = uuid.replace("\"", "");
|
||||||
|
sendPayloadToGoogle(uuid, payload, deviceIdentifier);
|
||||||
|
} catch (org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException e) {
|
||||||
|
String errorMessage = "App install failed for device " + deviceIdentifier.getId();
|
||||||
|
log.error(errorMessage, e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,7 +347,8 @@ public class AndroidDeviceUtils {
|
|||||||
* @param payload policy profile
|
* @param payload policy profile
|
||||||
* @param deviceIdentifier device to apply policy
|
* @param deviceIdentifier device to apply policy
|
||||||
*/
|
*/
|
||||||
private static void sendPayloadToGoogle(String payload, DeviceIdentifier deviceIdentifier) {
|
private static void sendPayloadToGoogle(String uuid, String payload, DeviceIdentifier deviceIdentifier)
|
||||||
|
throws org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException {
|
||||||
try {
|
try {
|
||||||
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigsFromGoogle();
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigsFromGoogle();
|
||||||
if (enterpriseConfigs != null && enterpriseConfigs.getErrorResponse() == null) {
|
if (enterpriseConfigs != null && enterpriseConfigs.getErrorResponse() == null) {
|
||||||
@ -358,11 +371,10 @@ public class AndroidDeviceUtils {
|
|||||||
.getGoogleUserId(), apps, enterpriseInstallPolicy.getProductSetBehavior());
|
.getGoogleUserId(), apps, enterpriseInstallPolicy.getProductSetBehavior());
|
||||||
googleAPIInvoker.updateAppsForUser(enterpriseConfigs.getEnterpriseId(), userDetail.getGoogleUserId(),
|
googleAPIInvoker.updateAppsForUser(enterpriseConfigs.getEnterpriseId(), userDetail.getGoogleUserId(),
|
||||||
AndroidEnterpriseUtils.convertToDeviceInstance(enterpriseInstallPolicy));
|
AndroidEnterpriseUtils.convertToDeviceInstance(enterpriseInstallPolicy));
|
||||||
|
AndroidEnterpriseUtils.getAppSubscriptionService()
|
||||||
// for (EnterpriseApp enterpriseApp : enterpriseInstallPolicy.getApps()) {
|
.performEntAppSubscription(uuid,
|
||||||
// googleAPIInvoker.addManagedConfigForDevice(enterpriseConfigs.getEnterpriseId(), userDetail
|
Arrays.asList(CarbonContext.getThreadLocalCarbonContext().getUsername()),
|
||||||
// .getGoogleUserId(), enterpriseInstallPolicy.getAndroidId(), enterpriseApp.getProductId());
|
SubscriptionType.USER.toString(), SubAction.INSTALL.toString(), false);
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,7 @@ import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManage
|
|||||||
import org.wso2.carbon.device.application.mgt.common.response.Application;
|
import org.wso2.carbon.device.application.mgt.common.response.Application;
|
||||||
import org.wso2.carbon.device.application.mgt.common.response.Category;
|
import org.wso2.carbon.device.application.mgt.common.response.Category;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.wrapper.PublicAppReleaseWrapper;
|
import org.wso2.carbon.device.application.mgt.common.wrapper.PublicAppReleaseWrapper;
|
||||||
import org.wso2.carbon.device.application.mgt.common.wrapper.PublicAppWrapper;
|
import org.wso2.carbon.device.application.mgt.common.wrapper.PublicAppWrapper;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||||
@ -266,6 +267,11 @@ public class AndroidEnterpriseUtils {
|
|||||||
return (ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null);
|
return (ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SubscriptionManager getAppSubscriptionService() {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
return (SubscriptionManager) ctx.getOSGiService(SubscriptionManager.class, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static void persistApp(ProductsListResponse productListResponse) throws ApplicationManagementException {
|
public static void persistApp(ProductsListResponse productListResponse) throws ApplicationManagementException {
|
||||||
|
|
||||||
ApplicationManager applicationManager = getAppManagerServer();
|
ApplicationManager applicationManager = getAppManagerServer();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user