diff options
author | Narayan Kamath <narayan@google.com> | 2014-11-27 17:20:21 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-11-27 17:23:41 +0000 |
commit | f1a9b1bc249161fe1a9b0d85d4ed31153e4421c1 (patch) | |
tree | 170b6838a1257d31310df66452872e282a94f3cd | |
parent | 8036d2ec739636c1913a417cace97a5027d0270d (diff) | |
download | frameworks_base-f1a9b1bc249161fe1a9b0d85d4ed31153e4421c1.zip frameworks_base-f1a9b1bc249161fe1a9b0d85d4ed31153e4421c1.tar.gz frameworks_base-f1a9b1bc249161fe1a9b0d85d4ed31153e4421c1.tar.bz2 |
Stop using ErrorStrings for apache.
These strings only ever end up in logcat (at best), so there's no
point having them translated. Also, rename the ErrorStrings class
and move it android.webkit where the last remaining caller lives.
(congrats webview people, this is now your mess to maintain.)
Change-Id: I04dae37c34191b26a69282970318c1b782af1edf
-rw-r--r-- | core/java/android/net/http/Connection.java | 57 | ||||
-rw-r--r-- | core/java/android/webkit/LegacyErrorStrings.java (renamed from core/java/android/net/http/ErrorStrings.java) | 11 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewDelegate.java | 3 |
3 files changed, 63 insertions, 8 deletions
diff --git a/core/java/android/net/http/Connection.java b/core/java/android/net/http/Connection.java index 834ad69..831bd0e 100644 --- a/core/java/android/net/http/Connection.java +++ b/core/java/android/net/http/Connection.java @@ -436,7 +436,7 @@ abstract class Connection { ret = false; String error; if (errorId < 0) { - error = ErrorStrings.getString(errorId, mContext); + error = getEventHandlerErrorString(errorId); } else { Throwable cause = e.getCause(); error = cause != null ? cause.toString() : e.getMessage(); @@ -451,6 +451,61 @@ abstract class Connection { 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() { return mHttpContext; } diff --git a/core/java/android/net/http/ErrorStrings.java b/core/java/android/webkit/LegacyErrorStrings.java index 8383681..11fc05d 100644 --- a/core/java/android/net/http/ErrorStrings.java +++ b/core/java/android/webkit/LegacyErrorStrings.java @@ -14,9 +14,10 @@ * limitations under the License. */ -package android.net.http; +package android.webkit; import android.content.Context; +import android.net.http.EventHandler; import android.util.Log; /** @@ -24,8 +25,8 @@ import android.util.Log; * * {@hide} */ -public class ErrorStrings { - private ErrorStrings() { /* Utility class, don't instantiate. */ } +class LegacyErrorStrings { + private LegacyErrorStrings() { /* Utility class, don't instantiate. */ } private static final String LOGTAG = "Http"; @@ -33,7 +34,7 @@ public class ErrorStrings { * Get the localized error message resource for the given error code. * 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(); } @@ -41,7 +42,7 @@ public class ErrorStrings { * Get the localized error message resource for the given error code. * 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) { case EventHandler.OK: return com.android.internal.R.string.httpErrorOk; diff --git a/core/java/android/webkit/WebViewDelegate.java b/core/java/android/webkit/WebViewDelegate.java index 3dcfda3..a247c46 100644 --- a/core/java/android/webkit/WebViewDelegate.java +++ b/core/java/android/webkit/WebViewDelegate.java @@ -22,7 +22,6 @@ import android.app.Application; import android.content.Context; import android.content.res.Resources; import android.graphics.Canvas; -import android.net.http.ErrorStrings; import android.os.SystemProperties; import android.os.Trace; import android.util.SparseArray; @@ -150,7 +149,7 @@ public final class WebViewDelegate { * Returns the error string for the given {@code errorCode}. */ public String getErrorString(Context context, int errorCode) { - return ErrorStrings.getString(errorCode, context); + return LegacyErrorStrings.getString(errorCode, context); } /** |