翰林优商.apk(点击下载) / b.java


package com.baidu.liantian.utility;

import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ProviderInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Base64;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;
import kotlin.UByte;

/* compiled from: DbUtil */
public final class b {
    public static final String a = "30212102dicudiab";
    private static final String[] b = {"liantian"};
    private static String c = "";

    public static void a(Context context) {
        try {
            com.baidu.liantian.b bVar = new com.baidu.liantian.b(context);
            String c2 = bVar.c();
            if (!TextUtils.isEmpty(c2)) {
                String c3 = a.c(c2);
                if (!TextUtils.isEmpty(c3) && !c3.equals(bVar.b())) {
                    bVar.a(c3);
                }
            }
        } catch (Throwable unused) {
            a.a();
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:32:?, code lost:
        com.baidu.liantian.utility.a.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:34:0x00bc, code lost:
        return "";
     */
    /* JADX WARNING: Exception block dominator not found, dom blocks: [] */
    /* JADX WARNING: Missing exception handler attribute for start block: B:31:0x00b6 */
    public static synchronized String b(Context context) {
        synchronized (b.class) {
            if (!TextUtils.isEmpty(c)) {
                return c;
            }
            com.baidu.liantian.b bVar = new com.baidu.liantian.b(context);
            String c2 = bVar.c();
            if (!TextUtils.isEmpty(c2)) {
                try {
                    String c3 = a.c(c2);
                    if (!TextUtils.isEmpty(c3)) {
                        c = c3;
                        return c3;
                    }
                } catch (Throwable unused) {
                    a.a();
                }
            }
            String b2 = bVar.b();
            if (!TextUtils.isEmpty(b2)) {
                bVar.b(new String(Base64.encode(d.a(a.getBytes(), b2.getBytes("UTF-8")), 10), "UTF-8"));
                c = b2;
                return b2;
            }
            String str = a(UUID.randomUUID().toString().getBytes()) + "|" + "0";
            String str2 = new String(Base64.encode(d.a(a.getBytes(), str.getBytes("UTF-8")), 10), "UTF-8");
            String b3 = bVar.b();
            if (TextUtils.isEmpty(b3)) {
                bVar.a(str);
                bVar.b(str2);
                c = str;
                return str;
            }
            c = b3;
            return b3;
        }
    }

    public static String c(Context context) {
        if (!TextUtils.isEmpty(c)) {
            return c;
        }
        String d = d(context);
        if (TextUtils.isEmpty(d)) {
            return b(context);
        }
        c = d;
        return d;
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(4:38|39|(1:41)|42) */
    /* JADX WARNING: Code restructure failed: missing block: B:39:?, code lost:
        com.baidu.liantian.utility.a.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:40:0x0091, code lost:
        if (r12 != null) goto L_0x0093;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:41:0x0093, code lost:
        r12.release();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:42:0x0096, code lost:
        r13 = null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:43:0x0098, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:45:0x009a, code lost:
        if (r12 != null) goto L_0x009c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:46:0x009c, code lost:
        r12.release();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:47:0x009f, code lost:
        throw r0;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:38:0x008e */
    private static String d(Context context) {
        ProviderInfo[] providerInfoArr;
        Bundle bundle;
        ContentProviderClient contentProviderClient;
        try {
            if (Build.VERSION.SDK_INT >= 11) {
                try {
                    providerInfoArr = context.getPackageManager().getPackageInfo(context.getPackageName(), 8).providers;
                } catch (Throwable unused) {
                    a.a();
                    providerInfoArr = null;
                }
                if (providerInfoArr == null || providerInfoArr.length <= 0) {
                    return "";
                }
                ContentResolver contentResolver = context.getContentResolver();
                String[] strArr = b;
                boolean z = false;
                for (String str : strArr) {
                    if (!TextUtils.isEmpty(str)) {
                        boolean z2 = "liantian".equals(str) ? true : z;
                        try {
                            String str2 = "content://" + context.getPackageName() + "." + str + ".ac.provider";
                            for (ProviderInfo providerInfo : providerInfoArr) {
                                if (str2.contains(providerInfo.authority)) {
                                    Uri parse = Uri.parse(str2);
                                    if (Build.VERSION.SDK_INT >= 17) {
                                        try {
                                            contentProviderClient = contentResolver.acquireUnstableContentProviderClient(parse);
                                            bundle = contentProviderClient.call("getRemoteZid", null, null);
                                            if (contentProviderClient != null) {
                                                contentProviderClient.release();
                                            }
                                        } catch (Throwable unused2) {
                                            contentProviderClient = null;
                                        }
                                    } else {
                                        bundle = contentResolver.call(parse, "getRemoteZid", (String) null, (Bundle) null);
                                    }
                                    if (bundle != null) {
                                        String string = bundle.getString("_zid");
                                        if (!TextUtils.isEmpty(string)) {
                                            return string;
                                        }
                                    } else {
                                        continue;
                                    }
                                }
                            }
                        } catch (Throwable unused3) {
                            a.a();
                        }
                        if (z2) {
                            break;
                        }
                        z = z2;
                    }
                }
            }
        } catch (Throwable unused4) {
            a.a();
        }
        return "";
    }

    private static String a(byte[] bArr) {
        try {
            MessageDigest instance = MessageDigest.getInstance("MD5");
            instance.reset();
            instance.update(bArr);
            byte[] digest = instance.digest();
            StringBuilder sb = new StringBuilder();
            for (byte b2 : digest) {
                String upperCase = Integer.toHexString(b2 & UByte.MAX_VALUE).toUpperCase();
                if (upperCase.length() == 1) {
                    sb.append("0");
                }
                sb.append(upperCase);
                sb.append("");
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException unused) {
            a.a();
            return null;
        }
    }
}