|
|
|
@ -24,13 +24,18 @@ import org.wso2.carbon.device.mgt.common.*;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
|
|
|
|
|
import org.wso2.carbon.device.mgt.extensions.license.mgt.RegistryBasedLicenseManager;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
|
|
|
|
import org.wso2.carbon.registry.api.Collection;
|
|
|
|
|
import org.wso2.carbon.registry.api.Registry;
|
|
|
|
|
import org.wso2.carbon.registry.api.Resource;
|
|
|
|
|
import org.wso2.carbon.registry.api.RegistryException;
|
|
|
|
|
|
|
|
|
@ -42,10 +47,18 @@ public class AndroidDeviceManager implements DeviceManager {
|
|
|
|
|
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
|
|
|
|
|
private static final Log log = LogFactory.getLog(AndroidDeviceManagementService.class);
|
|
|
|
|
private FeatureManager featureManager = new AndroidFeatureManager();
|
|
|
|
|
private License license;
|
|
|
|
|
private LicenseManager licenseManager;
|
|
|
|
|
|
|
|
|
|
public AndroidDeviceManager() {
|
|
|
|
|
mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
|
|
|
|
|
this.mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
|
|
|
|
|
try {
|
|
|
|
|
Registry registry =
|
|
|
|
|
MobileDeviceManagementDataHolder.getInstance().getRegistryService().getConfigSystemRegistry();
|
|
|
|
|
this.licenseManager = new RegistryBasedLicenseManager(registry);
|
|
|
|
|
} catch (org.wso2.carbon.registry.core.exceptions.RegistryException e) {
|
|
|
|
|
throw new IllegalStateException("Error occurred while retrieving config system registry of the tenant, " +
|
|
|
|
|
"which in turns fails the initialization of Android Device Manager", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -90,9 +103,11 @@ public class AndroidDeviceManager implements DeviceManager {
|
|
|
|
|
ConfigurationEntry entry;
|
|
|
|
|
Resource resource;
|
|
|
|
|
try {
|
|
|
|
|
String androidRegPath = MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants.
|
|
|
|
|
String androidRegPath =
|
|
|
|
|
MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants.
|
|
|
|
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
|
dsCollection = (Collection) MobileDeviceManagementUtil.getRegistryResource(androidRegPath);
|
|
|
|
|
dsCollection =
|
|
|
|
|
(Collection) MobileDeviceManagementUtil.getRegistryResource(androidRegPath);
|
|
|
|
|
String[] dsmPaths = dsCollection.getChildren();
|
|
|
|
|
for (String dsmPath : dsmPaths) {
|
|
|
|
|
entry = new ConfigurationEntry();
|
|
|
|
@ -152,8 +167,7 @@ public class AndroidDeviceManager implements DeviceManager {
|
|
|
|
|
log.debug("Modifying the Android device enrollment data");
|
|
|
|
|
}
|
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
|
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
|
|
|
|
.updateMobileDevice(mobileDevice);
|
|
|
|
|
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice);
|
|
|
|
|
AndroidDAOFactory.commitTransaction();
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
try {
|
|
|
|
@ -265,6 +279,16 @@ public class AndroidDeviceManager implements DeviceManager {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public License getLicense(String languageCode) throws LicenseManagementException {
|
|
|
|
|
return licenseManager.getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, languageCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addLicense(License license) throws LicenseManagementException {
|
|
|
|
|
licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, license);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device)
|
|
|
|
|
throws DeviceManagementException {
|
|
|
|
|