| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.webkit; |
| 18 |
|
| 19 |
import android.content.Context; |
| 20 |
import android.util.Log; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
class LegacyErrorStrings { |
| 28 |
private LegacyErrorStrings() { } |
| 29 |
|
| 30 |
private static final String LOGTAG = "Http"; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
static String getString(int errorCode, Context context) { |
| 37 |
return context.getText(getResource(errorCode)).toString(); |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
private static int getResource(int errorCode) { |
| 45 |
switch(errorCode) { |
| 46 |
case 0: |
| 47 |
return com.android.internal.R.string.httpErrorOk; |
| 48 |
|
| 49 |
case -1: |
| 50 |
return com.android.internal.R.string.httpError; |
| 51 |
|
| 52 |
case -2: |
| 53 |
return com.android.internal.R.string.httpErrorLookup; |
| 54 |
|
| 55 |
case -3: |
| 56 |
return com.android.internal.R.string.httpErrorUnsupportedAuthScheme; |
| 57 |
|
| 58 |
case -4: |
| 59 |
return com.android.internal.R.string.httpErrorAuth; |
| 60 |
|
| 61 |
case -5: |
| 62 |
return com.android.internal.R.string.httpErrorProxyAuth; |
| 63 |
|
| 64 |
case -6: |
| 65 |
return com.android.internal.R.string.httpErrorConnect; |
| 66 |
|
| 67 |
case -7: |
| 68 |
return com.android.internal.R.string.httpErrorIO; |
| 69 |
|
| 70 |
case -8: |
| 71 |
return com.android.internal.R.string.httpErrorTimeout; |
| 72 |
|
| 73 |
case -9: |
| 74 |
return com.android.internal.R.string.httpErrorRedirectLoop; |
| 75 |
|
| 76 |
case -10: |
| 77 |
return com.android.internal.R.string.httpErrorUnsupportedScheme; |
| 78 |
|
| 79 |
case -11: |
| 80 |
return com.android.internal.R.string.httpErrorFailedSslHandshake; |
| 81 |
|
| 82 |
case -12: |
| 83 |
return com.android.internal.R.string.httpErrorBadUrl; |
| 84 |
|
| 85 |
case -13: |
| 86 |
return com.android.internal.R.string.httpErrorFile; |
| 87 |
|
| 88 |
case -14: |
| 89 |
return com.android.internal.R.string.httpErrorFileNotFound; |
| 90 |
|
| 91 |
case -15: |
| 92 |
return com.android.internal.R.string.httpErrorTooManyRequests; |
| 93 |
|
| 94 |
default: |
| 95 |
Log.w(LOGTAG, "Using generic message for unknown error code: " + errorCode); |
| 96 |
return com.android.internal.R.string.httpError; |
| 97 |
} |
| 98 |
} |
| 99 |
} |