QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

以下内容为反编译后的 NovelUrlUtils.java 源代码,内容仅作参考


package com.tencent.mtt.external.novel.base.engine;

import MTT.CommContentPV;
import android.os.Bundle;
import android.text.TextUtils;
import com.huawei.hms.framework.common.ContainerUtils;
import com.tencent.common.featuretoggle.FeatureToggle;
import com.tencent.common.task.QBTask;
import com.tencent.common.utils.StringUtils;
import com.tencent.common.utils.UrlUtils;
import com.tencent.matrix.trace.config.SharePluginInfo;
import com.tencent.mtt.base.nativeframework.NativePage;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.base.stat.utils.PlatformStatUtils;
import com.tencent.mtt.browser.window.templayer.BaseNativeGroup;
import com.tencent.mtt.external.novel.base.MTT.NovelSysConfig;
import com.tencent.mtt.external.novel.base.model.NovelInfo;
import com.tencent.mtt.external.novel.base.tools.NovelContext;
import com.tencent.mtt.external.novel.base.ui.NovelBaseContainer;
import com.tencent.mtt.external.novel.inhost.base.NovelUrlUtilsInhost;
import com.tencent.mtt.history.base.IHistory;
import com.tencent.mtt.sdkcontext.SDKContext;
import com.tencent.mtt.setting.PublicSettingManager;
import com.tencent.mtt.video.browser.export.wc.m3u8.M3U8Constants;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import qb.novel.BuildConfig;

public class NovelUrlUtils extends NovelUrlUtilsInhost {

    protected static final NovelUrlUtils[] f54441a = {null, null};

    public NovelUrlUtils(int i) {
        super(i);
        f54441a[i] = this;
    }

    public static Bundle a(Bundle bundle, String str) {
        HashMap<String, String> urlParam;
        if (TextUtils.isEmpty(str) || (urlParam = UrlUtils.getUrlParam(str)) == null) {
            return bundle;
        }
        for (Map.Entry<String, String> entry : urlParam.entrySet()) {
            byte j = j(entry.getKey());
            if (j == 0) {
                bundle.putString(entry.getKey(), entry.getValue());
            } else if (j == 1) {
                try {
                    bundle.putInt(entry.getKey(), Integer.parseInt(entry.getValue()));
                } catch (Exception unused) {
                }
            }
        }
        return bundle;
    }

    public static String a(Bundle bundle) {
        StringBuilder sb;
        String sb2;
        if (bundle == null) {
            return "";
        }
        String str = "";
        for (String str2 : bundle.keySet()) {
            byte j = j(str2);
            if (j == 0) {
                sb = new StringBuilder();
                sb.append(str2);
                sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
                sb.append(bundle.getString(str2));
            } else if (j != 1) {
                sb2 = "";
                str = str + sb2 + ContainerUtils.FIELD_DELIMITER;
            } else {
                sb = new StringBuilder();
                sb.append(str2);
                sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
                sb.append(bundle.getInt(str2));
            }
            sb2 = sb.toString();
            str = str + sb2 + ContainerUtils.FIELD_DELIMITER;
        }
        return str;
    }

    public static String a(NativePage nativePage) {
        if (nativePage == null) {
            return null;
        }
        return a(nativePage.getNativeGroup());
    }

    public static String a(BaseNativeGroup baseNativeGroup) {
        if (baseNativeGroup != null && (baseNativeGroup instanceof NovelBaseContainer)) {
            return f(((NovelBaseContainer) baseNativeGroup).f());
        }
        return null;
    }

    public static String a(String str) {
        try {
            return UrlUtils.stripQuery(new URL(str)).toString();
        } catch (MalformedURLException unused) {
            int indexOf = str.indexOf("?");
            return indexOf != -1 ? str.substring(0, indexOf) : str;
        }
    }

    public static String a(String str, NovelContext novelContext) {
        String string = PublicSettingManager.a().getString("ANDROID_PUBLIC_PREFS_NOVEL_SUMMARY_URL", "");
        if (TextUtils.isEmpty(string)) {
            return b(str, novelContext);
        }
        return UrlUtils.addParamsToUrl(UrlUtils.removeArg(string, "bookid"), "bookid=" + str);
    }

    public static void a() {
        PlatformStatUtils.a("NOVEL_READER_SET_PAGE_TITLE");
    }

