diff options
author | Xavier Ducrohet <xav@android.com> | 2010-07-20 17:25:36 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2010-07-26 10:55:08 -0700 |
commit | 9db3286c710abeb2c9478c2f95657d945a55d176 (patch) | |
tree | d3e5b901646d1c2ee6bd3990bb8da99c05eb78d3 /eclipse/plugins | |
parent | f56173887a9f6430425c93203a8c260a73b1480a (diff) | |
download | sdk-9db3286c710abeb2c9478c2f95657d945a55d176.zip sdk-9db3286c710abeb2c9478c2f95657d945a55d176.tar.gz sdk-9db3286c710abeb2c9478c2f95657d945a55d176.tar.bz2 |
Update the ddmlib api for push/pull/install
The API now throws SyncException instead of returning SyncResult.
The IDevice API to install/uninstall now returns a single
InstallException that encapsulate all the other ddmlib
exception.
Also, the recently added exceptions now don't extend IOException
anymore.
Change-Id: Ib334c4157a6add1882233dfaaa032aea1910eede
Diffstat (limited to 'eclipse/plugins')
7 files changed, 80 insertions, 28 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/AndroidLaunchController.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/AndroidLaunchController.java index f122e1a..575502a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/AndroidLaunchController.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/AndroidLaunchController.java @@ -16,11 +16,15 @@ package com.android.ide.eclipse.adt.internal.launch; +import com.android.ddmlib.AdbCommandRejectedException; import com.android.ddmlib.AndroidDebugBridge; +import com.android.ddmlib.CanceledException; import com.android.ddmlib.Client; import com.android.ddmlib.ClientData; import com.android.ddmlib.IDevice; +import com.android.ddmlib.InstallException; import com.android.ddmlib.Log; +import com.android.ddmlib.TimeoutException; import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener; import com.android.ddmlib.AndroidDebugBridge.IDebugBridgeChangeListener; import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener; @@ -892,10 +896,29 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener return installResult; } catch (IOException e) { - String msg = String.format("Failed to upload %1$s on device '%2$s'", fileName, + String msg = String.format("Failed to install %1$s on device '%2$s': %3$s", fileName, + device.getSerialNumber(), e.getMessage()); + AdtPlugin.printErrorToConsole(launchInfo.getProject(), msg, e); + } catch (TimeoutException e) { + String msg = String.format("Failed to install %1$s on device '%2$s': timeout", fileName, device.getSerialNumber()); + AdtPlugin.printErrorToConsole(launchInfo.getProject(), msg); + } catch (AdbCommandRejectedException e) { + String msg = String.format( + "Failed to install %1$s on device '%2$s': adb rejected install command with: %3$s", + fileName, device.getSerialNumber(), e.getMessage()); AdtPlugin.printErrorToConsole(launchInfo.getProject(), msg, e); + } catch (CanceledException e) { + if (e.wasCanceled()) { + AdtPlugin.printToConsole(launchInfo.getProject(), + String.format("Install of %1$s canceled", fileName)); + } else { + String msg = String.format("Failed to install %1$s on device '%2$s': %3$s", + fileName, device.getSerialNumber(), e.getMessage()); + AdtPlugin.printErrorToConsole(launchInfo.getProject(), msg, e); + } } + return false; } @@ -987,7 +1010,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener */ return checkInstallResult(result, device, launchInfo, remotePath, InstallRetryMode.ALWAYS); - } catch (IOException e) { + } catch (Exception e) { String msg = String.format( "Failed to install %1$s on device '%2$s!", launchInfo.getPackageFile().getName(), device.getSerialNumber()); @@ -1005,10 +1028,10 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener * @param remotePath the temporary path of the package on the device * @param retryMode indicates what to do in case, a package already exists. * @return <code>true<code> if success, <code>false</code> otherwise. - * @throws IOException + * @throws InstallException */ private boolean checkInstallResult(String result, IDevice device, DelayedLaunchInfo launchInfo, - String remotePath, InstallRetryMode retryMode) throws IOException { + String remotePath, InstallRetryMode retryMode) throws InstallException { if (result == null) { AdtPlugin.printToConsole(launchInfo.getProject(), "Success!"); return true; @@ -1086,13 +1109,14 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener * @param device the device on which to install the application. * @param launchInfo the {@link DelayedLaunchInfo}. * @return a {@link String} with an error code, or <code>null</code> if success. - * @throws IOException + * @throws InstallException if the installation failed. */ @SuppressWarnings("unused") - private String doUninstall(IDevice device, DelayedLaunchInfo launchInfo) throws IOException { + private String doUninstall(IDevice device, DelayedLaunchInfo launchInfo) + throws InstallException { try { return device.uninstallPackage(launchInfo.getPackageName()); - } catch (IOException e) { + } catch (InstallException e) { String msg = String.format( "Failed to uninstall %1$s: %2$s", launchInfo.getPackageName(), e.getMessage()); AdtPlugin.printErrorToConsole(launchInfo.getProject(), msg); @@ -1108,10 +1132,10 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener * @param device the device on which to install the application. * @param reinstall * @return a {@link String} with an error code, or <code>null</code> if success. - * @throws IOException + * @throws InstallException if the uninstallation failed. */ private String doInstall(DelayedLaunchInfo launchInfo, final String remotePath, - final IDevice device, boolean reinstall) throws IOException { + final IDevice device, boolean reinstall) throws InstallException { return device.installRemotePackage(remotePath, reinstall); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchMessages.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchMessages.java index b2772f7..24111b6 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchMessages.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchMessages.java @@ -45,6 +45,8 @@ public class LaunchMessages extends NLS { public static String RemoteAdtTestRunner_RunIOException_s; public static String RemoteAdtTestRunner_RunTimeoutException; + public static String RemoteAdtTestRunner_RunAdbCommandRejectedException_s; + public static String RemoteAdtTestRunner_RunShellCommandUnresponsiveException; public static String RemoteAdtTestRunner_RunStoppedMsg; static { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java index 3484252..64e93b8 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java @@ -16,6 +16,8 @@ package com.android.ide.eclipse.adt.internal.launch.junit.runtime; +import com.android.ddmlib.AdbCommandRejectedException; +import com.android.ddmlib.ShellCommandUnresponsiveException; import com.android.ddmlib.TimeoutException; import com.android.ddmlib.testrunner.ITestRunListener; import com.android.ddmlib.testrunner.RemoteAndroidTestRunner; @@ -132,6 +134,12 @@ public class RemoteAdtTestRunner extends RemoteTestRunner { } catch (IOException e) { reportError(String.format(LaunchMessages.RemoteAdtTestRunner_RunIOException_s, e.getMessage())); + } catch (AdbCommandRejectedException e) { + reportError(String.format( + LaunchMessages.RemoteAdtTestRunner_RunAdbCommandRejectedException_s, + e.getMessage())); + } catch (ShellCommandUnresponsiveException e) { + reportError(LaunchMessages.RemoteAdtTestRunner_RunTimeoutException); } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/messages.properties b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/messages.properties index 1ac7fb2..2670316 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/messages.properties +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/messages.properties @@ -38,3 +38,5 @@ RemoteAdtTestRunner_RunFailedMsg_s=Test run failed: %1$s RemoteAdtTestRunner_RunTimeoutException=Connection with device timed out. RemoteAdtTestRunner_RunIOException_s=Lost connection with device: %s RemoteAdtTestRunner_RunStoppedMsg=Test run stopped +RemoteAdtTestRunner_RunAdbCommandRejectedException_s=Adb rejected command: %s +RemoteAdtTestRunner_RunShellCommandUnresponsiveException=Device stopped sending output diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ApkInstallManager.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ApkInstallManager.java index 48a433a..19d20d8 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ApkInstallManager.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ApkInstallManager.java @@ -27,7 +27,6 @@ import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonit import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; -import java.io.IOException; import java.util.HashSet; import java.util.Iterator; @@ -152,7 +151,7 @@ public final class ApkInstallManager { } return receiver.foundPackage; - } catch (IOException e) { + } catch (Exception e) { // failed to query pm? force reinstall. return false; } diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java index 079feb7..f7728f5 100644 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java @@ -21,17 +21,21 @@ import com.android.ddmlib.AndroidDebugBridge; import com.android.ddmlib.Client; import com.android.ddmlib.ClientData; import com.android.ddmlib.IDevice; +import com.android.ddmlib.SyncException; import com.android.ddmlib.SyncService; +import com.android.ddmlib.TimeoutException; import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener; import com.android.ddmlib.ClientData.IHprofDumpHandler; import com.android.ddmlib.ClientData.MethodProfilingStatus; -import com.android.ddmlib.SyncService.SyncResult; -import com.android.ddmuilib.handler.BaseFileHandler; -import com.android.ddmuilib.handler.MethodProfilingHandler; +import com.android.ddmlib.SyncService.ISyncProgressMonitor; import com.android.ddmuilib.DevicePanel; import com.android.ddmuilib.ImageLoader; import com.android.ddmuilib.ScreenShotDialog; +import com.android.ddmuilib.SyncProgressHelper; import com.android.ddmuilib.DevicePanel.IUiSelectionListener; +import com.android.ddmuilib.SyncProgressHelper.SyncRunnable; +import com.android.ddmuilib.handler.BaseFileHandler; +import com.android.ddmuilib.handler.MethodProfilingHandler; import com.android.ide.eclipse.ddms.DdmsPlugin; import com.android.ide.eclipse.ddms.DdmsPlugin.IDebugLauncher; import com.android.ide.eclipse.ddms.preferences.PreferenceInitializer; @@ -132,31 +136,43 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien IPreferenceStore store = DdmsPlugin.getDefault().getPreferenceStore(); String value = store.getString(PreferenceInitializer.ATTR_HPROF_ACTION); - SyncResult result = null; if (ACTION_OPEN.equals(value)) { File temp = File.createTempFile("android", DOT_HPROF); //$NON-NLS-1$ - String tempPath = temp.getAbsolutePath(); - result = pull(sync, tempPath, remoteFilePath); - if (result != null && result.getCode() == SyncService.RESULT_OK) { - open(tempPath); - } + final String tempPath = temp.getAbsolutePath(); + SyncProgressHelper.run(new SyncRunnable() { + + public void run(ISyncProgressMonitor monitor) + throws SyncException, IOException, + TimeoutException { + sync.pullFile(remoteFilePath, tempPath, monitor); + } + + public void close() { + sync.close(); + } + }, + String.format("Pulling %1$s from the device", remoteFilePath), + mParentShell); + + open(tempPath); } else { // default action is ACTION_SAVE - result = promptAndPull(sync, + promptAndPull(sync, client.getClientData().getClientDescription() + DOT_HPROF, remoteFilePath, "Save HPROF file"); } - - if (result != null && result.getCode() != SyncService.RESULT_OK) { - displayErrorFromUiThread( - "Unable to download HPROF file from device '%1$s'.\n\n%2$s", - device.getSerialNumber(), result.getMessage()); - } } else { - displayErrorFromUiThread("Unable to download HPROF file from device '%1$s'.", + displayErrorFromUiThread( + "Unable to download HPROF file from device '%1$s'.", device.getSerialNumber()); } + } catch (SyncException e) { + if (e.wasCanceled() == false) { + displayErrorFromUiThread( + "Unable to download HPROF file from device '%1$s'.\n\n%2$s", + device.getSerialNumber(), e.getMessage()); + } } catch (Exception e) { displayErrorFromUiThread("Unable to download HPROF file from device '%1$s'.", device.getSerialNumber()); diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs/.gitignore b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs/.gitignore new file mode 100644 index 0000000..f23b948 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs/.gitignore @@ -0,0 +1 @@ +*.jar
\ No newline at end of file |