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


package com.mbridge.msdk.foundation.tools;

import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import com.baidu.idl.face.platform.FaceEnvironment;
import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField;
import com.kuaishou.weapon.p0.h;
import com.mbridge.msdk.MBridgeConstans;
import com.mbridge.msdk.foundation.same.a;
import com.mbridge.msdk.foundation.same.f.b;
import com.tencent.smtt.sdk.TbsConfig;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Locale;
import java.util.TimeZone;
import java.util.UUID;
import org.json.JSONObject;

/* compiled from: SameDiTool */
public final class s extends e {
    private static String a = null;
    private static String b = null;
    private static int c = -1;
    private static int d = -1;
    private static volatile int e = -1;
    private static String f = "";
    private static String g = "";
    private static String h = "";
    private static String i = "";
    private static int j = 0;
    private static String k = "";
    private static String l = "";
    private static int m = -1;
    private static String n = "";
    private static int o = 0;
    private static String p = "";
    private static String q = null;
    private static int r = 0;
    private static int s = -1;
    private static int t = -1;

    public static int a(int i2) {
        switch (i2) {
            case 1:
            case 2:
            case 4:
            case 7:
            case 11:
            case 16:
                return 2;
            case 3:
            case 5:
            case 6:
            case 8:
            case 9:
            case 10:
            case 12:
            case 14:
            case 15:
            case 17:
                return 3;
            case 13:
            case 18:
            case 19:
                return 4;
            case 20:
                return 5;
            default:
                return 0;
        }
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(5:(1:11)|15|16|17|19) */
    /* JADX WARNING: Code restructure failed: missing block: B:20:?, code lost:
        return;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:16:0x00a4 */
    public static void q(Context context) {
        z();
        A(context);
        v(context);
        u(context);
        t(context);
        u();
        w();
        B();
        s(context);
        y();
        a.h = false;
        a.g = aa.a(h.b, context);
        w(context);
        e.g(context);
        e.b(context);
        e.c(context);
        e.i(context);
        e.j(context);
        try {
            int A = A();
            if (A < 17 || A >= 21) {
                if (A >= 21 || (A < 17 && A > 10)) {
                    m = Settings.Secure.getInt(com.mbridge.msdk.foundation.controller.a.f().j().getContentResolver(), "install_non_market_apps", 0);
                }
                w.d("SameDiTool", "getUSSForPe:" + m);
                a.j = aa.a(h.e, context);
                a.i = false;
                e.a(context);
                K();
            }
            m = Settings.Global.getInt(com.mbridge.msdk.foundation.controller.a.f().j().getContentResolver(), "install_non_market_apps", 0);
            w.d("SameDiTool", "getUSSForPe:" + m);
            a.j = aa.a(h.e, context);
            a.i = false;
            e.a(context);
            K();
        } catch (Throwable th) {
            w.b("SameDiTool", th.getMessage(), th);
        }
    }

    public static int r(Context context) {
        if (s == -1) {
            s = aa.c(context, TbsConfig.APP_WX) ? 1 : 0;
        }
        return s;
    }

    public static int t() {
        if (t == -1) {
            t = aa.c() ? 1 : 0;
        }
        return t;
    }

    public static String u() {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
            return "";
        }
        return Build.MODEL;
    }