    public static void a(final NovelContext novelContext, final Bundle bundle) {
        QBTask.a((Callable) new Callable<Object>() {
            @Override
            public Object call() throws Exception {
                String string;
                String string2;
                if (!PublicSettingManager.a().e() && !bundle.getBoolean("key_stealth", false)) {
                    NovelInfo a2 = novelContext.j().f54398c.a(bundle.getString("book_id"), 2);
                    if (a2 != null) {
                        string = a2.f36399b;
                        string2 = a2.f36400c;
                    } else {
                        string = bundle.getString("book_id");
                        string2 = bundle.getString("book_title");
                    }
                    if (!TextUtils.isEmpty(string) && !TextUtils.isEmpty(string2)) {
                        String str = "qb://ext/novel/content?book_id=" + string + ContainerUtils.FIELD_DELIMITER + "book_use_words" + ContainerUtils.KEY_VALUE_DELIMITER + "1&fromMain=tab_read&ch=004548";
                        String str2 = "《" + string2 + "》";
                        if (a2 == null) {
                            PlatformStatUtils.a("NOVEL_READER_HISTORY_INTERFACE_OLD");
                            ((IHistory) SDKContext.getInstance().getService(IHistory.class)).addHistory(str2, str);
                        } else {
                            PlatformStatUtils.a("NOVEL_READER_HISTORY_INTERFACE_NEW");
                            ((IHistory) SDKContext.getInstance().getService(IHistory.class)).addHistory(str2, str, a2.s, 0L, 1004, a2.f, a2.x);
                        }
                    }
                }
                return null;
            }
        });
    }

    public static String b() {
        return PublicSettingManager.a().getString("ANDROID_PUBLIC_PREFS_BOTTOM_TAB_NOVEL_URL", "qb://tab/feedschannel?component=FeedsNovelPage&module=novelsingletab&title=小说&backupUrl=qb%3a%2f%2fhome%2ffeeds%3ftabId%3d22%26ch%3d004530%26refresh%3d1");
    }

    public static String b(String str) {
        try {
            return UrlUtils.stripAnhcor(str);
        } catch (MalformedURLException unused) {
            int indexOf = str.indexOf(35);
            return indexOf != -1 ? str.substring(0, indexOf) : str;
        }
    }

    private static String b(String str, NovelContext novelContext) {
        if (novelContext == null || novelContext.f == null) {
            return "";
        }
        return novelContext.f.a(6) + str;
    }

    public static Bundle c(String str) {
        return a(new Bundle(), str);
    }

    public static String f(String str) {
        String str2;
        StackTraceElement[] stackTrace;
        String[] strArr;
        int i;
        int i2;
        HashMap<String, String> urlParam;
        Matcher matcher;
        if (!TextUtils.isEmpty(str) && (urlParam = UrlUtils.getUrlParam(str)) != null && urlParam.containsKey("ch")) {
            String str3 = urlParam.get("ch");
            if (!TextUtils.isEmpty(str3) && (matcher = Pattern.compile("\\d+").matcher(str3)) != null && matcher.find()) {
                str2 = matcher.group();
                if (!TextUtils.isEmpty(str2) || !str2.matches("\\d{6}")) {
                    str = URLEncoder.encode(str, "UTF-8");
                    String str4 = "";
                    stackTrace = Thread.currentThread().getStackTrace();
                    strArr = new String[4];
                    i = 0;
                    for (i2 = 2; i < 4 && i2 < stackTrace.length; i2++) {
                        strArr[i] = stackTrace[i2].toString();
                        i++;
                    }
                    str4 = Arrays.deepToString(strArr).replaceAll("com\\.tencent\\.mtt\\.external\\.novel", "_novel").replaceAll("com\\.tencent\\.mtt", "_mtt");
                    String str5 = URLEncoder.encode(str4, "UTF-8");
                    HashMap hashMap = new HashMap();
                    hashMap.put("ch", !TextUtils.isEmpty(str2) ? "_null" : str2);
                    hashMap.put("url", str);
                    hashMap.put(SharePluginInfo.ISSUE_TRACE_STACK, str5);
                    StatManager.b().b("get_novel_channel", hashMap);
                }
                return str2;
            }
        }
        str2 = null;
        if (!TextUtils.isEmpty(str2)) {
        }
        str = URLEncoder.encode(str, "UTF-8");
        String str42 = "";
        stackTrace = Thread.currentThread().getStackTrace();
        strArr = new String[4];
        i = 0;
        while (i < 4) {
            strArr[i] = stackTrace[i2].toString();
            i++;
        }
        str42 = Arrays.deepToString(strArr).replaceAll("com\\.tencent\\.mtt\\.external\\.novel", "_novel").replaceAll("com\\.tencent\\.mtt", "_mtt");
        String str52 = URLEncoder.encode(str42, "UTF-8");
        HashMap hashMap2 = new HashMap();
        hashMap2.put("ch", !TextUtils.isEmpty(str2) ? "_null" : str2);
        hashMap2.put("url", str);
        hashMap2.put(SharePluginInfo.ISSUE_TRACE_STACK, str52);
        StatManager.b().b("get_novel_channel", hashMap2);
        return str2;
    }

