1 /* 2 * Copyright 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.webkit; 18 19 import android.webkit.WebResourceError; 20 import android.webkit.WebViewClient; 21 22 import androidx.annotation.IntDef; 23 import androidx.annotation.NonNull; 24 import androidx.annotation.RequiresFeature; 25 import androidx.annotation.RestrictTo; 26 27 import java.lang.annotation.Retention; 28 import java.lang.annotation.RetentionPolicy; 29 30 /** 31 * Compatibility version of {@link WebResourceError}. 32 */ 33 public abstract class WebResourceErrorCompat { 34 /** @hide */ 35 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) 36 @IntDef(value = { 37 WebViewClient.ERROR_UNKNOWN, 38 WebViewClient.ERROR_HOST_LOOKUP, 39 WebViewClient.ERROR_UNSUPPORTED_AUTH_SCHEME, 40 WebViewClient.ERROR_AUTHENTICATION, 41 WebViewClient.ERROR_PROXY_AUTHENTICATION, 42 WebViewClient.ERROR_CONNECT, 43 WebViewClient.ERROR_IO, 44 WebViewClient.ERROR_TIMEOUT, 45 WebViewClient.ERROR_REDIRECT_LOOP, 46 WebViewClient.ERROR_UNSUPPORTED_SCHEME, 47 WebViewClient.ERROR_FAILED_SSL_HANDSHAKE, 48 WebViewClient.ERROR_BAD_URL, 49 WebViewClient.ERROR_FILE, 50 WebViewClient.ERROR_FILE_NOT_FOUND, 51 WebViewClient.ERROR_TOO_MANY_REQUESTS, 52 WebViewClient.ERROR_UNSAFE_RESOURCE, 53 }) 54 @Retention(RetentionPolicy.SOURCE) 55 public @interface NetErrorCode {} 56 57 /** 58 * Gets the error code of the error. The code corresponds to one 59 * of the {@code ERROR_*} constants in {@link WebViewClient}. 60 * 61 * @return The error code of the error 62 */ 63 @RequiresFeature(name = WebViewFeature.WEB_RESOURCE_ERROR_GET_CODE, 64 enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") getErrorCode()65 public abstract @NetErrorCode int getErrorCode(); 66 67 /** 68 * Gets the string describing the error. Descriptions are localized, 69 * and thus can be used for communicating the problem to the user. 70 * 71 * @return The description of the error 72 */ 73 @NonNull 74 @RequiresFeature(name = WebViewFeature.WEB_RESOURCE_ERROR_GET_DESCRIPTION, 75 enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") getDescription()76 public abstract CharSequence getDescription(); 77 78 /** 79 * This class cannot be created by applications. 80 * @hide 81 */ 82 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) WebResourceErrorCompat()83 public WebResourceErrorCompat() { 84 } 85 } 86