• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SyncService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.ddmlib.SyncService的典型用法代码示例。如果您正苦于以下问题:Java SyncService类的具体用法?Java SyncService怎么用?Java SyncService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SyncService类属于com.android.ddmlib包,在下文中一共展示了SyncService类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onSuccess

import com.android.ddmlib.SyncService; //导入依赖的package包/类
@Override
public void onSuccess(final String remoteFilePath, final Client client) {
    mParentShell.getDisplay().asyncExec(new Runnable() {
        @Override
        public void run() {
            if (remoteFilePath == null) {
                displayErrorFromUiThread(
                        "Unable to download trace file: unknown file name.\n" +
                        "This can happen if you disconnected the device while recording the trace.");
                return;
            }

            final IDevice device = client.getDevice();
            try {
                // get the sync service to pull the HPROF file
                final SyncService sync = client.getDevice().getSyncService();
                if (sync != null) {
                    pullAndOpen(sync, remoteFilePath);
                } else {
                    displayErrorFromUiThread(
                            "Unable to download trace file from device '%1$s'.",
                            device.getSerialNumber());
                }
            } catch (Exception e) {
                displayErrorFromUiThread("Unable to download trace file from device '%1$s'.",
                        device.getSerialNumber());
            }
        }

    });
}
 
开发者ID:utds3lab,项目名称:SMVHunter,代码行数:32,代码来源:MethodProfilingHandler.java


示例2: promptAndPull

import com.android.ddmlib.SyncService; //导入依赖的package包/类
/**
 * Prompts the user for a save location and pulls the remote files into this location.
 * <p/>This <strong>must</strong> be called from the UI Thread.
 * @param sync the {@link SyncService} to use to pull the file from the device
 * @param localFileName The default local name
 * @param remoteFilePath The name of the file to pull off of the device
 * @param title The title of the File Save dialog.
 * @return The result of the pull as a {@link SyncResult} object, or null if the sync
 * didn't happen (canceled by the user).
 * @throws InvocationTargetException
 * @throws InterruptedException
 * @throws SyncException if an error happens during the push of the package on the device.
 * @throws IOException
 */
protected void promptAndPull(final SyncService sync,
        String localFileName, final String remoteFilePath, String title)
        throws InvocationTargetException, InterruptedException, SyncException, TimeoutException,
        IOException {
    FileDialog fileDialog = new FileDialog(mParentShell, SWT.SAVE);

    fileDialog.setText(title);
    fileDialog.setFileName(localFileName);

    final String localFilePath = fileDialog.open();
    if (localFilePath != null) {
        SyncProgressHelper.run(new SyncRunnable() {
            @Override
            public void run(ISyncProgressMonitor monitor) throws SyncException, IOException,
                    TimeoutException {
                sync.pullFile(remoteFilePath, localFilePath, monitor);
            }

            @Override
            public void close() {
                sync.close();
            }
        },
        String.format("Pulling %1$s from the device", remoteFilePath), mParentShell);
    }
}
 
开发者ID:utds3lab,项目名称:SMVHunter,代码行数:41,代码来源:BaseFileHandler.java


示例3: pull

import com.android.ddmlib.SyncService; //导入依赖的package包/类
/**
 * Pulls a file from a device.
 * 
 * @param remote
 *            the remote file on the device
 * @param local
 *            the destination filepath
 */
public void pull(final String local, Shell parent, final Runnable callBack) {
    final SyncService sync;

    try {
        sync = sv.mDevice.getSyncService();

        if (sync != null) {
            SyncProgressHelper.run(new SyncRunnable() {
                @Override
                public void run(ISyncProgressMonitor monitor) throws SyncException,
                        IOException, TimeoutException {
                    sync.pullFile(getPath(), mEntry.getSizeValue(), local, monitor);
                }

                @Override
                public void close() {
                    sync.close();
                    if (callBack != null) {
                        callBack.run();
                    }
                }
            }, String.format("Pulling %1$s from the device", getName()), parent);
        }
    } catch (Exception e) {
        e.printStackTrace();
        MessageBox msg = new MessageBox(parent);
        if (e.getMessage() != null) {
            msg.setMessage(e.getMessage());
        }
        msg.setText("Error!!");
        msg.open();
    }
}
 
