智能工厂.apk(点击下载) / j.java


package com.tencent.smtt.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import androidx.core.os.EnvironmentCompat;
import com.baidu.speech.utils.cuid.util.DeviceId;
import com.tencent.smtt.sdk.TbsPrivacyAccess;
import com.tencent.smtt.sdk.c;
import java.security.MessageDigest;
import java.util.Locale;
import java.util.Random;
import java.util.UUID;
import org.altbeacon.bluetooth.Pdu;

public class j {
    private static SharedPreferences a;
    private static SharedPreferences.Editor b;

    private static String a() {
        int nextInt = new Random().nextInt(2147483646);
        return Build.FINGERPRINT + nextInt;
    }

    public static String a(Context context) {
        if (!d(context)) {
            return "";
        }
        a = context.getApplicationContext().getSharedPreferences("tsui", 0);
        SharedPreferences sharedPreferences = a;
        if (sharedPreferences != null) {
            String string = sharedPreferences.getString("tsui", "");
            if (!TextUtils.isEmpty(string)) {
                return string;
            }
        }
        StringBuilder sb = new StringBuilder();
        String a2 = a();
        String k = b.k(context);
        String c = c(context);
        String replace = b(context).replace("-", "");
        if (a2 != null && a2.length() > 0) {
            sb.append(a2);
            sb.append("|");
        }
        if (k != null && k.length() > 0) {
            sb.append(k);
            sb.append("|");
        }
        if (c != null && c.length() > 0) {
            sb.append(c);
            sb.append("|");
        }
        if (replace != null && replace.length() > 0) {
            sb.append(replace);
        }
        if (sb.length() > 0) {
            try {
                String a3 = a(a(sb.toString()));
                if (a3 != null && a3.length() > 0) {
                    a(context, "tsui", a3);
                    return a3;
                }
            } catch (Exception unused) {
            }
        }
        String replace2 = UUID.randomUUID().toString().replace("-", "");
        a(context, "tsui", replace2);
        return replace2;
    }

    private static String a(byte[] bArr) {
        StringBuilder sb = new StringBuilder();
        for (byte b2 : bArr) {
            String hexString = Integer.toHexString(b2 & Pdu.MANUFACTURER_DATA_PDU_TYPE);
            if (hexString.length() == 1) {
                sb.append(DeviceId.CUIDInfo.I_EMPTY);
            }
            sb.append(hexString);
        }
        return sb.toString().toUpperCase(Locale.CHINA);
    }

    private static void a(Context context, String str, String str2) {
        if (a == null) {
            a = context.getApplicationContext().getSharedPreferences("tsui", 0);
        }
        b = a.edit();
        b.putString(str, str2);
        b.commit();
    }

    private static byte[] a(String str) {
        try {
            MessageDigest instance = MessageDigest.getInstance("SHA1");
            instance.reset();
            instance.update(str.getBytes("UTF-8"));
            return instance.digest();
        } catch (Exception unused) {
            return "".getBytes();
        }
    }

    private static String b(Context context) {
        try {
            String d = r.d(context);
            int nextInt = new Random().nextInt(2147483646);
            return new UUID((long) ("" + nextInt + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10) + (Build.DEVICE.length() % 10) + (Build.HARDWARE.length() % 10) + (Build.ID.length() % 10) + (d.length() % 10) + (Build.PRODUCT.length() % 10) + (c(context).length() % 10)).hashCode(), (long) c(context).hashCode()).toString();
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    private static String c(Context context) {
        try {
            String configurePrivacy = TbsPrivacyAccess.getConfigurePrivacy(context, TbsPrivacyAccess.ConfigurablePrivacy.SERIAL, "");
            if (!TextUtils.isEmpty(configurePrivacy)) {
                if (!configurePrivacy.contains(EnvironmentCompat.MEDIA_UNKNOWN)) {
                    return configurePrivacy;
                }
            }
            return a();
        } catch (Exception unused) {
            return EnvironmentCompat.MEDIA_UNKNOWN;
        }
    }

    private static boolean d(final Context context) {
        boolean z = true;
        try {
            z = context.getSharedPreferences("sai", 0).getBoolean("sui", true);
            TbsLog.i("SDKUID", "isSDKUIDEnable is " + z);
            c.a().a(context, (Integer) 1002, (c.a) new c.a() {
                /* class com.tencent.smtt.utils.j.AnonymousClass1 */

                @Override // com.tencent.smtt.sdk.c.a
                public void a(String str) {
                    SharedPreferences.Editor edit = context.getSharedPreferences("sai", 0).edit();
                    edit.putBoolean("sui", false);
                    edit.commit();
                    TbsLog.e("TBSEmergency", "Execute command [1002](" + str + ")");
                }
            });
            return z;
        } catch (Throwable th) {
            TbsLog.i("SDKUID", "stack is " + Log.getStackTraceString(th));
            return z;
        }
    }
}