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

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


package com.tencent.mtt.stabilization.cooperate;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import com.tencent.common.http.Apn;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.base.utils.PackageUtils;
import com.tencent.mtt.browser.download.core.impl.DownloadServiceManager;
import com.tencent.mtt.browser.download.engine.DownloadInfo;
import com.tencent.mtt.browser.download.engine.DownloadTask;
import com.tencent.mtt.browser.download.engine.RemovePolicy;
import com.tencent.mtt.browser.file.FileProvider;
import com.tencent.mtt.setting.PublicSettingManager;
import com.tencent.mtt.view.dialog.alert.QBLinearDialogClickListener;
import com.tencent.mtt.view.dialog.bottomsheet.QBLinearBottomSheet;
import com.tencent.mtt.view.dialog.newui.SimpleDialogBuilder;
import com.tencent.mtt.view.dialog.newui.builder.api.base.IDialogBuilderInterface;
import com.tencent.mtt.view.dialog.newui.dialog.DialogBase;
import com.tencent.mtt.view.dialog.newui.view.ViewOnClickListener;
import com.tencent.mtt.view.toast.MttToaster;
import com.tencent.qqlive.module.videoreport.collect.EventCollector;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import qb.a.h;

public class SpecialAppPromotion {

    static QBLinearBottomSheet f71439a;

    public static class AppListItem {

        public static int f71448a = 0;

        public static int f71449b = 1;

        public static int f71450c = 2;

        public int f71451d = f71448a;
        public String e = null;
        public Drawable f = null;
        public String g = null;
        public String h;
        public String i;
        public ActivityInfo j;
        public View.OnClickListener k;
    }

    public static class SpecialAppInfo {

        public Drawable f71452a;

        public String f71453b;

        public String f71454c;

        public String f71455d;
        public String e;
        public String f;
        public int g;
        public String h;
        public int i;
        public String j;
        public String k;
    }