开发者ID:lrscp,项目名称:AndroidFileExplorer,代码行数:42,代码来源:File.java


示例4: pullFiles

import com.android.ddmlib.SyncService; //导入依赖的package包/类
public void pullFiles(final File[] files, final String local, Shell parent,
        final Runnable callBack) {
    try {
        final SyncService sync = sv.mDevice.getSyncService();
        if (sync != null) {
            SyncProgressHelper.run(new SyncRunnable() {
                @Override
                public void run(ISyncProgressMonitor monitor) throws SyncException,
                        IOException, TimeoutException {
                    monitor.start(getTotalRemoteFileSize(files));
                    doPullFiles(files, local, monitor, sync);
                    monitor.stop();
                }

                @Override
                public void close() {
                    sync.close();
                    if (callBack != null) {
                        callBack.run();
                    }
                }
            }, String.format("Pulling %1$s from the device", getName()), parent);
        }
    } catch (Exception e) {
        e.printStackTrace();
        MessageBox msg = new MessageBox(parent);
        if (e.getMessage() != null) {
            msg.setMessage(e.getMessage());
        }
        msg.setText("Error!!");
        msg.open();
    }
}
 
开发者ID:lrscp,项目名称:AndroidFileExplorer,代码行数:34,代码来源:File.java


示例5: getSyncService

