Merge "Stop using ErrorStrings for apache."

This commit is contained in:
Narayan Kamath
2014-11-27 17:53:04 +00:00
committed by Gerrit Code Review
3 changed files with 63 additions and 8 deletions

View File

@@ -436,7 +436,7 @@ abstract class Connection {
ret = false; ret = false;
String error; String error;
if (errorId < 0) { if (errorId < 0) {
error = ErrorStrings.getString(errorId, mContext); error = getEventHandlerErrorString(errorId);
} else { } else {
Throwable cause = e.getCause(); Throwable cause = e.getCause();
error = cause != null ? cause.toString() : e.getMessage(); error = cause != null ? cause.toString() : e.getMessage();
@@ -451,6 +451,61 @@ abstract class Connection {
return ret; return ret;
} }
private static String getEventHandlerErrorString(int errorId) {
switch (errorId) {
case EventHandler.OK:
return "OK";
case EventHandler.ERROR:
return "ERROR";
case EventHandler.ERROR_LOOKUP:
return "ERROR_LOOKUP";
case EventHandler.ERROR_UNSUPPORTED_AUTH_SCHEME:
return "ERROR_UNSUPPORTED_AUTH_SCHEME";
case EventHandler.ERROR_AUTH:
return "ERROR_AUTH";
case EventHandler.ERROR_PROXYAUTH:
return "ERROR_PROXYAUTH";
case EventHandler.ERROR_CONNECT:
return "ERROR_CONNECT";
case EventHandler.ERROR_IO:
return "ERROR_IO";
case EventHandler.ERROR_TIMEOUT:
return "ERROR_TIMEOUT";
case EventHandler.ERROR_REDIRECT_LOOP:
return "ERROR_REDIRECT_LOOP";
case EventHandler.ERROR_UNSUPPORTED_SCHEME:
return "ERROR_UNSUPPORTED_SCHEME";
case EventHandler.ERROR_FAILED_SSL_HANDSHAKE:
return "ERROR_FAILED_SSL_HANDSHAKE";
case EventHandler.ERROR_BAD_URL:
return "ERROR_BAD_URL";
case EventHandler.FILE_ERROR:
return "FILE_ERROR";
case EventHandler.FILE_NOT_FOUND_ERROR:
return "FILE_NOT_FOUND_ERROR";
case EventHandler.TOO_MANY_REQUESTS_ERROR:
return "TOO_MANY_REQUESTS_ERROR";
default:
return "UNKNOWN_ERROR";
}
}
HttpContext getHttpContext() { HttpContext getHttpContext() {
return mHttpContext; return mHttpContext;
} }

View File

@@ -14,9 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
package android.net.http; package android.webkit;
import android.content.Context; import android.content.Context;
import android.net.http.EventHandler;
import android.util.Log; import android.util.Log;
/** /**
@@ -24,8 +25,8 @@ import android.util.Log;
* *
* {@hide} * {@hide}
*/ */
public class ErrorStrings { class LegacyErrorStrings {
private ErrorStrings() { /* Utility class, don't instantiate. */ } private LegacyErrorStrings() { /* Utility class, don't instantiate. */ }
private static final String LOGTAG = "Http"; private static final String LOGTAG = "Http";
@@ -33,7 +34,7 @@ public class ErrorStrings {
* Get the localized error message resource for the given error code. * Get the localized error message resource for the given error code.
* If the code is unknown, we'll return a generic error message. * If the code is unknown, we'll return a generic error message.
*/ */
public static String getString(int errorCode, Context context) { static String getString(int errorCode, Context context) {
return context.getText(getResource(errorCode)).toString(); return context.getText(getResource(errorCode)).toString();
} }
@@ -41,7 +42,7 @@ public class ErrorStrings {
* Get the localized error message resource for the given error code. * Get the localized error message resource for the given error code.
* If the code is unknown, we'll return a generic error message. * If the code is unknown, we'll return a generic error message.
*/ */
public static int getResource(int errorCode) { private static int getResource(int errorCode) {
switch(errorCode) { switch(errorCode) {
case EventHandler.OK: case EventHandler.OK:
return com.android.internal.R.string.httpErrorOk; return com.android.internal.R.string.httpErrorOk;

View File

@@ -22,7 +22,6 @@ import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.net.http.ErrorStrings;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.os.Trace; import android.os.Trace;
import android.util.SparseArray; import android.util.SparseArray;
@@ -150,7 +149,7 @@ public final class WebViewDelegate {
* Returns the error string for the given {@code errorCode}. * Returns the error string for the given {@code errorCode}.
*/ */
public String getErrorString(Context context, int errorCode) { public String getErrorString(Context context, int errorCode) {
return ErrorStrings.getString(errorCode, context); return LegacyErrorStrings.getString(errorCode, context);
} }
/** /**