Search in sources :

Example 1 with SyncService

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;
}
Also used : SyncException(com.android.ddmlib.SyncException) IOException(java.io.IOException) File(java.io.File) SyncService(com.android.ddmlib.SyncService) TimeoutException(com.android.ddmlib.TimeoutException)

Example 2 with SyncService

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);
}
Also used : SyncException(com.android.ddmlib.SyncException) IOException(java.io.IOException) File(java.io.File) SyncService(com.android.ddmlib.SyncService) TimeoutException(com.android.ddmlib.TimeoutException)

Example 3 with SyncService

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());
}
Also used : StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) IDevice(com.android.ddmlib.IDevice) SyncService(com.android.ddmlib.SyncService) TimeoutException(com.android.ddmlib.TimeoutException) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException) IOException(java.io.IOException) Date(java.util.Date) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with SyncService

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;
}
Also used : FileEntry(com.android.ddmlib.FileListingService.FileEntry) SyncService(com.android.ddmlib.SyncService) IOException(java.io.IOException) TimeoutException(com.android.ddmlib.TimeoutException) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException)

Example 5 with SyncService

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, " ", " "));
}
Also used : ISyncProgressMonitor(com.android.ddmlib.SyncService.ISyncProgressMonitor) IDevice(com.android.ddmlib.IDevice) SyncService(com.android.ddmlib.SyncService) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Aggregations

SyncService (com.android.ddmlib.SyncService)18 Test (org.junit.Test)10 IOException (java.io.IOException)9 IDevice (com.android.ddmlib.IDevice)8 TimeoutException (com.android.ddmlib.TimeoutException)8 BaseTest (com.att.aro.core.BaseTest)7 AdbCommandRejectedException (com.android.ddmlib.AdbCommandRejectedException)6 ISyncProgressMonitor (com.android.ddmlib.SyncService.ISyncProgressMonitor)6 StatusResult (com.att.aro.core.datacollector.pojo.StatusResult)5 SyncException (com.android.ddmlib.SyncException)4 File (java.io.File)3 Date (java.util.Date)3 Ignore (org.junit.Ignore)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 FileEntry (com.android.ddmlib.FileListingService.FileEntry)1 IVideoImageSubscriber (com.att.aro.core.datacollector.IVideoImageSubscriber)1 IVideoCapture (com.att.aro.core.video.IVideoCapture)1 InputStream (java.io.InputStream)1 Hashtable (java.util.Hashtable)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1