Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1a9b1bc authored by Narayan Kamath's avatar Narayan Kamath
Browse files

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
parent 8036d2ec
Loading
Loading
Loading
Loading
+56 −1
Original line number Diff line number Diff line
@@ -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;
    }
+6 −5
Original line number Diff line number Diff line
@@ -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;
+1 −2
Original line number Diff line number Diff line
@@ -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);
    }

    /**