use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class RootedAndroidCollectorImpl method pullTrace.
/**
* Pulls trace files
*
* @param files
* String array of trace files to pull
* @return StatusResult for success/failure
*/
private StatusResult pullTrace(String[] files) {
StatusResult result = new StatusResult();
SyncService service = null;
try {
service = device.getSyncService();
} catch (TimeoutException e) {
log.error("Timeout error when getting SyncService from device");
} catch (AdbCommandRejectedException e) {
log.error(e.getMessage());
} catch (IOException e) {
log.error("IOException", e);
}
if (service == null) {
result.setError(ErrorCodeRegistry.getFailSyncService());
return result;
}
// first pull the last file to be prepared by AroDataCollector.APK
String alarmInfoStart = "alarm_info_start";
int count = 5;
File traceAlarmInfoStart = new File(this.localTraceFolder + "/" + alarmInfoStart);
while (!(traceAlarmInfoStart.exists() && traceAlarmInfoStart.length() > 0) && count-- > 0) {
try {
log.debug("alarm_info_start was missing or zero length, will sleep then pull again");
Thread.sleep(500);
} catch (InterruptedException e) {
log.error("InterruptedException", e);
}
pullFile(service, alarmInfoStart);
}
// now pull the rest of the trace files
deviceTracePath = "/sdcard/ARO/" + this.traceName + "/";
for (String file : files) {
pullFile(service, file);
}
result.setSuccess(true);
return result;
}
use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class RootedAndroidCollectorImplTest method teststopCollector_returnIsSuccess.
@Ignore
@Test
public void teststopCollector_returnIsSuccess() throws TimeoutException, AdbCommandRejectedException, IOException {
doReturn(5).when(rootedAndroidCollectorImpl).getMilliSecondsForTimeout();
when(filemanager.directoryExist(any(String.class))).thenReturn(true);
IDevice mockDevice = mock(IDevice.class);
when(mockDevice.isEmulator()).thenReturn(true);
SyncService service = mock(SyncService.class);
when(mockDevice.getSyncService()).thenReturn(service);
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(true);
when(filemanager.fileExist(any(String.class))).thenReturn(true);
when(extractor.extractFiles(any(String.class), any(String.class), any(ClassLoader.class))).thenReturn(true);
when(android.pushFile(any(IDevice.class), any(String.class), any(String.class))).thenReturn(true);
when(android.setExecutePermission(any(IDevice.class), any(String.class))).thenReturn(true);
rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.LREZ, false, "abc", null, null);
when(android.checkTcpDumpRunning(any(IDevice.class))).thenReturn(true);
when(android.stopTcpDump(any(IDevice.class))).thenReturn(true);
when(android.isTraceRunning()).thenReturn(false);
Date date = new Date();
when(mockDevice.isEmulator()).thenReturn(false);
when(videocapture.getVideoStartTime()).thenReturn(date);
when(videocapture.isVideoCaptureActive()).thenReturn(true);
StatusResult testResult = rootedAndroidCollectorImpl.stopCollector();
assertEquals(true, testResult.isSuccess());
}
use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class AndroidImpl method pushFile.
/*
* (non-Javadoc)
*
* @see com.att.aro.core.android.impl.IAndroid#pushFile
* (com.android.ddmlib.IDevice, java.lang.String, java.lang.String)
*/
@Override
public boolean pushFile(IDevice emulator, String local, String remote) {
SyncService service = getSyncService(emulator);
boolean success = false;
if (service != null) {
try {
service.pushFile(local, remote, SyncService.getNullProgressMonitor());
LOGGER.info(String.format("Pushed file %s on the device", remote));
success = true;
return success;
} catch (SyncException | IOException | TimeoutException e) {
LOGGER.error(e);
}
}
return success;
}
Aggregations