    private static byte j(String str) {
        return k(str) ? (byte) 1 : (byte) 0;
    }

    private static boolean k(String str) {
        return str.endsWith("book_serial_num") || str.endsWith("book_pay_type") || str.endsWith("book_serial_id") || str.endsWith("book_is_finish") || str.endsWith("book_chapter_id") || str.endsWith("book_serial_num") || str.endsWith("book_serial_words_num") || str.endsWith("book_bg_color") || str.endsWith("book_cur_skin") || str.endsWith("book_import_src_cp_id") || str.endsWith("book_copyright_cp_id") || str.endsWith("book_use_words") || str.endsWith("page_from_key") || str.endsWith("book_file_type");
    }

    public String a(int i) {
        NovelContext a2 = NovelContext.a(this.e);
        NovelSysConfig l = a2 != null ? a2.l() : null;
        switch (i) {
            case 0:
                return a(l);
            case 1:
                if (l != null && !TextUtils.isEmpty(l.strBookStoreUrl)) {
                    return l.strBookStoreUrl;
                }
                return a(l) + "#!/bookstore/tuijian/";
            case 2:
                return a(l) + "#!/search/";
            case 3:
                if (l != null && !TextUtils.isEmpty(l.strAfterReadingUrl)) {
                    return a(l.strAfterReadingUrl);
                }
                return "";
            case 4:
            case 7:
            default:
                return "";
            case 5:
                if (l != null && !TextUtils.isEmpty(l.strMyCirclesUrl)) {
                    return l.strMyCirclesUrl;
                }
                return "";
            case 6:
                return a(l) + "#!/catalog/";
            case 8:
                if (l != null && !TextUtils.isEmpty(l.strUserCenterUrl)) {
                    return l.strUserCenterUrl;
                }
                return "";
            case 9:
                if (l != null && !TextUtils.isEmpty(l.strUpgradeAccountWenxue2QmUrl)) {
                    return l.strUpgradeAccountWenxue2QmUrl;
                }
                return "";
            case 10:
                if (l != null && !TextUtils.isEmpty(l.strDiscoverySignUrl)) {
                    return l.strDiscoverySignUrl;
                }
                return "";
            case 11:
                if (l != null && !TextUtils.isEmpty(l.strRecommendTicketInteractiveUrl)) {
                    return l.strRecommendTicketInteractiveUrl;
                }
                return "";
            case 12:
                if (l != null && !TextUtils.isEmpty(l.strUgcCommunityUrl)) {
                    return l.strUgcCommunityUrl;
                }
                if (a2 != null) {
                    String c2 = a2.f54694c.c("key_novel_sysconfig_at_strUgcCommunityUrl", "");
                    if (!TextUtils.isEmpty(c2)) {
                        return c2;
                    }
                }
                return "";
            case 13:
                if (l != null && !TextUtils.isEmpty(l.strRecommendTicketQaUrl)) {
                    return l.strRecommendTicketQaUrl;
                }
                return "";
            case 14:
                if (FeatureToggle.a(BuildConfig.FEATURE_TOGGLE_869435151)) {
                    return "https://so.html5.qq.com/landingpage/page/novel-end-page?middleTitleShow=false";
                }
                if (l != null && !TextUtils.isEmpty(l.strAfterReadingUrlLocal)) {
                    return l.strAfterReadingUrlLocal;
                }
                return "";
            case 15:
                if (l != null && !TextUtils.isEmpty(l.sSearchUrl)) {
                    return l.sSearchUrl;
                }
                return "";
        }
    }

    protected String a(Object obj) {
        if (obj != null && (obj instanceof NovelSysConfig)) {
            String str = ((NovelSysConfig) obj).strBookStoreUrl;
            if (!TextUtils.isEmpty(str)) {
                return b(a(str)) + "?t=native";
            }
        }
        return this.e == 1 ? "https://bookshelf.html5.qq.com/epub.html?t=native" : "https://bookshelf.html5.qq.com/?t=native";
    }

