得物.apk(点击下载) / OaidCertHelper.java


package com.shizhuang.duapp.common.base.delegate.utils;

import a.f;
import android.content.Context;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import fd.n;
import fo.a;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.concurrent.CountDownLatch;
import jc.e;
import kotlin.Metadata;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Ref;
import org.jetbrains.annotations.NotNull;
import qc.b;

@Metadata(bv = {}, d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0006\u0010\u0007J\u000e\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002¨\u0006\b"}, d2 = {"Lcom/shizhuang/duapp/common/base/delegate/utils/OaidCertHelper;", "", "Landroid/content/Context;", "context", "", "getCertPemContent", "<init>", "()V", "du-delegate_release"}, k = 1, mv = {1, 4, 2})
/* compiled from: OaidCertHelper.kt */
public final class OaidCertHelper {
    public static ChangeQuickRedirect changeQuickRedirect;

    public final String a() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 1547, new Class[0], String.class);
        if (proxy.isSupported) {
            return (String) proxy.result;
        }
        return b.f37325a ? "https://apk.poizon.com/duApp/Android_Config/resource/arch/developer/com.shizhuang.duapp.cert.pem" : "https://apk.poizon.com/duApp/Android_Config/resource/arch/release/com.shizhuang.duapp.cert.pem";
    }

    public final String b(String str) {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{str}, this, changeQuickRedirect, false, 1544, new Class[]{String.class}, String.class);
        if (proxy.isSupported) {
            return (String) proxy.result;
        }
        try {
            FileReader fileReader = new FileReader(str);
            BufferedReader bufferedReader = new BufferedReader(fileReader);
            StringBuilder sb2 = new StringBuilder();
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    sb2.append(readLine);
                    sb2.append('\n');
                } else {
                    bufferedReader.close();
                    fileReader.close();
                    return sb2.toString();
                }
            }
        } catch (Exception e) {
            a.i("OaidCertHelper", "loadCertFromDownloadFile failed " + e);
            return "";
        }
    }

    public final String c(Context context) {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{context}, this, changeQuickRedirect, false, 1545, new Class[]{Context.class}, String.class);
        if (proxy.isSupported) {
            return (String) proxy.result;
        }
        try {
            InputStream open = context.getAssets().open(context.getPackageName() + ".cert.pem");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(open));
            StringBuilder sb2 = new StringBuilder();
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    sb2.append(readLine);
                    sb2.append('\n');
                } else {
                    open.close();
                    bufferedReader.close();
                    return sb2.toString();
                }
            }
        } catch (Exception e) {
            a.i("OaidCertHelper", "loadPemFromAssetFile failed " + e);
            return "";
        }
    }

    @NotNull
    public final String getCertPemContent(@NotNull Context context) {
        boolean z;
        boolean z4 = true;
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{context}, this, changeQuickRedirect, false, 1542, new Class[]{Context.class}, String.class);
        if (proxy.isSupported) {
            return (String) proxy.result;
        }
        Ref.ObjectRef objectRef = new Ref.ObjectRef();
        objectRef.element = "";
        Class cls = Boolean.TYPE;
        PatchProxyResult proxy2 = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 1546, new Class[0], cls);
        if (proxy2.isSupported) {
            z = ((Boolean) proxy2.result).booleanValue();
        } else {
            z = n.a("oaidCertConfig", "isCertOnline", false);
        }
        if (z) {
            CountDownLatch countDownLatch = new CountDownLatch(1);
            OaidCertHelper$getCertPemContent$1 oaidCertHelper$getCertPemContent$1 = new OaidCertHelper$getCertPemContent$1(objectRef, countDownLatch);
            if (!PatchProxy.proxy(new Object[]{context, oaidCertHelper$getCertPemContent$1}, this, changeQuickRedirect, false, 1543, new Class[]{Context.class, Function1.class}, Void.TYPE).isSupported) {
                String a5 = a();
                StringBuilder i = f.i(a5, '?');
                i.append(System.currentTimeMillis());
                File u4 = tl.a.u(i.toString(), null, null);
                if (u4 != null && u4.exists()) {
                    PatchProxyResult proxy3 = PatchProxy.proxy(new Object[]{u4}, this, changeQuickRedirect, false, 1548, new Class[]{File.class}, cls);
                    if (proxy3.isSupported) {
                        z4 = ((Boolean) proxy3.result).booleanValue();
                    } else if ((!Intrinsics.areEqual(iq.f.a(u4), n.f("oaidCertConfig", "certLatestMD5", "2bd8f4b5e0502f597c912ef204632908"))) && !tl.a.E(a())) {
                        ki.a.a(u4);
                        z4 = false;
                    }
                    if (z4) {
                        oaidCertHelper$getCertPemContent$1.invoke((Object) b(u4.getAbsolutePath()));
                    }
                }
                tl.a.r(a5, null, null, new e(this, oaidCertHelper$getCertPemContent$1, context, oaidCertHelper$getCertPemContent$1, context));
            }
            countDownLatch.await();
        } else {
            objectRef.element = (T) c(context);
        }
        return objectRef.element;
    }
}