花瓣 v4.6.12版本的 MD5 值为:6a3515d4d16d98931f1b3d25a91b257e

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


package com.uc.crashsdk.a;

import android.os.Build;
import android.os.Process;
import android.support.v4.media.session.PlaybackStateCompat;
import android.text.TextUtils;
import android.util.SparseArray;
import com.google.android.exoplayer2.b3;
import com.google.android.material.timepicker.TimeModel;
import com.huawei.hms.framework.common.ContainerUtils;
import com.uc.crashsdk.JNIBridge;
import com.umeng.analytics.pro.au;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
public class h {
    static final boolean a = !h.class.desiredAssertionStatus();
    private static final Object b = new Object();
    private static final Map<String, String> c = new HashMap();
    private static int f12840d = 0;
    private static final Map<String, a> f12841e = new HashMap();
    private static final Object f12842f = new Object();
    private static final Object f12843g = new Object();
    private static final SparseArray<String> f12844h = new SparseArray<>();
    private static boolean f12845i = false;
    private static boolean j = false;
    private static final Object k = new Object();
    private static String l = null;

    public static class a {
        long a = 0;
        int b = 0;
        Map<String, String> c = new HashMap();
        private String f12846d;
        private boolean f12847e;
        private boolean f12848f;

        a(String str, boolean z, boolean z2) {
            this.f12847e = false;
            this.f12848f = false;
            this.f12846d = str;
            this.f12847e = z;
            this.f12848f = z2;
        }

        private long d(String str) {
            return g.c(a(str));
        }

        final void a(String str, String str2) {
            this.c.put(str, str2);
        }

        final String b(String str) {
            String a = a(str);
            return a == null ? "" : a;
        }

        final boolean c(String str) {
            if (g.a(str)) {
                return false;
            }
            String str2 = null;
            long j = 0;
            HashMap hashMap = new HashMap();
            Map c = h.c(str);
            int i2 = 0;
            for (String str3 : c.keySet()) {
                String str4 = (String) c.get(str3);
                if (str3.equals("lt")) {
                    str2 = str4;
                } else if (this.f12847e && str3.equals("up")) {
                    j = g.c(str4);
                } else if (this.f12847e && str3.equals("pid")) {
                    i2 = (int) g.c(str4);
                } else {
                    hashMap.put(str3, str4);
                }
            }
            String str5 = this.f12846d;
            if (str5 == null || str5.equals(str2)) {
                this.a = j;
                this.b = i2;
                this.f12846d = str2;
                this.c = hashMap;
                return true;
            }
            return false;
        }

        final void a(String str, long j) {
            long d2 = d(str) + j;
            if (d2 <= 100) {
                j = d2 < 0 ? 0L : d2;
            }
            a(str, String.valueOf(j));
        }

        final boolean a(a aVar) {
            if (!this.f12848f) {
                com.uc.crashsdk.a.a.a("crashsdk", String.format(Locale.US, "WaItem '%s' is not mergable!", this.f12846d), null);
                return false;
            }
            for (String str : aVar.c.keySet()) {
                if (str.startsWith("c_")) {
                    a(str, aVar.a(str));
                } else {
                    long d2 = aVar.d(str);
                    if (d2 == 0) {
                        a(str, aVar.a(str));
                    } else if (d2 < 100) {
                        a(str, d2);
                    }
                }
            }
            return true;
        }

        final String a(String str) {
            return this.c.get(str);
        }

