use of com.att.aro.core.mobiledevice.pojo.IAroDevice in project VideoOptimzer by attdevsupport.
the class ARODataCollectorMenu method chooseDevice.
private IAroDevice chooseDevice(IAroDevices aroDevices, List<IDataCollector> collectors) {
ArrayList<IAroDevice> deviceList = aroDevices.getDeviceList();
IAroDevice device = null;
int delayTimeDL = 0;
int throttleDL = 0;
int throttleUL = 0;
boolean throttleDLEnable = false;
boolean throttleULEnable = false;
boolean profileBoolean = false;
String traceFolderName = "";
String profileLocation = "";
if (((MainFrame) parent).getPreviousOptions() != null) {
previousOptions = ((MainFrame) parent).getPreviousOptions();
}
metaDataModel = new MetaDataModel();
DataCollectorSelectNStartDialog dialog = new DataCollectorSelectNStartDialog(((MainFrame) parent).getJFrame(), parent, deviceList, traceFolderName, collectors, true, previousOptions, metaDataModel);
if (dialog.getResponse()) {
device = dialog.getDevice();
traceFolderName = dialog.getTraceFolder();
device.setCollector(dialog.getCollectorOption());
/*debug purpose*/
delayTimeDL = dialog.getDeviceOptionPanel().getAttenuatorModel().getDelayDS();
dialog.getDeviceOptionPanel().getAttenuatorModel().getDelayUS();
throttleDL = dialog.getDeviceOptionPanel().getAttenuatorModel().getThrottleDL();
throttleUL = dialog.getDeviceOptionPanel().getAttenuatorModel().getThrottleUL();
throttleDLEnable = dialog.getDeviceOptionPanel().getAttenuatorModel().isThrottleDLEnabled();
throttleULEnable = dialog.getDeviceOptionPanel().getAttenuatorModel().isThrottleULEnabled();
profileLocation = dialog.getDeviceOptionPanel().getAttenuatorModel().getLocalPath();
profileBoolean = dialog.getDeviceOptionPanel().getAttenuatorModel().isLoadProfile();
LOG.info("set U delay: " + delayTimeDL + ", set D delay: " + delayTimeDL + ", set U throttle: " + throttleUL + ", set D throttle: " + throttleDL + ", set profile: " + profileBoolean + ", set profileLocation: " + profileLocation);
if (device.isPlatform(IAroDevice.Platform.iOS)) {
IDataCollector iosCollector = findIOSCollector(collectors);
if ((throttleDLEnable || throttleULEnable) && !NetworkUtil.isNetworkUp(SharedNetIF)) {
MessageDialogFactory.getInstance().showInformationDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.attenuation.finalwarning"), ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.attenuation.noshared"));
return null;
}
if (!checkSetSuPassword(iosCollector)) {
return null;
} else {
LOG.info("pw validated");
}
}
String traceFolderPath = (device.getPlatform().equals(IAroDevice.Platform.Android)) ? Util.getAROTraceDirAndroid() + System.getProperty("file.separator") + traceFolderName : Util.getAROTraceDirIOS() + System.getProperty("file.separator") + traceFolderName;
String currentPath = ((MainFrame) parent).getTracePath();
if (fileManager.directoryExistAndNotEmpty(traceFolderPath)) {
int result = folderExistsDialog();
if (result == JOptionPane.OK_OPTION) {
if (traceFolderPath.equals(currentPath)) {
new MessageDialogFactory().showErrorDialog(null, ResourceBundleHelper.getMessageString("viewer.contentUnwritable"));
return null;
}
File mountPoint = fileManager.createFile(traceFolderPath, IOSCollectorImpl.IOSAPP_MOUNT);
if (fileManager.createFile(traceFolderPath, IOSCollectorImpl.IOSAPP_MOUNT).exists() && device.getPlatform().equals(IAroDevice.Platform.iOS)) {
IExternalProcessRunner runner = new ExternalProcessRunnerImpl();
String results = runner.executeCmd(String.format("umount %s;rmdir %s", mountPoint, mountPoint));
if (!results.isEmpty()) {
new MessageDialogFactory().showErrorDialog(null, traceFolderPath + "/" + IOSCollectorImpl.IOSAPP_MOUNT + " is BUSY");
return null;
} else {
int count = 0;
while (fileManager.directoryExistAndNotEmpty(mountPoint.toString())) {
if (++count > 5) {
new MessageDialogFactory().showErrorDialog(null, traceFolderPath + "/" + IOSCollectorImpl.IOSAPP_MOUNT + " will not release, please detach the iOS device and delete the foldere manually");
return null;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Log.error("sleep interrupted");
}
}
}
}
fileManager.deleteFolderContents(traceFolderPath);
} else {
return null;
}
}
Hashtable<String, Object> extras = prepareStartCollectorExtras(device, traceFolderName, dialog);
updateMetaData(device, traceFolderName, dialog);
extras.put("DIALOG_SIZE", dialog.getBaseSize());
if (dialog.getDeviceOptionPanel().getLabeledExpandedOptionFields().isVisible()) {
extras.put("MetaDataExpanded", true);
}
((MainFrame) parent).startCollector(device, traceFolderName, extras, metaDataModel);
} else {
traceFolderName = null;
}
dialog.dispose();
return device;
}
use of com.att.aro.core.mobiledevice.pojo.IAroDevice in project VideoOptimzer by attdevsupport.
the class DeviceDialogOptions method reselectPriorOptions.
public void reselectPriorOptions(Hashtable<String, Object> previousOptions) {
if (MapUtils.isNotEmpty(previousOptions) && previousOptions.containsKey("device")) {
IAroDevice device = (IAroDevice) previousOptions.get("device");
for (String key : previousOptions.keySet()) {
switch(key) {
case "video_option":
enableVideoOptions((VideoOption) previousOptions.get(key));
break;
case "videoOrientation":
enableVideoOritenation((Orientation) previousOptions.get(key));
break;
case "AttenuatorModel":
enableAttenuatorOptions((AttenuatorModel) previousOptions.get("AttenuatorModel"));
break;
case "traceType":
traceTypeField.setText((String) previousOptions.get(key));
break;
case "traceDesc":
traceDescField.setText((String) previousOptions.get(key));
break;
case "targetedApp":
targetedAppField.setText((String) previousOptions.get(key));
break;
case "appProducer":
appProducerField.setText((String) previousOptions.get(key));
break;
case "selectedAppName":
if (device.getId().equals(selectedDevice.getId())) {
appSelector.setSelectedItem((String) previousOptions.get(key));
}
break;
case "TraceFolderName":
parent.setTraceFolderName((String) previousOptions.get(key));
break;
case "MetaDataExpanded":
// trigger metadata Arrow Button display
getLabeledExpandedOptionFields().setVisible(true);
parent.getExpansionArrowButton().setDirection(SwingConstants.SOUTH);
break;
default:
break;
}
}
}
// handles when Low Res on Android was last trace
if (labelVideoOrientTitle.isVisible() && btn_lrez.isSelected()) {
labelVideoOrientTitle.setVisible(false);
}
}
use of com.att.aro.core.mobiledevice.pojo.IAroDevice in project VideoOptimzer by attdevsupport.
the class AdbServiceImplTest method installPayloadFile.
// @Test
// public void locate() throws Exception{
//
// FileListingService fileService = Mockito.mock(FileListingService.class);
//
// Mockito.when(device.getFileListingService()).thenReturn(fileService);
//
// FileEntry root = Mockito.mock(FileEntry.class);
//
// FileEntry entry = adbService.locate(device, root, "path");
// assertTrue(entry == root);
// }
@Test
public void installPayloadFile() throws Exception {
IAroDevice aroDevice = Mockito.mock(IAroDevice.class);
Mockito.when(aroDevice.getDevice()).thenReturn(device);
Mockito.when(extractor.extractFiles(Mockito.anyString(), Mockito.anyString(), Mockito.any(ClassLoader.class))).thenReturn(true);
Mockito.when(android.pushFile(Mockito.any(IDevice.class), Mockito.anyString(), Mockito.anyString())).thenReturn(true);
Mockito.when(fileManager.deleteFile(Mockito.anyString())).thenReturn(true);
boolean success = adbService.installPayloadFile(aroDevice, "local", "file", "remote");
assertTrue(success);
}
use of com.att.aro.core.mobiledevice.pojo.IAroDevice in project VideoOptimzer by attdevsupport.
the class RootedAndroidCollectorImpl method startCollector.
/**
* Start the rooted collector both for device and emulator<br>
*
* Start collector in background and returns result which indicates success
* or error and detail data.
*
* @param folderToSaveTrace
* directory to save trace to
* @param videoOption
* optional flag to capture video of device. default is false
* @param isLiveViewVideo
* this flag is ignored in Android
* @return a StatusResult to hold result and success or failure
*/
@Override
public StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace, VideoOption videoOption_old, boolean isLiveViewVideo, String deviceId, Hashtable<String, Object> extraParams, String password) {
VideoOption m_videoOption = VideoOption.NONE;
if (extraParams != null) {
m_videoOption = (VideoOption) extraParams.get("video_option");
if (m_videoOption == null) {
m_videoOption = VideoOption.NONE;
}
}
log.info("<" + Util.getMethod() + "> startCollector() for rooted-android-collector");
StatusResult result = new StatusResult();
// avoid running it twice
if (this.running) {
return result;
}
if (filemanager.directoryExistAndNotEmpty(folderToSaveTrace)) {
result.setError(ErrorCodeRegistry.getTraceDirExist());
return result;
}
// there might be permission issue to creating dir to save trace
filemanager.mkDir(folderToSaveTrace);
if (!filemanager.directoryExist(folderToSaveTrace)) {
result.setError(ErrorCodeRegistry.getFailedToCreateLocalTraceDirectory());
return result;
}
// check for any connected device
IDevice[] devlist = null;
try {
devlist = adbservice.getConnectedDevices();
} catch (Exception e1) {
if (e1.getMessage().contains("AndroidDebugBridge failed to start")) {
result.setError(ErrorCodeRegistry.getAndroidBridgeFailedToStart());
return result;
}
log.error("Exception :", e1);
}
if (devlist == null || devlist.length < 1) {
result.setError(ErrorCodeRegistry.getNoDeviceConnected());
return result;
}
device = null;
if (deviceId == null) {
device = devlist[0];
} else {
for (IDevice dev : devlist) {
if (deviceId.equals(dev.getSerialNumber())) {
device = dev;
break;
}
}
if (device == null) {
result.setError(ErrorCodeRegistry.getDeviceIdNotFound());
return result;
}
}
if (!device.getState().equals(DeviceState.ONLINE)) {
log.error("Android device is not online.");
result.setError(ErrorCodeRegistry.getDeviceNotOnline());
return result;
}
if (device.isEmulator()) {
IAroDevice aroDevice = new AROAndroidDevice(device, false);
if (!aroDevice.getAbi().contains("arm")) {
String message = "Emulator ABI:" + aroDevice.getAbi() + " does not support VPN collection! Use an armeabi instead.";
log.error(message);
result.setError(ErrorCodeRegistry.getNotSupported(message));
return result;
}
}
aroDevice = new AROAndroidDevice(device, true);
// device must be rooted to work
try {
if (androidDev.isAndroidRooted(device)) {
log.debug("device is detected to be rooted");
} else {
result.setError(ErrorCodeRegistry.getRootedStatus());
return result;
}
} catch (Exception exception) {
log.error("Failed to root test device ", exception);
result.setError(ErrorCodeRegistry.getProblemAccessingDevice(exception.getMessage()));
return result;
}
try {
device.createForward(TCPDUMP_PORT, TCPDUMP_PORT);
} catch (TimeoutException e) {
log.error("Timeout when creating port forwading: " + e.getMessage());
} catch (AdbCommandRejectedException e) {
log.error(e.getMessage());
} catch (IOException e) {
log.error(e.getMessage());
}
// check for running collector first => both tcpdump and ARO android app
if (android.checkTcpDumpRunning(device)) {
result.setError(ErrorCodeRegistry.getCollectorAlreadyRunning());
return result;
}
String tracename = folderToSaveTrace.substring(folderToSaveTrace.lastIndexOf(Util.FILE_SEPARATOR) + 1);
this.traceName = tracename;
this.localTraceFolder = folderToSaveTrace;
// delete all previous ARO traces on device or emulator /sdcard/ARO
android.removeEmulatorData(device, "/sdcard/ARO");
android.makeAROTraceDirectory(device, tracename);
this.videoOption = m_videoOption;
// check SELinux mode: true if SELinux-Enforced, false if permissive
try {
seLinuxEnforced = androidDev.isSeLinuxEnforced(device);
} catch (Exception e) {
// Failed to detect so assume not enforced
log.info("Failed to detect SELinux mode:" + e.getMessage());
seLinuxEnforced = false;
}
if (device.isEmulator()) {
// run collector inside Emulator
result = launchCollectorInEmulator(device, tracename, m_videoOption, extraParams);
} else {
GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getRootedCollector(), // GA Request
GoogleAnalyticsUtil.getAnalyticsEvents().getStartTrace());
// run collector inside Android device
result = launchCollectorInDevice(device, tracename, m_videoOption, extraParams);
}
if (result.isSuccess()) {
this.running = isTrafficCaptureRunning(getMilliSecondsForTimeout());
if (this.running) {
log.info("collector is running successfully");
} else {
timeOutShutdown();
haltCollectorInDevice();
log.info("collector timeout, traffic capture not started in time");
result.setSuccess(false);
result.setError(ErrorCodeRegistry.getCollectorTimeout());
result.setData("installed but traffic capture failed to start before timeout");
return result;
}
}
if (isVideo()) {
GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getRootedCollector(), // GA Request
GoogleAnalyticsUtil.getAnalyticsEvents().getVideoCheck());
startVideoCapture();
}
return result;
}
use of com.att.aro.core.mobiledevice.pojo.IAroDevice in project VideoOptimzer by attdevsupport.
the class IOSCollectorImpl method getDevices.
@Override
public IAroDevice[] getDevices(StatusResult status) {
IAroDevice[] aroDevices = null;
String[] iosDevices = getDeviceSerialNumber(status);
if (iosDevices != null && iosDevices.length > 0) {
aroDevices = new IAroDevice[iosDevices.length];
int pos = 0;
for (String udid : iosDevices) {
if (!udid.isEmpty()) {
try {
aroDevices[pos++] = new IOSDevice(udid);
} catch (IOException e) {
String errorMessage = "Failed to retrieve iOS device data:" + e.getMessage();
LOG.error(errorMessage);
status.setError(ErrorCodeRegistry.getFailedRetrieveDeviceData(errorMessage));
}
}
}
}
return aroDevices;
}
Aggregations