IDEA-67621 rollback to old ddmlib; fix incorrect encoding provided by it

This commit is contained in:
Eugene Kudelevsky
2011-04-06 18:17:39 +04:00
parent e96ffe2fe6
commit a80d5394d3
5 changed files with 66 additions and 12 deletions
Binary file not shown.
Binary file not shown.
@@ -618,10 +618,54 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
return false;
}
service.pushFile(localPath, remotePath, new MyISyncProgressMonitor());
}
catch (SyncException e) {
exceptionMessage = e.getMessage();
errorMessage = e.getErrorCode().getMessage();
SyncService.SyncResult result = service.pushFile(localPath, remotePath, new MyISyncProgressMonitor());
int code = result.getCode();
switch (code) {
case SyncService.RESULT_OK:
return true;
case SyncService.RESULT_CANCELED:
errorMessage = "Command canceled";
break;
case SyncService.RESULT_CONNECTION_ERROR:
errorMessage = "Connection error";
break;
case SyncService.RESULT_CONNECTION_TIMEOUT:
errorMessage = "Connection timeout";
break;
case SyncService.RESULT_FILE_READ_ERROR:
errorMessage = "Cannot read the file";
break;
case SyncService.RESULT_FILE_WRITE_ERROR:
errorMessage = "Cannot write the file";
break;
case SyncService.RESULT_LOCAL_IS_DIRECTORY:
errorMessage = "Local is directory";
break;
case SyncService.RESULT_NO_DIR_TARGET:
errorMessage = "Target directory not found";
break;
case SyncService.RESULT_NO_LOCAL_FILE:
errorMessage = "Local file not found";
break;
case SyncService.RESULT_NO_REMOTE_OBJECT:
errorMessage = "No remote object";
break;
case SyncService.RESULT_REMOTE_IS_FILE:
errorMessage = "Remote is a file";
break;
case SyncService.RESULT_REMOTE_PATH_ENCODING:
errorMessage = "Incorrect remote path encoding";
break;
case SyncService.RESULT_REMOTE_PATH_LENGTH:
errorMessage = "Incorrect remote path length";
break;
case SyncService.RESULT_TARGET_IS_FILE:
errorMessage = "Target is a file";
break;
default:
errorMessage = "Can't upload file";
}
}
catch (TimeoutException e) {
exceptionMessage = e.getMessage();
@@ -631,9 +675,6 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
exceptionMessage = e.getMessage();
errorMessage = "ADB refused the command";
}
if (errorMessage == null) {
return true;
}
if (errorMessage.equals(exceptionMessage) || exceptionMessage == null) {
message(errorMessage, STDERR);
}
@@ -23,8 +23,6 @@ import com.intellij.execution.process.ProcessOutputTypes;
import com.intellij.openapi.util.Comparing;
import org.jetbrains.android.run.AndroidRunningState;
import java.util.Map;
/**
* Created by IntelliJ IDEA.
* User: Eugene.Kudelevsky
@@ -72,7 +70,7 @@ public class AndroidTestListener implements ITestRunListener {
}
@Override
public void testRunStarted(String runName, int testCount) {
public void testRunStarted(int testCount) {
ProcessHandler handler = getProcessHandler();
handler.notifyTextAvailable("Test running started\n", ProcessOutputTypes.STDOUT);
TeamcityCommandBuilder builder = new TeamcityCommandBuilder("testCount");
@@ -81,7 +79,7 @@ public class AndroidTestListener implements ITestRunListener {
}
@Override
public void testRunEnded(long elapsedTime, Map<String, String> runMetrics) {
public void testRunEnded(long elapsedTime) {
if (myTestClassName != null) {
testSuiteFinished();
}
@@ -129,7 +127,7 @@ public class AndroidTestListener implements ITestRunListener {
}
@Override
public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
public void testEnded(TestIdentifier test) {
TeamcityCommandBuilder builder = new TeamcityCommandBuilder("testFinished");
builder.addAttribute("name", test.getTestName());
builder.addAttribute("duration", Long.toString(System.currentTimeMillis() - myTestStartingTime));
@@ -17,6 +17,9 @@
package org.jetbrains.android.util;
import com.android.ddmlib.MultiLineReceiver;
import com.intellij.openapi.diagnostic.Logger;
import java.io.UnsupportedEncodingException;
/**
* Created by IntelliJ IDEA.
@@ -27,12 +30,14 @@ import com.android.ddmlib.MultiLineReceiver;
*/
public abstract class AndroidOutputReceiver extends MultiLineReceiver {
private static final String BAD_ACCESS_ERROR = "Bad address (14)";
private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.util.AndroidOutputReceiver");
private boolean myTryAgain;
@Override
public void processNewLines(String[] lines) {
if (!myTryAgain) {
for (String line : lines) {
line = decodeIso8859_1(line);
processNewLine(line);
if (line.indexOf(BAD_ACCESS_ERROR) >= 0) {
myTryAgain = true;
@@ -51,4 +56,14 @@ public abstract class AndroidOutputReceiver extends MultiLineReceiver {
}
protected abstract void processNewLine(String line);
private static String decodeIso8859_1(String text) {
try {
return new String(text.getBytes("ISO8859_1"), "UTF-8");
}
catch (UnsupportedEncodingException e) {
LOG.error("Error while fix encoding", e);
return text;
}
}
}