use of com.att.aro.datacollector.ioscollector.attenuator.SaveCollectorOptions 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;
}
Aggregations