导航菜单

页面标题

页面副标题

Easycash v3.75.13 - YqdUtils.java 源代码

正在查看: Easycash v3.75.13 应用的 YqdUtils.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.lingyue.easycash.utils;

import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.Typeface;
import android.net.Uri;
import android.net.http.SslCertificate;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Looper;
import android.telephony.TelephonyManager;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.View;
import android.webkit.WebView;
import android.widget.EditText;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import com.fintopia.lender.module.utils.LocationHelper;
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.gson.Gson;
import com.lingyue.easycash.Configuration;
import com.lingyue.easycash.ECServerApiConfig;
import com.lingyue.easycash.EasyCashApplication;
import com.lingyue.easycash.R;
import com.lingyue.easycash.core.CommonCore;
import com.lingyue.easycash.models.EnvironmentInfo;
import com.lingyue.easycash.models.TerminalInfo;
import com.lingyue.idnbaselib.GeneralConstants;
import com.lingyue.idnbaselib.utils.DevUtil;
import com.lingyue.supertoolkit.customtools.CrashReporter;
import com.lingyue.supertoolkit.customtools.ScreenUtils;
import com.lingyue.supertoolkit.phonetools.AdaptScreenUtil;
import com.lingyue.supertoolkit.phonetools.NetworkUtils;
import com.lingyue.supertoolkit.resourcetools.ContextProvider;
import com.lingyue.supertoolkit.resourcetools.DeviceUtils;
import com.lingyue.supertoolkit.resourcetools.SharedPreferenceUtils;
import com.lingyue.supertoolkit.widgets.BaseUtils;
import com.qiniu.android.common.Constants;
import com.sensorsdata.analytics.android.autotrack.aop.SensorsDataAutoTrackHelper;
import com.sensorsdata.analytics.android.sdk.SensorsDataInstrumented;
import com.sensorsdata.analytics.android.sdk.jsbridge.JSHookAop;
import com.sensorsdata.analytics.android.sdk.util.SADataHelper;
import com.veda.android.bananalibrary.common.BananaBaseApplication;
import com.veda.android.bananalibrary.net.HttpsUtils;
import com.yangqianguan.statistics.AutoTrackHelper;
import com.yangqianguan.statistics.annotation.DataTrackViewOnClick;
import cz.msebera.android.httpclient.client.config.CookieSpecs;
import cz.msebera.android.httpclient.protocol.HTTP;
import io.sentry.ITransaction;
import io.sentry.Sentry;
import io.sentry.SpanStatus;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import okhttp3.HttpUrl;
import okhttp3.internal.publicsuffix.PublicSuffixDatabase;

public class YqdUtils {
    private static volatile String f;
    private static Gson a = new Gson();
    private static TerminalInfo b = new TerminalInfo();
    private static EnvironmentInfo c = new EnvironmentInfo();
    private static ReentrantReadWriteLock d = new ReentrantReadWriteLock();
    private static DisplayMetrics e = new DisplayMetrics();
    private static boolean g = false;
    private static int h = 0;

    public static byte[] A(Context context, int i) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        byte[] bArr = new byte[SADataHelper.MAX_LENGTH_1024];
        InputStream inputStream = null;
        try {
            try {
                try {
                    inputStream = context.getResources().openRawResource(i);
                    while (true) {
                        int read = inputStream.read(bArr);
                        if (read == -1) {
                            break;
                        }
                        byteArrayOutputStream.write(bArr, 0, read);
                    }
                    byteArrayOutputStream.close();
                    inputStream.close();
                } catch (IOException e2) {
                    e2.printStackTrace();
                    if (inputStream != null) {
                        inputStream.close();
                    }
                }
            } catch (Throwable th) {
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    } catch (IOException e3) {
                        e3.printStackTrace();
                    }
                }
                throw th;
            }
        } catch (IOException e4) {
            e4.printStackTrace();
        }
        return byteArrayOutputStream.toByteArray();
    }

    @MainThread
    private static void B(WebView webView, String str, Map<String, String> map) {
        if (webView == null || !x(str)) {
            return;
        }
        StringBuilder sb = new StringBuilder();
        sb.append("window.OVERSEA_ENV = window.OVERSEA_ENV||{};");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            sb.append(MessageFormat.format("window.OVERSEA_ENV.{0}=''{1}'';", entry.getKey(), entry.getValue() + ""));
        }
        webView.evaluateJavascript(sb.toString(), null);
    }

    public static String C(Context context) {
        if (context == null) {
            return null;
        }
        ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService("clipboard");
        if (clipboardManager.hasPrimaryClip() && clipboardManager.getPrimaryClipDescription().hasMimeType(HTTP.PLAIN_TEXT_TYPE)) {
            return String.valueOf(clipboardManager.getPrimaryClip().getItemAt(0).getText());
        }
        return null;
    }

    public static boolean D(float f2) {
        if (f2 == 0.0f) {
            return false;
        }
        return f2 == 1.0f || Math.random() <= ((double) f2);
    }

    static int b() {
        int i = h;
        h = i + 1;
        return i;
    }

    public static String f(String str) {
        return !x(str) ? str : g(str, System.currentTimeMillis());
    }

    public static String g(String str, long j) {
        if (!x(str)) {
            return str;
        }
        try {
            Uri parse = Uri.parse(str);
            Uri.Builder buildUpon = parse.buildUpon();
            if (!parse.isOpaque()) {
                buildUpon.clearQuery();
                for (String str2 : parse.getQueryParameterNames()) {
                    if (!str2.equals("easycash_csr_iwt")) {
                        Iterator<String> it = parse.getQueryParameters(str2).iterator();
                        while (it.hasNext()) {
                            buildUpon.appendQueryParameter(str2, it.next());
                        }
                    }
                }
            }
            return buildUpon.appendQueryParameter("easycash_csr_iwt", j + "").build().toString();
        } catch (Exception e2) {
            CrashReporter.a(e2);
            return str;
        }
    }

    public static boolean h(String str, SslCertificate sslCertificate) {
        return w(ECServerApiConfig.e().h(), str) && HttpsUtils.f(ContextProvider.c(), Configuration.a(), sslCertificate);
    }

    public static void i(Context context, String str) {
        try {
            ((ClipboardManager) context.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText(null, str.trim()));
        } catch (Exception e2) {
            CrashReporter.a(e2);
        }
        BaseUtils.p(context, context.getResources().getString(R.string.easycash_copy_success));
    }

    public static void j(Context context, String str) {
        if (context == null || TextUtils.isEmpty(str)) {
            return;
        }
        try {
            ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService("clipboard");
            ClipData newPlainText = ClipData.newPlainText("text", str);
            if (clipboardManager != null) {
                clipboardManager.setPrimaryClip(newPlainText);
            }
        } catch (Exception e2) {
            CrashReporter.a(e2);
        }
    }

    @Nullable
    public static Pair<String, String> k(String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        Uri parse = Uri.parse(str);
        return new Pair<>(parse.getQueryParameter("messageSourceId"), parse.getQueryParameter("messageSourceType"));
    }

    public static ClickableSpan l(@NonNull final Runnable runnable) {
        return new ClickableSpan() {
            @Override
            @DataTrackViewOnClick
            @SensorsDataInstrumented
            public void onClick(@NonNull View view) {
                if (BaseUtils.l()) {
                    SensorsDataAutoTrackHelper.trackViewOnClick(view);
                    AutoTrackHelper.trackViewOnClick(view);
                } else {
                    runnable.run();
                    SensorsDataAutoTrackHelper.trackViewOnClick(view);
                    AutoTrackHelper.trackViewOnClick(view);
                }
            }

            @Override
            public void updateDrawState(@NonNull TextPaint textPaint) {
                textPaint.setColor(ContextCompat.getColor(BananaBaseApplication.getContext(), 2131099780));
                textPaint.setUnderlineText(false);
                textPaint.clearShadowLayer();
            }
        };
    }

    public static ClickableSpan m(@NonNull final Runnable runnable) {
        return new ClickableSpan() {
            @Override
            @DataTrackViewOnClick
            @SensorsDataInstrumented
            public void onClick(@NonNull View view) {
                if (BaseUtils.l()) {
                    SensorsDataAutoTrackHelper.trackViewOnClick(view);
                    AutoTrackHelper.trackViewOnClick(view);
                } else {
                    runnable.run();
                    SensorsDataAutoTrackHelper.trackViewOnClick(view);
                    AutoTrackHelper.trackViewOnClick(view);
                }
            }

            @Override
            public void updateDrawState(@NonNull TextPaint textPaint) {
                textPaint.setColor(ContextCompat.getColor(BananaBaseApplication.getContext(), 2131099728));
                textPaint.setUnderlineText(true);
                textPaint.clearShadowLayer();
            }
        };
    }

    private static Map<String, String> n(String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        return CustomJSEnvUtils.b().a(str);
    }

    public static EnvironmentInfo o(Context context) {
        EnvironmentInfo environmentInfo = c;
        environmentInfo.userAgentCust = "";
        environmentInfo.referCust = "";
        environmentInfo.ip = NetworkUtils.a(context);
        c.deviceUniqueId = DeviceUtils.f(context);
        EnvironmentInfo environmentInfo2 = c;
        environmentInfo2.smartId = "";
        environmentInfo2.networkType = NetworkUtils.f(context);
        EnvironmentInfo environmentInfo3 = c;
        environmentInfo3.intranelIP = "";
        environmentInfo3.mac = NetworkUtils.b(context);
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
        try {
            c.phoneOperator = URLEncoder.encode(telephonyManager.getNetworkOperatorName().replaceAll("\"", ""), Constants.UTF_8);
        } catch (UnsupportedEncodingException unused) {
            c.phoneOperator = telephonyManager.getNetworkOperatorName().replaceAll("\"", "");
        }
        c.phoneMarker = Build.MANUFACTURER;
        c.phoneModel = Build.MODEL;
        EnvironmentInfo environmentInfo4 = c;
        environmentInfo4.computerHost = "";
        environmentInfo4.operationSys = "Android";
        environmentInfo4.operationSysVersion = Build.VERSION.RELEASE;
        if (context instanceof Activity) {
            Activity activity = (Activity) context;
            c.resolution = String.format(Locale.CHINA, "%d x %d", Integer.valueOf(ScreenUtils.f(activity)), Integer.valueOf(ScreenUtils.d(activity)));
        }
        c.font = String.valueOf(Typeface.DEFAULT.getStyle());
        c.fontSize = String.valueOf(context.getResources().getConfiguration().fontScale);
        ResolveInfo resolveActivity = context.getPackageManager().resolveActivity(new Intent("android.intent.action.VIEW", Uri.parse("http://")), 65536);
        if (resolveActivity != null) {
            c.browserType = resolveActivity.activityInfo.packageName;
        } else {
            c.browserType = "NONE";
        }
        if (Looper.getMainLooper().equals(Looper.myLooper())) {
            try {
                c.browserVersion = new WebView(context).getSettings().getUserAgentString();
            } catch (Exception unused2) {
            }
        }
        c.isEmulator = DeviceUtils.m() ? "Y" : "N";
        c.root = DeviceUtils.l();
        d.readLock().lock();
        LocationHelper.LocationInfo g2 = LocationHelper.d().g();
        if (g2 != null) {
            EnvironmentInfo environmentInfo5 = c;
            environmentInfo5.latiTude = g2.a;
            environmentInfo5.longiTude = g2.b;
        }
        d.readLock().unlock();
        if (TextUtils.isEmpty(f)) {
            String s = SharedPreferenceUtils.s(context, "gaid", "");
            if (!TextUtils.isEmpty(s)) {
                f = s;
                c.gaid = s;
            } else if (!g) {
                p(context);
            }
        } else {
            c.gaid = f;
        }
        return c;
    }

    public static void p(final Context context) {
        g = true;
        final ITransaction C = Sentry.C("GaidInit", "monitor");
        new AsyncTask<Void, Void, String>() {
            @Override
            public String doInBackground(Void... voidArr) {
                AdvertisingIdClient.Info info;
                try {
                    info = AdvertisingIdClient.getAdvertisingIdInfo(context);
                } catch (Exception e2) {
                    if (YqdUtils.h < 2) {
                        CrashReporter.a(e2);
                    }
                    YqdUtils.b();
                    info = null;
                }
                if (info == null) {
                    return null;
                }
                try {
                    return info.getId();
                } catch (Exception e3) {
                    if (YqdUtils.h < 2) {
                        DevUtil.a(e3);
                    }
                    YqdUtils.b();
                    return null;
                }
            }

            @Override
            public void onPostExecute(String str) {
                String unused = YqdUtils.f = str;
                SharedPreferenceUtils.J(context, "gaid", YqdUtils.f);
                if (TextUtils.isEmpty(str)) {
                    C.o(SpanStatus.INTERNAL_ERROR);
                } else {
                    HeaderCacheHelper.x().v();
                    C.o(SpanStatus.OK);
                }
                CommonCore.t().G(YqdUtils.f + "");
                boolean unused2 = YqdUtils.g = false;
            }
        }.execute(new Void[0]);
    }

    @NonNull
    public static Map<String, String> q(Context context) {
        int i = com.lingyue.supertoolkit.phonetools.ScreenUtils.i(BaseUtils.e(context));
        HashMap hashMap = new HashMap();
        hashMap.put("statusBarHeight", "" + com.lingyue.supertoolkit.phonetools.ScreenUtils.h(context));
        hashMap.put("deviceToken", DeviceUtils.h(context));
        hashMap.put("toolbarHeight", "" + i);
        hashMap.put("fontSize", "" + AdaptScreenUtil.h());
        hashMap.put("mobileNumber", EasyCashApplication.getInstance().getUserSession().b().mobileNumber);
        hashMap.put("nsrABType", "B");
        hashMap.put("appCurrentOpenTime", ContextProvider.b() + "");
        String str = EasyCashApplication.getInstance().appGlobal.g;
        if (TextUtils.isEmpty(str)) {
            str = "";
        }
        hashMap.put("exactStatus", EasyCashApplication.getInstance().getUserSession().b().exactStatus + "");
        hashMap.put("blackbox", str);
        return hashMap;
    }

    private static String[] r() {
        return new String[]{ECServerApiConfig.e().h(), "https://easycash.id/", GeneralConstants.b};
    }

    public static TerminalInfo s(Context context) {
        TerminalInfo terminalInfo = b;
        terminalInfo.lang = "java";
        terminalInfo.deviceKey = DeviceUtils.h(context);
        TerminalInfo terminalInfo2 = b;
        terminalInfo2.terminalType = "app";
        terminalInfo2.appVersion = String.valueOf(37513);
        TerminalInfo terminalInfo3 = b;
        terminalInfo3.productType = "easycash";
        terminalInfo3.appType = "android";
        terminalInfo3.appName = "easycash";
        terminalInfo3.systemVersion = Build.VERSION.RELEASE;
        TerminalInfo terminalInfo4 = b;
        terminalInfo4.idfa = "";
        terminalInfo4.appChannel = "fintopia";
        terminalInfo4.productName = "easycash_android";
        terminalInfo4.subAppChannel = CookieSpecs.DEFAULT;
        terminalInfo4.activity = CookieSpecs.DEFAULT;
        return terminalInfo4;
    }

    @MainThread
    public static void u(WebView webView) {
        v(webView, webView.getUrl());
    }

    @MainThread
    public static void v(WebView webView, String str) {
        if (webView == null || !x(str)) {
            return;
        }
        Map<String, String> q = q(webView.getContext());
        Map<String, String> n = n(str);
        if (n != null) {
            q.putAll(n);
        }
        B(webView, str, q);
    }

    public static boolean w(String str, String str2) {
        if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
            try {
                PublicSuffixDatabase.Companion companion = PublicSuffixDatabase.h;
                String d2 = companion.c().d(new URL(str).getHost());
                String d3 = companion.c().d(new URL(str2).getHost());
                if (d2 != null) {
                    return d2.equals(d3);
                }
                return false;
            } catch (Exception e2) {
                ErrorHolder.a(e2);
            }
        }
        return false;
    }

    public static boolean x(String str) {
        for (String str2 : r()) {
            if (w(str2, str)) {
                return true;
            }
        }
        return !TextUtils.isEmpty(str) && DomainCheckWrapper.a(HttpUrl.i(str));
    }

    public static void y(EditText editText) {
        if (editText == null) {
            return;
        }
        editText.setFilters(new InputFilter[]{new InputFilter() {
            @Override
            public CharSequence filter(CharSequence charSequence, int i, int i2, Spanned spanned, int i3, int i4) {
                String str = "";
                while (i < i2) {
                    char charAt = charSequence.charAt(i);
                    if (!Character.isWhitespace(charAt)) {
                        str = str + charAt;
                    }
                    i++;
                }
                return str;
            }
        }});
    }

    public static void z(WebView webView, String str) {
        JSHookAop.loadUrl(webView, str);
        webView.loadUrl(str);
    }

    public static String t(String str) {
        return str;
    }
}