%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD.apk(点击下载) / s.java


package com.baidu.techain.i;

import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.os.PowerManager;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
import com.baidu.techain.h.a;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import java.util.Arrays;
import java.util.HashSet;
import org.json.JSONArray;
import org.json.JSONObject;

/* compiled from: PrivacyOperationUtil */
public final class s {
    private static long A = 0;
    private static String a = null;
    private static long b = 0;
    private static String c = null;
    private static long d = 0;
    private static String e = null;
    private static long f = 0;
    private static String g = null;
    private static long h = 0;
    private static String i = null;
    private static long j = 0;
    private static String k = null;
    private static long l = 0;
    private static String m = null;
    private static long n = 0;
    private static boolean o = true;
    private static boolean p = true;
    private static boolean q = true;
    private static boolean r = true;
    private static boolean s = true;
    private static boolean t = true;
    private static boolean u = true;
    private static boolean v = true;
    private static boolean w = true;
    private static boolean x = true;
    private static boolean y = false;
    private static boolean z;

    public static void a(Context context, JSONObject jSONObject) {
        if (context != null && jSONObject != null) {
            try {
                a a2 = a.a(context);
                a2.b.putString("p_s_p_c", jSONObject.toString());
                a2.b.commit();
                a(jSONObject);
            } catch (Throwable unused) {
                c.a();
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:14:?, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:16:0x002c, code lost:
        return;
     */
    /* JADX WARNING: Exception block dominator not found, dom blocks: [] */
    /* JADX WARNING: Missing exception handler attribute for start block: B:13:0x0028 */
    public static synchronized void a(Context context) {
        synchronized (s.class) {
            if (context != null) {
                if (!y) {
                    y = true;
                    a(new JSONObject(a.a(context).a.getString("p_s_p_c", "")));
                }
            }
        }
    }

    private static void a(JSONObject jSONObject) {
        if (jSONObject != null) {
            w = jSONObject.optInt(PushConstants.PUSH_TYPE_NOTIFY, 1) != 0;
            JSONArray optJSONArray = jSONObject.optJSONArray("1");
            if (optJSONArray != null) {
                HashSet hashSet = new HashSet();
                for (int i2 = 0; i2 < optJSONArray.length(); i2++) {
                    hashSet.add(Integer.valueOf(optJSONArray.optInt(i2)));
                }
                if (hashSet.contains(27)) {
                    o = false;
                } else {
                    o = true;
                }
                if (hashSet.contains(34)) {
                    u = false;
                } else {
                    u = true;
                }
                if (hashSet.contains(40)) {
                    p = false;
                } else {
                    p = true;
                }
                if (hashSet.contains(41)) {
                    x = false;
                } else {
                    x = true;
                }
                if (hashSet.contains(42)) {
                    q = false;
                } else {
                    q = true;
                }
                if (hashSet.contains(43)) {
                    s = false;
                } else {
                    s = true;
                }
                if (hashSet.contains(44)) {
                    r = false;
                } else {
                    r = true;
                }
                if (hashSet.contains(45)) {
                    t = false;
                } else {
                    t = true;
                }
                if (hashSet.contains(46)) {
                    v = false;
                } else {
                    v = true;
                }
            }
        }
    }

    private static boolean n(Context context) {
        if (System.currentTimeMillis() - A < 1000) {
            return z;
        }
        z = p(context) && q(context);
        A = System.currentTimeMillis();
        return z;
    }

    private static boolean o(Context context) {
        return t.a(context) && n(context);
    }

    public static boolean b(Context context) {
        return context != null && q && o(context);
    }

    public static boolean c(Context context) {
        return context != null && r && o(context);
    }

    public static boolean d(Context context) {
        return context != null && s && o(context);
    }

    public static boolean e(Context context) {
        return context != null && t && o(context);
    }

    public static String f(Context context) {
        if (context != null) {
            try {
                if (r) {
                    if (t.a(context)) {
                        if (!TextUtils.isEmpty(g) && System.currentTimeMillis() - h < 86400000) {
                            return g;
                        }
                        a a2 = a.a(context);
                        if (TextUtils.isEmpty(g)) {
                            g = a2.z();
                            h = a2.a.getLong("p_s_e_c_t_t", 0);
                            if (!TextUtils.isEmpty(g) && System.currentTimeMillis() - h < 86400000) {
                                return g;
                            }
                        }
                        if (!r.b(context)) {
                            return g;
                        }
                        if (!n(context)) {
                            return g;
                        }
                        try {
                            String f2 = e.f(context);
                            if (!TextUtils.isEmpty(f2)) {
                                g = f2;
                                h = System.currentTimeMillis();
                                String str = g;
                                if (TextUtils.isEmpty(str)) {
                                    a2.b.putString("p_s_e_c_t", "");
                                    a2.b.commit();
                                } else {
                                    try {
                                        a2.b.putString("p_s_e_c_t", new String(Base64.encode(g.a("MzAyMTIxMDJkaWN1ZGlhYg==".getBytes(), str.getBytes("UTF-8")), 10), "UTF-8"));
                                        a2.b.commit();
                                    } catch (Throwable unused) {
                                        c.a();
                                    }
                                }
                                a2.b.putLong("p_s_e_c_t_t", h);
                                a2.b.commit();
                            }
                        } catch (Throwable unused2) {
                            c.a();
                        }
                        return g;
                    }
                }
            } catch (Throwable unused3) {
                c.a();
                return "";
            }
        }
        return "";
    }

    public static String g(Context context) {
        if (context != null) {
            try {
                if (q) {
                    if (t.a(context)) {
                        if (!TextUtils.isEmpty(e) && System.currentTimeMillis() - f < 86400000) {
                            return e;
                        }
                        a a2 = a.a(context);
                        if (TextUtils.isEmpty(g)) {
                            e = a2.A();
                            f = a2.a.getLong("p_s_s_c_t_t", 0);
                            if (!TextUtils.isEmpty(e) && System.currentTimeMillis() - f < 86400000) {
                                return e;
                            }
                        }
                        if (!n(context)) {
                            return e;
                        }
                        try {
                            String e2 = e.e(context);
                            if (!TextUtils.isEmpty(e2)) {
                                e = e2;
                                f = System.currentTimeMillis();
                                String str = e;
                                if (TextUtils.isEmpty(str)) {
                                    a2.b.putString("p_s_s_c_t", "");
                                    a2.b.commit();
                                } else {
                                    try {
                                        a2.b.putString("p_s_s_c_t", new String(Base64.encode(g.a("MzAyMTIxMDJkaWN1ZGlhYg==".getBytes(), str.getBytes("UTF-8")), 10), "UTF-8"));
                                        a2.b.commit();
                                    } catch (Throwable unused) {
                                        c.a();
                                    }
                                }
                                a2.b.putLong("p_s_s_c_t_t", f);
                                a2.b.commit();
                            }
                        } catch (Throwable unused2) {
                            c.a();
                        }
                        return e;
                    }
                }
            } catch (Throwable unused3) {
                c.a();
                return "";
            }
        }
        return "";
    }

    public static String h(Context context) {
        if (context != null) {
            try {
                if (o) {
                    if (t.a(context)) {
                        if (!TextUtils.isEmpty(a) && System.currentTimeMillis() - b < 86400000) {
                            return a;
                        }
                        if ("com.baidu.input_huawei".equals(context.getPackageName())) {
                            return "";
                        }
                        a a2 = a.a(context);
                        if (TextUtils.isEmpty(a)) {
                            a = a2.x();
                            b = a2.a.getLong("p_s_i_t_t", 0);
                            if (!TextUtils.isEmpty(a) && System.currentTimeMillis() - b < 86400000) {
                                return a;
                            }
                        }
                        if (!r.a(context)) {
                            return a;
                        }
                        if (!n(context)) {
                            return a;
                        }
                        try {
                            String deviceId = ((TelephonyManager) context.getSystemService("phone")).getDeviceId();
                            if (!TextUtils.isEmpty(deviceId)) {
                                a = deviceId;
                                b = System.currentTimeMillis();
                                String str = a;
                                if (TextUtils.isEmpty(str)) {
                                    a2.b.putString("p_s_i_t", "");
                                    a2.b.commit();
                                } else {
                                    try {
                                        a2.b.putString("p_s_i_t", new String(Base64.encode(g.a("MzAyMTIxMDJkaWN1ZGlhYg==".getBytes(), str.getBytes("UTF-8")), 10), "UTF-8"));
                                        a2.b.commit();
                                    } catch (Throwable unused) {
                                        c.a();
                                    }
                                }
                                a2.b.putLong("p_s_i_t_t", b);
                                a2.b.commit();
                            }
                        } catch (Throwable unused2) {
                            c.a();
                        }
                        return a;
                    }
                }
            } catch (Throwable unused3) {
                c.a();
                return "";
            }
        }
        return "";
    }

    public static String i(Context context) {
        if (context != null) {
            try {
                if (p) {
                    if (t.a(context)) {
                        if (!TextUtils.isEmpty(c) && System.currentTimeMillis() - d < 86400000) {
                            return c;
                        }
                        a a2 = a.a(context);
                        if (TextUtils.isEmpty(c)) {
                            c = a2.y();
                            d = a2.a.getLong("p_s_a_i_t_t", 0);
                            if (!TextUtils.isEmpty(c) && System.currentTimeMillis() - d < 86400000) {
                                return c;
                            }
                        }
                        if (!n(context)) {
                            return c;
                        }
                        try {
                            String string = Settings.Secure.getString(context.getContentResolver(), "android_id");
                            if (!TextUtils.isEmpty(string)) {
                                c = string;
                                d = System.currentTimeMillis();
                                String str = c;
                                if (TextUtils.isEmpty(str)) {
                                    a2.b.putString("p_s_a_i_t", "");
                                    a2.b.commit();
                                } else {
                                    try {
                                        a2.b.putString("p_s_a_i_t", new String(Base64.encode(g.a("MzAyMTIxMDJkaWN1ZGlhYg==".getBytes(), str.getBytes("UTF-8")), 10), "UTF-8"));
                                        a2.b.commit();
                                    } catch (Throwable unused) {
                                        c.a();
                                    }
                                }
                                a2.b.putLong("p_s_a_i_t_t", d);
                                a2.b.commit();
                            }
                        } catch (Throwable unused2) {
                            c.a();
                        }
                        return c;
                    }
                }
            } catch (Throwable unused3) {
                c.a();
                return "";
            }
        }
        return "";
    }

    public static String j(Context context) {
        if (context != null) {
            try {
                if (x) {
                    if (t.a(context)) {
                        if (!TextUtils.isEmpty(i) && System.currentTimeMillis() - j < 86400000) {
                            return i;
                        }
                        a a2 = a.a(context);
                        if (TextUtils.isEmpty(i)) {
                            i = a2.B();
                            j = a2.a.getLong("p_s_o_d_t_t", 0);
                            if (!TextUtils.isEmpty(i) && System.currentTimeMillis() - j < 86400000) {
                                return i;
                            }
                        }
                        if (!n(context)) {
                            return i;
                        }
                        try {
                            String b2 = com.baidu.techain.j.a.a().b();
                            if (!TextUtils.isEmpty(b2)) {
                                i = b2;
                                j = System.currentTimeMillis();
                                String str = i;
                                if (TextUtils.isEmpty(str)) {
                                    a2.b.putString("p_s_o_d_t", "");
                                    a2.b.commit();
                                } else {
                                    try {
                                        a2.b.putString("p_s_o_d_t", new String(Base64.encode(g.a("MzAyMTIxMDJkaWN1ZGlhYg==".getBytes(), str.getBytes("UTF-8")), 10), "UTF-8"));
                                        a2.b.commit();
                                    } catch (Throwable unused) {
                                        c.a();
                                    }
                                }
                                a2.b.putLong("p_s_o_d_t_t", j);
                                a2.b.commit();
                            }
                        } catch (Throwable unused2) {
                            c.a();
                        }
                        return i;
                    }
                }
            } catch (Throwable unused3) {
                c.a();
                return "";
            }
        }
        return "";
    }

    public static String k(Context context) {
        if (context != null) {
            try {
                if (u) {
                    if (t.a(context)) {
                        if (!TextUtils.isEmpty(k) && System.currentTimeMillis() - l < 86400000) {
                            return k;
                        }
                        a a2 = a.a(context);
                        if (TextUtils.isEmpty(k)) {
                            k = a2.C();
                            l = a2.a.getLong("p_s_s_o_t_t", 0);
                            if (!TextUtils.isEmpty(k) && System.currentTimeMillis() - l < 86400000) {
                                return k;
                            }
                        }
                        if (!n(context)) {
                            return k;
                        }
                        try {
                            String simOperatorName = ((TelephonyManager) context.getSystemService("phone")).getSimOperatorName();
                            if (!TextUtils.isEmpty(simOperatorName)) {
                                k = simOperatorName;
                                l = System.currentTimeMillis();
                                String str = k;
                                if (TextUtils.isEmpty(str)) {
                                    a2.b.putString("p_s_s_o_t", "");
                                    a2.b.commit();
                                } else {
                                    try {
                                        a2.b.putString("p_s_s_o_t", new String(Base64.encode(g.a("MzAyMTIxMDJkaWN1ZGlhYg==".getBytes(), str.getBytes("UTF-8")), 10), "UTF-8"));
                                        a2.b.commit();
                                    } catch (Throwable unused) {
                                        c.a();
                                    }
                                }
                                a2.b.putLong("p_s_s_o_t_t", l);
                                a2.b.commit();
                            }
                        } catch (Throwable unused2) {
                            c.a();
                        }
                        return k;
                    }
                }
            } catch (Throwable unused3) {
                c.a();
                return "";
            }
        }
        return "";
    }

    public static String l(Context context) {
        if (context != null) {
            try {
                if (v) {
                    if (t.a(context)) {
                        if (!TextUtils.isEmpty(m) && System.currentTimeMillis() - n < 86400000) {
                            return m;
                        }
                        a a2 = a.a(context);
                        if (TextUtils.isEmpty(m)) {
                            m = a2.D();
                            n = a2.a.getLong("p_s_n_o_t_t", 0);
                            if (!TextUtils.isEmpty(m) && System.currentTimeMillis() - n < 86400000) {
                                return m;
                            }
                        }
                        if (!n(context)) {
                            return m;
                        }
                        try {
                            String networkOperator = ((TelephonyManager) context.getSystemService("phone")).getNetworkOperator();
                            if (!TextUtils.isEmpty(networkOperator)) {
                                m = networkOperator;
                                n = System.currentTimeMillis();
                                String str = m;
                                if (TextUtils.isEmpty(str)) {
                                    a2.b.putString("p_s_n_o_t", "");
                                    a2.b.commit();
                                } else {
                                    try {
                                        a2.b.putString("p_s_n_o_t", new String(Base64.encode(g.a("MzAyMTIxMDJkaWN1ZGlhYg==".getBytes(), str.getBytes("UTF-8")), 10), "UTF-8"));
                                        a2.b.commit();
                                    } catch (Throwable unused) {
                                        c.a();
                                    }
                                }
                                a2.b.putLong("p_s_n_o_t_t", n);
                                a2.b.commit();
                            }
                        } catch (Throwable unused2) {
                            c.a();
                        }
                        return m;
                    }
                }
            } catch (Throwable unused3) {
                c.a();
                return "";
            }
        }
        return "";
    }

    private static boolean p(Context context) {
        try {
            return ((PowerManager) context.getSystemService("power")).isScreenOn();
        } catch (Throwable unused) {
            c.a();
            return false;
        }
    }

    private static boolean q(Context context) {
        try {
            if (Build.VERSION.SDK_INT < 21) {
                return r(context);
            }
            if (context == null) {
                return false;
            }
            for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : ((ActivityManager) context.getSystemService(PushConstants.INTENT_ACTIVITY_NAME)).getRunningAppProcesses()) {
                if (runningAppProcessInfo.importance == 100 && runningAppProcessInfo.importanceReasonCode == 0 && runningAppProcessInfo.pkgList != null && runningAppProcessInfo.pkgList.length != 0 && Arrays.asList(runningAppProcessInfo.pkgList).contains(context.getPackageName())) {
                    return true;
                }
            }
            return false;
        } catch (Throwable unused) {
            c.a();
            return false;
        }
    }

    private static boolean r(Context context) {
        ActivityManager.RunningTaskInfo runningTaskInfo;
        try {
            ActivityManager activityManager = (ActivityManager) context.getSystemService(PushConstants.INTENT_ACTIVITY_NAME);
            if (activityManager.getRunningTasks(1) == null || (runningTaskInfo = activityManager.getRunningTasks(1).get(0)) == null) {
                return false;
            }
            return context.getPackageName().equals(runningTaskInfo.topActivity.getPackageName());
        } catch (Throwable unused) {
            c.a();
            return false;
        }
    }

    public static boolean m(Context context) {
        if (context == null) {
            return false;
        }
        return w || n(context);
    }
}