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

Commit 77d73900 authored by Kristian Monsen's avatar Kristian Monsen Committed by Android (Google) Code Review
Browse files

Merge "Part of fix for bug 4997380: Some error types unknown to SslError"

parents 2043b01b 1abd5b3e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11206,7 +11206,7 @@ package android.net.http {
    method public boolean hasError(int);
    field public static final int SSL_EXPIRED = 1; // 0x1
    field public static final int SSL_IDMISMATCH = 2; // 0x2
    field public static final int SSL_MAX_ERROR = 4; // 0x4
    field public static final int SSL_MAX_ERROR = 6; // 0x6
    field public static final int SSL_NOTYETVALID = 0; // 0x0
    field public static final int SSL_UNTRUSTED = 3; // 0x3
  }
+3 −1
Original line number Diff line number Diff line
@@ -11541,9 +11541,11 @@ package android.net.http {
    method public int getPrimaryError();
    method public java.lang.String getUrl();
    method public boolean hasError(int);
    field public static final int SSL_DATE_INVALID = 4; // 0x4
    field public static final int SSL_EXPIRED = 1; // 0x1
    field public static final int SSL_IDMISMATCH = 2; // 0x2
    field public static final int SSL_MAX_ERROR = 4; // 0x4
    field public static final int SSL_INVALID = 5; // 0x5
    field public static final deprecated int SSL_MAX_ERROR = 6; // 0x6
    field public static final int SSL_NOTYETVALID = 0; // 0x0
    field public static final int SSL_UNTRUSTED = 3; // 0x3
  }
+37 −2
Original line number Diff line number Diff line
@@ -43,12 +43,23 @@ public class SslError {
     * The certificate authority is not trusted
     */
    public static final int SSL_UNTRUSTED = 3;
    /**
     * The date of the certificate is invalid
     */
    public static final int SSL_DATE_INVALID = 4;
    /**
     * The certificate is invalid
     */
    public static final int SSL_INVALID = 5;


    /**
     * The number of different SSL errors (update if you add a new SSL error!!!)
     * @deprecated This constant is not necessary for using the SslError API and
     *             can change from release to release.
     */
    public static final int SSL_MAX_ERROR = 4;
    @Deprecated
    public static final int SSL_MAX_ERROR = 6;

    /**
     * The SSL error set bitfield (each individual error is an bit index;
@@ -116,6 +127,30 @@ public class SslError {
        mUrl = url;
    }

    /**
     * Creates an SslError object from a chromium error code.
     * @param error The chromium error code
     * @param certificate The associated SSL certificate
     * @param url The associated URL.
     * @hide  chromium error codes only available inside the framework
     */
    public static SslError SslErrorFromChromiumErrorCode(
            int error, SslCertificate cert, String url) {
        // The chromium error codes are in:
        // external/chromium/net/base/net_error_list.h
        if (error > -200 || error < -299) {
            throw new NullPointerException("Not a valid chromium SSL error code.");
        }
        if (error == -200)
            return new SslError(SSL_IDMISMATCH, cert, url);
        if (error == -201)
            return new SslError(SSL_DATE_INVALID, cert, url);
        if (error == -202)
            return new SslError(SSL_UNTRUSTED, cert, url);
        // Map all other errors to SSL_INVALID
        return new SslError(SSL_INVALID, cert, url);
    }

    /**
     * Creates a new SSL error set object
     * @param error The SSL error