|
|
@ -49,317 +49,319 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class AndroidDeviceManager implements DeviceManager {
|
|
|
|
public class AndroidDeviceManager implements DeviceManager {
|
|
|
|
|
|
|
|
|
|
|
|
private AbstractMobileDeviceManagementDAOFactory daoFactory;
|
|
|
|
private AbstractMobileDeviceManagementDAOFactory daoFactory;
|
|
|
|
private static final Log log = LogFactory.getLog(AndroidDeviceManagementService.class);
|
|
|
|
private static final Log log = LogFactory.getLog(AndroidDeviceManagementService.class);
|
|
|
|
private FeatureManager featureManager = new AndroidFeatureManager();
|
|
|
|
private FeatureManager featureManager = new AndroidFeatureManager();
|
|
|
|
private LicenseManager licenseManager;
|
|
|
|
private LicenseManager licenseManager;
|
|
|
|
|
|
|
|
|
|
|
|
public AndroidDeviceManager() {
|
|
|
|
public AndroidDeviceManager() {
|
|
|
|
this.daoFactory = new AndroidDAOFactory();
|
|
|
|
this.daoFactory = new AndroidDAOFactory();
|
|
|
|
this.licenseManager = new RegistryBasedLicenseManager();
|
|
|
|
this.licenseManager = new RegistryBasedLicenseManager();
|
|
|
|
|
|
|
|
License defaultLicense;
|
|
|
|
|
|
|
|
|
|
|
|
License defaultLicense = AndroidPluginUtils.getDefaultLicense();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (licenseManager.getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, "en_US") == null) {
|
|
|
|
licenseManager
|
|
|
|
defaultLicense = AndroidPluginUtils.getDefaultLicense();
|
|
|
|
.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, defaultLicense);
|
|
|
|
licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, defaultLicense);
|
|
|
|
featureManager.addSupportedFeaturesToDB();
|
|
|
|
}
|
|
|
|
} catch (LicenseManagementException e) {
|
|
|
|
featureManager.addSupportedFeaturesToDB();
|
|
|
|
log.error("Error occurred while adding default license for Android devices", e);
|
|
|
|
} catch (LicenseManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
log.error("Error occurred while adding default license for Android devices", e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
log.error("Error occurred while adding supported device features for Android platform", e);
|
|
|
|
log.error("Error occurred while adding supported device features for Android platform", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public FeatureManager getFeatureManager() {
|
|
|
|
public FeatureManager getFeatureManager() {
|
|
|
|
return featureManager;
|
|
|
|
return featureManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean saveConfiguration(TenantConfiguration tenantConfiguration)
|
|
|
|
public boolean saveConfiguration(TenantConfiguration tenantConfiguration)
|
|
|
|
throws DeviceManagementException {
|
|
|
|
throws DeviceManagementException {
|
|
|
|
boolean status;
|
|
|
|
boolean status;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Persisting android configurations in Registry");
|
|
|
|
log.debug("Persisting android configurations in Registry");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String resourcePath = MobileDeviceManagementUtil.getPlatformConfigPath(
|
|
|
|
String resourcePath = MobileDeviceManagementUtil.getPlatformConfigPath(
|
|
|
|
DeviceManagementConstants.
|
|
|
|
DeviceManagementConstants.
|
|
|
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
StringWriter writer = new StringWriter();
|
|
|
|
StringWriter writer = new StringWriter();
|
|
|
|
JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class);
|
|
|
|
JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class);
|
|
|
|
Marshaller marshaller = context.createMarshaller();
|
|
|
|
Marshaller marshaller = context.createMarshaller();
|
|
|
|
marshaller.marshal(tenantConfiguration, writer);
|
|
|
|
marshaller.marshal(tenantConfiguration, writer);
|
|
|
|
|
|
|
|
|
|
|
|
Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newResource();
|
|
|
|
Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newResource();
|
|
|
|
resource.setContent(writer.toString());
|
|
|
|
resource.setContent(writer.toString());
|
|
|
|
resource.setMediaType(MobilePluginConstants.MEDIA_TYPE_XML);
|
|
|
|
resource.setMediaType(MobilePluginConstants.MEDIA_TYPE_XML);
|
|
|
|
MobileDeviceManagementUtil.putRegistryResource(resourcePath, resource);
|
|
|
|
MobileDeviceManagementUtil.putRegistryResource(resourcePath, resource);
|
|
|
|
status = true;
|
|
|
|
status = true;
|
|
|
|
} catch (MobileDeviceMgtPluginException e) {
|
|
|
|
} catch (MobileDeviceMgtPluginException e) {
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
"Error occurred while retrieving the Registry instance : " + e.getMessage(), e);
|
|
|
|
"Error occurred while retrieving the Registry instance : " + e.getMessage(), e);
|
|
|
|
} catch (RegistryException e) {
|
|
|
|
} catch (RegistryException e) {
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
"Error occurred while persisting the Registry resource of Android Configuration : " + e.getMessage(), e);
|
|
|
|
"Error occurred while persisting the Registry resource of Android Configuration : " + e.getMessage(), e);
|
|
|
|
} catch (JAXBException e) {
|
|
|
|
} catch (JAXBException e) {
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
"Error occurred while parsing the Android configuration : " + e.getMessage(), e);
|
|
|
|
"Error occurred while parsing the Android configuration : " + e.getMessage(), e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public TenantConfiguration getConfiguration() throws DeviceManagementException {
|
|
|
|
public TenantConfiguration getConfiguration() throws DeviceManagementException {
|
|
|
|
Resource resource;
|
|
|
|
Resource resource;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String androidRegPath =
|
|
|
|
String androidRegPath =
|
|
|
|
MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants.
|
|
|
|
MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants.
|
|
|
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
resource = MobileDeviceManagementUtil.getRegistryResource(androidRegPath);
|
|
|
|
resource = MobileDeviceManagementUtil.getRegistryResource(androidRegPath);
|
|
|
|
if(resource != null){
|
|
|
|
if (resource != null) {
|
|
|
|
JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class);
|
|
|
|
JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class);
|
|
|
|
Unmarshaller unmarshaller = context.createUnmarshaller();
|
|
|
|
Unmarshaller unmarshaller = context.createUnmarshaller();
|
|
|
|
return (TenantConfiguration) unmarshaller.unmarshal(
|
|
|
|
return (TenantConfiguration) unmarshaller.unmarshal(
|
|
|
|
new StringReader(new String((byte[]) resource.getContent(), Charset.
|
|
|
|
new StringReader(new String((byte[]) resource.getContent(), Charset.
|
|
|
|
forName(MobilePluginConstants.CHARSET_UTF8))));
|
|
|
|
forName(MobilePluginConstants.CHARSET_UTF8))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
} catch (MobileDeviceMgtPluginException e) {
|
|
|
|
} catch (MobileDeviceMgtPluginException e) {
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
"Error occurred while retrieving the Registry instance : " + e.getMessage(), e);
|
|
|
|
"Error occurred while retrieving the Registry instance : " + e.getMessage(), e);
|
|
|
|
} catch (JAXBException e) {
|
|
|
|
} catch (JAXBException e) {
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
"Error occurred while parsing the Android configuration : " + e.getMessage(), e);
|
|
|
|
"Error occurred while parsing the Android configuration : " + e.getMessage(), e);
|
|
|
|
} catch (RegistryException e) {
|
|
|
|
} catch (RegistryException e) {
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
"Error occurred while retrieving the Registry resource of Android Configuration : " + e.getMessage(), e);
|
|
|
|
"Error occurred while retrieving the Registry resource of Android Configuration : " + e.getMessage(), e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
|
|
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
|
|
|
boolean status = false;
|
|
|
|
boolean status = false;
|
|
|
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
|
|
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier());
|
|
|
|
log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
boolean isEnrolled = this.isEnrolled(
|
|
|
|
boolean isEnrolled = this.isEnrolled(
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
if (isEnrolled) {
|
|
|
|
if (isEnrolled) {
|
|
|
|
this.modifyEnrollment(device);
|
|
|
|
this.modifyEnrollment(device);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice);
|
|
|
|
status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice);
|
|
|
|
AndroidDAOFactory.commitTransaction();
|
|
|
|
AndroidDAOFactory.commitTransaction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
AndroidDAOFactory.rollbackTransaction();
|
|
|
|
AndroidDAOFactory.rollbackTransaction();
|
|
|
|
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
|
|
|
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
|
|
|
String msg = "Error occurred while roll back the device enrol transaction :" +
|
|
|
|
String msg = "Error occurred while roll back the device enrol transaction :" +
|
|
|
|
device.toString();
|
|
|
|
device.toString();
|
|
|
|
log.warn(msg, mobileDAOEx);
|
|
|
|
log.warn(msg, mobileDAOEx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String msg =
|
|
|
|
String msg =
|
|
|
|
"Error while enrolling the Android device : " + device.getDeviceIdentifier();
|
|
|
|
"Error while enrolling the Android device : " + device.getDeviceIdentifier();
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
|
|
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
|
|
|
boolean status;
|
|
|
|
boolean status;
|
|
|
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
|
|
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Modifying the Android device enrollment data");
|
|
|
|
log.debug("Modifying the Android device enrollment data");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
status = daoFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice);
|
|
|
|
status = daoFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice);
|
|
|
|
AndroidDAOFactory.commitTransaction();
|
|
|
|
AndroidDAOFactory.commitTransaction();
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
AndroidDAOFactory.rollbackTransaction();
|
|
|
|
AndroidDAOFactory.rollbackTransaction();
|
|
|
|
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
|
|
|
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
|
|
|
String msg = "Error occurred while roll back the update device transaction :" +
|
|
|
|
String msg = "Error occurred while roll back the update device transaction :" +
|
|
|
|
device.toString();
|
|
|
|
device.toString();
|
|
|
|
log.warn(msg, mobileDAOEx);
|
|
|
|
log.warn(msg, mobileDAOEx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String msg = "Error while updating the enrollment of the Android device : " +
|
|
|
|
String msg = "Error while updating the enrollment of the Android device : " +
|
|
|
|
device.getDeviceIdentifier();
|
|
|
|
device.getDeviceIdentifier();
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
boolean status;
|
|
|
|
boolean status;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Dis-enrolling Android device : " + deviceId);
|
|
|
|
log.debug("Dis-enrolling Android device : " + deviceId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
status = daoFactory.getMobileDeviceDAO().deleteMobileDevice(deviceId.getId());
|
|
|
|
status = daoFactory.getMobileDeviceDAO().deleteMobileDevice(deviceId.getId());
|
|
|
|
AndroidDAOFactory.commitTransaction();
|
|
|
|
AndroidDAOFactory.commitTransaction();
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
AndroidDAOFactory.rollbackTransaction();
|
|
|
|
AndroidDAOFactory.rollbackTransaction();
|
|
|
|
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
|
|
|
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
|
|
|
|
String msg = "Error occurred while roll back the device dis enrol transaction :" +
|
|
|
|
String msg = "Error occurred while roll back the device dis enrol transaction :" +
|
|
|
|
deviceId.toString();
|
|
|
|
deviceId.toString();
|
|
|
|
log.warn(msg, mobileDAOEx);
|
|
|
|
log.warn(msg, mobileDAOEx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String msg = "Error while removing the Android device : " + deviceId.getId();
|
|
|
|
String msg = "Error while removing the Android device : " + deviceId.getId();
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
boolean isEnrolled = false;
|
|
|
|
boolean isEnrolled = false;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Checking the enrollment of Android device : " + deviceId.getId());
|
|
|
|
log.debug("Checking the enrollment of Android device : " + deviceId.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MobileDevice mobileDevice =
|
|
|
|
MobileDevice mobileDevice =
|
|
|
|
daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId());
|
|
|
|
daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId());
|
|
|
|
if (mobileDevice != null) {
|
|
|
|
if (mobileDevice != null) {
|
|
|
|
isEnrolled = true;
|
|
|
|
isEnrolled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
String msg = "Error while checking the enrollment status of Android device : " +
|
|
|
|
String msg = "Error while checking the enrollment status of Android device : " +
|
|
|
|
deviceId.getId();
|
|
|
|
deviceId.getId();
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isEnrolled;
|
|
|
|
return isEnrolled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean setActive(DeviceIdentifier deviceId, boolean status)
|
|
|
|
public boolean setActive(DeviceIdentifier deviceId, boolean status)
|
|
|
|
throws DeviceManagementException {
|
|
|
|
throws DeviceManagementException {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
Device device;
|
|
|
|
Device device;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Getting the details of Android device : '" + deviceId.getId() + "'");
|
|
|
|
log.debug("Getting the details of Android device : '" + deviceId.getId() + "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MobileDevice mobileDevice = daoFactory.getMobileDeviceDAO().
|
|
|
|
MobileDevice mobileDevice = daoFactory.getMobileDeviceDAO().
|
|
|
|
getMobileDevice(deviceId.getId());
|
|
|
|
getMobileDevice(deviceId.getId());
|
|
|
|
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
|
|
|
|
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
"Error occurred while fetching the Android device: '" +
|
|
|
|
"Error occurred while fetching the Android device: '" +
|
|
|
|
deviceId.getId() + "'", e);
|
|
|
|
deviceId.getId() + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return device;
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
|
|
|
|
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
|
|
|
|
throws DeviceManagementException {
|
|
|
|
throws DeviceManagementException {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
|
|
|
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser,
|
|
|
|
public boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser,
|
|
|
|
EnrolmentInfo.Status status) throws DeviceManagementException {
|
|
|
|
EnrolmentInfo.Status status) throws DeviceManagementException {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public License getLicense(String languageCode) throws LicenseManagementException {
|
|
|
|
public License getLicense(String languageCode) throws LicenseManagementException {
|
|
|
|
return licenseManager.
|
|
|
|
return licenseManager.
|
|
|
|
getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, languageCode);
|
|
|
|
getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, languageCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addLicense(License license) throws LicenseManagementException {
|
|
|
|
public void addLicense(License license) throws LicenseManagementException {
|
|
|
|
licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, license);
|
|
|
|
licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, license);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean requireDeviceAuthorization() {
|
|
|
|
public boolean requireDeviceAuthorization() {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device)
|
|
|
|
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device)
|
|
|
|
throws DeviceManagementException {
|
|
|
|
throws DeviceManagementException {
|
|
|
|
boolean status;
|
|
|
|
boolean status;
|
|
|
|
Device existingDevice = this.getDevice(deviceIdentifier);
|
|
|
|
Device existingDevice = this.getDevice(deviceIdentifier);
|
|
|
|
// This object holds the current persisted device object
|
|
|
|
// This object holds the current persisted device object
|
|
|
|
MobileDevice existingMobileDevice =
|
|
|
|
MobileDevice existingMobileDevice =
|
|
|
|
MobileDeviceManagementUtil.convertToMobileDevice(existingDevice);
|
|
|
|
MobileDeviceManagementUtil.convertToMobileDevice(existingDevice);
|
|
|
|
|
|
|
|
|
|
|
|
// This object holds the newly received device object from response
|
|
|
|
// This object holds the newly received device object from response
|
|
|
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
|
|
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
|
|
|
|
|
|
|
|
|
|
|
// Updating current object features using newer ones
|
|
|
|
// Updating current object features using newer ones
|
|
|
|
existingMobileDevice.setLatitude(mobileDevice.getLatitude());
|
|
|
|
existingMobileDevice.setLatitude(mobileDevice.getLatitude());
|
|
|
|
existingMobileDevice.setLongitude(mobileDevice.getLongitude());
|
|
|
|
existingMobileDevice.setLongitude(mobileDevice.getLongitude());
|
|
|
|
existingMobileDevice.setDeviceProperties(mobileDevice.getDeviceProperties());
|
|
|
|
existingMobileDevice.setDeviceProperties(mobileDevice.getDeviceProperties());
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug(
|
|
|
|
log.debug(
|
|
|
|
"updating the details of Android device : " + device.getDeviceIdentifier());
|
|
|
|
"updating the details of Android device : " + device.getDeviceIdentifier());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
status = daoFactory.getMobileDeviceDAO().updateMobileDevice(existingMobileDevice);
|
|
|
|
status = daoFactory.getMobileDeviceDAO().updateMobileDevice(existingMobileDevice);
|
|
|
|
AndroidDAOFactory.commitTransaction();
|
|
|
|
AndroidDAOFactory.commitTransaction();
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
AndroidDAOFactory.rollbackTransaction();
|
|
|
|
AndroidDAOFactory.rollbackTransaction();
|
|
|
|
} catch (MobileDeviceManagementDAOException e1) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e1) {
|
|
|
|
log.warn("Error occurred while roll back the update device info transaction : '" +
|
|
|
|
log.warn("Error occurred while roll back the update device info transaction : '" +
|
|
|
|
device.toString() + "'", e1);
|
|
|
|
device.toString() + "'", e1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
"Error occurred while updating the Android device: '" +
|
|
|
|
"Error occurred while updating the Android device: '" +
|
|
|
|
device.getDeviceIdentifier() + "'", e);
|
|
|
|
device.getDeviceIdentifier() + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Device> getAllDevices() throws DeviceManagementException {
|
|
|
|
public List<Device> getAllDevices() throws DeviceManagementException {
|
|
|
|
List<Device> devices = null;
|
|
|
|
List<Device> devices = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Fetching the details of all Android devices");
|
|
|
|
log.debug("Fetching the details of all Android devices");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<MobileDevice> mobileDevices =
|
|
|
|
List<MobileDevice> mobileDevices =
|
|
|
|
daoFactory.getMobileDeviceDAO().getAllMobileDevices();
|
|
|
|
daoFactory.getMobileDeviceDAO().getAllMobileDevices();
|
|
|
|
if (mobileDevices != null) {
|
|
|
|
if (mobileDevices != null) {
|
|
|
|
devices = new ArrayList<>();
|
|
|
|
devices = new ArrayList<>();
|
|
|
|
for (MobileDevice mobileDevice : mobileDevices) {
|
|
|
|
for (MobileDevice mobileDevice : mobileDevices) {
|
|
|
|
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
|
|
|
|
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while fetching all Android devices",
|
|
|
|
throw new DeviceManagementException("Error occurred while fetching all Android devices",
|
|
|
|
e);
|
|
|
|
e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return devices;
|
|
|
|
return devices;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|