Search in sources :

Example 16 with SyncService

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;
}
Also used : StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException) IOException(java.io.IOException) File(java.io.File) SyncService(com.android.ddmlib.SyncService) TimeoutException(com.android.ddmlib.TimeoutException)

Example 17 with SyncService

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());
}
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 18 with SyncService

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

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