com.testvagrant.mdb.android.Android Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optimusmonitor Show documentation
Show all versions of optimusmonitor Show documentation
The Java Client provides access to Optimus cloud for all java based projects.
The newest version!
package com.testvagrant.mdb.android;
import com.testvagrant.mdb.Exceptions.ConnectedDevicesException;
import com.testvagrant.mdb.core.Mobile;
import com.testvagrant.mdb.helpers.AndroidHelper;
import com.testvagrant.monitor.entities.DeviceDetails;
import com.testvagrant.monitor.entities.SmartBOT;
import com.testvagrant.monitor.entities.device.Platform;
import com.testvagrant.monitor.entities.performance.Activity;
import com.testvagrant.monitor.entities.performance.CpuStatistics;
import com.testvagrant.monitor.entities.performance.Exceptions;
import com.testvagrant.monitor.entities.performance.MemoryStatistics;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import static com.testvagrant.mdb.utils.Commands.AndroidCommands.ADB_HEADER;
public class Android extends Mobile implements ADB {
private List deviceDetails;
public Android() {
deviceDetails = new ArrayList<>();
collectDeviceDetails();
}
protected void collectDeviceDetails() {
List devices = collectDevicesOutput(Platform.ANDROID);
List collectedDevices = devices.stream().filter(line -> !(line.equals(ADB_HEADER))).collect(Collectors.toList());
if(collectedDevices.size()==0) {
throw new ConnectedDevicesException("Could not find any devices, are any devices available?");
} else {
AndroidHelper androidHelper = new AndroidHelper(deviceDetails);
androidHelper.initADevices(collectedDevices);
androidHelper.initEmulators(collectedDevices);
}
}
public List getDevices() {
return deviceDetails;
}
public List getDevices(Predicate deviceFilter) {
return deviceDetails.stream().filter(deviceFilter).collect(Collectors.toList());
}
public List getDevices(Predicate deviceFilter, Predicate deviceFilter1) {
return deviceDetails.stream().filter(deviceFilter).filter(deviceFilter1).collect(Collectors.toList());
}
public List getDevices(Predicate deviceFilter, Predicate deviceFilter2, Predicate deviceFilter3) {
return deviceDetails.stream().filter(deviceFilter).filter(deviceFilter2).filter(deviceFilter3).collect(Collectors.toList());
}
public MemoryStatistics getMemoryInfo(SmartBOT smartBOT) {
DumpsysParser dumpsysParser = new DumpsysParser(smartBOT);
return dumpsysParser.getMemoryInfo();
}
public CpuStatistics getCpuInfo(SmartBOT smartBOT) {
DumpsysParser dumpsysParser = new DumpsysParser(smartBOT);
return dumpsysParser.getCpuUsage();
}
public Activity getActivity(SmartBOT smartBOT) {
return new DumpsysParser(smartBOT).getCurrentActivity();
}
public Optional getException(SmartBOT smartBOT){
return new DumpsysParser(smartBOT).getException();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy