use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class AndroidImpl method pullTraceFilesFromEmulator.
/*
* (non-Javadoc)
*
* @see com.att.aro.core.android.impl.IAndroid#pullTraceFilesFromEmulator
* (com.android.ddmlib.IDevice, java.lang.String, java.lang.String)
*/
@Override
public boolean pullTraceFilesFromEmulator(IDevice device, String remoteFilepath, String localFilename) {
SyncService service = getSyncService(device);
boolean success = false;
if (service != null && remoteFilepath != null && localFilename != null) {
for (String file : DATAEMULATORCOLLECTORTRACEFILENAMES) {
try {
// v24 api return change
File tempfile = filereader.createFile(localFilename, file);
service.pullFile(remoteFilepath + "/" + file, tempfile.getAbsolutePath(), SyncService.getNullProgressMonitor());
success = true;
} catch (SyncException e) {
success = false;
LOGGER.error(e.getMessage());
} catch (TimeoutException e) {
success = false;
LOGGER.error(e.getMessage());
} catch (IOException e) {
success = false;
LOGGER.error(e.getMessage());
}
}
}
return success;
}
use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class AndroidImpl method pullTraceFilesFromDevice.
/*
* (non-Javadoc)
*
* @see
* com.att.aro.core.android.impl.IAndroid#pullTraceFilesFromDevice(com.android
* .ddmlib.IDevice , java.lang.String, java.lang.String)
*/
@Override
public boolean pullTraceFilesFromDevice(IDevice device, String remoteFilepath, String localFilename) {
SyncService service = getSyncService(device);
boolean success1 = false;
boolean success2 = false;
if (service != null && remoteFilepath != null && localFilename != null) {
String srcFile = null;
String dstFile = null;
for (String file : DATADEVICECOLLECTORTRACEFILENAMES) {
srcFile = remoteFilepath + "/" + file;
File tempfile2 = filereader.createFile(localFilename, file);
dstFile = tempfile2.getAbsolutePath();
try {
service.pullFile(srcFile, dstFile, SyncService.getNullProgressMonitor());
success1 = true;
} catch (SyncException e) {
success1 = false;
LOGGER.error(e.getMessage());
} catch (TimeoutException e) {
success1 = false;
LOGGER.error(e.getMessage());
} catch (IOException e) {
success1 = false;
LOGGER.error(e.getMessage());
}
}
// available in trace directory (traffic1.cap,traffic2.cap ...)
for (int index = 1; index < 50; index++) {
try {
String fileName = "traffic" + index + ".cap";
service.pullFile(remoteFilepath + "/" + fileName, filereader.createFile(localFilename, fileName).getAbsolutePath(), SyncService.getNullProgressMonitor());
success2 = true;
} catch (SyncException e) {
success2 = false;
LOGGER.error(e.getMessage());
} catch (TimeoutException e) {
success2 = false;
LOGGER.error(e.getMessage());
} catch (IOException e) {
success2 = false;
LOGGER.error(e.getMessage());
}
}
}
return (success1 && success2);
}
use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class RootedAndroidCollectorImplTest method teststopCollector_emulator_returnIsSuccess.
@Ignore
@Test
public void teststopCollector_emulator_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(true);
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 ScreenRecorderImpl method pullVideos.
/**
* @throws IOException
* @throws AdbCommandRejectedException
* @throws TimeoutException
*/
@Override
public boolean pullVideos() throws Exception {
SyncService service = null;
FileEntry files = adbservice.locate(device, null, remoteVideoPath);
if (files == null) {
throw new Exception("Failed to locate files :" + remoteVideoPath);
}
filemanager.directoryDeleteInnerFiles(localVidsFolder);
service = device.getSyncService();
service.pull(files.getCachedChildren(), localVidsFolder, SyncService.getNullProgressMonitor());
if (adbservice.pullFile(service, remoteVideoPath, "video-time", localVidsFolder)) {
setState(State.PullComplete);
}
return true;
}
use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class AndroidImplTest method pullTraceFilesFromDevice_returnIsTrue.
@Test
public void pullTraceFilesFromDevice_returnIsTrue() throws TimeoutException, AdbCommandRejectedException, IOException, SyncException {
IDevice device = mock(IDevice.class);
SyncService syncServ = mock(SyncService.class);
when(device.getSyncService()).thenReturn(syncServ);
when(filereader.createFile(any(String.class), any(String.class))).thenReturn(folder.newFile("cpu"));
doNothing().when(syncServ).pullFile(any(String.class), any(String.class), any(ISyncProgressMonitor.class));
assertTrue(androidImpl.pullTraceFilesFromDevice(device, " ", " "));
}
Aggregations