|
|
@ -41,12 +41,11 @@ public class AndroidFeatureManager implements FeatureManager {
|
|
|
|
|
|
|
|
|
|
|
|
public AndroidFeatureManager() {
|
|
|
|
public AndroidFeatureManager() {
|
|
|
|
mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
|
|
|
|
mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
|
|
|
|
this.featureDAO = mobileDeviceManagementDAOFactory.getMobileFeatureDao();
|
|
|
|
this.featureDAO = mobileDeviceManagementDAOFactory.getMobileFeatureDAO();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean addFeature(Feature feature) throws DeviceManagementException {
|
|
|
|
public boolean addFeature(Feature feature) throws DeviceManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
|
|
|
|
MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
|
|
|
@ -63,6 +62,27 @@ public class AndroidFeatureManager implements FeatureManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean addFeatures(List<Feature> features) throws DeviceManagementException {
|
|
|
|
|
|
|
|
List<MobileFeature> mobileFeatures = new ArrayList<MobileFeature>();
|
|
|
|
|
|
|
|
for (Feature feature:features) {
|
|
|
|
|
|
|
|
mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
featureDAO.addFeatures(mobileFeatures);
|
|
|
|
|
|
|
|
AndroidDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
AndroidDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
} catch (MobileDeviceManagementDAOException e1) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while roll-backing the transaction", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while adding the features", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Feature getFeature(String name) throws DeviceManagementException {
|
|
|
|
public Feature getFeature(String name) throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -76,7 +96,6 @@ public class AndroidFeatureManager implements FeatureManager {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Feature> getFeatures() throws DeviceManagementException {
|
|
|
|
public List<Feature> getFeatures() throws DeviceManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
List<Feature> featureList = new ArrayList<Feature>();
|
|
|
|
List<Feature> featureList = new ArrayList<Feature>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<MobileFeature> mobileFeatures = featureDAO.getAllFeatures();
|
|
|
|
List<MobileFeature> mobileFeatures = featureDAO.getAllFeatures();
|
|
|
@ -92,7 +111,7 @@ public class AndroidFeatureManager implements FeatureManager {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean removeFeature(String code) throws DeviceManagementException {
|
|
|
|
public boolean removeFeature(String code) throws DeviceManagementException {
|
|
|
|
boolean status = false;
|
|
|
|
boolean status;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
AndroidDAOFactory.beginTransaction();
|
|
|
|
featureDAO.deleteFeatureByCode(code);
|
|
|
|
featureDAO.deleteFeatureByCode(code);
|
|
|
@ -109,4 +128,115 @@ public class AndroidFeatureManager implements FeatureManager {
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
|
|
|
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
|
|
|
List<Feature> supportedFeatures = getSupportedFeatures();
|
|
|
|
|
|
|
|
List<Feature> existingFeatures = this.getFeatures();
|
|
|
|
|
|
|
|
List<Feature> missingFeatures = MobileDeviceManagementUtil.
|
|
|
|
|
|
|
|
getMissingFeatures(supportedFeatures, existingFeatures);
|
|
|
|
|
|
|
|
return this.addFeatures(missingFeatures);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Get the supported feature list.
|
|
|
|
|
|
|
|
private static List<Feature> getSupportedFeatures() {
|
|
|
|
|
|
|
|
List<Feature> supportedFeatures = new ArrayList<Feature>();
|
|
|
|
|
|
|
|
Feature feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("DEVICE_LOCK");
|
|
|
|
|
|
|
|
feature.setName("Device Lock");
|
|
|
|
|
|
|
|
feature.setDescription("Lock the device");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("DEVICE_LOCATION");
|
|
|
|
|
|
|
|
feature.setName("Location");
|
|
|
|
|
|
|
|
feature.setDescription("Request coordinates of device location");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("WIFI");
|
|
|
|
|
|
|
|
feature.setName("wifi");
|
|
|
|
|
|
|
|
feature.setDescription("Setting up wifi configuration");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("CAMERA");
|
|
|
|
|
|
|
|
feature.setName("camera");
|
|
|
|
|
|
|
|
feature.setDescription("Enable or disable camera");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("EMAIL");
|
|
|
|
|
|
|
|
feature.setName("Email");
|
|
|
|
|
|
|
|
feature.setDescription("Configure email settings");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("DEVICE_MUTE");
|
|
|
|
|
|
|
|
feature.setName("mute");
|
|
|
|
|
|
|
|
feature.setDescription("Enable mute in the device");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("DEVICE_INFO");
|
|
|
|
|
|
|
|
feature.setName("Device info");
|
|
|
|
|
|
|
|
feature.setDescription("Request device information");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("ENTERPRISE_WIPE");
|
|
|
|
|
|
|
|
feature.setName("Enterprise Wipe");
|
|
|
|
|
|
|
|
feature.setDescription("Remove enterprise applications");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("CLEAR_PASSWORD");
|
|
|
|
|
|
|
|
feature.setName("Clear Password");
|
|
|
|
|
|
|
|
feature.setDescription("Clear current password");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("WIPE_DATA");
|
|
|
|
|
|
|
|
feature.setName("Wipe Data");
|
|
|
|
|
|
|
|
feature.setDescription("Factory reset the device");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("APPLICATION_LIST");
|
|
|
|
|
|
|
|
feature.setName("Application List");
|
|
|
|
|
|
|
|
feature.setDescription("Request list of current installed applications");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("CHANGE_LOCK_CODE");
|
|
|
|
|
|
|
|
feature.setName("Change Lock-code");
|
|
|
|
|
|
|
|
feature.setDescription("Change current lock code");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("INSTALL_APPLICATION");
|
|
|
|
|
|
|
|
feature.setName("Install App");
|
|
|
|
|
|
|
|
feature.setDescription("Install Enterprise or Market application");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("UNINSTALL_APPLICATION");
|
|
|
|
|
|
|
|
feature.setName("Uninstall App");
|
|
|
|
|
|
|
|
feature.setDescription("Uninstall application");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("BLACKLIST_APPLICATIONS");
|
|
|
|
|
|
|
|
feature.setName("Blacklist app");
|
|
|
|
|
|
|
|
feature.setDescription("Blacklist applications");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("ENCRYPT_STORAGE");
|
|
|
|
|
|
|
|
feature.setName("Encrypt storage");
|
|
|
|
|
|
|
|
feature.setDescription("Encrypt storage");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("DEVICE_RING");
|
|
|
|
|
|
|
|
feature.setName("Ring");
|
|
|
|
|
|
|
|
feature.setDescription("Ring the device");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("PASSCODE_POLICY");
|
|
|
|
|
|
|
|
feature.setName("Password Policy");
|
|
|
|
|
|
|
|
feature.setDescription("Set passcode policy");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
feature = new Feature();
|
|
|
|
|
|
|
|
feature.setCode("NOTIFICATION");
|
|
|
|
|
|
|
|
feature.setName("Message");
|
|
|
|
|
|
|
|
feature.setDescription("Send message");
|
|
|
|
|
|
|
|
supportedFeatures.add(feature);
|
|
|
|
|
|
|
|
return supportedFeatures;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|