        final String a(boolean z, boolean z2, boolean z3) {
            if (this.f12846d == null) {
                return null;
            }
            StringBuilder sb = new StringBuilder();
            if (z) {
                h.b(sb, "lt", "uc");
                h.b(sb, "pre", com.uc.crashsdk.g.e());
                h.b(sb, "pkg", com.uc.crashsdk.a.a);
                h.b(sb, "rom", Build.VERSION.RELEASE);
                h.b(sb, "brd", Build.BRAND);
                h.b(sb, "model", Build.MODEL);
                h.a(sb, "sdk", Build.VERSION.SDK_INT);
                h.b(sb, "cpu", com.uc.crashsdk.e.e());
                h.b(sb, "hdw", com.uc.crashsdk.e.f());
                long l = h.l();
                h.a(sb, "ram", l);
                h.b(sb, "aram", h.a(l));
                h.b(sb, "cver", "3.3.2.2");
                h.b(sb, "cseq", "211215141717");
                h.b(sb, "ctag", "release");
                h.b(sb, "aver", com.uc.crashsdk.a.a());
                h.b(sb, "ver", com.uc.crashsdk.g.T());
                h.b(sb, "sver", com.uc.crashsdk.g.U());
                h.b(sb, "seq", com.uc.crashsdk.g.V());
                h.b(sb, "grd", com.uc.crashsdk.b.A() ? "fg" : "bg");
                h.b(sb, "os", "android");
                h.b(sb, "dn", com.uc.crashsdk.e.q());
                String ab = com.uc.crashsdk.g.ab();
                if (TextUtils.isEmpty(ab)) {
                    ab = com.uc.crashsdk.e.q();
                }
                h.b(sb, "k_uid", ab);
                String ac = com.uc.crashsdk.g.ac();
                if (!TextUtils.isEmpty(ac)) {
                    h.b(sb, "k_channel", ac);
                }
                sb.append("\n");
            }
            h.b(sb, "lt", this.f12846d);
            h.a(sb, this.c);
            if (this.f12847e && !z2) {
                long j = this.a;
                if (j != 0) {
                    h.b(sb, "up", String.valueOf(j));
                }
                if (z3) {
                    h.b(sb, "pid", String.format(Locale.US, TimeModel.NUMBER_FORMAT, Integer.valueOf(Process.myPid())));
                } else {
                    int i2 = this.b;
                    if (i2 != 0) {
                        h.b(sb, "pid", String.format(Locale.US, TimeModel.NUMBER_FORMAT, Integer.valueOf(i2)));
                    }
                }
            }
            sb.append("\n");
            return sb.toString();
        }
    }

    static String a(long j2) {
        return j2 < PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE_ENABLED ? "512M" : String.format(Locale.US, "%dG", Long.valueOf(((j2 / 1024) + 512) / 1024));
    }

    public static void b(StringBuilder sb, String str, String str2) {
        sb.append(str);
        sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
        sb.append(str2);
        sb.append("`");
    }

    static Map c(String str) {
        String[] split;
        HashMap hashMap = new HashMap();
        for (String str2 : str.split("`")) {
            if (str2.length() > 1) {
                String[] split2 = str2.split(ContainerUtils.KEY_VALUE_DELIMITER, 3);
                if (split2.length == 2) {
                    hashMap.put(split2[0], split2[1]);
                }
            }
        }
        return hashMap;
    }

    public static void d() {
        b(2, (long) b3.b);
        a(1, 70000L);
    }

    public static boolean e() {
        return j;
    }

    public static void f() {
        b(1, (long) b3.b);
    }

    public static void g() {
        b(3, 0L);
    }

    public static void h() {
        b(4, 0L);
    }

    public static void i() {
        if (com.uc.crashsdk.g.Q()) {
            f.a(1, new e(303));
        }
    }

    public static byte[] j() {
        return new byte[]{Byte.MAX_VALUE, 100, 110, com.google.common.base.c.I};
    }

    public static void k() {
        synchronized (k) {
            l = null;
        }
    }

    static long l() {
        return o();
    }

    private static String m() {
        return com.uc.crashsdk.g.W() + "pv.wa";
    }

    private static String n() {
        return com.uc.crashsdk.g.W() + "cdt.wa";
    }