    public String a(String str, Object[] objArr) {
        if (TextUtils.isEmpty(str) || NovelUrlUtilsInhost.g(str) != this.e) {
            return str;
        }
        if (!str.startsWith("qb://ext/novel/store") && !str.startsWith("qb://ext/cbnovel/store")) {
            return str;
        }
        String decode = UrlUtils.decode(str);
        int indexOf = decode.indexOf("#!");
        int indexOf2 = decode.indexOf(ContainerUtils.FIELD_DELIMITER, indexOf);
        if (indexOf <= -1) {
            return str;
        }
        String substring = (indexOf2 <= -1 || indexOf2 <= indexOf) ? decode.substring(indexOf + 2) : decode.substring(indexOf + 2, indexOf2);
        if (!substring.startsWith("/catalog")) {
            return str;
        }
        String substring2 = substring.substring(9);
        int indexOf3 = substring2.indexOf("/");
        boolean z = false;
        if (indexOf3 > -1) {
            substring2 = substring2.substring(0, indexOf3);
        }
        int b2 = StringUtils.b(UrlUtils.getUrlParamValue(decode, "book_import_src_cp_id"), 0);
        int b3 = StringUtils.b(UrlUtils.getUrlParamValue(decode, "book_use_words"), 0);
        String urlParamValue = UrlUtils.getUrlParamValue(decode, "ch");
        if (urlParamValue != null && urlParamValue.indexOf("#!") > -1) {
            urlParamValue = urlParamValue.substring(0, urlParamValue.indexOf("#!"));
        }
        if (objArr != null && objArr.length >= 1) {
            objArr[0] = substring2;
        }
        NovelContext a2 = NovelContext.a(this.e);
        if (a2 != null && a2.j() != null && a2.j().f != null) {
            z = a2.j().f.a(substring2, b2);
        }
        if (!z && !NovelInfo.a(substring2)) {
            return str;
        }
        return new String[]{"qb://ext/novel/content", "qb://ext/cbnovel/content"}[this.e] + "/?book_id" + ContainerUtils.KEY_VALUE_DELIMITER + substring2 + ContainerUtils.FIELD_DELIMITER + "book_import_src_cp_id" + ContainerUtils.KEY_VALUE_DELIMITER + b2 + ContainerUtils.FIELD_DELIMITER + "book_use_words" + ContainerUtils.KEY_VALUE_DELIMITER + b3 + "&ch=" + urlParamValue;
    }

    public void a(String str, String str2, String str3, String str4, String str5) {
        CommContentPV commContentPV = new CommContentPV();
        commContentPV.sAppKey = "novel";
        commContentPV.sOutChannel = this.f55233b;
        commContentPV.sInnerChannel = str;
        commContentPV.sContentType = str2;
        commContentPV.sActionType = str3;
        commContentPV.sContentId = str4;
        commContentPV.sHostName = str5;
        StatManager.b().a(commContentPV);
    }

    public boolean a(String str, int i) {
        return a(str, i, (byte) 3);
    }

    public boolean a(String str, int i, byte b2) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        String host = UrlUtils.getHost(str);
        String a2 = a(i);
        String host2 = UrlUtils.getHost(a2);
        if (TextUtils.isEmpty(host) || TextUtils.isEmpty(host2) || !host.equalsIgnoreCase(host2)) {
            return false;
        }
        if (b2 >= 1) {
            String[] split = str.split(M3U8Constants.COMMENT_PREFIX);
            String[] split2 = a2.split(M3U8Constants.COMMENT_PREFIX);
            if (split == null || split.length == 0 || split2 == null || split2.length == 0 || !StringUtils.b(UrlUtils.getPath(split[0]), UrlUtils.getPath(split2[0]))) {
                return false;
            }
            if (b2 >= 2) {
                HashMap<String, String> urlParam = UrlUtils.getUrlParam(split[0]);
                for (Map.Entry<String, String> entry : UrlUtils.getUrlParam(split2[0]).entrySet()) {
                    if (!"ch".equalsIgnoreCase(entry.getKey()) && !"t".equalsIgnoreCase(entry.getKey()) && !StringUtils.b(urlParam.get(entry.getKey()), entry.getValue())) {
                        return false;
                    }
                }
                if (b2 >= 3) {
                    if (split.length == 1) {
                        return split2.length == 1;
                    }
                    if (split2.length == 1) {
                        return false;
                    }
                    return StringUtils.b(split[1], split2[1]);
                }
            }
        }
        return true;
    }

    public boolean d(String str) {
        String f = f(str);
        if (TextUtils.isEmpty(f)) {
            return false;
        }
        this.f55233b = f;
        f55232c = f;
        this.f55234d = "";
        return true;
    }

    public boolean e(String str) {
        String f = f(str);
        if (TextUtils.isEmpty(f)) {
            return false;
        }
        this.f55234d = f;
        return true;
    }
}