    private static View.OnClickListener a(final Intent intent, final AppListItem appListItem, final String str) {
        return new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent2;
                Context appContext;
                EventCollector.getInstance().onViewClickedBefore(view);
                if (AppListItem.this != null) {
                    if (!TextUtils.isEmpty(str)) {
                        StatManager.b().c(str);
                    }
                    if (AppListItem.this.f71451d == AppListItem.f71449b) {
                        intent.setPackage(AppListItem.this.g);
                        appContext = ContextHolder.getAppContext();
                        intent2 = intent;
                    } else {
                        File a2 = SpecialAppPromotion.a(AppListItem.this.i);
                        if (a2 != null) {
                            intent2 = new Intent("android.intent.action.VIEW");
                            intent2.addFlags(268435456);
                            intent2.setDataAndType(FileProvider.a(a2), "application/vnd.android.package-archive");
                            intent2.addFlags(3);
                            appContext = ContextHolder.getAppContext();
                        } else if (Apn.isCharge()) {
                            new Handler().post(new Runnable() {
                                @Override
                                public void run() {
                                    SpecialAppPromotion.a(AppListItem.this);
                                }
                            });
                        } else {
                            DownloadTask e = DownloadServiceManager.b().e(AppListItem.this.i);
                            if (e != null) {
                                DownloadServiceManager.a().removeDownloadTask(e.i(), RemovePolicy.DELETE_TASK_ONLY);
                            }
                            DownloadInfo downloadInfo = new DownloadInfo();
                            downloadInfo.f37604a = AppListItem.this.i;
                            downloadInfo.j = false;
                            downloadInfo.p = true;
                            DownloadServiceManager.a().startDownloadTask(downloadInfo, null, null);
                        }
                    }
                    appContext.startActivity(intent2);
                }
                EventCollector.getInstance().onViewClicked(view);
            }
        };
    }

    public static QBLinearDialogClickListener a(final Intent intent, final ArrayList<AppListItem> arrayList) {
        return new QBLinearDialogClickListener() {
            @Override
            public void a(int i) {
                AppListItem appListItem = (AppListItem) arrayList.get(i);
                try {
                    if ((appListItem.f71451d == AppListItem.f71449b || appListItem.f71451d == AppListItem.f71450c) && appListItem.k != null) {
                        appListItem.k.onClick(null);
                        return;
                    }
                    ActivityInfo activityInfo = appListItem.j;
                    if (activityInfo != null) {
                        intent.setClassName(activityInfo.packageName, activityInfo.name);
                    }
                    ContextHolder.getAppContext().startActivity(intent);
                } catch (Exception unused) {
                    MttToaster.show(MttResources.l(h.I), 0);
                }
            }
        };
    }

    public static File a(String str) {
        File downloadFileByTask;
        DownloadTask b2 = DownloadServiceManager.b().b(str);
        if (b2 == null || (downloadFileByTask = DownloadServiceManager.a().getDownloadFileByTask(b2)) == null || !downloadFileByTask.exists()) {
            return null;
        }
        return downloadFileByTask;
    }

    public static void a(Activity activity, Intent intent, SpecialAppInfo specialAppInfo) {
        String str;
        Iterator it;
        boolean z;
        CharSequence loadLabel;
        intent.setFlags(269484032);
        List<ResolveInfo> a2 = PackageUtils.a(ContextHolder.getAppContext(), intent, 65536);
        if (a2 == null) {
            return;
        }
        boolean a3 = a(specialAppInfo, a2);
        ArrayList arrayList = new ArrayList();
        int i = PublicSettingManager.a().getInt("key_promote_wx_pb_count" + specialAppInfo.h + specialAppInfo.g, 0);
        a(intent, specialAppInfo, a3, arrayList, i, specialAppInfo.f71454c.equalsIgnoreCase("com.tencent.androidqqmail") ? PublicSettingManager.a().getBoolean("key_promote_qmail_enable", true) : true);
        if (specialAppInfo.g == 100028) {
            PublicSettingManager.a().setInt("key_promote_wx_pb_count" + specialAppInfo.h + specialAppInfo.g, i + 1);
        }
        for (ResolveInfo resolveInfo : a2) {
            if (!a(resolveInfo)) {
                Drawable drawable = null;
                try {
                    loadLabel = resolveInfo.loadLabel(ContextHolder.getAppContext().getPackageManager());
                } catch (Exception unused) {
                }
                if (loadLabel != null) {
                    str = loadLabel.toString();
                    if (str == null) {
                        str = MttResources.l(h.y);
                    }
                    drawable = resolveInfo.activityInfo.loadIcon(ContextHolder.getAppContext().getPackageManager());
                    String str2 = resolveInfo.activityInfo.packageName;
                    it = arrayList.iterator();
                    z = false;
                    while (it.hasNext()) {
                        if (((AppListItem) it.next()).g.equalsIgnoreCase(str2)) {
                            z = true;
                        }
                    }
                    if (z) {
                        AppListItem appListItem = new AppListItem();
                        appListItem.j = resolveInfo.activityInfo;
                        appListItem.e = str;
                        appListItem.f = drawable;
                        appListItem.g = str2;
                        arrayList.add(appListItem);
                    }
                }
                str = null;
                if (str == null) {
                }
                drawable = resolveInfo.activityInfo.loadIcon(ContextHolder.getAppContext().getPackageManager());
                String str22 = resolveInfo.activityInfo.packageName;
                it = arrayList.iterator();
                z = false;
                while (it.hasNext()) {
                }
                if (z) {
                }
            }
        }
        a(activity, (ArrayList<AppListItem>) arrayList, specialAppInfo.f71455d, a(intent, (ArrayList<AppListItem>) arrayList));
    }

    public static void a(Activity activity, String str, int i, int i2) {
        Intent intent = new Intent("android.intent.action.SENDTO", Uri.parse("mailto:" + str));
        SpecialAppInfo specialAppInfo = new SpecialAppInfo();
        specialAppInfo.f71452a = MttResources.i(R.drawable.b35);
        specialAppInfo.f71453b = MttResources.l(R.string.b60);
        specialAppInfo.f71454c = "com.tencent.androidqqmail";
        specialAppInfo.f71455d = MttResources.a(R.string.b6e, str);
        specialAppInfo.e = MttResources.l(R.string.b5z);
        specialAppInfo.f = "https://app.mail.qq.com/cgi-bin/mailapp?latest=match&apv=QQbrowers";
        specialAppInfo.g = i;
        specialAppInfo.h = "promotion_type_qmail";
        specialAppInfo.i = i2;
        if (i == 100028) {
            specialAppInfo.j = "AHNG401";
            specialAppInfo.k = "AHNG403";
        }
        a(activity, intent, specialAppInfo);
    }

    private static void a(Context context, ArrayList<AppListItem> arrayList, String str, final QBLinearDialogClickListener qBLinearDialogClickListener) {
        QBLinearBottomSheet qBLinearBottomSheet = f71439a;
        if (qBLinearBottomSheet == null || !qBLinearBottomSheet.isShowing()) {
            f71439a = new QBLinearBottomSheet(context);
            f71439a.b(str);
            int s = MttResources.s(48) / 2;
            for (int i = 0; i < arrayList.size(); i++) {
                try {
                    if (arrayList.get(i).f71451d == AppListItem.f71450c) {
                        f71439a.a(arrayList.get(i).f, arrayList.get(i).e, arrayList.get(i).h, s, s, true);
                    } else if (arrayList.get(i).f71451d == AppListItem.f71449b) {
                        f71439a.a(arrayList.get(i).f, arrayList.get(i).e, arrayList.get(i).h, s, s, false);
                    } else {
                        f71439a.a(arrayList.get(i).f, arrayList.get(i).e, s, s);
                    }
                } catch (Throwable unused) {
                }
            }
            f71439a.a(new QBLinearDialogClickListener() {
                @Override
                public void a(int i2) {
                    if (SpecialAppPromotion.f71439a != null) {
                        SpecialAppPromotion.f71439a.dismiss();
                        SpecialAppPromotion.f71439a = null;
                    }
                    QBLinearDialogClickListener qBLinearDialogClickListener2 = QBLinearDialogClickListener.this;
                    if (qBLinearDialogClickListener2 != null) {
                        qBLinearDialogClickListener2.a(i2);
                    }
                }
            });
            f71439a.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    SpecialAppPromotion.f71439a = null;
                }
            });
            f71439a.show();
        }
    }

    private static void a(Intent intent, SpecialAppInfo specialAppInfo, boolean z, ArrayList<AppListItem> arrayList, int i, boolean z2) {
        String str;
        if (z || z2) {
            if (z || specialAppInfo.i == 0 || i < specialAppInfo.i) {
                AppListItem appListItem = new AppListItem();
                if (z) {
                    appListItem.f71451d = AppListItem.f71449b;
                    str = specialAppInfo.j;
                } else {
                    appListItem.f71451d = AppListItem.f71450c;
                    str = specialAppInfo.k;
                }
                appListItem.k = a(intent, appListItem, str);
                appListItem.g = specialAppInfo.f71454c;
                appListItem.f = specialAppInfo.f71452a;
                appListItem.i = specialAppInfo.f;
                appListItem.h = specialAppInfo.e;
                appListItem.e = specialAppInfo.f71453b;
                arrayList.add(appListItem);
            }
        }
    }

    public static void a(final AppListItem appListItem) {
        SimpleDialogBuilder.e().e(MttResources.l(R.string.b94)).a(IDialogBuilderInterface.ButtonStyle.BLUE).a(MttResources.l(h.g)).c(MttResources.l(h.l)).a_(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                DownloadTask e = DownloadServiceManager.b().e(AppListItem.this.i);
                if (e != null) {
                    DownloadServiceManager.a().removeDownloadTask(e.i(), RemovePolicy.DELETE_TASK_ONLY);
                }
                DownloadInfo downloadInfo = new DownloadInfo();
                downloadInfo.f37604a = AppListItem.this.i;
                downloadInfo.j = false;
                DownloadServiceManager.a().startDownloadTask(downloadInfo, null, null);
                dialogBase.dismiss();
            }
        }).c(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                dialogBase.dismiss();
            }
        }).d().show();
    }

    private static boolean a(ResolveInfo resolveInfo) {
        return resolveInfo == null || resolveInfo.activityInfo == null || TextUtils.isEmpty(resolveInfo.activityInfo.packageName);
    }

    private static boolean a(SpecialAppInfo specialAppInfo, List<ResolveInfo> list) {
        Iterator<ResolveInfo> it = list.iterator();
        boolean z = false;
        while (it.hasNext()) {
            if (it.next().activityInfo.packageName.contains(specialAppInfo.f71454c)) {
                it.remove();
                z = true;
            }
        }
        return z;
    }
}