mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Improve performance of the core
This commit is contained in:
parent
7dc3802ff1
commit
9e99e2ec7a
@ -335,7 +335,7 @@ public class AndroidDeviceManager implements DeviceManager {
|
||||
List<MobileDevice> mobileDevices =
|
||||
daoFactory.getMobileDeviceDAO().getAllMobileDevices();
|
||||
if (mobileDevices != null) {
|
||||
devices = new ArrayList<>();
|
||||
devices = new ArrayList<>(mobileDevices.size());
|
||||
for (MobileDevice mobileDevice : mobileDevices) {
|
||||
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class AndroidFeatureManager implements FeatureManager {
|
||||
|
||||
@Override
|
||||
public boolean addFeatures(List<Feature> features) throws DeviceManagementException {
|
||||
List<MobileFeature> mobileFeatures = new ArrayList<MobileFeature>();
|
||||
List<MobileFeature> mobileFeatures = new ArrayList<MobileFeature>(features.size());
|
||||
for (Feature feature : features) {
|
||||
mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature));
|
||||
}
|
||||
@ -96,9 +96,9 @@ public class AndroidFeatureManager implements FeatureManager {
|
||||
|
||||
@Override
|
||||
public List<Feature> getFeatures() throws DeviceManagementException {
|
||||
List<Feature> featureList = new ArrayList<Feature>();
|
||||
try {
|
||||
List<MobileFeature> mobileFeatures = featureDAO.getAllFeatures();
|
||||
List<Feature> featureList = new ArrayList<Feature>(mobileFeatures.size());
|
||||
for (MobileFeature mobileFeature : mobileFeatures) {
|
||||
featureList.add(MobileDeviceManagementUtil.convertToFeature(mobileFeature));
|
||||
}
|
||||
|
||||
@ -61,8 +61,6 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService {
|
||||
if (compliancePayload == null || policy == null) {
|
||||
return complianceData;
|
||||
}
|
||||
List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>();
|
||||
List<ComplianceFeature> nonComplianceFeatures = new ArrayList<>();
|
||||
String compliancePayloadString = new Gson().toJson(compliancePayload);
|
||||
// Parsing json string to get compliance features.
|
||||
JsonElement jsonElement;
|
||||
@ -75,6 +73,8 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService {
|
||||
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
||||
Gson gson = new Gson();
|
||||
ComplianceFeature complianceFeature;
|
||||
List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>(jsonArray.size());
|
||||
List<ComplianceFeature> nonComplianceFeatures = new ArrayList<>();
|
||||
|
||||
for (JsonElement element : jsonArray) {
|
||||
complianceFeature = gson.fromJson(element, ComplianceFeature.class);
|
||||
|
||||
@ -43,7 +43,7 @@ public class GCMService {
|
||||
}
|
||||
|
||||
public void sendNotification(String messageData, Device device) {
|
||||
List<Device> devices = new ArrayList<>();
|
||||
List<Device> devices = new ArrayList<>(1);
|
||||
devices.add(device);
|
||||
GCMResult result = GCMUtil.sendWakeUpCall(messageData, devices);
|
||||
if (result.getStatusCode() != 200) {
|
||||
|
||||
@ -134,7 +134,7 @@ public class GCMUtil {
|
||||
}
|
||||
|
||||
private static List<String> getGCMTokens(List<Device> devices) {
|
||||
List<String> tokens = new ArrayList<>();
|
||||
List<String> tokens = new ArrayList<>(devices.size());
|
||||
for (Device device : devices) {
|
||||
tokens.add(getGCMToken(device.getProperties()));
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ public class WindowsDeviceManager implements DeviceManager {
|
||||
WindowsDAOFactory.openConnection();
|
||||
List<MobileDevice> mobileDevices = daoFactory.getMobileDeviceDAO().getAllMobileDevices();
|
||||
if (mobileDevices != null) {
|
||||
devices = new ArrayList<>();
|
||||
devices = new ArrayList<>(mobileDevices.size());
|
||||
for (MobileDevice mobileDevice : mobileDevices) {
|
||||
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ public class WindowsFeatureManager implements FeatureManager {
|
||||
|
||||
@Override
|
||||
public boolean addFeatures(List<Feature> features) throws DeviceManagementException {
|
||||
List<MobileFeature> mobileFeatures = new ArrayList<MobileFeature>();
|
||||
List<MobileFeature> mobileFeatures = new ArrayList<MobileFeature>(features.size());
|
||||
for (Feature feature : features) {
|
||||
mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature));
|
||||
}
|
||||
@ -92,10 +92,10 @@ public class WindowsFeatureManager implements FeatureManager {
|
||||
@Override
|
||||
public List<Feature> getFeatures() throws DeviceManagementException {
|
||||
|
||||
List<Feature> featureList = new ArrayList<Feature>();
|
||||
try {
|
||||
WindowsDAOFactory.openConnection();
|
||||
List<MobileFeature> mobileFeatures = featureDAO.getAllFeatures();
|
||||
List<Feature> featureList = new ArrayList<Feature>(mobileFeatures.size());
|
||||
for (MobileFeature mobileFeature : mobileFeatures) {
|
||||
featureList.add(MobileDeviceManagementUtil.convertToFeature(mobileFeature));
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ public class MobileDeviceManagementUtil {
|
||||
|
||||
public static List<Integer> getMobileOperationIdsFromMobileDeviceOperations(
|
||||
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings) {
|
||||
List<Integer> mobileOperationIds = new ArrayList<Integer>();
|
||||
List<Integer> mobileOperationIds = new ArrayList<Integer>(mobileDeviceOperationMappings.size());
|
||||
for (MobileDeviceOperationMapping mobileDeviceOperationMapping : mobileDeviceOperationMappings) {
|
||||
mobileOperationIds.add(mobileDeviceOperationMapping.getOperationId());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user