use of com.att.aro.core.datacollector.pojo.StatusResult in project VideoOptimzer by attdevsupport.
the class RootedAndroidCollectorImpl method launchCollectorInDevice.
StatusResult launchCollectorInDevice(IDevice device, String folderToSaveTrace, VideoOption videoOption, Hashtable<String, Object> extraParams) {
StatusResult result = new StatusResult();
// just in case previous collector was not shutdown
if (android.checkTcpDumpRunning(device)) {
log.error("unknown collection still running on device");
result.setError(ErrorCodeRegistry.getCollectorAlreadyRunning());
return result;
}
haltCollectorInDevice();
// check for ARO Collector on device, if not try installing it
if (!android.checkPackageExist(device, "com.att.android.arodatacollector") && !pushApk(device)) {
result.setError(ErrorCodeRegistry.getFailToInstallAPK());
return result;
}
String cmd = "am start -n " + "com.att.android.arodatacollector/com.att.android.arodatacollector.activities.AROCollectorSplashActivity" + " -e ERRORDIALOGID 100 -e TraceFolderName " + folderToSaveTrace;
if (android.runApkInDevice(device, cmd)) {
result.setSuccess(true);
} else {
result.setError(ErrorCodeRegistry.getFailToRunApk());
}
return result;
}
use of com.att.aro.core.datacollector.pojo.StatusResult in project VideoOptimzer by attdevsupport.
the class IOSCollectorImpl method startVideoCapture.
private StatusResult startVideoCapture(StatusResult status) {
LOG.info("startVideoCapture");
GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getIosCollector(), GoogleAnalyticsUtil.getAnalyticsEvents().getVideoCheck());
if (videoCapture == null) {
final String videofilepath = datadir + Util.FILE_SEPARATOR + TraceDataConst.FileName.VIDEO_MOV_FILE;
videofile = new File(videofilepath);
try {
videoCapture = new VideoCaptureMacOS(videofile, udId);
} catch (IOException e) {
LOG.error(rvi.getErrorMessage());
status.setSuccess(false);
status.setError(ErrorCodeRegistry.getrviError());
return status;
}
videoCapture.setWorkingFolder(datadir);
videoCapture.addSubscriber(this);
}
videoworker = new SwingWorker<String, Object>() {
@Override
protected String doInBackground() throws Exception {
if (videoCapture != null) {
videoCapture.start();
}
return null;
}
@Override
protected void done() {
try {
get();
if (videoCapture.getStatusResult() != null) {
StatusResult temp = videoCapture.getStatusResult();
status.setError(temp.getError());
status.setSuccess(temp.isSuccess());
}
} catch (Exception ex) {
LOG.error("Error thrown by videoworker: ", ex);
}
}
};
videoworker.execute();
return status;
}
use of com.att.aro.core.datacollector.pojo.StatusResult in project VideoOptimzer by attdevsupport.
the class IOSCollectorImpl method stopWorkers.
/**
* Close down collection processes, Video, RemoteVirtualInterface(tcpdump). Record start times for Video and tcpdump into video_time file Report stop times to
* time file
*/
StatusResult stopWorkers() {
StatusResult status = new StatusResult();
if (videoCapture != null) {
videoCapture.signalStop();
}
if (monitor != null) {
monitor.stopMonitoring();
}
if (rvi != null) {
try {
rvi.stop();
} catch (IOException e) {
LOG.error("IOException", e);
}
recordPcapStartStop();
}
if (mitmAttenuator != null) {
mitmAttenuator.stopCollect();
recordPcapStartStop();
}
if (packetworker != null) {
packetworker.cancel(true);
packetworker = null;
LOG.info("disposed packetworker");
}
if (rviTestWorker != null) {
rviTestWorker.cancel(true);
rviTestWorker = null;
LOG.info("disposed rviTestWorker");
}
if (videoCapture != null) {
// blocking till video capture engine fully stops
videoCapture.stopCapture();
try (BufferedWriter videoTimeStampWriter = new BufferedWriter(new FileWriter(new File(localTraceFolder, TraceDataConst.FileName.VIDEO_TIME_FILE)))) {
LOG.info("Writing video time to file");
String timestr = Double.toString(videoCapture.getVideoStartTime().getTime() / 1000.0);
if (rvi != null) {
timestr += " " + Double.toString(rvi.getTcpdumpInitDate().getTime() / 1000.0);
} else if (mitmAttenuator != null) {
timestr += " " + Double.toString(mitmAttenuator.getStartDate().getTime() / 1000.0);
}
videoTimeStampWriter.write(timestr);
} catch (IOException e) {
LOG.info("Error writing video time to file: ", e);
}
if (videoCapture.isAlive()) {
videoCapture.interrupt();
}
videoCapture = null;
LOG.info("disposed videoCapture");
}
if (videoworker != null) {
videoworker.cancel(true);
videoworker = null;
LOG.info("disposed videoworker");
}
running = false;
status.setSuccess(true);
return status;
}
use of com.att.aro.core.datacollector.pojo.StatusResult in project VideoOptimzer by attdevsupport.
the class IOSCollectorImpl method startCollector.
@Override
public StatusResult startCollector(boolean commandLine, String folderToSaveTrace, VideoOption videoOption, boolean liveViewVideo, String udId, Hashtable<String, Object> extraParams, String password) {
if (extraParams != null) {
this.videoOption = (VideoOption) extraParams.get("video_option");
this.attenuatorModel = (AttenuatorModel) extraParams.get("AttenuatorModel");
}
hdVideoPulled = true;
if (password != null && !validPW) {
setPassword(password);
}
isCapturingVideo = isVideo();
this.udId = udId;
this.isCommandLine = commandLine;
if (isCommandLine) {
isLiveViewVideo = false;
}
this.isLiveViewVideo = liveViewVideo;
StatusResult status = new StatusResult();
status.setSuccess(true);
// avoid running it twice
if (this.running) {
return status;
}
if (filemanager.directoryExistAndNotEmpty(folderToSaveTrace)) {
status.setError(ErrorCodeRegistry.getTraceDirExist());
return status;
}
// there might be permission issue to creating dir to save trace
filemanager.mkDir(folderToSaveTrace);
if (!filemanager.directoryExist(folderToSaveTrace)) {
status.setError(ErrorCodeRegistry.getFailedToCreateLocalTraceDirectory());
return status;
}
// initialize monitor, xcode and rvi
status = init(status);
if (!status.isSuccess()) {
// an error has occurred in initialization
LOG.error("Something went wrong while initializing monitor, xcode or rvi");
return status;
}
if (udId == null || udId.length() < 2) {
// Failed to get Serial Number of Device, connect an IOS device to start.
LOG.error(defaultBundle.getString("Error.serialnumberconnection"));
status.setSuccess(false);
status.setError(ErrorCodeRegistry.getIncorrectSerialNumber());
}
if (!status.isSuccess()) {
// failed to get device s/n
return status;
}
datadir = folderToSaveTrace;
localTraceFolder = new File(folderToSaveTrace);
if (!localTraceFolder.exists()) {
if (!localTraceFolder.mkdirs()) {
datadir = "";
// There was an error creating directory:
LOG.error(defaultBundle.getString("Error.foldernamerequired"));
status.setSuccess(false);
status.setError(ErrorCodeRegistry.getMissingFolderName());
return status;
}
}
// "traffic.pcap";
final String trafficFilePath = datadir + Util.FILE_SEPARATOR + defaultBundle.getString("datadump.trafficFile");
// device info
String deviceDetails = datadir + Util.FILE_SEPARATOR + "device_details";
status = collectDeviceDetails(status, udId, deviceDetails);
if (!status.isSuccess()) {
LOG.error("Something went wrong while fetching the device information");
// device info error
return status;
}
GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getIosCollector(), GoogleAnalyticsUtil.getAnalyticsEvents().getStartTrace(), // GA
deviceinfo != null && deviceinfo.getDeviceVersion() != null ? deviceinfo.getDeviceVersion() : "Unknown");
if ("".equals(this.sudoPassword) || !validPW) {
LOG.info(defaultBundle.getString("Error.sudopasswordissue"));
if (isCommandLine) {
status.setError(ErrorCodeRegistry.getSudoPasswordIssue());
return status;
} else {
status.setData("requestPassword");
// bad or missing sudo password
return status;
}
}
if (saveCollectorOptions == null) {
saveCollectorOptions = new SaveCollectorOptions();
}
status = checkDumpcap(status);
if (!status.isSuccess()) {
LOG.error("Something went wrong while setting up dumpcap");
return status;
}
if (isCapturingVideo) {
status = startVideoCapture(status);
if (!status.isSuccess()) {
LOG.error("Something went wrong while starting the video capture");
return status;
}
}
if (isCapturingVideo && isLiveViewVideo) {
if (isDeviceConnected) {
LOG.info("device is connected");
} else {
LOG.info("Device not connected");
}
}
try {
EnvironmentDetails environmentDetails = new EnvironmentDetails(folderToSaveTrace);
environmentDetails.populateDeviceInfo(deviceinfo.getDeviceVersion(), null, IAroDevice.Platform.iOS.name());
environmentDetails.populateMacOSDetails(xcode.getXcodeVersion(), dumpcapVersion, getLibimobileDeviceVersion());
FileWriter writer = new FileWriter(folderToSaveTrace + "/environment_details.json");
writer.append(new ObjectMapper().writeValueAsString(environmentDetails));
writer.close();
} catch (IOException e) {
LOG.error("Error while writing environment details", e);
}
if ((attenuatorModel.isConstantThrottle() && (attenuatorModel.isThrottleDLEnabled() || attenuatorModel.isThrottleULEnabled()))) {
// Attenuator or Secure Collection performed here
rvi = null;
startAttenuatorCollection(datadir, attenuatorModel, saveCollectorOptions, status, trafficFilePath);
} else {
mitmAttenuator = null;
launchCollection(trafficFilePath, udId, status);
saveCollectorOptions.recordCollectOptions(datadir, 0, 0, -1, -1, false, "", "PORTRAIT");
}
return status;
}
use of com.att.aro.core.datacollector.pojo.StatusResult in project VideoOptimzer by attdevsupport.
the class RootedAndroidCollectorImplTest method teststartCollector_resultIsErrorCode205.
@Ignore
@Test
public void teststartCollector_resultIsErrorCode205() {
when(filemanager.directoryExist(any(String.class))).thenReturn(true);
IDevice mockDevice = mock(IDevice.class);
when(mockDevice.isEmulator()).thenReturn(true);
IDevice[] devlist = { mockDevice };
when(mockDevice.getSerialNumber()).thenReturn("abc");
try {
when(adbservice.getConnectedDevices()).thenReturn(devlist);
} catch (Exception e) {
e.printStackTrace();
}
try {
when(androidev.isAndroidRooted(any(IDevice.class))).thenReturn(true);
} catch (Exception e) {
e.printStackTrace();
}
when(android.isSDCardEnoughSpace(any(IDevice.class), any(long.class))).thenReturn(false);
StatusResult testResult = rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.NONE, false, "abc", null, null);
assertEquals(205, testResult.getError().getCode());
}
Aggregations