    public static String v() {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
            return "";
        }
        return Build.MANUFACTURER + " " + Build.MODEL;
    }

    public static String w() {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
            return "";
        }
        return Build.BRAND;
    }

    public static String s(Context context) {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
            return "";
        }
        if (TextUtils.isEmpty(k)) {
            if (context == null) {
                return "en-US";
            }
            try {
                if (context.getResources() != null) {
                    if (context.getResources().getConfiguration() != null) {
                        Locale locale = context.getResources().getConfiguration().locale;
                        if (locale == null) {
                            return "en-US";
                        }
                        if (Build.VERSION.SDK_INT >= 21) {
                            k = locale.toLanguageTag();
                        } else {
                            k = locale.getLanguage() + "-" + locale.getCountry();
                        }
                        return k;
                    }
                }
                return "en-US";
            } catch (Throwable th) {
                w.a("SameDiTool", th.getMessage());
                k = "en-US";
            }
        }
        return k;
    }

    public static int t(Context context) {
        Configuration configuration;
        if (context == null || context.getResources() == null || (configuration = context.getResources().getConfiguration()) == null || configuration.orientation != 2) {
            return 1;
        }
        return 2;
    }

    public static int u(Context context) {
        if (context == null) {
            return j;
        }
        int i2 = j;
        if (i2 != 0) {
            return i2;
        }
        try {
            int i3 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
            j = i3;
            return i3;
        } catch (Exception e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public static String v(Context context) {
        if (context == null) {
            return i;
        }
        try {
            if (!TextUtils.isEmpty(i)) {
                return i;
            }
            String str = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
            i = str;
            return str;
        } catch (Exception e2) {
            e2.printStackTrace();
            return "";
        }
    }

    public static int w(Context context) {
        if (context == null) {
            return o;
        }
        if (o == 0) {
            try {
                o = context.getApplicationInfo().targetSdkVersion;
            } catch (Exception e2) {
                w.d("SameDiTool", e2.getMessage());
            }
        }
        return o;
    }

    public static int x(Context context) {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA) || context == null) {
            return 0;
        }
        try {
            DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
            HashMap z = z(context);
            return z.get("width") == null ? displayMetrics.widthPixels : ((Integer) z.get("width")).intValue();
        } catch (Exception e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public static int y(Context context) {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA) || context == null) {
            return 0;
        }
        try {
            DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
            HashMap z = z(context);
            return z.get("height") == null ? displayMetrics.heightPixels : ((Integer) z.get("height")).intValue();
        } catch (Exception e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public static HashMap z(Context context) {
        HashMap hashMap = new HashMap();
        if (context == null) {
            return hashMap;
        }
        try {
            Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
            DisplayMetrics displayMetrics = new DisplayMetrics();
            if (Build.VERSION.SDK_INT >= 17) {
                defaultDisplay.getRealMetrics(displayMetrics);
            } else {
                defaultDisplay.getMetrics(displayMetrics);
            }
            hashMap.put("height", Integer.valueOf(displayMetrics.heightPixels));
            hashMap.put("width", Integer.valueOf(displayMetrics.widthPixels));
        } catch (Exception e2) {
            w.b("SameDiTool", e2.getMessage(), e2);
        }
        return hashMap;
    }

    public static String A(Context context) {
        if (context == null) {
            return h;
        }
        try {
            if (!TextUtils.isEmpty(h)) {
                return h;
            }
            String str = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).packageName;
            h = str;
            return str;
        } catch (Exception e2) {
            e2.printStackTrace();
            return "";
        }
    }

    public static void B(final Context context) {
        if (context != null) {
            try {
                if (Looper.myLooper() == Looper.getMainLooper()) {
                    p(context);
                } else {
                    new Handler(context.getMainLooper()).post(new Runnable() {
                        /* class com.mbridge.msdk.foundation.tools.s.AnonymousClass1 */

                        public final void run() {
                            e.p(context);
                        }
                    });
                }
            } catch (Exception e2) {
                w.b("SameDiTool", "", e2);
            }
        }
    }

    public static String C(final Context context) {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
            return null;
        }
        if (TextUtils.isEmpty(f)) {
            try {
                f = ac.b(context, "mbridge_ua", "").toString();
            } catch (Throwable th) {
                w.b("SameDiTool", th.getMessage(), th);
            }
        }
        try {
            if (!(Looper.myLooper() == Looper.getMainLooper())) {
                M();
            } else if (TextUtils.isEmpty(f)) {
                try {
                    if (Build.VERSION.SDK_INT >= 17) {
                        f = WebSettings.getDefaultUserAgent(context);
                    }
                } catch (Throwable unused) {
                }
                if (TextUtils.isEmpty(f)) {
                    try {
                        Constructor declaredConstructor = WebSettings.class.getDeclaredConstructor(Context.class, WebView.class);
                        declaredConstructor.setAccessible(true);
                        f = ((WebSettings) declaredConstructor.newInstance(context, null)).getUserAgentString();
                        declaredConstructor.setAccessible(false);
                    } catch (Throwable th2) {
                        th2.printStackTrace();
                    }
                    if (TextUtils.isEmpty(f)) {
                        try {
                            f = new WebView(context).getSettings().getUserAgentString();
                        } catch (Throwable th3) {
                            th3.printStackTrace();
                        }
                    }
                    if (TextUtils.isEmpty(f)) {
                        M();
                    }
                }
            } else {
                try {
                    new Thread(new Runnable() {
                        /* class com.mbridge.msdk.foundation.tools.s.AnonymousClass2 */

                        /* JADX WARNING: Failed to process nested try/catch */
                        /* JADX WARNING: Missing exception handler attribute for start block: B:6:0x0010 */
                        public final void run() {
                            String str = null;
                            if (Build.VERSION.SDK_INT >= 17) {
                                str = WebSettings.getDefaultUserAgent(context);
                            }
                            try {
                                if (TextUtils.isEmpty(str) && !str.equals(s.f)) {
                                    String unused = s.f = str;
                                    s.H(context);
                                }
                            } catch (Throwable th) {
                                th.printStackTrace();
                            }
                        }
                    }).start();
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            }
        } catch (Throwable th4) {
            w.b("SameDiTool", th4.getMessage(), th4);
        }
        H(context);
        return f;
    }

    /* access modifiers changed from: private */
    public static void H(Context context) {
        try {
            ac.a(context, "mbridge_ua", f);
        } catch (Throwable th) {
            w.b("SameDiTool", th.getMessage(), th);
        }
    }

    public static String x() {
        if (TextUtils.isEmpty(f)) {
            C(com.mbridge.msdk.foundation.controller.a.f().j());
        }
        return f;
    }

    private static void M() {
        String str = Build.VERSION.RELEASE;
        String u = u();
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(u)) {
            f = "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19";
            return;
        }
        f = "Mozilla/5.0 (Linux; Android " + str + "; " + u + " Build/) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19";
    }

    public static int D(Context context) {
        try {
            final Context j2 = com.mbridge.msdk.foundation.controller.a.f().j();
            if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
                return e;
            }
            if (j2 == null) {
                return e;
            }
            if (e != -1) {
                try {
                    AnonymousClass3 r2 = new Runnable() {
                        /* class com.mbridge.msdk.foundation.tools.s.AnonymousClass3 */

                        public final void run() {
                            try {
                                ConnectivityManager connectivityManager = (ConnectivityManager) j2.getSystemService("connectivity");
                                if (connectivityManager != null && a.g) {
                                    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
                                    if (activeNetworkInfo == null) {
                                        int unused = s.e = 0;
                                    } else if (activeNetworkInfo.getType() == 1) {
                                        int unused2 = s.e = 9;
                                    } else {
                                        TelephonyManager telephonyManager = (TelephonyManager) j2.getSystemService("phone");
                                        if (telephonyManager == null) {
                                            int unused3 = s.e = 0;
                                        } else {
                                            int unused4 = s.e = s.a(telephonyManager.getNetworkType());
                                        }
                                    }
                                }
                            } catch (Exception e) {
                                w.b("SameDiTool", e.getMessage(), e);
                                int unused5 = s.e = 0;
                            }
                        }
                    };
                    if (b.c().getActiveCount() < 1) {
                        b.c().execute(r2);
                    }
                } catch (Throwable th) {
                    w.d("SameDiTool", th.getMessage());
                }
                return e;
            }
            e = 0;
            return e;
        } catch (Exception e2) {
            w.b("SameDiTool", e2.getMessage(), e2);
            e = 0;
            return e;
        }
    }

    public static String a(Context context, int i2) {
        TelephonyManager telephonyManager;
        if (i2 == 0 || i2 == 9) {
            return "";
        }
        try {
            if (!a.g || (telephonyManager = (TelephonyManager) context.getSystemService("phone")) == null) {
                return "";
            }
            return String.valueOf(telephonyManager.getNetworkType());
        } catch (Throwable th) {
            w.b("SameDiTool", th.getMessage(), th);
            return "";
        }
    }

    public static String y() {
        try {
            if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_OTHER)) {
                return "";
            }
            if (TextUtils.isEmpty(l)) {
                new Thread(new Runnable() {
                    /* class com.mbridge.msdk.foundation.tools.s.AnonymousClass4 */

                    public final void run() {
                        try {
                            String unused = s.l = TimeZone.getDefault().getDisplayName(false, 0, Locale.ENGLISH);
                        } catch (Throwable th) {
                            th.printStackTrace();
                        }
                    }
                }).start();
                return l;
            }
            return l;
        } catch (Throwable th) {
            w.b("SameDiTool", th.getMessage(), th);
        }
    }

    public static String z() {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
            return "";
        }
        if (TextUtils.isEmpty(g)) {
            int A = A();
            g = A + "";
        }
        return g;
    }

    public static int A() {
        try {
            return Build.VERSION.SDK_INT;
        } catch (Exception e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public static void a(String str) {
        b = r.a(str);
        a = str;
    }

    public static String B() {
        String str;
        if (com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_DEVICE_ID) && (str = a) != null) {
            return str;
        }
        return "";
    }

    public static String C() {
        String str;
        if (com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_DEVICE_ID) && (str = b) != null) {
            return str;
        }
        return "";
    }

    public static UUID D() {
        try {
            return UUID.randomUUID();
        } catch (Throwable th) {
            w.b("SameDiTool", th.getMessage(), th);
            return null;
        }
    }

    public static String a(String str, Context context) {
        try {
            if (!TextUtils.isEmpty(n)) {
                return n;
            }
            if (!TextUtils.isEmpty(str) && context != null) {
                n = context.getPackageManager().getInstallerPackageName(str);
                w.a("SameDiTool", "PKGSource:" + n);
            }
            return n;
        } catch (Exception e2) {
            w.b("SameDiTool", e2.getMessage(), e2);
        }
    }

    public static String E() {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
            return "";
        }
        return Build.MANUFACTURER;
    }

    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:18:0x006b */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x008a A[SYNTHETIC, Splitter:B:31:0x008a] */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x0091  */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x00a2 A[SYNTHETIC, Splitter:B:40:0x00a2] */
    /* JADX WARNING: Removed duplicated region for block: B:44:0x00a9  */
    public static String F() {
        FileReader fileReader;
        Exception e2;
        BufferedReader bufferedReader;
        Throwable th;
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
            return "";
        }
        if (r > 0) {
            return r + "GB";
        }
        r = 0;
        try {
            fileReader = new FileReader("/proc/meminfo");
            try {
                bufferedReader = new BufferedReader(fileReader, 8192);
                try {
                    String str = bufferedReader.readLine().split("\\s+")[1];
                    bufferedReader.close();
                    if (str != null) {
                        r = (int) Math.ceil(new Float(Float.valueOf(str).floatValue() / 1048576.0f).doubleValue());
                    }
                    fileReader.close();
                    try {
                        bufferedReader.close();
                    } catch (IOException e3) {
                        e3.printStackTrace();
                    }
                } catch (Exception e4) {
                    e2 = e4;
                    w.b("SameDiTool", e2.getMessage(), e2);
                    if (fileReader != null) {
                    }
                    if (bufferedReader != null) {
                    }
                    return r + "GB";
                } catch (Throwable th2) {
                    th = th2;
                    try {
                        w.b("SameDiTool", th.getMessage(), th);
                        if (fileReader != null) {
                        }
                        if (bufferedReader != null) {
                        }
                        return r + "GB";
                    } catch (Throwable th3) {
                        if (fileReader != null) {
                            try {
                                fileReader.close();
                            } catch (IOException unused) {
                            }
                        }
                        if (bufferedReader != null) {
                            try {
                                bufferedReader.close();
                            } catch (IOException e5) {
                                e5.printStackTrace();
                            }
                        }
                        throw th3;
                    }
                }
            } catch (Exception e6) {
                e2 = e6;
                bufferedReader = null;
                w.b("SameDiTool", e2.getMessage(), e2);
                if (fileReader != null) {
                }
                if (bufferedReader != null) {
                }
                return r + "GB";
            } catch (Throwable th4) {
                th = th4;
                bufferedReader = null;
                w.b("SameDiTool", th.getMessage(), th);
                if (fileReader != null) {
                }
                if (bufferedReader != null) {
                }
                return r + "GB";
            }
        } catch (Exception e7) {
            fileReader = null;
            e2 = e7;
            bufferedReader = null;
            w.b("SameDiTool", e2.getMessage(), e2);
            if (fileReader != null) {
                try {
                    fileReader.close();
                } catch (IOException unused2) {
                }
            }
            if (bufferedReader != null) {
                bufferedReader.close();
            }
            return r + "GB";
        } catch (Throwable th5) {
            fileReader = null;
            th = th5;
            bufferedReader = null;
            w.b("SameDiTool", th.getMessage(), th);
            if (fileReader != null) {
                try {
                    fileReader.close();
                } catch (IOException unused3) {
                }
            }
            if (bufferedReader != null) {
                bufferedReader.close();
            }
            return r + "GB";
        }
        return r + "GB";
    }

    public static String E(Context context) {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA) || context == null) {
            return "";
        }
        try {
            return Settings.System.getString(context.getContentResolver(), "time_12_24");
        } catch (Exception e2) {
            w.b("SameDiTool", e2.getMessage(), e2);
            return "";
        } catch (Throwable th) {
            w.b("SameDiTool", th.getMessage(), th);
            return "";
        }
    }

    /* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: java.io.FileReader */
    /* JADX DEBUG: Multi-variable search result rejected for r4v1, resolved type: java.io.FileReader */
    /* JADX DEBUG: Multi-variable search result rejected for r4v2, resolved type: java.io.FileReader */
    /* JADX DEBUG: Multi-variable search result rejected for r4v3, resolved type: java.io.FileReader */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARNING: Removed duplicated region for block: B:36:0x007b A[SYNTHETIC, Splitter:B:36:0x007b] */
    /* JADX WARNING: Removed duplicated region for block: B:41:0x0089 A[SYNTHETIC, Splitter:B:41:0x0089] */
    /* JADX WARNING: Removed duplicated region for block: B:47:0x0098 A[SYNTHETIC, Splitter:B:47:0x0098] */
    /* JADX WARNING: Removed duplicated region for block: B:52:0x00a6  */
    public static String F(Context context) {
        IOException e2;
        FileReader fileReader;
        Throwable th;
        FileReader fileReader2;
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA) || context == null) {
            return "";
        }
        if (!TextUtils.isEmpty(q)) {
            return q;
        }
        BufferedReader bufferedReader = null;
        try {
            FileReader fileReader3 = new FileReader("/proc/meminfo");
            try {
                BufferedReader bufferedReader2 = new BufferedReader(fileReader3, 8192);
                try {
                    String formatFileSize = Formatter.formatFileSize(context, Long.valueOf(bufferedReader2.readLine().split("\\s+")[1]).longValue() * 1024);
                    q = formatFileSize;
                    try {
                        bufferedReader2.close();
                    } catch (IOException e3) {
                        w.b("SameDiTool", e3.getMessage(), e3);
                    }
                    try {
                        fileReader3.close();
                    } catch (IOException e4) {
                        w.b("SameDiTool", e4.getMessage(), e4);
                    }
                    return formatFileSize;
                } catch (IOException e5) {
                    e2 = e5;
                    bufferedReader = bufferedReader2;
                    fileReader = fileReader3;
                    w.b("SameDiTool", e2.getMessage(), e2);
                    if (bufferedReader != null) {
                    }
                    if (fileReader != 0) {
                    }
                    return "";
                } catch (Throwable th2) {
                    th = th2;
                    bufferedReader = bufferedReader2;
                    fileReader2 = fileReader3;
                    try {
                        w.b("SameDiTool", th.getMessage(), th);
                        return "";
                    } finally {
                        if (bufferedReader != null) {
                            try {
                                bufferedReader.close();
                            } catch (IOException e6) {
                                w.b("SameDiTool", e6.getMessage(), e6);
                            }
                        }
                        if (fileReader2 != 0) {
                            try {
                                fileReader2.close();
                            } catch (IOException e7) {
                                w.b("SameDiTool", e7.getMessage(), e7);
                            }
                        }
                    }
                }
            } catch (IOException e8) {
                e2 = e8;
                fileReader = fileReader3;
                w.b("SameDiTool", e2.getMessage(), e2);
                if (bufferedReader != null) {
                }
                if (fileReader != 0) {
                }
                return "";
            } catch (Throwable th3) {
                th = th3;
                fileReader2 = fileReader3;
                w.b("SameDiTool", th.getMessage(), th);
                return "";
            }
        } catch (IOException e9) {
            e2 = e9;
            fileReader = bufferedReader;
            w.b("SameDiTool", e2.getMessage(), e2);
            if (bufferedReader != null) {
                try {
                    bufferedReader.close();
                } catch (IOException e10) {
                    w.b("SameDiTool", e10.getMessage(), e10);
                }
            }
            if (fileReader != 0) {
                fileReader.close();
            }
            return "";
        } catch (Throwable th4) {
            th = th4;
            fileReader2 = bufferedReader;
            w.b("SameDiTool", th.getMessage(), th);
            return "";
        }
    }

    public static String G() {
        Exception e2;
        String str = "";
        try {
            Context j2 = com.mbridge.msdk.foundation.controller.a.f().j();
            long currentTimeMillis = System.currentTimeMillis() - SystemClock.elapsedRealtime();
            long N = N();
            String str2 = "app_tki_" + currentTimeMillis + "_" + N;
            String str3 = (String) ac.b(j2, str2, str);
            try {
                if (!TextUtils.isEmpty(str3)) {
                    return str3;
                }
                JSONObject jSONObject = new JSONObject();
                try {
                    jSONObject.put("1", str);
                    jSONObject.put("2", String.valueOf(N));
                    jSONObject.put("3", String.valueOf(currentTimeMillis));
                    jSONObject.put("4", str);
                    jSONObject.put("5", str);
                } catch (Exception e3) {
                    e3.printStackTrace();
                }
                str = a.a(jSONObject.toString());
                ac.a(j2, str2, str);
                return str;
            } catch (Exception e4) {
                e2 = e4;
                str = str3;
                e2.printStackTrace();
                return str;
            }
        } catch (Exception e5) {
            e2 = e5;
            e2.printStackTrace();
            return str;
        }
    }

    public static int H() {
        try {
            if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
                return 0;
            }
            Context j2 = com.mbridge.msdk.foundation.controller.a.f().j();
            long j3 = 0;
            long longValue = ((Long) ac.b(j2, "FreeRamSize", 0L)).longValue();
            long currentTimeMillis = System.currentTimeMillis();
            if (currentTimeMillis - longValue > 1800000 || d == -1) {
                Context j4 = com.mbridge.msdk.foundation.controller.a.f().j();
                if (j4 != null) {
                    ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
                    ((ActivityManager) j4.getSystemService(TTDownloadField.TT_ACTIVITY)).getMemoryInfo(memoryInfo);
                    j3 = memoryInfo.availMem;
                }
                d = Long.valueOf((j3 / 1000) / 1000).intValue();
                ac.a(j2, "FreeRamSize", Long.valueOf(currentTimeMillis));
            }
            return d;
        } catch (Throwable th) {
            w.b("SameDiTool", th.getMessage(), th);
        }
    }

    private static long N() {
        Context j2 = com.mbridge.msdk.foundation.controller.a.f().j();
        if (j2 == null) {
            return 0;
        }
        ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
        ((ActivityManager) j2.getSystemService(TTDownloadField.TT_ACTIVITY)).getMemoryInfo(memoryInfo);
        if (Build.VERSION.SDK_INT >= 16) {
            return memoryInfo.totalMem;
        }
        return 0;
    }

    public static int I() {
        if (!com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) {
            return 0;
        }
        if (c < 1) {
            try {
                Context j2 = com.mbridge.msdk.foundation.controller.a.f().j();
                long longValue = ((Long) ac.b(j2, "TotalRamSize", 0L)).longValue();
                long currentTimeMillis = System.currentTimeMillis();
                if (currentTimeMillis - longValue > 1800000 || c == -1) {
                    c = Long.valueOf((N() / 1000) / 1000).intValue();
                    ac.a(j2, "TotalRamSize", Long.valueOf(currentTimeMillis));
                }
            } catch (Throwable th) {
                w.b("SameDiTool", th.getMessage(), th);
            }
        }
        return c;
    }

    public static int J() {
        return m;
    }

    public static String K() {
        if (!TextUtils.isEmpty(p)) {
            return p;
        }
        JSONObject jSONObject = new JSONObject();
        String str = null;
        try {
            Class<?> cls = Class.forName("com.huawei.system.BuildEx");
            str = (String) cls.getMethod("getOsBrand", new Class[0]).invoke(cls, new Object[0]);
        } catch (Throwable th) {
            w.d("SameDiTool", th.getMessage());
        }
        try {
            if (TextUtils.isEmpty(str) || !str.equals("harmony")) {
                p = FaceEnvironment.OS;
                return p;
            }
            jSONObject.put("osType", str);
            try {
                Class<?> cls2 = Class.forName("ohos.system.version.SystemVersion");
                jSONObject.put("version", (String) cls2.getMethod("getVersion", new Class[0]).invoke(cls2, new Object[0]));
            } catch (Throwable th2) {
                w.d("SameDiTool", th2.getMessage());
            }
            try {
                jSONObject.put("pure_state", Settings.Secure.getInt(com.mbridge.msdk.foundation.controller.a.f().j().getContentResolver(), "pure_mode_state", -1));
            } catch (Throwable th3) {
                w.d("SameDiTool", th3.getMessage());
            }
            String jSONObject2 = jSONObject.toString();
            if (!TextUtils.isEmpty(jSONObject2)) {
                jSONObject2 = r.a(jSONObject2);
            }
            p = jSONObject2;
            return p;
        } catch (Throwable th4) {
            w.d("SameDiTool", th4.getMessage());
        }
    }
}