Search in sources :

Example 1 with FileEntry

use of com.android.ddmlib.FileListingService.FileEntry in project VideoOptimzer by attdevsupport.

the class AdbServiceImpl method locate.

/**
 * traverse Android filesystem to locate file/folder
 *
 * @param root of current directory
 * @param path to follow
 * @return FileEntry of target
 */
@Override
public FileEntry locate(IDevice device, FileEntry rootPath, String path) {
    FileListingService fileService = device.getFileListingService();
    FileEntry root = rootPath;
    if (root == null) {
        root = fileService.getRoot();
    }
    // root gets populated with children
    fileService.getChildren(root, false, null);
    if (path == null) {
        return root;
    }
    String[] pathNodes = path.split("/");
    FileEntry node = root;
    FileEntry nnode = root;
    for (String pathNode : pathNodes) {
        if (!"".equals(pathNode)) {
            nnode = node.findChild(pathNode);
            if (nnode == null) {
                return null;
            }
            // nnode gets populated with children
            fileService.getChildren(nnode, false, null);
            // traverse to next node
            node = nnode;
        }
    }
    return node;
}
Also used : FileListingService(com.android.ddmlib.FileListingService) FileEntry(com.android.ddmlib.FileListingService.FileEntry)

Example 2 with FileEntry

use of com.android.ddmlib.FileListingService.FileEntry 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)

Aggregations

FileEntry (com.android.ddmlib.FileListingService.FileEntry)2 AdbCommandRejectedException (com.android.ddmlib.AdbCommandRejectedException)1 FileListingService (com.android.ddmlib.FileListingService)1 SyncService (com.android.ddmlib.SyncService)1 TimeoutException (com.android.ddmlib.TimeoutException)1 IOException (java.io.IOException)1