    private static long o() {
        Iterator<String> it = g.a(new File("/proc/meminfo"), 2).iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            String next = it.next();
            if (next.contains("MemTotal:")) {
                try {
                    return Long.parseLong(next.replaceAll("\\D+", ""));
                } catch (NumberFormatException e2) {
                    g.a(e2);
                }
            }
        }
        return 0L;
    }

    static void a(StringBuilder sb, String str, long j2) {
        b(sb, str, String.valueOf(j2));
    }

    public static void b() {
        a(2, 0L);
    }

    public static void c() {
        a(3, 0L);
    }

    private static void b(int i2, long j2) {
        if (com.uc.crashsdk.g.Q()) {
            f.a(1, new e(301, new Object[]{Integer.valueOf(i2)}), j2);
        }
    }

    private static boolean c(String str, String str2) {
        boolean z;
        String d2;
        String sb;
        byte[] a2;
        byte[] a3;
        if (g.a(str2)) {
            return true;
        }
        byte[] bytes = str2.getBytes();
        try {
            byte[] bArr = new byte[16];
            c.a(bArr, 0, c.a());
            c.a(bArr, 4, j());
            c.a(bArr, 8, com.uc.crashsdk.a.f());
            c.a(bArr, 12, d.d());
            a3 = c.a(bytes, bArr);
        } catch (Throwable th) {
            g.a(th);
        }
        if (a3 != null) {
            bytes = a3;
            z = true;
            if (str == null) {
                str = "unknown";
            }
            String str3 = !com.uc.crashsdk.g.R() ? "4ea4e41a3993" : "28ef1713347d";
            String valueOf = String.valueOf(System.currentTimeMillis());
            d2 = g.d(str3 + str + valueOf + "AppChk#2014");
            if (d2 != null) {
                sb = null;
            } else {
                StringBuilder sb2 = new StringBuilder();
                sb2.append(com.uc.crashsdk.g.z());
                sb2.append("?chk=");
                sb2.append(d2.substring(d2.length() - 8, d2.length()));
                sb2.append("&vno=");
                sb2.append(valueOf);
                sb2.append("&uuid=");
                sb2.append(str);
                sb2.append("&app=");
                sb2.append(str3);
                if (z) {
                    sb2.append("&enc=aes");
                }
                sb = sb2.toString();
            }
            return sb == null && (a2 = c.a(sb, bytes)) != null && new String(a2).contains("retcode=0");
        }
        z = false;
        if (str == null) {
        }
        if (!com.uc.crashsdk.g.R()) {
        }
        String valueOf2 = String.valueOf(System.currentTimeMillis());
        d2 = g.d(str3 + str + valueOf2 + "AppChk#2014");
        if (d2 != null) {
        }
        if (sb == null) {
            return false;
        }
    }

    private static boolean d(String str) {
        boolean c2;
        File file = new File(str);
        Iterator<a> it = a(file, "cst", 30).iterator();
        while (it.hasNext()) {
            a next = it.next();
            String a2 = next.a("prc");
            if (!g.a(a2)) {
                a aVar = f12841e.get(a2);
                if (aVar != null) {
                    aVar.a(next);
                } else {
                    f12841e.put(a2, next);
                }
            }
        }
        StringBuilder a3 = a((Iterable<a>) f12841e.values(), true, false);
        if (com.uc.crashsdk.g.aa()) {
            c2 = b(com.uc.crashsdk.e.q(), a3.toString());
        } else {
            c2 = c(com.uc.crashsdk.e.q(), a3.toString());
        }
        g.b(file);
        if (c2 || g.a(file, a((Iterable<a>) f12841e.values(), false, true).toString())) {
            f12841e.clear();
        }
        return true;
    }

    static void a(StringBuilder sb, Map map) {
        for (String str : map.keySet()) {
            b(sb, str, (String) map.get(str));
        }
    }

    public static void a(String str) {
        synchronized (b) {
            File file = new File(m());
            a aVar = new a("pv", true, true);
            String c2 = g.c(file);
            if (!g.a(c2)) {
                aVar.c(c2);
            }
            aVar.a(str, 1L);
            aVar.a("aujv", 1L);
            g.a(file, aVar.a(false, false, false));
        }
    }

    public static boolean b(int i2, Object[] objArr) {
        switch (i2) {
            case 351:
                if (a || objArr != null) {
                    String str = (String) objArr[0];
                    int intValue = ((Integer) objArr[1]).intValue();
                    if (intValue == 1) {
                        if (j) {
                            return false;
                        }
                        j = true;
                    }
                    if (com.uc.crashsdk.g.Z()) {
                        File file = new File(str);
                        ArrayList<a> a2 = a(file, "crp", 100);
                        if (intValue != 4) {
                            a aVar = new a("crp", false, false);
                            if (intValue == 1) {
                                aVar.a("et", String.valueOf(com.uc.crashsdk.b.I()));
                                aVar.a("ete", String.valueOf(com.uc.crashsdk.b.J()));
                            } else if (intValue == 3) {
                                aVar.a("et", "1");
                                aVar.a("ete", "1");
                            } else if (intValue == 2) {
                                aVar.a("hpv", "1");
                            }
                            aVar.a("prc", com.uc.crashsdk.e.h());
                            aVar.a(au.c, com.uc.crashsdk.b.F() ? "1" : "0");
                            a(aVar);
                            a2.add(0, aVar);
                        }
                        if (!a2.isEmpty()) {
                            boolean c2 = c(com.uc.crashsdk.e.q(), a((Iterable<a>) a2, true, false).toString());
                            g.b(file);
                            if (!c2) {
                                g.a(file, a((Iterable<a>) a2, false, true).toString());
                            }
                        }
                        return true;
                    }
                    return false;
                }
                throw new AssertionError();
            case 352:
                if (a || objArr != null) {
                    return d((String) objArr[0]);
                }
                throw new AssertionError();
            case 353:
                if (a || objArr != null) {
                    return b((String) objArr[0], (String) objArr[1], ((Boolean) objArr[2]).booleanValue(), ((Boolean) objArr[3]).booleanValue());
                }
                throw new AssertionError();
            case 354:
                if (a || objArr != null) {
                    File file2 = new File((String) objArr[0]);
                    boolean c3 = c(com.uc.crashsdk.e.q(), a((Iterable<a>) a(file2, "cst", 30), true, false).toString());
                    if (c3) {
                        g.b(file2);
                    }
                    return c3;
                }
                throw new AssertionError();
            default:
                return false;
        }
    }

    public static void a() {
        a(0, com.uc.crashsdk.b.H() ? 700000L : 70000L);
    }

    private static void a(int i2, long j2) {
        if (com.uc.crashsdk.b.F()) {
            f.a(0, new e(302, new Object[]{Integer.valueOf(i2)}), j2);
        }
    }

    public static boolean a(String str, String str2) {
        try {
            String str3 = "c_" + str.replaceAll("[^0-9a-zA-Z-_]", "-");
            String replaceAll = g.a(str2) ? "" : str2.replaceAll("[`=]", "-");
            synchronized (c) {
                if (c.get(str3) == null) {
                    if (f12840d >= 20) {
                        return false;
                    }
                    f12840d++;
                }
                c.put(str3, replaceAll);
                return true;
            }
        } catch (Throwable th) {
            g.a(th);
            return false;
        }
    }

    public static void b(boolean z) {
        if (a(z, "crash detail upload")) {
            return;
        }
        String str = com.uc.crashsdk.g.W() + "dt.wa";
        com.uc.crashsdk.b.a(f12842f, str, new e(352, new Object[]{str}));
        String n = n();
        com.uc.crashsdk.b.a(f12843g, n, new e(354, new Object[]{n}));
    }

    private static boolean b(String str, String str2) {
        boolean z;
        byte[] a2;
        byte[] a3;
        if (g.a(str2)) {
            return true;
        }
        byte[] bytes = str2.getBytes();
        long currentTimeMillis = System.currentTimeMillis();
        String d2 = g.d(com.uc.crashsdk.g.e() + str + currentTimeMillis + "AppChk#2014");
        try {
            a3 = c.a(bytes, d2.substring(d2.length() - 16, d2.length()).getBytes());
        } catch (Throwable th) {
            g.a(th);
        }
        if (a3 != null) {
            bytes = a3;
            z = true;
            String substring = d2.substring(d2.length() - 8, d2.length());
            StringBuilder sb = new StringBuilder();
            sb.append(com.uc.crashsdk.g.z());
            sb.append("/api/v1/crashtrack/upload?chk=");
            sb.append(substring);
            sb.append("&vno=");
            sb.append(currentTimeMillis);
            sb.append("&uuid=");
            sb.append(str);
            sb.append("&app=");
            sb.append(com.uc.crashsdk.g.e());
            if (z) {
                sb.append("&enc=aes");
            }
            String sb2 = sb.toString();
            return sb2 == null && (a2 = c.a(sb2, bytes)) != null && new String(a2).contains("retcode=0");
        }
        z = false;
        String substring2 = d2.substring(d2.length() - 8, d2.length());
        StringBuilder sb3 = new StringBuilder();
        sb3.append(com.uc.crashsdk.g.z());
        sb3.append("/api/v1/crashtrack/upload?chk=");
        sb3.append(substring2);
        sb3.append("&vno=");
        sb3.append(currentTimeMillis);
        sb3.append("&uuid=");
        sb3.append(str);
        sb3.append("&app=");
        sb3.append(com.uc.crashsdk.g.e());
        if (z) {
        }
        String sb22 = sb3.toString();
        if (sb22 == null) {
            return false;
        }
    }

    private static void a(a aVar) {
        synchronized (c) {
            for (String str : c.keySet()) {
                aVar.a(str, c.get(str));
            }
        }
    }

    public static void a(boolean z) {
        a(1, z);
    }

    public static boolean a(boolean z, String str) {
        if (com.uc.crashsdk.b.f12849d && !z && JNIBridge.nativeIsCrashing()) {
            com.uc.crashsdk.a.a.b("crashsdk", "Native is crashing, skip stat for " + str);
            return true;
        }
        return false;
    }

    private static boolean b(String str, String str2, boolean z, boolean z2) {
        a aVar;
        File file = new File(n());
        ArrayList<a> a2 = a(file, "cst", 30);
        String str3 = str + str2;
        Iterator<a> it = a2.iterator();
        while (true) {
            if (!it.hasNext()) {
                aVar = null;
                break;
            }
            aVar = it.next();
            if (str3.equals(aVar.b("prc") + aVar.b("typ"))) {
                break;
            }
        }
        if (aVar == null) {
            aVar = new a("cst", false, true);
            aVar.a("prc", str);
            aVar.a("typ", str2);
            a(aVar);
            a2.add(aVar);
        }
        aVar.a("cnt", 1L);
        if (z) {
            aVar.a("lim", 1L);
        }
        if (z2) {
            aVar.a("syu", 1L);
        }
        return g.a(file, a((Iterable<a>) a2, false, false).toString());
    }

    private static void a(int i2, boolean z) {
        if (a(z, "crash rate")) {
            return;
        }
        String str = com.uc.crashsdk.g.W() + "cr.wa";
        com.uc.crashsdk.b.a(b, str, new e(351, new Object[]{str, Integer.valueOf(i2)}));
    }

    public static void a(int i2, Object[] objArr) {
        String str;
        String q;
        long j2;
        boolean z;
        switch (i2) {
            case 301:
                if (!a && objArr == null) {
                    throw new AssertionError();
                }
                a(((Integer) objArr[0]).intValue(), false);
                return;
            case 302:
                if (!a && objArr == null) {
                    throw new AssertionError();
                }
                synchronized (b) {
                    int intValue = ((Integer) objArr[0]).intValue();
                    if (intValue == 0) {
                        if (!f12845i) {
                            f12845i = true;
                        }
                    }
                    if (!com.uc.crashsdk.a.b.equals("2.0") || !com.uc.crashsdk.b.c(268435456)) {
                        File file = new File(m());
                        String c2 = g.c(file);
                        a aVar = new a("pv", true, true);
                        if (!g.a(c2)) {
                            aVar.c(c2);
                        }
                        if (intValue == 0) {
                            if (aVar.b != Process.myPid()) {
                                z = false;
                                break;
                            } else {
                                z = true;
                                break;
                            }
                        }
                        if (intValue == 0) {
                            aVar.a("pv", 1L);
                            str = "fjv";
                        } else if (intValue == 1) {
                            str = "hpv";
                        } else {
                            if (intValue == 2) {
                                aVar.a("pv", 1L);
                                str = "npv";
                            }
                            q = com.uc.crashsdk.e.q();
                            j2 = aVar.a;
                            if ((j2 != 0 || System.currentTimeMillis() - j2 >= 28800000) ? c(q, aVar.a(true, true, false)) : false) {
                                aVar.c = new HashMap();
                                aVar.a = System.currentTimeMillis();
                                aVar.b = Process.myPid();
                            }
                            g.a(file, aVar.a(false, false, true));
                        }
                        aVar.a(str, 1L);
                        q = com.uc.crashsdk.e.q();
                        j2 = aVar.a;
                        if ((j2 != 0 || System.currentTimeMillis() - j2 >= 28800000) ? c(q, aVar.a(true, true, false)) : false) {
                        }
                        g.a(file, aVar.a(false, false, true));
                    }
                }
                return;
            case 303:
                b(false);
                return;
            default:
                if (!a) {
                    throw new AssertionError();
                }
                return;
        }
    }

    public static void b(String str) {
        synchronized (k) {
            l = str;
            String k2 = com.uc.crashsdk.b.k();
            b.a(k2, str + "\n");
        }
    }

    private static StringBuilder a(Iterable<a> iterable, boolean z, boolean z2) {
        StringBuilder sb = new StringBuilder();
        boolean z3 = true;
        for (a aVar : iterable) {
            if (z3) {
                sb.append(aVar.a(z, z, z2));
                z3 = false;
            } else {
                sb.append(aVar.a(false, z, z2));
            }
        }
        return sb;
    }

    public static void a(String str, int i2, int i3) {
        if (com.uc.crashsdk.g.Q()) {
            synchronized (f12842f) {
                a aVar = f12841e.get(str);
                if (aVar == null) {
                    aVar = new a("cst", false, true);
                    f12841e.put(str, aVar);
                    a(aVar);
                }
                synchronized (f12844h) {
                    if (f12844h.size() == 0) {
                        a(100, "pv");
                        a(102, "hpv");
                        a(1, "all");
                        a(2, "afg");
                        a(101, "abg");
                        a(3, "jfg");
                        a(4, "jbg");
                        a(7, "nfg");
                        a(8, "nbg");
                        a(27, "nafg");
                        a(28, "nabg");
                        a(9, "nho");
                        a(10, "uar");
                        a(29, "ulm");
                        a(30, "ukt");
                        a(31, "uet");
                        a(32, "urs");
                        a(11, "ufg");
                        a(12, "ubg");
                        a(40, "anf");
                        a(41, "anb");
                        a(42, "ancf");
                        a(43, "ancb");
                        a(13, "lup");
                        a(14, "luf");
                        a(15, "lef");
                        a(200, "ltf");
                        a(16, "laf");
                        a(22, "lac");
                        a(23, "lau");
                        a(17, "llf");
                        a(18, "lul");
                        a(19, "lub");
                        a(20, "luc");
                        a(21, "luu");
                        a(24, "lzc");
                        a(201, "lec");
                        a(25, "lrc");
                        a(26, "lss");
                    }
                }
                String str2 = f12844h.get(i2);
                if (str2 == null) {
                    com.uc.crashsdk.a.a.a("crashsdk", "map key is not set with: " + i2, null);
                }
                aVar.a("prc", str);
                if (str2 != null) {
                    aVar.a(str2, String.valueOf(i3));
                }
            }
        }
    }

    public static boolean a(String str, String str2, boolean z, boolean z2) {
        if (com.uc.crashsdk.g.Q()) {
            return com.uc.crashsdk.b.a(f12843g, n(), new e(353, new Object[]{str, str2, Boolean.valueOf(z), Boolean.valueOf(z2)}));
        }
        return false;
    }

    private static void a(int i2, String str) {
        f12844h.put(i2, str);
    }

    private static ArrayList<a> a(File file, String str, int i2) {
        ArrayList<String> a2 = g.a(file, i2);
        ArrayList<a> arrayList = new ArrayList<>();
        Iterator<String> it = a2.iterator();
        while (it.hasNext()) {
            a aVar = new a(str, false, false);
            if (aVar.c(it.next())) {
                arrayList.add(aVar);
            }
        }
        return arrayList;
    }
}