本文整理汇总了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());
}
}
});
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例5: getSyncService
import com.android.ddmlib.SyncService; //导入依赖的package包/类
@Override
public SyncService getSyncService() throws TimeoutException, AdbCommandRejectedException, IOException {
// TODO Auto-generated method stub
return null;
}
示例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;
}
示例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;
}
示例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());
}
}
示例9: getSyncService
import com.android.ddmlib.SyncService; //导入依赖的package包/类
@Override
public SyncService getSyncService() throws TimeoutException,
AdbCommandRejectedException, IOException {
throw new UnsupportedOperationException();
}
示例10: getSyncService
import com.android.ddmlib.SyncService; //导入依赖的package包/类
@Override
public SyncService getSyncService()
throws TimeoutException, AdbCommandRejectedException, IOException {
throw new UnsupportedOperationException();
}
示例11: getSyncService
import com.android.ddmlib.SyncService; //导入依赖的package包/类
@Override
public SyncService getSyncService() throws TimeoutException,
AdbCommandRejectedException, IOException {
// TODO Auto-generated method stub
return null;
}