导航菜单

页面标题

页面副标题

零界绘 v1.0.2 - i.java 源代码

正在查看: 零界绘 v1.0.2 应用的 i.java JAVA 源代码文件

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


package com.ss.android.downloadlib.st;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.kuaishou.weapon.p0.t;
import com.kwad.sdk.liteapi.encrypt.LiteKsSig1Util;
import com.ss.android.downloadlib.activity.JumpKllkActivity;
import com.ss.android.downloadlib.activity.TTDelegateActivity;
import com.ss.android.y.y.cl.k;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class i {
    public static final String y = "i";

    public static void a(Context context, com.ss.android.downloadlib.addownload.cl.io ioVar, String str) {
        JSONObject jSONObject = new JSONObject();
        try {
            TTDelegateActivity.y(str, ioVar.y, "need_comment");
        } catch (Exception unused) {
            com.ss.android.downloadlib.cl.y.y(y(context, Uri.parse("market://details?id=" + str)), ioVar, true);
            cl(ioVar, jSONObject, 9, 8, "market://details?id=" + str);
        }
    }

    public static void h(final Context context, final com.ss.android.downloadlib.addownload.cl.io ioVar, final String str) {
        com.ss.android.downloadlib.io.y().y(new Runnable() {
            @Override
            public void run() {
                JSONObject a = com.ss.android.downloadlib.addownload.jv.a();
                final JSONObject jSONObject = new JSONObject();
                try {
                    String optString = a.optString(t.g);
                    String y2 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("bw"), optString);
                    String y3 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("bx"), optString);
                    String y4 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("by"), optString);
                    Uri.Builder builder = new Uri.Builder();
                    builder.scheme("https").authority(y2).appendPath(y3).appendQueryParameter(y4, str);
                    com.ss.android.downloadlib.addownload.jv.p().y("GET", builder.build().toString(), null, new k() {
                        @Override
                        public void y(java.lang.String r6) {
                            throw new UnsupportedOperationException("Method not decompiled: com.ss.android.downloadlib.st.i.AnonymousClass6.AnonymousClass1.y(java.lang.String):void");
                        }

                        @Override
                        public void y(Throwable th) {
                            com.ss.android.downloadlib.cl.y.y(i.y(context, Uri.parse("market://details?id=" + str)), ioVar, true);
                            da.y(jSONObject, "ttdownloader_message", th != null ? th.getMessage() : "null");
                            i.cl(ioVar, jSONObject, 11, 9, "market://details?id=" + str);
                        }
                    });
                } catch (Exception e) {
                    com.bytedance.sdk.component.utils.jv.y(e);
                    i.cl(ioVar, jSONObject, 4, 9, "market://details?id=" + str);
                }
            }
        });
    }

    public static void i(final Context context, final com.ss.android.downloadlib.addownload.cl.io ioVar, final String str) {
        com.ss.android.downloadlib.io.y().y(new Runnable() {
            @Override
            public void run() {
                JSONObject a = com.ss.android.downloadlib.addownload.jv.a();
                String optString = a.optString(t.g);
                final JSONObject jSONObject = new JSONObject();
                String y2 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("x"), optString);
                JSONObject jSONObject2 = new JSONObject();
                da.y(jSONObject2, "t", t.c);
                da.y(jSONObject2, "p", str);
                byte[] bytes = jSONObject2.toString().getBytes();
                com.ss.android.downloadlib.addownload.jv.p().y(y2, com.ss.android.downloadlib.addownload.jv.oe().y(bytes, bytes.length), "application/octet-stream;tt-data=a", 0, new k() {
                    @Override
                    public void y(String str2) {
                        AnonymousClass7 anonymousClass7 = AnonymousClass7.this;
                        i.cl(context, str, str2, ioVar, jSONObject);
                    }

                    @Override
                    public void y(Throwable th) {
                        com.ss.android.downloadlib.cl.y.y(i.y(context, Uri.parse("market://details?id=" + str)), ioVar, true);
                        da.y(jSONObject, "ttdownloader_message", th != null ? th.getMessage() : "null");
                        i.cl(ioVar, jSONObject, 7, 5, "market://details?id=" + str);
                    }
                });
            }
        });
    }

    public static void io(final Context context, final com.ss.android.downloadlib.addownload.cl.io ioVar, final String str) {
        com.ss.android.downloadlib.io.y().y(new Runnable() {
            @Override
            public void run() {
                com.ss.android.downloadlib.cl.y.y(i.y(context, Uri.parse("market://details?id=" + str)), ioVar, true);
                JSONObject jSONObject = new JSONObject();
                try {
                    JSONObject a = com.ss.android.downloadlib.addownload.jv.a();
                    Thread.sleep(a.optInt("m2_delay_millis", 1000));
                    com.ss.android.downloadlib.y.y.y.y().y(context, true);
                    com.ss.android.downloadlib.y.y.cl clVar = new com.ss.android.downloadlib.y.y.cl();
                    clVar.y = 1;
                    clVar.cl = 0;
                    String y2 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString(t.c), a.optString(t.g));
                    clVar.lu = String.format(y2, str);
                    com.ss.android.downloadlib.y.y.y.y().y(clVar, (com.ss.android.downloadlib.y.y.p) null);
                    com.ss.android.downloadlib.y.y.y.y().cl();
                    i.cl(ioVar, jSONObject, -1, 2, String.format(y2, str));
                } catch (Throwable th) {
                    com.bytedance.sdk.component.utils.jv.y(th);
                    i.cl(ioVar, jSONObject, 1, 2, "market://details?id=" + str);
                }
            }
        });
    }

    public static void lu(Context context, com.ss.android.downloadlib.addownload.cl.io ioVar, String str) {
        JSONObject jSONObject = new JSONObject();
        try {
            TTDelegateActivity.y(context, str, ioVar.y);
        } catch (Exception unused) {
            com.ss.android.downloadlib.cl.y.y(y(context, Uri.parse("market://details?id=" + str)), ioVar, true);
            cl(ioVar, jSONObject, 14, 11, "market://details?id=" + str);
        }
    }

    public static com.ss.android.downloadlib.addownload.cl.st p(@NonNull Context context, @NonNull String str) {
        try {
            Uri parse = Uri.parse("https://www.samsungapps.com/appquery/appDetail.as?appId=" + str);
            Intent intent = new Intent();
            intent.setClassName("com.sec.android.app.samsungapps", "com.sec.android.app.samsungapps.Main");
            intent.setData(parse);
            if (!(context instanceof Activity)) {
                intent.addFlags(268435456);
            }
            intent.putExtra("start_only_for_android", true);
            context.startActivity(intent);
            return new com.ss.android.downloadlib.addownload.cl.st(5);
        } catch (Exception unused) {
            return new com.ss.android.downloadlib.addownload.cl.st(6, 14);
        }
    }

    public static void st(Context context, com.ss.android.downloadlib.addownload.cl.io ioVar, String str) {
        JSONObject jSONObject = new JSONObject();
        try {
            TTDelegateActivity.y(str, ioVar.y);
        } catch (Exception unused) {
            com.ss.android.downloadlib.cl.y.y(y(context, Uri.parse("market://details?id=" + str)), ioVar, true);
            cl(ioVar, jSONObject, 13, 10, "market://details?id=" + str);
        }
    }

    public static com.ss.android.downloadlib.addownload.cl.st cl(Context context, com.ss.android.downloadlib.addownload.cl.io ioVar, String str) {
        Intent intent = new Intent(context, (Class<?>) JumpKllkActivity.class);
        intent.addFlags(268435456);
        intent.putExtra("p", str);
        intent.putExtra("id", ioVar.y);
        intent.putExtra("start_only_for_android", true);
        JSONObject jSONObject = new JSONObject();
        try {
            context.startActivity(intent);
            return new com.ss.android.downloadlib.addownload.cl.st(7, "am_kllk2");
        } catch (Throwable unused) {
            cl(ioVar, jSONObject, 1, 3, "market://details?id=" + str);
            return y(context, Uri.parse("market://details?id=" + str));
        }
    }

    public static boolean lu(@NonNull Activity activity, Uri uri) {
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setData(uri);
        intent.putExtra("start_only_for_android", true);
        String q = com.ss.android.socialbase.appdownloader.h.io.q();
        if (da.io(com.ss.android.downloadlib.addownload.jv.getContext(), q)) {
            intent.setPackage(q);
        }
        if (!da.y(com.ss.android.downloadlib.addownload.jv.getContext(), intent)) {
            return false;
        }
        try {
            activity.startActivity(intent);
            return true;
        } catch (Exception e) {
            com.ss.android.downloadlib.io.lu.y().y(e, "start HM2");
            return false;
        }
    }

    public static com.ss.android.downloadlib.addownload.cl.st y(Context context, Uri uri) {
        Intent intent;
        if (!com.ss.android.socialbase.appdownloader.h.io.lu() && (context == null || uri == null || !"market".equals(uri.getScheme()))) {
            return new com.ss.android.downloadlib.addownload.cl.st(6, 12);
        }
        try {
            String q = com.ss.android.socialbase.appdownloader.h.io.q();
            if (com.ss.android.socialbase.appdownloader.h.io.dw() && (TextUtils.isEmpty(q) || !da.io(context, q))) {
                q = "com.huawei.appmarket";
                Uri.Builder buildUpon = uri.buildUpon();
                buildUpon.scheme("market");
                intent = new Intent("android.intent.action.VIEW", buildUpon.build());
            } else {
                intent = new Intent("android.intent.action.VIEW", uri);
            }
            if (!da.y(context, intent)) {
                return new com.ss.android.downloadlib.addownload.cl.st(6, 13);
            }
            if (da.io(context, q) && !com.ss.android.socialbase.appdownloader.h.io.st()) {
                intent.setPackage(q);
            }
            if (com.ss.android.socialbase.downloader.da.y.lu().y("fix_jump_market")) {
                intent.addFlags(335544320);
            } else if (!(context instanceof Activity)) {
                intent.addFlags(268435456);
            }
            if (com.ss.android.socialbase.downloader.da.y.lu().cl("test_jump_market_failed") == 1) {
                com.ss.android.downloadlib.io.lu.y().y(false, "jump market error");
                return new com.ss.android.downloadlib.addownload.cl.st(6, 25);
            }
            intent.putExtra("start_only_for_android", true);
            context.startActivity(intent);
            return new com.ss.android.downloadlib.addownload.cl.st(5);
        } catch (Exception unused) {
            return new com.ss.android.downloadlib.addownload.cl.st(6, 14);
        }
    }

    public static com.ss.android.downloadlib.addownload.cl.st p(Context context, com.ss.android.downloadlib.addownload.cl.io ioVar, String str) {
        Intent intent = new Intent(context, (Class<?>) JumpKllkActivity.class);
        intent.addFlags(268435456);
        intent.putExtra("dl", true);
        intent.putExtra("p", str);
        intent.putExtra("id", ioVar.y);
        if (Build.VERSION.SDK_INT >= 29) {
            intent.putExtra("bk", "com.heytap.browser");
        } else if (da.io(context, "com.android.browser")) {
            intent.putExtra("bk", "com.android.browser");
        } else if (da.io(context, "com.coloros.browser")) {
            intent.putExtra("bk", "com.coloros.browser");
        } else {
            return y(context, Uri.parse("market://details?id=" + str));
        }
        intent.putExtra("start_only_for_android", true);
        JSONObject jSONObject = new JSONObject();
        try {
            context.startActivity(intent);
            return new com.ss.android.downloadlib.addownload.cl.st(7, "am_kllk3");
        } catch (Throwable unused) {
            cl(ioVar, jSONObject, 1, 3, "market://details?id=" + str);
            return y(context, Uri.parse("market://details?id=" + str));
        }
    }

    public static void cl(Context context, String str, String str2, @NonNull com.ss.android.downloadlib.addownload.cl.io ioVar, @NonNull JSONObject jSONObject) {
        da.y(jSONObject, "ttdownloader_type", (Object) 5);
        try {
            String y2 = com.ss.android.socialbase.appdownloader.h.lu.y(new JSONObject(str2).optString("a"));
            if (!TextUtils.isEmpty(y2)) {
                TTDelegateActivity.y(str, ioVar.y, y2, jSONObject);
                return;
            }
            com.ss.android.downloadlib.cl.y.y(y(context, Uri.parse("market://details?id=" + str)), ioVar, true);
            cl(ioVar, jSONObject, 5, 5, "market://details?id=" + str);
        } catch (Exception unused) {
            com.ss.android.downloadlib.cl.y.y(y(context, Uri.parse("market://details?id=" + str)), ioVar, true);
            cl(ioVar, jSONObject, 6, 5, "market://details?id=" + str);
        }
    }

    public static boolean lu(Context context, String str) {
        if (context == null) {
            return false;
        }
        try {
            Uri parse = Uri.parse(str);
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.setData(parse);
            intent.addFlags(268435456);
            intent.putExtra("open_url", str);
            intent.putExtra("start_only_for_android", true);
            context.startActivity(intent);
            return true;
        } catch (Throwable th) {
            com.bytedance.sdk.component.utils.jv.y(th);
            return false;
        }
    }

    public static boolean cl(@NonNull Activity activity, Uri uri) {
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setData(uri);
        intent.putExtra("start_only_for_android", true);
        String q = com.ss.android.socialbase.appdownloader.h.io.q();
        if (da.io(com.ss.android.downloadlib.addownload.jv.getContext(), q)) {
            intent.setPackage(q);
        }
        if (!da.y(com.ss.android.downloadlib.addownload.jv.getContext(), intent)) {
            return false;
        }
        try {
            activity.startActivity(intent);
            return true;
        } catch (Exception e) {
            com.ss.android.downloadlib.io.lu.y().y(e, "start HM1");
            return false;
        }
    }

    public static String lu(String str) {
        Matcher matcher = Pattern.compile("<input[\\s\\S]*>\\n").matcher(str);
        String group = matcher.find() ? matcher.group() : "";
        if (!group.equals(null) && group.length() > 0) {
            for (String str2 : group.split("\\n")) {
                if (str2.startsWith("<input")) {
                    for (String str3 : str2.split("\\s")) {
                        if (str3.startsWith("value")) {
                            return str3.substring(7, str3.length() - 1);
                        }
                    }
                }
            }
        }
        return null;
    }

    public static com.ss.android.downloadlib.addownload.cl.st y(final Context context, Uri uri, com.ss.android.downloadlib.addownload.cl.io ioVar) {
        if (context != null && com.ss.android.downloadlib.cl.q.y(uri)) {
            try {
                final Intent intent = new Intent("android.intent.action.VIEW", uri);
                if (!da.y(context, intent)) {
                    return new com.ss.android.downloadlib.addownload.cl.st(6, 13);
                }
                String q = com.ss.android.socialbase.appdownloader.h.io.q();
                if (da.io(context, q)) {
                    intent.setPackage(q);
                }
                intent.addFlags(335544320);
                if (com.ss.android.socialbase.downloader.da.y.lu().cl("test_jump_market_failed") == 1 && "local_test".equals(com.ss.android.downloadlib.addownload.jv.q().lu)) {
                    com.ss.android.downloadlib.io.lu.y().y(false, "jump market error");
                    return new com.ss.android.downloadlib.addownload.cl.st(6, 25);
                }
                intent.putExtra("start_only_for_android", true);
                long optLong = com.ss.android.downloadlib.addownload.jv.a().optLong("market_jump_delay", 1000L);
                if (optLong > 0 && ioVar != null && ioVar.f56io != null && !ioVar.f56io.rc()) {
                    com.ss.android.downloadlib.i.y().cl().post(new Runnable() {
                        @Override
                        public void run() {
                            com.ss.android.downloadlib.addownload.jv.lu().y(8, com.ss.android.downloadlib.addownload.jv.getContext(), null, "浏览器跳转失败,正在前往应用商店", null, 0);
                        }
                    });
                }
                com.ss.android.downloadlib.io.y().y(new Runnable() {
                    @Override
                    public void run() {
                        context.startActivity(intent);
                    }
                }, optLong);
                return new com.ss.android.downloadlib.addownload.cl.st(5);
            } catch (Exception unused) {
                return new com.ss.android.downloadlib.addownload.cl.st(6, 14);
            }
        }
        return new com.ss.android.downloadlib.addownload.cl.st(6, 12);
    }

    public static String p(String str) {
        List<String> pathSegments = Uri.parse(str).getPathSegments();
        if (pathSegments.size() > 0) {
            return pathSegments.get(pathSegments.size() - 1);
        }
        return null;
    }

    public static void cl(com.ss.android.downloadlib.addownload.cl.io ioVar, JSONObject jSONObject, int i, int i2, String str) {
        da.y(jSONObject, "error_code", Integer.valueOf(i));
        da.y(jSONObject, "ttdownloader_type", Integer.valueOf(i2));
        da.y(jSONObject, "rmu", str);
        da.y(jSONObject, com.ss.android.socialbase.appdownloader.h.io.q(), Integer.valueOf(da.cl(com.ss.android.downloadlib.addownload.jv.getContext(), com.ss.android.socialbase.appdownloader.h.io.q())));
        com.ss.android.downloadlib.p.y.y().cl("am_result", jSONObject, ioVar);
    }

    public static com.ss.android.downloadlib.addownload.cl.st cl(Context context, String str) {
        if (TextUtils.isEmpty(str)) {
            return new com.ss.android.downloadlib.addownload.cl.st(4, 11);
        }
        if (context == null) {
            context = com.ss.android.downloadlib.addownload.jv.getContext();
        }
        Intent st = da.st(context, str);
        if (st == null) {
            return new com.ss.android.downloadlib.addownload.cl.st(4, 22);
        }
        st.putExtra("start_only_for_android", true);
        try {
            context.startActivity(st);
            return new com.ss.android.downloadlib.addownload.cl.st(3);
        } catch (Exception unused) {
            return new com.ss.android.downloadlib.addownload.cl.st(4, 23);
        }
    }

    public static com.ss.android.downloadlib.addownload.cl.st cl(String str, com.ss.android.cl.y.cl.y yVar) {
        if (TextUtils.isEmpty(str)) {
            return new com.ss.android.downloadlib.addownload.cl.st(2, 21);
        }
        Context context = com.ss.android.downloadlib.addownload.jv.getContext();
        String yv = yVar.k().yv();
        if (!TextUtils.isEmpty(yv)) {
            jv.y().y(y, "tryOpenByUrl", "获取到跳转中转Activity的intent");
            Intent y2 = y(context, yVar, yv, 2, str);
            if (y2 != null) {
                com.ss.android.downloadlib.addownload.cl.st y3 = y(context, y2, yVar, true, str);
                if (y3.getType() == 1) {
                    return y3;
                }
            }
        }
        Uri parse = Uri.parse(str);
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setData(parse);
        intent.addFlags(268435456);
        intent.putExtra("open_url", str);
        intent.putExtra("start_only_for_android", true);
        if (com.ss.android.socialbase.downloader.da.y.lu().y("fix_app_link_flag")) {
            intent.addFlags(67108864);
        }
        return y(context, intent, yVar, false, str);
    }

    public static com.ss.android.downloadlib.addownload.cl.st y(Context context, String str) {
        if (context != null && !TextUtils.isEmpty(str)) {
            if (com.ss.android.socialbase.appdownloader.h.io.st() && da.io(context, "com.sec.android.app.samsungapps")) {
                return p(context, str);
            }
            return y(context, com.ss.android.y.y.h.y.y(context, str));
        }
        return new com.ss.android.downloadlib.addownload.cl.st(6, 11);
    }

    public static com.ss.android.downloadlib.addownload.cl.st y(Context context, com.ss.android.downloadlib.addownload.cl.io ioVar, String str) {
        if (context != null && !TextUtils.isEmpty(str)) {
            if (com.ss.android.socialbase.appdownloader.h.io.st() && da.io(context, "com.sec.android.app.samsungapps")) {
                return p(context, str);
            }
            if (ioVar.cl.v() && ioVar.p.hr()) {
                JSONArray optJSONArray = com.ss.android.downloadlib.addownload.jv.a().optJSONArray("am_plans");
                if (com.ss.android.socialbase.appdownloader.h.io.io() && com.ss.android.socialbase.appdownloader.h.y.y(optJSONArray, "am_3")) {
                    return cl(context, ioVar, str);
                }
                if (com.ss.android.socialbase.appdownloader.h.io.h() && com.ss.android.socialbase.appdownloader.h.y.y(optJSONArray, "am_2")) {
                    io(context, ioVar, str);
                    return new com.ss.android.downloadlib.addownload.cl.st(7, "am_m2");
                }
                if (com.ss.android.socialbase.appdownloader.h.io.p() && com.ss.android.socialbase.appdownloader.h.y.y(optJSONArray, "am_5")) {
                    i(context, ioVar, str);
                    return new com.ss.android.downloadlib.addownload.cl.st(7, "am_v1");
                }
                if (com.ss.android.socialbase.appdownloader.h.io.io() && com.ss.android.socialbase.appdownloader.h.y.y(optJSONArray, "am_7")) {
                    com.ss.android.y.y.lu.y yVar = ioVar.p;
                    if ((yVar instanceof com.ss.android.cl.y.y.y) && ((com.ss.android.cl.y.y.y) yVar).dw()) {
                        return p(context, ioVar, str);
                    }
                }
                if (com.ss.android.socialbase.appdownloader.h.io.p() && com.ss.android.socialbase.appdownloader.h.y.y(optJSONArray, "am_8") && da.y(da.lu(context, "com.bbk.appstore"), "8.7.2.0") >= 0) {
                    a(context, ioVar, str);
                    return new com.ss.android.downloadlib.addownload.cl.st(7, "am_v2");
                }
                if ((com.ss.android.socialbase.appdownloader.h.io.y() || com.ss.android.socialbase.appdownloader.h.io.cl()) && com.ss.android.socialbase.appdownloader.h.y.y(optJSONArray, "am_9")) {
                    h(context, ioVar, str);
                    return new com.ss.android.downloadlib.addownload.cl.st(7, "am_hr");
                }
                if ((com.ss.android.socialbase.appdownloader.h.io.y() || com.ss.android.socialbase.appdownloader.h.io.cl()) && com.ss.android.socialbase.appdownloader.h.y.y(optJSONArray, "am_10")) {
                    st(context, ioVar, str);
                    return new com.ss.android.downloadlib.addownload.cl.st(7, "am_hr2");
                }
                com.ss.android.y.y.lu.y yVar2 = ioVar.p;
                if ((yVar2 instanceof com.ss.android.cl.y.y.y) && ((com.ss.android.cl.y.y.y) yVar2).dw() && ((com.ss.android.cl.y.y.y) ioVar.p).oe() != null && ioVar.cl.oe().optInt("is_use_obm_convert", 0) == 1) {
                    lu(context, ioVar, str);
                    return new com.ss.android.downloadlib.addownload.cl.st(7, "am_kllk4");
                }
                return y(context, com.ss.android.y.y.h.y.y(context, str));
            }
            return y(context, Uri.parse("market://details?id=" + str));
        }
        return new com.ss.android.downloadlib.addownload.cl.st(6, 11);
    }

    public static void cl(Context context, @NonNull com.ss.android.downloadlib.addownload.cl.io ioVar, @NonNull String str, @NonNull String str2) {
        JSONObject jSONObject = new JSONObject();
        try {
            TTDelegateActivity.cl(str, ioVar.y, str2);
        } catch (Exception unused) {
            com.ss.android.downloadlib.cl.y.y(y(context, Uri.parse("market://details?id=" + str)), ioVar, true);
            cl(ioVar, jSONObject, 12, 9, "market://details?id=" + str);
        }
    }

    public static void cl(@NonNull Activity activity, String str, long j, String str2) {
        com.ss.android.downloadlib.addownload.cl.io io2 = com.ss.android.downloadlib.addownload.cl.h.y().io(j);
        JSONObject jSONObject = new JSONObject();
        JSONObject a = com.ss.android.downloadlib.addownload.jv.a();
        String optString = a.optString(t.g);
        String y2 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("bz"), optString);
        String y3 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("ca"), optString);
        String y4 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("cb"), optString);
        Uri.Builder builder = new Uri.Builder();
        builder.scheme("hiapplink").authority("com.huawei.appmarket");
        if (!TextUtils.isEmpty(y2)) {
            builder.appendQueryParameter(y2, str2);
        }
        if (!TextUtils.isEmpty(y3) && !TextUtils.isEmpty(y4)) {
            builder.appendQueryParameter(y3, y4);
        }
        if (cl(activity, builder.build())) {
            cl(io2, jSONObject, -1, 9, "market://details?id=" + str);
            com.ss.android.downloadlib.cl.y.y("am_hr", jSONObject, io2, true);
            return;
        }
        cl(io2, jSONObject, 2, 9, "market://details?id=" + str);
        com.ss.android.downloadlib.cl.y.y(y((Context) activity, Uri.parse("market://details?id=" + str)), io2, true);
    }

    public static void cl(@NonNull Activity activity, String str, long j) {
        com.ss.android.downloadlib.addownload.cl.io io2 = com.ss.android.downloadlib.addownload.cl.h.y().io(j);
        JSONObject jSONObject = new JSONObject();
        boolean dw = ((com.ss.android.cl.y.y.y) io2.p).dw();
        HashMap hashMap = new HashMap();
        hashMap.put("is_button", Boolean.valueOf(dw));
        da.y(jSONObject, "is_button", Boolean.valueOf(dw));
        Map<String, Object> y2 = ((com.ss.android.cl.y.y.y) io2.p).oe().y(hashMap);
        if (y2 != null && y2.get("convert_result") != null && Boolean.parseBoolean(y2.get("convert_result").toString())) {
            cl(io2, jSONObject, -1, 11, "market://details?id=" + str);
            com.ss.android.downloadlib.cl.y.y("am_kllk4", jSONObject, io2, true);
            return;
        }
        cl(io2, jSONObject, 15, 11, "market://details?id=" + str);
        com.ss.android.downloadlib.cl.y.y(y((Context) activity, Uri.parse("market://details?id=" + str)), io2, true);
    }

    public static boolean y(Context context, com.ss.android.downloadlib.addownload.cl.io ioVar, String str, JSONObject jSONObject, boolean z, int i) {
        da.y(jSONObject, "download_scene", Integer.valueOf(ioVar.l()));
        com.ss.android.downloadlib.p.y.y().cl("market_click_open", jSONObject, ioVar);
        com.ss.android.downloadlib.addownload.cl.st y2 = y(context, Uri.parse(str));
        String y3 = da.y(y2.cl(), "open_market");
        int type = y2.getType();
        if (type == 5) {
            com.ss.android.downloadlib.cl.y.y(y3, jSONObject, ioVar, true);
        } else {
            if (type == 6) {
                da.y(jSONObject, "error_code", Integer.valueOf(y2.y()));
                da.y(jSONObject, "download_scene", Integer.valueOf(ioVar.l()));
                com.ss.android.downloadlib.p.y.y().cl("market_open_failed", jSONObject, ioVar);
                return false;
            }
            if (type != 7) {
                return false;
            }
        }
        if (z) {
            com.ss.android.downloadlib.p.y.y().y(ioVar.y, i);
        }
        return true;
    }

    public static void y(Context context, String str, long j, boolean z) {
        JSONObject jSONObject = new JSONObject();
        com.ss.android.downloadlib.addownload.cl.io io2 = com.ss.android.downloadlib.addownload.cl.h.y().io(j);
        try {
            JSONObject a = com.ss.android.downloadlib.addownload.jv.a();
            String optString = a.optString(t.g);
            String y2 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("aa"), optString);
            String y3 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("ac"), optString);
            String y4 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("af"), optString);
            boolean y5 = com.ss.android.socialbase.appdownloader.h.y.y(a, context, y3);
            StringBuilder sb = new StringBuilder(String.format(y2, str, y4, y3));
            Intent intent = new Intent("android.intent.action.VIEW");
            String q = com.ss.android.socialbase.appdownloader.h.io.q();
            if (da.io(context, q)) {
                intent.setPackage(q);
            }
            if (z) {
                sb.append(com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("ae"), optString));
            } else {
                intent.addFlags(335544320);
            }
            da.y(jSONObject, "mf", Boolean.valueOf(y5));
            da.y(jSONObject, "if", Boolean.valueOf(z));
            intent.setData(Uri.parse(sb.toString()));
            intent.putExtra("start_only_for_android", true);
            context.startActivity(intent);
            com.ss.android.downloadlib.cl.y.y("am_kllk2", jSONObject, io2, true);
            if (y5) {
                cl(io2, jSONObject, -1, 3, sb.toString());
            } else {
                cl(io2, jSONObject, 3, 3, sb.toString());
            }
        } catch (Exception unused) {
            com.ss.android.downloadlib.cl.y.y(y(com.ss.android.downloadlib.addownload.jv.getContext(), Uri.parse("market://details?id=" + str)), io2, true);
            cl(io2, jSONObject, 2, 3, "market://details?id=" + str);
        }
    }

    public static void y(final Context context, String str, long j, String str2, boolean z) {
        JSONObject jSONObject = new JSONObject();
        com.ss.android.downloadlib.addownload.cl.io io2 = com.ss.android.downloadlib.addownload.cl.h.y().io(j);
        try {
            JSONObject a = com.ss.android.downloadlib.addownload.jv.a();
            String optString = a.optString(t.g);
            String y2 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("br"), optString);
            String y3 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("bs_1"), optString);
            String y4 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("bs_2"), optString);
            String y5 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("bs_3"), optString);
            String y6 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("bt"), optString);
            String y7 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("bu"), optString);
            StringBuilder sb = new StringBuilder(String.format("https://", new Object[0]));
            sb.append(y2);
            sb.append(y3);
            sb.append(y4);
            sb.append(y5);
            sb.append(y6);
            sb.append(y7);
            final Intent intent = new Intent("android.intent.action.VIEW");
            intent.setPackage(str2);
            if (z) {
                sb.append("pkg=" + str);
                sb.append("&dl=true");
            } else {
                intent.addFlags(335544320);
            }
            da.y(jSONObject, "dl", Boolean.valueOf(z));
            intent.setData(Uri.parse(sb.toString()));
            intent.putExtra("start_only_for_android", true);
            long optLong = com.ss.android.downloadlib.addownload.jv.a().optLong("oppo_browser_jump_delay", 1000L);
            if (optLong > 0) {
                com.ss.android.downloadlib.i.y().cl().post(new Runnable() {
                    @Override
                    public void run() {
                        com.ss.android.downloadlib.addownload.jv.lu().y(12, com.ss.android.downloadlib.addownload.jv.getContext(), null, "正在前往浏览器下载", null, 0);
                    }
                });
            }
            com.ss.android.downloadlib.io.y().y(new Runnable() {
                @Override
                public void run() {
                    context.startActivity(intent);
                }
            }, optLong);
            if (io2.f56io != null) {
                io2.f56io.u(true);
            }
            com.ss.android.downloadlib.cl.y.y("am_kllk3", jSONObject, io2, true);
            cl(io2, jSONObject, -1, 7, sb.toString());
        } catch (Exception unused) {
            com.ss.android.cl.y.cl.cl clVar = io2.f56io;
            if (clVar != null) {
                clVar.u(false);
            }
            com.ss.android.downloadlib.cl.y.y(y(com.ss.android.downloadlib.addownload.jv.getContext(), Uri.parse("market://details?id=" + str), io2), io2, true);
            cl(io2, jSONObject, 2, 7, "market://details?id=" + str);
        }
    }

    public static boolean y(@NonNull Activity activity, @NonNull String str, @NonNull HashMap<String, String> hashMap) {
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setData(Uri.parse("market://details?id=" + str));
        intent.putExtra("start_only_for_android", true);
        intent.putExtra("param", hashMap);
        String q = com.ss.android.socialbase.appdownloader.h.io.q();
        if (da.io(com.ss.android.downloadlib.addownload.jv.getContext(), q)) {
            intent.setPackage(q);
        }
        if (!da.y(com.ss.android.downloadlib.addownload.jv.getContext(), intent)) {
            return false;
        }
        try {
            activity.startActivity(intent);
            return true;
        } catch (Exception e) {
            com.ss.android.downloadlib.io.lu.y().y(e, "start v1");
            return false;
        }
    }

    public static void y(@NonNull Activity activity, String str, long j, String str2, String str3) {
        JSONObject jSONObject;
        int i;
        try {
            jSONObject = new JSONObject(str3);
        } catch (JSONException unused) {
            jSONObject = new JSONObject();
        }
        com.ss.android.downloadlib.addownload.cl.io io2 = com.ss.android.downloadlib.addownload.cl.h.y().io(j);
        try {
            JSONObject a = com.ss.android.downloadlib.addownload.jv.a();
            boolean y2 = com.ss.android.socialbase.appdownloader.h.y.y(a, activity, com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("bg"), a.optString(t.g)));
            HashMap<String, String> cl = da.cl(new JSONObject(str2));
            if (y2 && !cl.isEmpty() && y(activity, str, cl)) {
                cl(io2, jSONObject, -1, 5, "market://details?id=" + str);
                com.ss.android.downloadlib.cl.y.y("am_v1", jSONObject, io2, true);
                return;
            }
            if (y2) {
                i = cl.isEmpty() ? 1 : 2;
            } else {
                i = 3;
            }
            cl(io2, jSONObject, i, 5, "market://details?id=" + str);
            com.ss.android.downloadlib.cl.y.y(y((Context) activity, Uri.parse("market://details?id=" + str)), io2, true);
        } catch (Exception unused2) {
            com.ss.android.downloadlib.cl.y.y(y(com.ss.android.downloadlib.addownload.jv.getContext(), Uri.parse("market://details?id=" + str)), io2, true);
            cl(io2, jSONObject, 4, 5, "market://details?id=" + str);
        }
    }

    public static void y(@NonNull Activity activity, String str, long j, String str2) {
        com.ss.android.downloadlib.addownload.cl.io io2 = com.ss.android.downloadlib.addownload.cl.h.y().io(j);
        JSONObject jSONObject = new JSONObject();
        JSONObject a = com.ss.android.downloadlib.addownload.jv.a();
        String y2 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("bv"), a.optString(t.g));
        Uri.Builder builder = new Uri.Builder();
        builder.scheme("market").authority("details").appendQueryParameter("id", str);
        if (!TextUtils.isEmpty(y2)) {
            builder.appendQueryParameter(y2, str2);
        }
        if (y(activity, builder.build())) {
            cl(io2, jSONObject, -1, 8, "market://details?id=" + str);
            com.ss.android.downloadlib.cl.y.y("am_v2", jSONObject, io2, true);
            return;
        }
        cl(io2, jSONObject, 2, 8, "market://details?id=" + str);
        com.ss.android.downloadlib.cl.y.y(y((Context) activity, Uri.parse("market://details?id=" + str)), io2, true);
    }

    public static boolean y(@NonNull Activity activity, Uri uri) {
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setData(uri);
        intent.putExtra("start_only_for_android", true);
        String q = com.ss.android.socialbase.appdownloader.h.io.q();
        if (da.io(com.ss.android.downloadlib.addownload.jv.getContext(), q)) {
            intent.setPackage(q);
        }
        if (!da.y(com.ss.android.downloadlib.addownload.jv.getContext(), intent)) {
            return false;
        }
        try {
            activity.startActivity(intent);
            return true;
        } catch (Exception e) {
            com.ss.android.downloadlib.io.lu.y().y(e, "start v2");
            return false;
        }
    }

    public static com.ss.android.downloadlib.addownload.cl.st y(Context context, String str, com.ss.android.cl.y.cl.y yVar) {
        Intent y2 = y(context, yVar, str, 1, (String) null);
        if (y2 != null) {
            jv.y().y(y, "tryOpenByPackage", "成功构造了跳转中转Activity的intent");
            com.ss.android.downloadlib.addownload.cl.st y3 = y(y2, true, context, str, yVar);
            if (y3.getType() == 3) {
                return y3;
            }
        }
        Intent st = da.st(context, str);
        if (st == null) {
            return new com.ss.android.downloadlib.addownload.cl.st(4, 22);
        }
        return y(st, false, context, str, yVar);
    }

    public static com.ss.android.downloadlib.addownload.cl.st y(Intent intent, boolean z, Context context, String str, com.ss.android.cl.y.cl.y yVar) {
        if (Build.VERSION.SDK_INT >= 26 && com.ss.android.downloadlib.addownload.jv.a().optInt("open_package_mode") == 1 && com.ss.android.downloadlib.addownload.jv.jv() != null && com.ss.android.downloadlib.addownload.jv.jv().y() && yVar.dw() && !z) {
            TTDelegateActivity.cl(str, yVar);
            return new com.ss.android.downloadlib.addownload.cl.st(3);
        }
        intent.putExtra("start_only_for_android", true);
        try {
            context.startActivity(intent);
            return new com.ss.android.downloadlib.addownload.cl.st(3);
        } catch (Exception e) {
            if (z) {
                jv.y().cl(y, "realTryOpenByPackage", "调起中转Activity出现异常,可能是没接转化SDK,回退普通调起" + e.getMessage());
                return new com.ss.android.downloadlib.addownload.cl.st(8, 23);
            }
            jv.y().cl(y, "realTryOpenByPackage", "包名调起失败了,抛出异常" + e.getMessage());
            return new com.ss.android.downloadlib.addownload.cl.st(4, 23);
        }
    }

    public static com.ss.android.downloadlib.addownload.cl.st y(String str, com.ss.android.cl.y.cl.y yVar) {
        return y(com.ss.android.downloadlib.addownload.jv.getContext(), str, yVar);
    }

    public static com.ss.android.downloadlib.addownload.cl.st y(Context context, Intent intent, com.ss.android.cl.y.cl.y yVar, boolean z, String str) {
        if (context == null) {
            context = com.ss.android.downloadlib.addownload.jv.getContext();
        }
        if (da.cl(context, intent)) {
            if (com.ss.android.downloadlib.addownload.jv.a().optInt("open_url_mode") == 0 && com.ss.android.downloadlib.addownload.jv.jv() != null && com.ss.android.downloadlib.addownload.jv.jv().y() && Build.VERSION.SDK_INT >= 26 && yVar.dw() && !z) {
                TTDelegateActivity.y(str, yVar);
                return new com.ss.android.downloadlib.addownload.cl.st(1);
            }
            try {
                context.startActivity(intent);
                return new com.ss.android.downloadlib.addownload.cl.st(1);
            } catch (Exception e) {
                if (z) {
                    jv.y().cl(y, "realTryOpenByUrl", "商店直投注入clickId优化url调起场景,抛出异常,没接转化SDK,回退普通调起" + e.getMessage());
                    return new com.ss.android.downloadlib.addownload.cl.st(9);
                }
                jv.y().cl(y, "realTryOpenByUrl", "url调起失败了,抛出异常" + e.getMessage());
                return new com.ss.android.downloadlib.addownload.cl.st(2);
            }
        }
        return new com.ss.android.downloadlib.addownload.cl.st(2, 24);
    }

    public static com.ss.android.downloadlib.addownload.cl.st y(@NonNull com.ss.android.cl.y.cl.cl clVar, String str, String str2) {
        com.ss.android.downloadlib.addownload.cl.st cl = cl(str, clVar);
        return (com.ss.android.downloadlib.cl.h.y(clVar) && cl.getType() == 2) ? y(str2, clVar) : cl;
    }

    public static void y(@NonNull Activity activity, String str, long j) {
        com.ss.android.downloadlib.addownload.cl.io io2 = com.ss.android.downloadlib.addownload.cl.h.y().io(j);
        JSONObject jSONObject = new JSONObject();
        JSONObject a = com.ss.android.downloadlib.addownload.jv.a();
        String optString = a.optString(t.g);
        String y2 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("ca"), optString);
        String y3 = com.ss.android.socialbase.appdownloader.h.lu.y(a.optString("cc"), optString);
        StringBuilder sb = new StringBuilder("market://details?id=");
        if (!TextUtils.isEmpty(y2) && !TextUtils.isEmpty(y3)) {
            sb.append(str);
            sb.append(LiteKsSig1Util.JOIN_STRING);
            sb.append(y2);
            sb.append("=");
            sb.append(y3);
        }
        if (lu(activity, Uri.parse(sb.toString()))) {
            cl(io2, jSONObject, -1, 10, "market://details?id=" + str);
            com.ss.android.downloadlib.cl.y.y("am_hr2", jSONObject, io2, true);
            return;
        }
        cl(io2, jSONObject, 2, 10, "market://details?id=" + str);
        com.ss.android.downloadlib.cl.y.y(y((Context) activity, Uri.parse("market://details?id=" + str)), io2, true);
    }

    public static Intent y(Context context, com.ss.android.cl.y.cl.y yVar, String str, int i, String str2) {
        if (!yVar.lu() || yVar.g() == null || yVar.g().cl() != 2 || yVar.k() == null || io.y(yVar).y("app_link_market_open_add_info", 0) != 1) {
            return null;
        }
        String lu = com.ss.android.downloadlib.addownload.a.lu(yVar.k());
        String p = com.ss.android.downloadlib.addownload.a.p(yVar.k());
        Intent intent = new Intent();
        intent.setClassName(str, "com.bytedance.ads.convert.BDBridgeActivity");
        ResolveInfo resolveActivity = context.getPackageManager().resolveActivity(intent, 0);
        if (TextUtils.isEmpty(lu) || resolveActivity == null) {
            return null;
        }
        intent.putExtra("click_id", lu);
        if (!(context instanceof Activity)) {
            intent.setFlags(268435456);
        }
        if (!TextUtils.isEmpty(p)) {
            intent.putExtra("intent_extra", p);
        }
        if (i == 2 && !TextUtils.isEmpty(str2)) {
            intent.putExtra("open_url", str2);
        }
        return intent;
    }
}