import com.android.ddmlib.SyncService; //导入依赖的package包/类
@Override
public SyncService getSyncService() throws TimeoutException, AdbCommandRejectedException, IOException {
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:6,代码来源:ShellCommandExecutorTest.java


示例6: uploadDatabase

import com.android.ddmlib.SyncService; //导入依赖的package包/类
public static boolean uploadDatabase(@NotNull IDevice device,
                                     @NotNull String packageName,
                                     @NotNull String dbName,
                                     boolean external,
                                     @NotNull String localDbPath,
                                     @NotNull final ProgressIndicator progressIndicator,
                                     @NotNull AndroidDbErrorReporter errorReporter) {
  try {
    final SyncService syncService = device.getSyncService();

    try {
      syncService.pushFile(localDbPath, TEMP_REMOTE_DB_PATH, new MySyncProgressMonitor(progressIndicator));
    }
    finally {
      syncService.close();
    }
    final String remoteDbPath = getDatabaseRemoteFilePath(packageName, dbName, external);
    final String remoteDbDirPath = remoteDbPath.substring(0, remoteDbPath.lastIndexOf('/'));

    MyShellOutputReceiver outputReceiver = new MyShellOutputReceiver(progressIndicator, device);
    device.executeShellCommand(getRunAsPrefix(packageName, external) +
                               "mkdir " + remoteDbDirPath, outputReceiver,
                               DB_COPYING_TIMEOUT_SEC, TimeUnit.SECONDS);
    String output = outputReceiver.getOutput();

    if (!output.isEmpty() && !output.startsWith("mkdir failed")) {
      errorReporter.reportError(output);
      return false;
    }
    // recreating is needed for Genymotion emulator (IDEA-114732)
    if (!external && !recreateRemoteFile(device, packageName, remoteDbPath, errorReporter, progressIndicator)) {
      return false;
    }
    outputReceiver = new MyShellOutputReceiver(progressIndicator, device);
    device.executeShellCommand(getRunAsPrefix(packageName, external) + "cat " + TEMP_REMOTE_DB_PATH + " >" + remoteDbPath,
                               outputReceiver, DB_COPYING_TIMEOUT_SEC, TimeUnit.SECONDS);
    output = outputReceiver.getOutput();

    if (!output.isEmpty()) {
      errorReporter.reportError(output);
      return false;
    }
    progressIndicator.checkCanceled();
  }
  catch (Exception e) {
    errorReporter.reportError(e);
    return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:51,代码来源:AndroidDbUtil.java


示例7: downloadDatabase

import com.android.ddmlib.SyncService; //导入依赖的package包/类
public static boolean downloadDatabase(@NotNull IDevice device,
                                       @NotNull String packageName,
                                       @NotNull String dbName,
                                       boolean external,
                                       @NotNull File localDbFile,
                                       @NotNull final ProgressIndicator progressIndicator,
                                       @NotNull AndroidDbErrorReporter errorReporter) {
  try {
    final MyShellOutputReceiver receiver = new MyShellOutputReceiver(progressIndicator, device);
    device.executeShellCommand(getRunAsPrefix(packageName, external) + "cat " +
                               getDatabaseRemoteFilePath(packageName, dbName, external) + " >" +
                               TEMP_REMOTE_DB_PATH, receiver,
                               DB_COPYING_TIMEOUT_SEC, TimeUnit.SECONDS);
    final String output = receiver.getOutput();

    if (!output.isEmpty()) {
      errorReporter.reportError(output);
      return false;
    }
    progressIndicator.checkCanceled();
    final File parent = localDbFile.getParentFile();

    if (!parent.exists()) {
      if (!parent.mkdirs()) {
        errorReporter.reportError("cannot create directory '" + parent.getPath() + "'");
        return false;
      }
    }
    final SyncService syncService = device.getSyncService();

    try {
      syncService.pullFile(TEMP_REMOTE_DB_PATH, localDbFile.getPath(), new MySyncProgressMonitor(progressIndicator));
    }
    finally {
      syncService.close();
    }
  }
  catch (Exception e) {
    errorReporter.reportError(e);
    return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:AndroidDbUtil.java


示例8: pushFiles

import com.android.ddmlib.SyncService; //导入依赖的package包/类
public void pushFiles(Shell parent, final String[] local, final File remote,
        final Runnable callBack) {
    try {
        final SyncService sync = sv.mDevice.getSyncService();
        if (sync != null) {
            SyncProgressHelper.run(new SyncRunnable() {
                @Override
                public void run(ISyncProgressMonitor monitor) throws SyncException,
                        IOException, TimeoutException {
                    if (remote.isDirectory() == false) {
                        throw new SyncException(SyncError.REMOTE_IS_FILE);
                    }

                    // make a list of File from the list of String
                    ArrayList<java.io.File> files = new ArrayList<java.io.File>();
                    for (String path : local) {
                        files.add(new java.io.File(path));
                    }

                    // get the total count of the bytes to transfer
                    java.io.File[] fileArray = files.toArray(new java.io.File[files.size()]);
                    int total = sync.getTotalLocalFileSize(fileArray);

                    monitor.start(total);

                    sync.doPush(fileArray, remote.getPath(), monitor);

                    monitor.stop();
                }

                @Override
                public void close() {
                    sync.close();
                    if (callBack != null) {
                        callBack.run();
                    }
                }
            }, String.format("Push to the device %1$s", getName()), parent);
        }
    } catch (Exception e) {
        e.printStackTrace();
        notifyError(e.getMessage());
    }
}
 
开发者ID:lrscp,项目名称:AndroidFileExplorer,代码行数:45,代码来源:File.java


示例9: getSyncService

import com.android.ddmlib.SyncService; //导入依赖的package包/类
@Override
public SyncService getSyncService() throws TimeoutException,
    AdbCommandRejectedException, IOException {
  throw new UnsupportedOperationException();
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:6,代码来源:TestDevice.java


示例10: getSyncService

import com.android.ddmlib.SyncService; //导入依赖的package包/类
@Override
public SyncService getSyncService()
    throws TimeoutException, AdbCommandRejectedException, IOException {
  throw new UnsupportedOperationException();
}
 
开发者ID:facebook,项目名称:buck,代码行数:6,代码来源:TestDevice.java


示例11: getSyncService

import com.android.ddmlib.SyncService; //导入依赖的package包/类
@Override
public SyncService getSyncService() throws TimeoutException,
		AdbCommandRejectedException, IOException {
	// TODO Auto-generated method stub
	return null;
}
 
开发者ID:oliver32767,项目名称:MonkeyBoard,代码行数:7,代码来源:DeviceController.java



注:本文中的com.android.ddmlib.SyncService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MappedTrackInfo类代码示例发布时间:2022-05-22
下一篇:
Java ParameterizableViewController类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap