CamScanner.apk(点击下载) / WebUrlUtils.java


package com.intsig.utils;

import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import android.util.ArrayMap;
import com.applovin.impl.sdk.utils.Utils;
import com.facebook.appevents.AppEventsConstants;
import com.facebook.appevents.codeless.internal.Constants;
import com.facebook.share.internal.MessengerShareContentUtility;
import com.intsig.busniess.DateTool;
import com.intsig.camscanner.attention.PurhcaseUsingCoupon;
import com.intsig.comm.R;
import com.intsig.comm.account_data.AccountHelper;
import com.intsig.comm.account_data.AccountPreference;
import com.intsig.log.LogUtils;
import com.intsig.logagent.LogAgent;
import com.intsig.tianshu.TianShuAPI;
import com.intsig.vendor.VendorHelper;
import com.microsoft.services.msa.OAuth;
import com.umeng.analytics.pro.ak;
import com.umeng.analytics.pro.d;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Map;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt__StringsJVMKt;

/* compiled from: WebUrlUtils.kt */
public final class WebUrlUtils {

    /* renamed from: a  reason: collision with root package name */
    public static final WebUrlUtils f40148a = new WebUrlUtils();

    private WebUrlUtils() {
    }

    public static final String A() {
        String E = E();
        String d10 = d(ApplicationHelper.f39907a.e(), E);
        return E + "android/service?" + d10;
    }

    private final String C(Context context) {
        String str = "light";
        if (context != null) {
            if (f40148a.F(context)) {
                str = "dark";
            }
        }
        return str;
    }

    public static final String D() {
        return ApplicationHelper.p() ? "https://mo-translate-sandbox.camscanner.com/" : "https://mo-translate.camscanner.com/";
    }

    public static final String E() {
        boolean p10 = ApplicationHelper.p();
        if (p10) {
            return "https://v3-sandbox.camscanner.com/";
        }
        if (!p10) {
            return "https://v3.camscanner.com/";
        }
        throw new NoWhenBranchMatchedException();
    }

    private final boolean F(Context context) {
        boolean z10 = (context.getResources().getConfiguration().uiMode & 48) == 32;
        LogUtils.a("UrlUtil", "isDark = " + z10);
        return z10;
    }

    public static final String a(Context context) {
        String x10 = x();
        String d10 = d(context, x10);
        return x10 + "app/syncPage?type=account&" + d10;
    }

    public static final String c() {
        String E = E();
        String d10 = d(ApplicationHelper.f39907a.e(), E);
        return E + "android/appPermission?" + d10;
    }

    /* JADX WARNING: Removed duplicated region for block: B:15:0x0082  */
    /* JADX WARNING: Removed duplicated region for block: B:16:0x0085  */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x00ca  */
    /* JADX WARNING: Removed duplicated region for block: B:20:0x00cf  */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x0133  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0138  */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x0144  */
    /* JADX WARNING: Removed duplicated region for block: B:28:0x0146  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x01ce A[Catch:{ UnsupportedEncodingException -> 0x0226 }] */
    /* JADX WARNING: Removed duplicated region for block: B:51:0x023f  */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x022b A[EDGE_INSN: B:54:0x022b->B:49:0x022b ?: BREAK  , SYNTHETIC] */
    public static final String d(Context context, String str) {
        String sb2;
        Iterator it;
        ArrayMap arrayMap = new ArrayMap();
        String str2 = "";
        if (str == null || !WhiteHostListManager.g(str)) {
            LogUtils.a("UrlUtil", "getArgsWhenSkipToWebN not in white host url:" + str);
        } else {
            arrayMap.put("intsig_key", AccountPreference.L(context) ? AESNopadding.b(TianShuAPI.G0()) : str2);
            if (!AccountHelper.i()) {
                arrayMap.put("encrypt_uid", AESNopadding.b(ApplicationHelper.i()));
                arrayMap.put(ak.N, LanguageUtil.i());
                arrayMap.put("country", LanguageUtil.d());
                String str3 = null;
                arrayMap.put("client_version", context != null ? null : context.getString(R.string.app_version));
                WebUrlUtils webUrlUtils = f40148a;
                arrayMap.put("client_type", h());
                arrayMap.put("platform", u());
                arrayMap.put("client_app", AccountPreference.d());
                arrayMap.put("account_type", webUrlUtils.b());
                arrayMap.put(Utils.PLAY_STORE_SCHEME, !VendorHelper.g() ? "gp" : VendorHelper.f40227c);
                arrayMap.put("phone_model", Build.MANUFACTURER + "_" + Build.MODEL);
                arrayMap.put(ak.f45419y, Build.VERSION.RELEASE);
                arrayMap.put("app_type", VendorHelper.f40227c);
                int h10 = CommonUtil.h();
                StringBuilder sb3 = new StringBuilder();
                sb3.append(h10);
                arrayMap.put("time_zone", sb3.toString());
                VendorHelper vendorHelper = VendorHelper.f40225a;
                arrayMap.put("pay_type", !vendorHelper.e(context) ? "1" : AppEventsConstants.EVENT_PARAM_VALUE_NO);
                if (context == null) {
                    str3 = context.getPackageName();
                }
                arrayMap.put("app_package", str3);
                arrayMap.put("vendor", VendorHelper.f40227c);
                LogUtils.a("UrlUtil", " register_days " + DateTool.a());
                int a10 = DateTool.a();
                StringBuilder sb4 = new StringBuilder();
                sb4.append(a10);
                arrayMap.put("register_days", sb4.toString());
                arrayMap.put("payway", vendorHelper.b(context));
                arrayMap.put("cs_ept_d", ApplicationHelper.g());
                arrayMap.put(OAuth.THEME, webUrlUtils.C(context));
                StringBuilder sb5 = new StringBuilder();
                it = arrayMap.entrySet().iterator();
                loop0:
                while (true) {
                    while (true) {
                        if (it.hasNext()) {
                            break loop0;
                        }
                        Map.Entry entry = (Map.Entry) it.next();
                        String str4 = (String) entry.getKey();
                        String str5 = (String) entry.getValue();
                        if (!TextUtils.isEmpty(str4)) {
                            if (!TextUtils.isEmpty(str5)) {
                                if (sb5.length() > 0) {
                                    sb5.append("&");
                                }
                                sb5.append(str4);
                                sb5.append("=");
                                sb5.append(URLEncoder.encode(str5, "utf-8"));
                            }
                        }
                    }
                }
                sb2 = sb5.toString();
                Intrinsics.e(sb2, "sb.toString()");
                if (!TextUtils.isEmpty(sb2)) {
                    str2 = sb2;
                }
                return str2;
            }
        }
        arrayMap.put(ak.N, LanguageUtil.i());
        arrayMap.put("country", LanguageUtil.d());
        String str32 = null;
        arrayMap.put("client_version", context != null ? null : context.getString(R.string.app_version));
        WebUrlUtils webUrlUtils2 = f40148a;
        arrayMap.put("client_type", h());
        arrayMap.put("platform", u());
        arrayMap.put("client_app", AccountPreference.d());
        arrayMap.put("account_type", webUrlUtils2.b());
        arrayMap.put(Utils.PLAY_STORE_SCHEME, !VendorHelper.g() ? "gp" : VendorHelper.f40227c);
        arrayMap.put("phone_model", Build.MANUFACTURER + "_" + Build.MODEL);
        arrayMap.put(ak.f45419y, Build.VERSION.RELEASE);
        arrayMap.put("app_type", VendorHelper.f40227c);
        int h102 = CommonUtil.h();
        StringBuilder sb32 = new StringBuilder();
        sb32.append(h102);
        arrayMap.put("time_zone", sb32.toString());
        VendorHelper vendorHelper2 = VendorHelper.f40225a;
        arrayMap.put("pay_type", !vendorHelper2.e(context) ? "1" : AppEventsConstants.EVENT_PARAM_VALUE_NO);
        if (context == null) {
        }
        arrayMap.put("app_package", str32);
        arrayMap.put("vendor", VendorHelper.f40227c);
        LogUtils.a("UrlUtil", " register_days " + DateTool.a());
        int a102 = DateTool.a();
        StringBuilder sb42 = new StringBuilder();
        sb42.append(a102);
        arrayMap.put("register_days", sb42.toString());
        arrayMap.put("payway", vendorHelper2.b(context));
        arrayMap.put("cs_ept_d", ApplicationHelper.g());
        arrayMap.put(OAuth.THEME, webUrlUtils2.C(context));
        StringBuilder sb52 = new StringBuilder();
        try {
            it = arrayMap.entrySet().iterator();
            loop0:
            while (true) {
                while (true) {
                    if (it.hasNext()) {
                    }
                }
            }
        } catch (UnsupportedEncodingException e10) {
            LogUtils.e("UrlUtil", e10);
        }
        sb2 = sb52.toString();
        Intrinsics.e(sb2, "sb.toString()");
        if (!TextUtils.isEmpty(sb2)) {
        }
        return str2;
    }

    /* JADX WARNING: Removed duplicated region for block: B:10:0x0025  */
    /* JADX WARNING: Removed duplicated region for block: B:11:0x002a  */
    public static final String e(String str, String str2) {
        boolean z10;
        String str3;
        Intrinsics.f(str, "type");
        String x10 = x();
        if (str2 != null) {
            if (!(StringsKt__StringsJVMKt.s(str2))) {
                z10 = false;
                if (!z10) {
                    str3 = "";
                } else {
                    str3 = "from=" + str2 + "&";
                }
                return x10 + "app/dataPapers?type=" + str + "&" + str3 + d(ApplicationHelper.f39907a.e(), x10);
            }
        }
        z10 = true;
        if (!z10) {
        }
        return x10 + "app/dataPapers?type=" + str + "&" + str3 + d(ApplicationHelper.f39907a.e(), x10);
    }

    public static final String f() {
        String x10 = x();
        String d10 = d(ApplicationHelper.f39907a.e(), x10);
        return x10 + "user/changeAccount?" + d10;
    }

    public static final String g() {
        String E = E();
        String d10 = d(ApplicationHelper.f39907a.e(), E);
        return E + "android/childrenPrivacy?" + d10;
    }

    public static final String h() {
        return ApplicationHelper.n() ? MessengerShareContentUtility.WEBVIEW_RATIO_FULL : "lite";
    }

    public static final String i(Context context) {
        Intrinsics.f(context, d.R);
        String x10 = x();
        String d10 = d(context, x10);
        return x10 + "user/closeAccount?" + d10;
    }

    public static final String j(String str, int i10) {
        Intrinsics.f(str, "webFuncType");
        String x10 = x();
        String d10 = d(ApplicationHelper.f39907a.e(), x10);
        return x10 + "integral/funcIntro?" + d10 + "&targetpart=" + str + "&targetid=" + i10 + "&frompart=scan_first_doc_premium";
    }

    public static final String k() {
        return e("data", null);
    }

    public static final String l() {
        return ApplicationHelper.p() ? "https://mo-faq-sandbox.camscanner.com/" : "https://mo-faq.camscanner.com/";
    }

    public static final String m(Context context) {
        String x10 = x();
        String d10 = d(context, x10);
        return x10 + "integral/privilege?" + d10;
    }

    public static final String n() {
        String w10 = w();
        String d10 = d(ApplicationHelper.f39907a.e(), w10);
        return w10 + "informedConsent?" + d10;
    }

    public static final String o() {
        return ApplicationHelper.p() ? "https://mo-msdoc-sandbox.camscanner.com/" : "https://mo-msdoc.camscanner.com/";
    }

    public static final String p(Context context) {
        String x10 = x();
        String d10 = d(context, x10);
        return x10 + "app/syncPage?type=sync&" + d10;
    }

    public static final String q() {
        String o10 = o();
        String d10 = d(ApplicationHelper.f39907a.e(), o10);
        return o10 + "msdoc/index?" + d10;
    }

    public static final String r(String str) {
        Intrinsics.f(str, "type");
        return s(str, null);
    }

    /* JADX WARNING: Removed duplicated region for block: B:10:0x0025  */
    /* JADX WARNING: Removed duplicated region for block: B:11:0x002a  */
    public static final String s(String str, String str2) {
        boolean z10;
        String str3;
        Intrinsics.f(str, "type");
        String x10 = x();
        if (str2 != null) {
            if (!(StringsKt__StringsJVMKt.s(str2))) {
                z10 = false;
                if (!z10) {
                    str3 = "";
                } else {
                    str3 = "scheme=" + str2 + "&";
                }
                return x10 + "app/ocrPage?type=" + str + "&" + str3 + d(ApplicationHelper.f39907a.e(), x10);
            }
        }
        z10 = true;
        if (!z10) {
        }
        return x10 + "app/ocrPage?type=" + str + "&" + str3 + d(ApplicationHelper.f39907a.e(), x10);
    }

    public static final String t() {
        String E = E();
        String d10 = d(ApplicationHelper.f39907a.e(), E);
        return E + "android/personalInformation?" + d10;
    }

    public static final String u() {
        return Constants.PLATFORM;
    }

    public static final String v() {
        String E = E();
        String d10 = d(ApplicationHelper.f39907a.e(), E);
        return E + "android/privacy?" + d10;
    }

    public static final String w() {
        return ApplicationHelper.p() ? "https://www-sandbox.camscanner.com/" : "http://www.camscanner.com/";
    }

    public static final String x() {
        return ApplicationHelper.p() ? "https://mo-sandbox.camscanner.com/" : "https://mo.camscanner.com/";
    }

    public static final String y() {
        return ApplicationHelper.p() ? "https://mo-premium-sandbox.camscanner.com/" : "https://mo-premium.camscanner.com/";
    }

    public static final String z() {
        String E = E();
        String d10 = d(ApplicationHelper.f39907a.e(), E);
        return E + "android/privacySummary?" + d10;
    }

    public final String B(String str, int i10) {
        Intrinsics.f(str, "duuid");
        String x10 = x();
        String d10 = d(ApplicationHelper.f39907a.e(), x10);
        return x10 + "app/shareInfo?" + d10 + "&duuid=" + str + "&hide_share_dir=" + i10;
    }

    public final String b() {
        if (!AccountPreference.G()) {
            if (!AccountPreference.D()) {
                return AccountPreference.R() ? PurhcaseUsingCoupon.CTION_UPDATE_USER_INFO_TYPE_PREMIUM : AccountPreference.Q() ? "team" : AccountPreference.P() ? "prestige" : LogAgent.ERROR_NORMAL;
            }
        }
        return "edu";
    }
}