整点视频 v3.3.0版本的 MD5 值为:cba0457dc37421eed445b30f92de25d3

以下内容为反编译后的 e.java 源代码,内容仅作参考


package com.sigmob.sdk.base;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.webkit.CookieSyncManager;
import android.webkit.URLUtil;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.annotation.Nullable;
import com.czhj.sdk.logger.SigmobLog;
import fi.iki.elonen.NanoHTTPD;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.CookieManager;
import java.net.HttpCookie;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
import java.text.MessageFormat;
import java.util.List;
import java.util.Locale;
import java.util.Map;
public class e extends WebViewClient {
    static final String a = "Set-Cookie";
    static final String b = "Referer";
    private static final String c = "mraid.js";
    private static final String d = "Cookie";
    private CookieManager e = new CookieManager();
    private boolean f = false;
    private String g;

    public static WebResourceResponse a(Uri uri) {
        return null;
    }

    private WebResourceResponse a(String str, String str2, Map<String, String> map) {
        String str3 = NanoHTTPD.MIME_HTML;
        if (URLUtil.isHttpUrl(str) || URLUtil.isHttpsUrl(str)) {
            try {
                String host = Uri.parse(str).getHost();
                if (host != null && !host.equals("127.0.0.1")) {
                    HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
                    httpURLConnection.setRequestMethod(str2);
                    if (map != null && map.size() > 0) {
                        for (Map.Entry<String, String> entry : map.entrySet()) {
                            httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
                        }
                    }
                    String cookie = android.webkit.CookieManager.getInstance().getCookie(str);
                    if (!TextUtils.isEmpty(cookie)) {
                        for (String str4 : cookie.split(";")) {
                            httpURLConnection.addRequestProperty(d.toLowerCase(), str4.replace(" ", ""));
                        }
                    }
                    httpURLConnection.connect();
                    String contentType = httpURLConnection.getContentType();
                    String contentEncoding = httpURLConnection.getContentEncoding();
                    InputStream inputStream = httpURLConnection.getInputStream();
                    a(httpURLConnection, this.e);
                    if (contentType.contains(NanoHTTPD.MIME_HTML)) {
                        inputStream = a(inputStream, contentEncoding);
                    } else {
                        str3 = contentType;
                    }
                    return new WebResourceResponse(str3, contentEncoding, inputStream);
                }
                return null;
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }
        return null;
    }

    private InputStream a(InputStream inputStream, String str) throws IOException {
        byte[] bArr = new byte[1024];
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        while (true) {
            int read = inputStream.read(bArr);
            if (read == -1) {
                break;
            }
            byteArrayOutputStream.write(bArr, 0, read);
        }
        String str2 = new String(byteArrayOutputStream.toByteArray());
        if (str == null) {
            str = Charset.defaultCharset().displayName();
        }
        return new ByteArrayInputStream(str2.getBytes(str));
    }

    public static void a(@Nullable HttpURLConnection httpURLConnection, @Nullable CookieManager cookieManager) {
        if (cookieManager == null || httpURLConnection == null) {
            return;
        }
        Map<String, List<String>> headerFields = httpURLConnection.getHeaderFields();
        SigmobLog.d("headerFields : " + headerFields.toString());
        List<String> list = headerFields.get(a);
        if (list != null) {
            for (String str : list) {
                try {
                    List<HttpCookie> parse = HttpCookie.parse(str);
                    if (parse != null) {
                        SigmobLog.d("{0} -- Reading Cookies from the response :" + httpURLConnection.getURL().toString());
                        SigmobLog.d("{0} -- Reading Cookies from the response :" + parse.get(0));
                        for (HttpCookie httpCookie : parse) {
                            SigmobLog.d(httpCookie.toString());
                            android.webkit.CookieManager cookieManager2 = android.webkit.CookieManager.getInstance();
                            String url = httpURLConnection.getURL().toString();
                            cookieManager2.setCookie(url, httpCookie.getName() + "=" + httpCookie.getValue());
                        }
                    }
                } catch (NullPointerException unused) {
                    SigmobLog.e(MessageFormat.format("{0} -- Null header for the cookie : {1}", httpURLConnection.getURL().toString(), str.toString()));
                }
            }
            if (Build.VERSION.SDK_INT >= 21) {
                android.webkit.CookieManager.getInstance().flush();
            } else {
                CookieSyncManager.getInstance().sync();
            }
        }
    }

    public void a(boolean z) {
        this.f = z;
    }

    boolean a(String str) {
        return c.equals(Uri.parse(str.toLowerCase(Locale.US)).getLastPathSegment());
    }

    public void b(String str) {
        try {
            Uri parse = Uri.parse(str);
            this.g = parse.getScheme() + "://" + parse.getHost() + "/" + parse.getPath();
        } catch (Throwable unused) {
        }
    }

    @Override
    public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
        super.onPageStarted(webView, str, bitmap);
    }

    @Override
    public void onReceivedError(WebView webView, int i, String str, String str2) {
        super.onReceivedError(webView, i, str, str2);
    }

    @Override
    @Nullable
    @SuppressLint({"NewApi"})
    public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
        WebResourceResponse a2;
        try {
            WebResourceResponse a3 = a(webResourceRequest.getUrl());
            if (a3 != null) {
                return a3;
            }
        } catch (Throwable unused) {
        }
        return (!this.f || a(webResourceRequest.getUrl().toString()) || (a2 = a(webResourceRequest.getUrl().toString(), webResourceRequest.getMethod(), webResourceRequest.getRequestHeaders())) == null) ? super.shouldInterceptRequest(webView, webResourceRequest) : a2;
    }

    @Override
    @Nullable
    public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
        WebResourceResponse a2;
        try {
            WebResourceResponse a3 = a(Uri.parse(str));
            if (a3 != null) {
                return a3;
            }
        } catch (Throwable unused) {
        }
        return (!this.f || a(str) || (a2 = a(str, "GET", null)) == null) ? super.shouldInterceptRequest(webView, str) : a2;
    }
}