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

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


package com.tencent.common.plugin.impl;

import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.Signature;
import android.os.Build;
import android.os.Message;
import android.os.Process;
import android.os.RemoteException;
import android.text.TextUtils;
import com.tencent.basesupport.FLogger;
import com.tencent.common.connectivitydetect.ConnectivityDetector;
import com.tencent.common.http.Apn;
import com.tencent.common.manifest.AppManifest;
import com.tencent.common.plugin.exports.IGetPluginInfoCallback;
import com.tencent.common.plugin.exports.IInstallPluginCallback;
import com.tencent.common.plugin.exports.QBPluginInfo;
import com.tencent.common.plugin.exports.QBPluginItemInfo;
import com.tencent.common.plugin.external.IDownloadSpecicalWhiteList;
import com.tencent.common.plugin.external.IPluginDir;
import com.tencent.common.plugin.external.IPluginLoader;
import com.tencent.common.plugin.external.IPluginLocalConfigExt;
import com.tencent.common.plugin.external.IPluginRelateFunc;
import com.tencent.common.plugin.external.PluginConfigInfo;
import com.tencent.common.plugin.external.QBPluginLogExt;
import com.tencent.common.plugin.impl.IQBPluginService;
import com.tencent.common.plugin.impl.QBPluginSystem;
import com.tencent.common.plugin.impl.TBSPluginCallbackHandler;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.ByteUtils;
import com.tencent.common.utils.FileUtils;
import com.tencent.common.utils.FileUtilsF;
import com.tencent.common.utils.GdiMeasureImpl;
import com.tencent.common.utils.Md5Utils;
import com.tencent.common.utils.SignatureUtil;
import com.tencent.common.utils.StorageDirs;
import com.tencent.common.utils.StringUtils;
import com.tencent.common.utils.TbsMode;
import com.tencent.common.wup.IWUPRequestCallBack;
import com.tencent.common.wup.WUPRequestBase;
import com.tencent.common.wup.WUPResponseBase;
import com.tencent.common.wup.WUPTaskProxy;
import com.tencent.imsdk.BaseConstants;
import com.tencent.luggage.wxa.kr.ar;
import com.tencent.luggage.wxa.mq.e;
import com.tencent.map.geolocation.util.DateUtils;
import com.tencent.mm.ui.widget.dialog.MMTipsBar;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.apkplugin.impl.IAPInjectService;
import com.tencent.mtt.base.task.WalledGardenDetectTask;
import com.tencent.mtt.browser.download.business.flowctrl.IFlowCtrlHelperFactory;
import com.tencent.mtt.browser.download.business.flowctrl.IMultiFlowCtrlHelper;
import com.tencent.mtt.browser.download.engine.DownloadErrorDetail;
import com.tencent.mtt.browser.download.engine.DownloadInfo;
import com.tencent.mtt.browser.download.engine.DownloadTask;
import com.tencent.mtt.browser.download.engine.DownloadTaskListener;
import com.tencent.mtt.browser.download.engine.IDownloadManager;
import com.tencent.mtt.browser.download.engine.PauseReason;
import com.tencent.mtt.browser.download.engine.Priority;
import com.tencent.mtt.browser.download.engine.RemovePolicy;
import com.tencent.mtt.browser.plugin.facade.IPluginService;
import com.tencent.mtt.external.ar.facade.IArService;
import com.tencent.mtt.external.reader.IReader;
import com.tencent.mtt.video.browser.export.engine.WonderPluginSession;
import com.tencent.tbs.common.MTT.UniPluginReq;
import com.tencent.tbs.common.MTT.UniPluginRsp;
import com.xiaomi.mipush.sdk.Constants;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.security.cert.Certificate;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import tmsdk.common.gourd.vine.IActionReportService;

public class QBPluginServiceImpl extends IQBPluginService.Stub implements IWUPRequestCallBack, IMultiFlowCtrlHelper.Callback, DownloadTaskListener {

    public static ILogPushUploadHelper f9836a = null;

    public static int f9837b = 0;

    public static int f9838c = 1;

    public static int f9839d = 2;
    public static int e = 3;
    public static int f = 4;
    public static int g = 5;
    public static int h = 6;
    public static int i = 11;
    public static int j = 12;
    public static int k = 13;
    public static int l = 14;
    public static int m = 16;
    public static int n = 20;
    public static int o = 17;
    public static int p = 30;
    public static int q = 31;
    public static int r = 32;
    final IMultiFlowCtrlHelper G;
    ArrayList<IQBPluginCallback> t;
    public static long[] s = {0, 0, 0};
    public static Context x = null;
    public static Context y = null;
    static QBPluginServiceImpl A = null;
    static final Map<String, PluginConfigInfo> B = new HashMap();
    public static IPluginDir D = null;
    public static IPluginRelateFunc E = null;
    public static IPluginLoader F = null;
    private static final AtomicInteger W = new AtomicInteger(0);
    static final String H = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    private static Signature X = null;
    public static int J = -12;
    public static int K = -11;
    public static int L = -10;
    public static int M = -2;
    public static int N = -1;
    public static int O = 1;
    public static int P = 0;
    List<QBPluginSystem.PluginPkgKey> u = new ArrayList();
    public int v = 0;
    public int w = 0;
    private PluginCallbackHandler S = null;
    private int T = 0;
    private volatile boolean U = false;
    private IDownloadManager V = null;
    final Map<QBPluginSystem.PluginPkgKey, QBPluginInfo> z = new ConcurrentHashMap();
    IDownloadSpecicalWhiteList C = null;
    private ArrayList<AsynGetPluginInfo> Y = new ArrayList<>();
    public final Object I = new Object();
    private boolean Z = true;
    private long aa = BaseConstants.DEFAULT_MSG_TIMEOUT;
    private WalledGardenDetectTask ab = null;
    boolean Q = false;
    boolean R = false;

    public static class AsynGetPluginInfo {

        public String f9855a;

        public IGetPluginInfoCallback f9856b;

        public int f9857c = 0;
    }

    static class FlowCtrlTag {

        String f9858a;

        DownloadInfo f9859b;

        int f9860c;

        FlowCtrlTag() {
        }

        public String toString() {
            return "FlowCtrlTag{mPackageName=" + this.f9858a + ", downloadUrl={" + this.f9859b.f37604a + "}, mPluginTaskFlag=0x" + Integer.toHexString(this.f9860c) + '}';
        }
    }

    public interface ILogPushUploadHelper {
        void a(List<File> list);
    }

    private QBPluginServiceImpl() {
        this.t = null;
        this.t = new ArrayList<>();
        a(new TBSPluginCallbackHandler());
        this.G = IFlowCtrlHelperFactory.PROXY.get().createMultiHelper(3, "QBPlugin", this, true);
    }

    static int a(int i2, boolean z, int i3) {
        return a(i2, z, h(i3));
    }

    static int a(int i2, boolean z, boolean z2) {
        return (z || !z2) ? i2 | 4 : i2 | 268435456;
    }

    public static int a(String str, File file, QBPluginItemInfo qBPluginItemInfo, int i2, int i3, String str2, boolean z) {
        if (file == null || !file.exists() || file.length() == 0) {
            if (file != null) {
                PluginStatBehavior.d(str, 3, file.getParent());
                PluginStatBehavior.f(str, 3, file.getName());
            }
            PluginStatBehavior.c(str, 3, 512);
            PluginStatBehavior.a(str, 3, 512);
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "preInstallCheck " + str + ",localFileNotExist");
            return 6003;
        }
        ByteBuffer a2 = FileUtilsF.a(file.getAbsolutePath(), 0L, 256);
        long a3 = StringUtils.a(qBPluginItemInfo.mPackageSize, -1L);
        if (a3 >= 0 && a3 != file.length()) {
            PluginStatBehavior.c(str, 3, new String(a2.array(), 0, a2.position()));
            FileUtilsF.f().a(a2);
            PluginStatBehavior.i(str, 3, "FS[" + file.length() + "]PS[" + qBPluginItemInfo.mPackageSize + "_" + z);
            PluginStatBehavior.a(str, 3, 568);
            return 6004;
        }
        String byteToHexString = ByteUtils.byteToHexString(Md5Utils.a(a2.array(), 0, a2.position()));
        FileUtilsF.f().a(a2);
        PluginStatBehavior.a(str, 3, str2);
        PluginStatBehavior.c(str, 3, "[" + byteToHexString + "],[" + str2 + "]");
        if (TextUtils.isEmpty(byteToHexString) || TextUtils.isEmpty(str2) || byteToHexString.length() != str2.length() || byteToHexString.equals(str2)) {
            if (i2 != 9 ? b(file.getAbsolutePath(), str, i2) : true) {
                return 0;
            }
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "preInstallCheck " + str + ",checkPluginSign failed");
            return 6006;
        }
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "InstallPluginFailed filePath=" + file.getAbsolutePath() + ",pkgName=" + str + "localFileMd5=" + byteToHexString + ",pluginListMd5=" + str2 + ",本地文件计算md5和服务器md5不一样,不安装....");
        StringBuilder sb = new StringBuilder();
        sb.append("516_");
        sb.append(z);
        PluginStatBehavior.i(str, 3, sb.toString());
        PluginStatBehavior.a(str, 3, 516);
        return 6005;
    }

    public int a(String str, String str2, AsynGetPluginInfo asynGetPluginInfo, int i2) {
        synchronized (this.I) {
            boolean c2 = PluginSetting.a(b()).c(i2);
            if (c2 && !k(i2)) {
                return L;
            }
            String str3 = "24Hour_";
            PluginStatBehavior.b("PluginList", PluginStatBehavior.a(i2));
            PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), 311);
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "requestPluginList: " + str + ",reqStatus=" + d(i2));
            WUPRequestBase c3 = c(str, str3 + str2, i2);
            if (c3 == null) {
                synchronized (this.Y) {
                    if (asynGetPluginInfo != null) {
                        this.Y.add(asynGetPluginInfo);
                    }
                }
                return O;
            }
            if (!WUPTaskProxy.send(c3)) {
                c(3, i2);
                FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginRequest  :Send Failed");
                PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), 314);
                PluginStatBehavior.a("PluginList", PluginStatBehavior.a(i2), 314);
                return K;
            }
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginRequest  :Send Out");
            c(1, i2);
            PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), 313);
            synchronized (this.Y) {
                if (asynGetPluginInfo != null) {
                    this.Y.add(asynGetPluginInfo);
                }
            }
            return P;
        }
    }

    public static File a(Context context, String str, String str2) {
        File a2;
        File a3;
        if (TextUtils.isEmpty(str2)) {
            return PluginFileUtils.a(PluginFileUtils.a().getAbsoluteFile(), "unknown", "755");
        }
        if (!TbsMode.TBSISQB()) {
            File h2 = FileUtils.h(context);
            PluginStatBehavior.a(str2, "437(10:" + h2 + ")", 2, 4);
            if (h2 != null && (a2 = FileUtilsF.a(h2.getAbsoluteFile(), PluginFileUtils.f9792a)) != null && (a3 = FileUtilsF.a(a2.getAbsoluteFile(), str2)) != null) {
                return a3;
            }
        }
        if (D != null) {
            try {
                if (TextUtils.isEmpty(str) || !str.toLowerCase().endsWith(".zip")) {
                    File qQBrowserDownloadDir = D.getQQBrowserDownloadDir();
                    PluginStatBehavior.a(str2, "437(20:" + qQBrowserDownloadDir + ")", 2, 4);
                    File a4 = PluginFileUtils.a(qQBrowserDownloadDir, "755", PluginFileUtils.f9792a, str2);
                    if (a4 != null) {
                        return a4;
                    }
                    File a5 = PluginFileUtils.a();
                    PluginStatBehavior.a(str2, "437(30:" + a5 + ")", 2, 4);
                    File a6 = PluginFileUtils.a(a5.getAbsoluteFile(), str2, "755");
                    if (a6 != null) {
                        return a6;
                    }
                }
                if (D.hasSdcard()) {
                    File qQBrowserDownloadDir2 = D.getQQBrowserDownloadDir();
                    PluginStatBehavior.a(str2, "437(40:" + qQBrowserDownloadDir2 + ")", 2, 4);
                    if (qQBrowserDownloadDir2 != null) {
                        long j2 = D.getSdcardSpace(qQBrowserDownloadDir2.getAbsolutePath()).f10297a;
                        PluginStatBehavior.a(str2, "437(50:" + j2 + ")", 2, 4);
                        if (j2 >= 10485760) {
                            File a7 = PluginFileUtils.a(qQBrowserDownloadDir2, "755", PluginFileUtils.f9792a, str2);
                            if (a7 != null) {
                                return a7;
                            }
                        }
                    }
                }
            } catch (Throwable th) {
                PluginStatBehavior.a(str2, "437(60:" + th + ")", 2, 4);
            }
        }
        File a8 = PluginFileUtils.a();
        PluginStatBehavior.a(str2, "437(70:" + a8 + ")", 2, 4);
        File a9 = PluginFileUtils.a(a8.getAbsoluteFile(), str2, "755");
        if (a9 != null) {
            return a9;
        }
        File a10 = StorageDirs.a(PluginFileUtils.f9792a);
        PluginStatBehavior.a(str2, "437(75:" + a10 + ")", 2, 4);
        File a11 = PluginFileUtils.a(a10.getAbsoluteFile(), str2, "755");
        if (a11 != null) {
            return a11;
        }
        try {
            a10 = PluginFileUtils.a(context);
            PluginStatBehavior.a(str2, "437(80:" + a10 + ")", 2, 4);
            if (a10 == null) {
                return null;
            }
            File a12 = PluginFileUtils.a(a10.getAbsoluteFile(), str2, "755");
            if (a12 != null) {
                return a12;
            }
            return null;
        } catch (Throwable unused) {
            PluginStatBehavior.a(str2, "437(89:" + a10 + ")", 2, 4);
            return null;
        }
    }

    public static File a(Context context, String str, boolean z) {
        File a2;
        File qQBrowserDownloadDir;
        File a3;
        if (!TbsMode.TBSISQB()) {
            File g2 = FileUtils.g(context);
            if (g2 == null) {
                return null;
            }
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInstallDir  tesDataShare = " + g2.getAbsolutePath());
            File a4 = PluginFileUtils.a(g2.getAbsoluteFile(), PluginFileUtils.f9792a, "755");
            if (a4 != null) {
                return PluginFileUtils.a(a4.getAbsoluteFile(), str, "755");
            }
        }
        if (z) {
            try {
                File a5 = (!D.hasSdcard() || (qQBrowserDownloadDir = D.getQQBrowserDownloadDir()) == null || (a3 = FileUtilsF.a(qQBrowserDownloadDir, PluginFileUtils.f9792a)) == null) ? null : FileUtilsF.a(a3, str);
                return (a5 != null || (a2 = PluginFileUtils.a(context)) == null || FileUtilsF.f(context) < 20971520) ? a5 : FileUtilsF.a(a2, str);
            } catch (Throwable unused) {
                return null;
            }
        }
        try {
            File a6 = StorageDirs.a(PluginFileUtils.f9792a);
            if (a6 == null) {
                PluginStatBehavior.c(str, 3, 5181);
                return null;
            }
            File a7 = FileUtilsF.a(a6, str);
            if (a7 == null) {
                PluginStatBehavior.c(str, 3, 5183);
            }
            return a7;
        } catch (Throwable unused2) {
            PluginStatBehavior.c(str, 3, 5184);
            return null;
        }
    }

    static String a(WUPResponseBase wUPResponseBase, UniPluginRsp uniPluginRsp) {
        String str;
        StringBuilder sb = new StringBuilder();
        sb.append(334);
        sb.append("(rsp");
        if (uniPluginRsp == null) {
            sb.append("_null");
        } else {
            sb.append("_");
            sb.append(uniPluginRsp.sMd5);
            sb.append("_");
            sb.append(uniPluginRsp.vPluginList == null ? IAPInjectService.EP_NULL : Integer.valueOf(uniPluginRsp.vPluginList.size()));
        }
        if (Build.VERSION.SDK_INT >= 19) {
            Objects.requireNonNull(wUPResponseBase);
        }
        sb.append("_wup");
        Map<String, List<String>> resHeaders = wUPResponseBase.getResHeaders();
        List<String> list = resHeaders == null ? null : resHeaders.get("Content-Length");
        if (list == null || list.size() <= 0) {
            str = "_unknown";
        } else {
            sb.append("_");
            str = list.get(0);
        }
        sb.append(str);
        byte[] orglResponseData = wUPResponseBase.getOrglResponseData();
        if (orglResponseData == null) {
            sb.append("_null");
        } else {
            sb.append("_");
            sb.append(orglResponseData.length);
        }
        sb.append(")");
        return sb.toString();
    }

    private void a(int i2, IPluginDir iPluginDir) {
        for (IPluginLocalConfigExt iPluginLocalConfigExt : (IPluginLocalConfigExt[]) AppManifest.getInstance().queryExtensions(IPluginLocalConfigExt.class)) {
            Map<String, PluginConfigInfo> addPluginLocalConfig = iPluginLocalConfigExt.addPluginLocalConfig(i2, iPluginDir);
            if (addPluginLocalConfig != null) {
                for (Map.Entry<String, PluginConfigInfo> entry : addPluginLocalConfig.entrySet()) {
                    B.put(entry.getKey(), entry.getValue());
                    FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "initPluginConfigInfo: " + entry.getKey() + " -> " + entry.getValue() + "");
                }
            }
        }
    }

    private void a(QBPluginItemInfo qBPluginItemInfo, int i2, int i3, int i4) {
        Message obtainMessage = e().obtainMessage();
        obtainMessage.obj = qBPluginItemInfo;
        obtainMessage.what = i2;
        obtainMessage.arg1 = i3;
        obtainMessage.arg2 = i4;
        e().sendMessage(obtainMessage);
    }

    public static void a(IPluginLoader iPluginLoader) {
        F = iPluginLoader;
    }

    private void a(PluginCallbackHandler pluginCallbackHandler) {
        pluginCallbackHandler.a(this);
        this.S = pluginCallbackHandler;
        this.S.a(this.t);
    }

    public static boolean a() {
        return W.get() < 4;
    }

    static boolean a(UniPluginRsp uniPluginRsp) {
        return uniPluginRsp == null;
    }

    public static Signature[] a(String str, String str2) {
        JarFile jarFile;
        boolean z;
        byte[] bArr = new byte[8192];
        JarFile jarFile2 = null;
        try {
            try {
                jarFile = new JarFile(str);
                try {
                    Enumeration<JarEntry> entries = jarFile.entries();
                    Certificate[] certificateArr = null;
                    loop0: while (true) {
                        if (!entries.hasMoreElements()) {
                            if (certificateArr == null || certificateArr.length <= 0) {
                                PluginStatBehavior.c(str2, 3, 5174);
                                try {
                                    jarFile.close();
                                } catch (IOException unused) {
                                }
                                return null;
                            }
                            int length = certificateArr.length;
                            Signature[] signatureArr = new Signature[certificateArr.length];
                            for (int i2 = 0; i2 < length; i2++) {
                                signatureArr[i2] = new Signature(certificateArr[i2].getEncoded());
                            }
                            try {
                                jarFile.close();
                            } catch (IOException unused2) {
                            }
                            return signatureArr;
                        }
                        JarEntry nextElement = entries.nextElement();
                        if (!nextElement.isDirectory() && !nextElement.getName().startsWith("META-INF/")) {
                            Certificate[] a2 = a(jarFile, nextElement, bArr, str2);
                            if (a2 == null) {
                                try {
                                    jarFile.close();
                                } catch (IOException unused3) {
                                }
                                return null;
                            }
                            if (certificateArr != null) {
                                for (int i3 = 0; i3 < certificateArr.length; i3++) {
                                    int i4 = 0;
                                    while (true) {
                                        if (i4 >= a2.length) {
                                            z = false;
                                            break;
                                        }
                                        if (certificateArr[i3] != null && certificateArr[i3].equals(a2[i4])) {
                                            z = true;
                                            break;
                                        }
                                        i4++;
                                    }
                                    if (!z || certificateArr.length != a2.length) {
                                        break loop0;
                                    }
                                }
                            } else {
                                certificateArr = a2;
                            }
                        }
                    }
                    return null;
                } catch (Exception e2) {
                    e = e2;
                    String message = e.getMessage();
                    PluginStatBehavior.i(str2, 3, 5170 + message);
                    if (TextUtils.isEmpty(message) || !message.toLowerCase().contains("invalid digest")) {
                        if (jarFile != null) {
                            try {
                                jarFile.close();
                            } catch (IOException unused4) {
                            }
                        }
                        return null;
                    }
                    PluginStatBehavior.a(str2, 3, 517);
                    if (jarFile != null) {
                        try {
                            jarFile.close();
                        } catch (IOException unused5) {
                        }
                    }
                    return null;
                }
            } catch (Throwable th) {
                th = th;
                if (0 != 0) {
                    try {
                        jarFile2.close();
                    } catch (IOException unused6) {
                    }
                }
                throw th;
            }
        } catch (Exception e3) {
            e = e3;
            jarFile = null;
        } catch (Throwable th2) {
            th = th2;
            if (0 != 0) {
            }
            throw th;
        }
    }

    private static Certificate[] a(JarFile jarFile, JarEntry jarEntry, byte[] bArr, String str) {
        InputStream inputStream;
        try {
            try {
                inputStream = jarFile.getInputStream(jarEntry);
                do {
                    try {
                    } catch (IOException e2) {
                        e = e2;
                        PluginStatBehavior.i(str, 3, 5172 + e.getMessage());
                    } catch (RuntimeException e3) {
                        e = e3;
                        PluginStatBehavior.i(str, 3, 5171 + e.getMessage());
                    }
                } while (inputStream.read(bArr, 0, bArr.length) != -1);
                inputStream.close();
                Certificate[] certificates = jarEntry != null ? jarEntry.getCertificates() : null;
                if (certificates == null) {
                    PluginStatBehavior.c(str, 3, 5175);
                }
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    } catch (IOException unused) {
                    }
                }
                return certificates;
            } catch (Throwable th) {
                th = th;
                if (jarFile != 0) {
                    try {
                        jarFile.close();
                    } catch (IOException unused2) {
                    }
                }
                throw th;
            }
        } catch (IOException e4) {
            e = e4;
            inputStream = null;
        } catch (RuntimeException e5) {
            e = e5;
            inputStream = null;
        } catch (Throwable th2) {
            th = th2;
            jarFile = 0;
            if (jarFile != 0) {
            }
            throw th;
        }
    }

    public static PluginConfigInfo b(String str) {
        PluginConfigInfo pluginConfigInfo;
        synchronized (B) {
            pluginConfigInfo = B.get(str);
        }
        return pluginConfigInfo;
    }

    static synchronized void b(Context context, String str) {
        FileLock fileLock;
        RandomAccessFile randomAccessFile;
        FileLock fileLock2;
        FileChannel channel;
        synchronized (QBPluginServiceImpl.class) {
            if (TbsMode.TBSISQB()) {
                return;
            }
            String packageName = context.getPackageName();
            if (TextUtils.isEmpty(packageName)) {
                return;
            }
            FileChannel fileChannel = null;
            r2 = null;
            FileLock fileLock3 = null;
            r2 = null;
            fileChannel = null;
            FileChannel fileChannel2 = null;
            try {
                try {
                    String str2 = FileUtils.h(context).getAbsolutePath() + "/" + packageName + "_" + str + "_pid";
                    FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "downloadPlugin deletePidFile write processid -1 to file=" + str2);
                    randomAccessFile = new RandomAccessFile(str2, "rws");
                    try {
                        channel = randomAccessFile.getChannel();
                    } catch (Exception unused) {
                        fileLock2 = null;
                    } catch (Throwable th) {
                        th = th;
                        fileLock = null;
                    }
                } catch (IOException unused2) {
                }
            } catch (Exception unused3) {
                fileLock2 = null;
                randomAccessFile = null;
            } catch (Throwable th2) {
                th = th2;
                fileLock = null;
                randomAccessFile = null;
            }
            try {
                fileLock3 = channel.lock();
                randomAccessFile.seek(0L);
                randomAccessFile.writeInt(-1);
                randomAccessFile.close();
                FileUtilsF.a(channel);
                FileUtilsF.a(randomAccessFile);
            } catch (Exception unused4) {
                FileLock fileLock4 = fileLock3;
                fileChannel2 = channel;
                fileLock2 = fileLock4;
                FileUtilsF.a(fileChannel2);
                FileUtilsF.a(randomAccessFile);
                if (fileLock2 != null) {
                    fileLock2.release();
                }
            } catch (Throwable th3) {
                th = th3;
                FileLock fileLock5 = fileLock3;
                fileChannel = channel;
                fileLock = fileLock5;
                FileUtilsF.a(fileChannel);
                FileUtilsF.a(randomAccessFile);
                if (fileLock != null) {
                    try {
                        fileLock.release();
                    } catch (IOException unused5) {
                    }
                }
                throw th;
            }
            if (fileLock3 != null) {
                fileLock3.release();
            }
        }
    }

    private void b(String str, int i2, int i3, IInstallPluginCallback iInstallPluginCallback, QBPluginItemInfo qBPluginItemInfo, boolean z) throws RemoteException {
        String str2;
        int i4;
        boolean z2;
        if (TextUtils.isEmpty(qBPluginItemInfo.mDownloadDir) || TextUtils.isEmpty(qBPluginItemInfo.mDownloadFileName)) {
            a(qBPluginItemInfo, k, 6001, i2);
            return;
        }
        String str3 = qBPluginItemInfo.mDownloadDir + "/" + qBPluginItemInfo.mDownloadFileName;
        PluginStatBehavior.b(str, 3);
        PluginStatBehavior.e(str, 3, str3 + ";installFrom=" + z);
        if (iInstallPluginCallback != null && !iInstallPluginCallback.canInstallPlugin(str, qBPluginItemInfo)) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "installPluginImpl,pluginName:" + str + " user not permit to install");
            PluginStatBehavior.c(str, 3, 564);
            PluginStatBehavior.a(str, 3, 564);
            a(qBPluginItemInfo, k, 6002, i2);
            return;
        }
        int b2 = StringUtils.b(qBPluginItemInfo.mVersion, -1);
        String str4 = qBPluginItemInfo.mMd5;
        File file = new File(str3);
        int a2 = a(str, file, qBPluginItemInfo, i3, b2, str4, z);
        if (a2 != 0) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "installPluginImpl(" + str + ") preInstallCheck=false");
            if (file.exists()) {
                FileUtilsF.b(file);
            }
            a(qBPluginItemInfo, k, a2, i2);
            return;
        }
        if (i3 != 1) {
            if (i3 != 2) {
                switch (i3) {
                    case 9:
                        z2 = PluginUtils.a(b(), d(), str3, str, b2, qBPluginItemInfo, iInstallPluginCallback, i2);
                        str2 = "installPluginImpl(";
                        break;
                    case 10:
                    case 12:
                    case 13:
                        str2 = "installPluginImpl(";
                        z2 = PluginUtils.a(b(), d(), file, str3, str, b2, qBPluginItemInfo, iInstallPluginCallback, i2);
                        break;
                    case 11:
                        str2 = "installPluginImpl(";
                        z2 = PluginUtils.b(b(), d(), str3, str, b2, qBPluginItemInfo, iInstallPluginCallback, i2);
                        break;
                    default:
                        str2 = "installPluginImpl(";
                        z2 = false;
                        break;
                }
            } else {
                str2 = "installPluginImpl(";
                z2 = PluginUtils.a(b(), d(), str3, str, 2, b2, str4, qBPluginItemInfo, i2);
            }
            i4 = 0;
        } else {
            str2 = "installPluginImpl(";
            int a3 = ZipPluginUtils.a(b(), d(), file, str3, str, b2, str4, qBPluginItemInfo, i2);
            i4 = a3;
            z2 = a3 == 0;
        }
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, str2 + str + ") needNotify= installRet=" + z2 + " installRetCode=" + i4);
        if (!z2) {
            a(qBPluginItemInfo, k, i4, i2);
            if (file.exists()) {
                file.delete();
                return;
            }
            return;
        }
        QBPluginDBHelper.a(d()).e(str, b2 + "", i2);
        a(qBPluginItemInfo, i, i4, i2);
    }

    static boolean b(UniPluginRsp uniPluginRsp) {
        return a(uniPluginRsp) || uniPluginRsp.vPluginList == null;
    }

    public static boolean b(String str, String str2, int i2) {
        try {
            Signature[] a2 = a(str, str2);
            if (a2 != null && a2.length > 0) {
                Signature signature = a2[0];
                if (k().equals(signature)) {
                    return true;
                }
                PluginStatBehavior.c(str2, 3, k().toString());
                if (signature != null) {
                    PluginStatBehavior.a(str2, 3, signature.toString());
                }
                PluginStatBehavior.a(str2, 3, 517);
                return false;
            }
        } catch (NoSuchMethodError unused) {
        }
        return true;
    }

    public static IPluginRelateFunc c(int i2) {
        return E;
    }

    public static String c(String str) {
        if (str.split("\\.") != null) {
            str = str.split("\\.")[str.split("\\.").length - 1];
        }
        return "_" + str.toUpperCase();
    }

    static boolean c(UniPluginRsp uniPluginRsp) {
        return a(uniPluginRsp) || TextUtils.isEmpty(uniPluginRsp.sMd5) || uniPluginRsp.sMd5.length() < 32;
    }

    private int d(String str, String str2, int i2) {
        synchronized (this.I) {
            PluginStatBehavior.b("PluginList", PluginStatBehavior.a(i2));
            PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), 311);
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "requestPluginList: " + str + ",reqStatus=" + d(i2));
            WUPRequestBase c2 = c(str, str2, i2);
            if (c2 == null) {
                return O;
            }
            if (WUPTaskProxy.send(c2)) {
                FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginRequest  :Send Out");
                c(1, i2);
                PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), 313);
                return P;
            }
            c(3, i2);
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginRequest  :Send Failed");
            PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), 314);
            PluginStatBehavior.a("PluginList", PluginStatBehavior.a(i2), 314);
            return K;
        }
    }

    public static boolean e(String str) {
        try {
            Signature[] a2 = SignatureUtil.a(str);
            if (a2 == null || a2.length <= 0) {
                return a2 == null;
            }
            return k().equals(a2[0]);
        } catch (Throwable unused) {
            return true;
        }
    }

    public static synchronized QBPluginServiceImpl g() {
        QBPluginServiceImpl qBPluginServiceImpl;
        synchronized (QBPluginServiceImpl.class) {
            if (A == null) {
                A = new QBPluginServiceImpl();
            }
            qBPluginServiceImpl = A;
        }
        return qBPluginServiceImpl;
    }

    public static boolean h(int i2) {
        return ((i2 & 1) == 0 && (i2 & 4) == 0) ? false : true;
    }

    public static Signature k() {
        if (X == null) {
            X = new Signature("30820257308201c0a00302010202044e9d598c300d06092a864886f70d01010505003070310b30090603550406130238363110300e060355040813075369436875616e3110300e060355040713074368656e6744753110300e060355040a130754656e63656e743110300e060355040b130754656e63656e743119301706035504031310506c7567696e20515142726f77736572301e170d3131313031383130343834345a170d3431313031303130343834345a3070310b30090603550406130238363110300e060355040813075369436875616e3110300e060355040713074368656e6744753110300e060355040a130754656e63656e743110300e060355040b130754656e63656e743119301706035504031310506c7567696e20515142726f7773657230819f300d06092a864886f70d010101050003818d00308189028181008c48633deb6c0f4876ec16f8955ee0b773f320d3aa3e7339f0469e40730d0251d1d26c85fd5e39ddc8ecca5a98c1493ce52c9fb1bda6b3e015ccf71a8ebb0817f60c4c523269ecd0afdef21c9faf862bc69bbb8df6e88376f9f87f0139e323b73dc1b59172de5a2789f1895a3cc65d784ad3dd0919231d90f8f19c778698d1210203010001300d06092a864886f70d010105050003818100210e39580e198469e63f6fc43557295c94ebb60f0a4c81b3c15749b69f85ad8d9a0ef006137c5a1f624cc535fa30d54052477a9246266973f09b3189818a77f7a1039de32b74777e2838c4c5f81b2198531f3cf8a0b4a4fecbaf9ee3536e1b15dee7f28e389e2aff656afa6f4bb408f1910c75180250be64b720a1179df64b20");
        }
        return X;
    }

    private void l(int i2) {
        synchronized (this.Y) {
            Iterator<AsynGetPluginInfo> it = this.Y.iterator();
            while (it.hasNext()) {
                AsynGetPluginInfo next = it.next();
                if (next != null && !TextUtils.isEmpty(next.f9855a) && next.f9856b != null) {
                    QBPluginItemInfo c2 = QBPluginDBHelper.a(d()).c(next.f9855a, next.f9857c);
                    FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "callGetPluginInfoBack retCode=" + i2 + ",callback.pkgName=" + next.f9855a + ",callback.infoFrom=" + next.f9857c + ",pluginItemInfo=" + c2);
                    try {
                        PluginStatBehavior.i(next.f9855a, 4, "mem=" + QBPluginDBHelper.a(d()).f9812d + "_" + QBPluginDBHelper.a(d()).f);
                        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + next.f9855a + ",infoFrom=0 callGetPluginInfoBack");
                        next.f9856b.onRecvPluignInfo(next.f9855a, i2, c2);
                    } catch (RemoteException unused) {
                        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + next.f9855a + ",infoFrom=0 nocallGetPluginInfoBack Exception");
                    }
                }
            }
            this.Y.clear();
        }
    }

    static String o() {
        return Process.myPid() + "_" + System.currentTimeMillis() + "_" + PluginUtils.a() + "_" + H + "_" + PluginUtils.b();
    }

    private void p() {
        if (D != null) {
            synchronized (B) {
                File specialInstallDir = D.getSpecialInstallDir(13);
                if (specialInstallDir != null) {
                    B.put("com.tencent.qb.plugin.mipush", new PluginConfigInfo(13, "6800", specialInstallDir.getAbsolutePath(), "com.tencent.mtt.mipush.jar"));
                }
                a(1, D);
            }
        }
    }

    @Override
    public int a(String str, int i2, int i3, QBPluginItemInfo qBPluginItemInfo) throws RemoteException {
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "downloadPlugin: " + str + ",infoFrom=" + i2 + ",taskFlag=" + i3);
        PluginStatBehavior.b(str, 2);
        c(str);
        Integer[] numArr = {null};
        QBPluginItemInfo a2 = a(str, i2, numArr);
        QBPluginItemInfo qBPluginItemInfo2 = qBPluginItemInfo == null ? a2 : qBPluginItemInfo;
        if (a2 == null || qBPluginItemInfo2 == null) {
            if (!ConnectivityDetector.a()) {
                PluginStatBehavior.c(str, 2, 433);
                PluginStatBehavior.a(str, 2, 433);
                return 3018;
            }
            PluginStatBehavior.i(str, 2, "420(cnn_" + PluginStatBehavior.d("PluginDB", 7) + ")");
            if (numArr[0] == null || numArr[0].intValue() != 332) {
                PluginStatBehavior.a(str, 2, 420);
                return 3015;
            }
            PluginStatBehavior.a(str, 2, 332);
            return 332;
        }
        boolean z = (qBPluginItemInfo == null || TextUtils.isEmpty(qBPluginItemInfo.mVersion) || TextUtils.isEmpty(a2.mVersion) || qBPluginItemInfo.mVersion.equalsIgnoreCase(a2.mVersion)) ? false : true;
        if (TbsMode.thirdTbsMode() && !a(str)) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "DownloadPlugin " + str + " Third App and not special package");
            PluginStatBehavior.c(str, 2, 423);
            PluginStatBehavior.a(str, 2, 423);
            return 3016;
        }
        boolean a3 = TbsMode.TBSISQB() ? true : a(b(), str);
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "DownloadPlugin " + str + " canDownloadPlugIn=" + a3);
        if (!a3) {
            PluginStatBehavior.c(str, 2, 424);
            PluginStatBehavior.a(str, 2, 424);
            return 3011;
        }
        i(i2);
        try {
            PluginStatBehavior.i(str, 4, "436(call:20_" + System.currentTimeMillis() + ")");
            if (c(str, i2, qBPluginItemInfo2)) {
                PluginStatBehavior.c(str, 2, 417);
                DownloadTask b2 = this.V.b(qBPluginItemInfo2.mUrl);
                if (b2 != null && b2.U() == 3) {
                    FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "downloadPlugin " + str + "  newViersionFile is already on disk. call onTaskCompleted directly.");
                    onTaskCompleted(PluginUtils.a(b2, qBPluginItemInfo2, i2));
                    return 0;
                }
                PluginStatBehavior.c(str, 2, 418);
            }
        } catch (RemoteException unused) {
        }
        boolean c2 = this.V.c(qBPluginItemInfo2.mUrl);
        DownloadInfo downloadInfo = new DownloadInfo();
        downloadInfo.f37604a = qBPluginItemInfo2.mUrl;
        if (!TextUtils.isEmpty(qBPluginItemInfo2.mPackageSize)) {
            long a4 = StringUtils.a(qBPluginItemInfo2.mPackageSize, -1L);
            if (a4 > 0 && !TextUtils.isEmpty(qBPluginItemInfo2.mAntiHijackUrl)) {
                FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "addAnitHijackUrl=" + qBPluginItemInfo2.mAntiHijackUrl);
                PluginStatBehavior.c(str, 2, e.CTRL_INDEX);
                downloadInfo.f37605b = new ArrayList();
                downloadInfo.f37605b.add(qBPluginItemInfo2.mAntiHijackUrl);
                downloadInfo.f37607d = a4;
            }
        }
        File a5 = a(b(), qBPluginItemInfo2.mUrl, str);
        PluginStatBehavior.a(str, "437(0:downloadPlugin_" + a5 + ")", 2, 4);
        if (a5 != null) {
            downloadInfo.f = a5.getAbsolutePath();
        }
        if (!c2 && !z && !TextUtils.isEmpty(downloadInfo.f) && (TextUtils.isEmpty(qBPluginItemInfo2.mInstallDir) || !qBPluginItemInfo2.mInstallDir.toLowerCase().contains(downloadInfo.f.toLowerCase()))) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "downloadDir=" + downloadInfo.f + ",installDir=" + qBPluginItemInfo2.mInstallDir + ",will delete all the downloadedFile isTaskDowning=" + c2 + ",maybeNewverion=" + z);
            if ((TbsMode.TBSISQB() && !downloadInfo.f.toLowerCase().startsWith("/data")) || !TbsMode.TBSISQB()) {
                try {
                    PluginStatBehavior.c(str, 2, 426);
                    PluginStatBehavior.c(str, 4, 426);
                    FileUtilsF.c(a5);
                } catch (IOException | IllegalArgumentException unused2) {
                }
            }
        }
        qBPluginItemInfo2.mDownloadDir = downloadInfo.f;
        QBPluginDBHelper.a(g().d()).c(str, qBPluginItemInfo2.mDownloadDir, i2);
        downloadInfo.H |= 32;
        downloadInfo.B = Priority.HIGH;
        downloadInfo.O = true;
        downloadInfo.n = str;
        downloadInfo.o = i2 + "";
        if (qBPluginItemInfo2.mUrl.toLowerCase().endsWith(".zip")) {
            downloadInfo.f37606c = str + qBPluginItemInfo2.mVersion + ".zip";
        }
        PluginStatBehavior.d(str, 2, qBPluginItemInfo2.mDownloadDir);
        PluginStatBehavior.f(str, 2, downloadInfo.f37606c);
        IPluginRelateFunc iPluginRelateFunc = E;
        if (!h(i3)) {
            if (iPluginRelateFunc != null) {
                iPluginRelateFunc.platformAction("QBPLUGIN_864152143_FLOWCTRL_NOT_BACKGROUND_DOWNLOAD");
            }
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "ignore flowctrl: url=" + downloadInfo.f37604a);
            this.G.b(downloadInfo.f37604a);
            TBSPluginCallbackHandler.MessageDetail a6 = TBSPluginCallbackHandler.MessageDetail.a(new QBPluginSystem.PluginPkgKey(str, i2));
            if (a6 != null) {
                this.S.removeMessages(g, a6);
            }
            downloadInfo.H = a(downloadInfo.H, c2, false);
            return a(str, downloadInfo);
        }
        if (iPluginRelateFunc != null) {
            iPluginRelateFunc.platformAction("QBPLUGIN_864152143_FLOWCTRL_START");
            iPluginRelateFunc.platformAction("QBPLUGIN_864152143_FLOWCTRL_START_" + str);
        }
        FlowCtrlTag flowCtrlTag = new FlowCtrlTag();
        flowCtrlTag.f9859b = downloadInfo;
        flowCtrlTag.f9858a = str;
        flowCtrlTag.f9860c = i3;
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "start flowctrl:tag=" + flowCtrlTag + " url=" + downloadInfo.f37604a);
        PluginStatBehavior.a(flowCtrlTag.f9858a, "438(start_" + downloadInfo.f37604a + "_" + i3 + ")", 2, 4);
        this.G.a(downloadInfo.f37604a, flowCtrlTag);
        return 0;
    }

    int a(String str, DownloadInfo downloadInfo) {
        DownloadTask b2 = this.V.b(downloadInfo);
        int i2 = b2 == null ? 0 : b2.i();
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "DownloadPlugin, mDownloadManager.startDownload()=" + i2 + ", packageName=" + str);
        if (i2 > 0) {
            PluginStatBehavior.i(str, 2, "421(" + System.currentTimeMillis() + ")");
            PluginStatBehavior.i(str, 4, "421(" + System.currentTimeMillis() + ")");
            return 0;
        }
        PluginStatBehavior.i(str, 2, "416(" + i2 + ")");
        PluginStatBehavior.i(str, 4, "416(" + i2 + ")");
        PluginStatBehavior.a(str, 2, 416);
        return 3011;
    }

    @Override
    public QBPluginItemInfo a(String str, int i2) throws RemoteException {
        return a(str, i2, (Integer[]) null);
    }

    protected QBPluginItemInfo a(String str, final int i2, Integer[] numArr) throws RemoteException {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        if (TbsMode.thirdTbsMode() && !a(str)) {
            QBPluginItemInfo qBPluginItemInfo = new QBPluginItemInfo();
            qBPluginItemInfo.mPackageName = str;
            qBPluginItemInfo.mUpdateType = 0;
            File a2 = a(c(), (String) null, str);
            if (a2 != null) {
                qBPluginItemInfo.mDownloadDir = a2.getAbsolutePath();
            }
            File a3 = a(c(), str, true);
            if (a3 != null) {
                qBPluginItemInfo.mInstallDir = a3.getAbsolutePath();
                qBPluginItemInfo.mIsInstall = a3.exists() ? 1 : 0;
                qBPluginItemInfo.mUnzipDir = a3.getAbsolutePath();
            } else {
                qBPluginItemInfo.mIsInstall = 0;
            }
            return qBPluginItemInfo;
        }
        BrowserExecutorSupplier.postForBackgroundTasks(new BrowserExecutorSupplier.BackgroundRunable() {
            @Override
            public void doRun() {
                QBPluginServiceImpl.this.a((String) null, "Visit_getPluignInfo", (AsynGetPluginInfo) null, i2);
            }
        });
        QBPluginItemInfo c2 = QBPluginDBHelper.a(d()).c(str, i2);
        if (c2 == null || b(str) == null || b(str).compatableId.equals(c2.mPluginCompatiID)) {
            return c2;
        }
        String str2 = "332(" + b(str).compatableId + "_" + c2.mPluginCompatiID + "_" + c2.mVersion + "_" + PluginStatBehavior.d("PluginDB", 7) + ")";
        PluginStatBehavior.i(str, 2, str2);
        PluginStatBehavior.i(str, 4, str2);
        if (numArr != null && numArr.length >= 1) {
            numArr[0] = 332;
        }
        return null;
    }

    public WUPRequestBase a(String str, String str2, int i2) {
        String str3;
        if (d(i2) == 1) {
            PluginStatBehavior.i("PluginList", PluginStatBehavior.a(i2), "312(" + Thread.currentThread().getId() + ")");
            PluginStatBehavior.a("PluginList", PluginStatBehavior.a(i2));
            return null;
        }
        PluginStatBehavior.b("PluginList", PluginStatBehavior.a(i2));
        PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), IReader.SET_FIND_NEXT);
        UniPluginReq uniPluginReq = new UniPluginReq();
        String a2 = QBPluginProxy.a();
        uniPluginReq.iSDKVersion = GdiMeasureImpl.b();
        if (TextUtils.isEmpty(a2)) {
            a2 = PluginSetting.a(b()).b();
        } else {
            PluginSetting.a(b()).a(a2);
        }
        uniPluginReq.strCpu = a2;
        uniPluginReq.vGuid = c(i2).getByteGuid();
        uniPluginReq.sQua = c(i2).getQUA();
        if (i2 == 1) {
            str3 = "SR=QB";
        } else {
            if (i2 != 2) {
                PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), 331);
                PluginStatBehavior.a("PluginList", PluginStatBehavior.a(i2), 331);
                return null;
            }
            str3 = "SR=TBS";
        }
        uniPluginReq.sQua2ExInfo = str3;
        PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), uniPluginReq.sQua2ExInfo + IActionReportService.COMMON_SEPARATOR + uniPluginReq.sMd5 + IActionReportService.COMMON_SEPARATOR + uniPluginReq.strCpu);
        PluginStatBehavior.a("PluginList", PluginStatBehavior.a(i2), uniPluginReq.sQua + Constants.ACCEPT_TIME_SEPARATOR_SERVER + uniPluginReq.strCpu + ",req.sMd5=" + uniPluginReq.sMd5);
        PluginStatBehavior.e("PluginList", PluginStatBehavior.a(i2), str2);
        PluginStatBehavior.d("PluginList", PluginStatBehavior.a(i2), o());
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "requestPluginList  iSDKVersion:" + uniPluginReq.iSDKVersion + " strCpu: " + uniPluginReq.strCpu + " sMd5: " + uniPluginReq.sMd5 + " vGuid: " + uniPluginReq.vGuid + " sQua: " + uniPluginReq.sQua);
        WUPRequestBase wUPRequestBase = new WUPRequestBase("uniplugin", "getPluginList", this);
        if (PluginSetting.a(x).a()) {
            wUPRequestBase.setUrl("http://14.17.41.197:18000");
        }
        wUPRequestBase.put("stReq", uniPluginReq);
        wUPRequestBase.setBindObject(str);
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "requestPluginList  :" + str + " infoFrom=" + i2);
        wUPRequestBase.setType((byte) i2);
        return wUPRequestBase;
    }

    @Override
    public List<QBPluginItemInfo> a(final int i2) throws RemoteException {
        BrowserExecutorSupplier.postForBackgroundTasks(new BrowserExecutorSupplier.BackgroundRunable() {
            @Override
            public void doRun() {
                QBPluginServiceImpl.this.a((String) null, "Visit_getAllList", (AsynGetPluginInfo) null, i2);
            }
        });
        return QBPluginDBHelper.a(d()).a(i2);
    }

    public void a(IDownloadSpecicalWhiteList iDownloadSpecicalWhiteList) {
        this.C = iDownloadSpecicalWhiteList;
    }

    @Override
    public void a(IQBPluginCallback iQBPluginCallback, int i2) throws RemoteException {
        IPluginLoader iPluginLoader;
        if (i2 == 2 && !this.Z && (iPluginLoader = F) != null) {
            this.Z = iPluginLoader.tbsPluginLoader();
        }
        iQBPluginCallback.a(this.Z, i2);
    }

    void a(WUPRequestBase wUPRequestBase) {
        byte type = wUPRequestBase.getType();
        if (PluginSetting.a(b()).c(type)) {
            return;
        }
        Message obtainMessage = this.S.obtainMessage(n);
        obtainMessage.arg1 = type;
        this.S.sendMessageDelayed(obtainMessage, this.aa);
        this.aa *= 2;
        if (this.aa > DateUtils.ONE_HOUR) {
            this.aa = DateUtils.ONE_HOUR;
        }
    }

    public void a(IDownloadManager iDownloadManager) {
        this.V = iDownloadManager;
        this.V.a(this);
    }

    @Override
    public void a(Object obj, int i2, long j2) {
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "onFlowCtrlDelayed: tag=" + obj + ", type=" + i2 + ", delayMillis=" + j2);
        FlowCtrlTag flowCtrlTag = (FlowCtrlTag) obj;
        IPluginRelateFunc iPluginRelateFunc = E;
        if (iPluginRelateFunc != null) {
            iPluginRelateFunc.platformAction("QBPLUGIN_864152143_FLOWCTRL_DELAYED");
            iPluginRelateFunc.platformAction("QBPLUGIN_864152143_FLOWCTRL_DELAYED_" + flowCtrlTag.f9858a);
        }
        int b2 = StringUtils.b(flowCtrlTag.f9859b.o, 0);
        if (b2 == 0) {
            return;
        }
        TBSPluginCallbackHandler.MessageDetail messageDetail = new TBSPluginCallbackHandler.MessageDetail();
        messageDetail.f9903b = b2;
        messageDetail.f = 3035;
        messageDetail.f9902a = flowCtrlTag.f9858a;
        messageDetail.e = -1;
        messageDetail.f9905d = flowCtrlTag.f9859b.f37604a;
        messageDetail.a();
        Message obtainMessage = this.S.obtainMessage();
        obtainMessage.what = g;
        obtainMessage.obj = messageDetail;
        obtainMessage.arg1 = messageDetail.f9903b;
        this.S.sendMessage(obtainMessage);
        PluginStatBehavior.a(flowCtrlTag.f9858a, "438(delayed_" + j2 + ")", 2, 4);
        PluginStatBehavior.a(flowCtrlTag.f9858a, 2, 438);
    }

    @Override
    public void a(String str, int i2, int i3) {
        QBPluginDBHelper.a(d()).a(str, i2, i3);
    }

    @Override
    public void a(String str, int i2, int i3, IInstallPluginCallback iInstallPluginCallback, QBPluginItemInfo qBPluginItemInfo, boolean z) throws RemoteException {
        QBPluginSystem.PluginPkgKey pluginPkgKey = new QBPluginSystem.PluginPkgKey(str, i2);
        synchronized (this.u) {
            if (this.u.contains(pluginPkgKey)) {
                return;
            }
            this.u.add(pluginPkgKey);
            if (!a(b(), str)) {
                a(qBPluginItemInfo, k, 6011, i2);
                return;
            }
            b(str, i2, i3, iInstallPluginCallback, qBPluginItemInfo, z);
            f(str);
            synchronized (this.u) {
                this.u.remove(pluginPkgKey);
            }
        }
    }

    public void a(byte[] bArr) {
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "handlePushRet");
        PluginSetting.a(b()).a(1, false);
        PluginSetting.a(b()).a(2, false);
        a((String) null, "PushNotify", (AsynGetPluginInfo) null, 1);
        a((String) null, "PushNotify", (AsynGetPluginInfo) null, 2);
    }

    public synchronized boolean a(Context context, Context context2, boolean z) {
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "initApplicationCommon=" + this);
        if (!W.compareAndSet(0, 1)) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "PluginSystem Init initApplicationContext : already init");
            return true;
        }
        x = context;
        y = context2;
        PluginStatBehavior.a(x);
        f();
        W.compareAndSet(1, 2);
        return true;
    }

    public synchronized boolean a(Context context, String str) {
        FileChannel fileChannel;
        boolean z;
        if (TbsMode.TBSISQB()) {
            return true;
        }
        int myPid = Process.myPid();
        String packageName = context.getPackageName();
        StringBuilder sb = new StringBuilder();
        ?? r5 = "canMultiProcessPlugin getPkgName=";
        sb.append("canMultiProcessPlugin getPkgName=");
        sb.append(packageName);
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, sb.toString());
        if (TextUtils.isEmpty(packageName)) {
            return true;
        }
        ?? h2 = FileUtils.h(context);
        if (h2 == 0 || !h2.exists()) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "canMultiProcessPlugin getTesCorePrivateDir is= not exits");
            return true;
        }
        FileLock fileLock = null;
        try {
            try {
                r5 = new RandomAccessFile(h2.getAbsolutePath() + "/" + packageName + "_" + str + "_pid", "rws");
            } catch (Throwable th) {
                th = th;
            }
            try {
                fileChannel = r5.getChannel();
                try {
                    FileLock lock = fileChannel.lock();
                    int readInt = r5.length() != 0 ? r5.readInt() : -1;
                    FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "canMultiProcessPlugin Host:" + packageName + ",plugin:" + str + "theDownloadingProcessId is=" + readInt);
                    if (readInt == -1) {
                        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "canMultiProcessPlugin Host:" + packageName + ",plugin:" + str + " downloaderID =" + myPid);
                        r5.seek(0L);
                        r5.writeInt(myPid);
                        if (lock != null) {
                            try {
                                lock.release();
                            } catch (IOException unused) {
                            }
                        }
                        FileUtilsF.a(fileChannel);
                        FileUtilsF.a((Closeable) r5);
                        return true;
                    }
                    FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "canMultiProcessPlugin Host:" + packageName + ",plugin:" + str + " theDownloadingProcessId" + readInt + ",SELF");
                    if (readInt == myPid) {
                        if (lock != null) {
                            try {
                                lock.release();
                            } catch (IOException unused2) {
                            }
                        }
                        FileUtilsF.a(fileChannel);
                        FileUtilsF.a((Closeable) r5);
                        return true;
                    }
                    Iterator<ActivityManager.RunningAppProcessInfo> it = ((ActivityManager) context.getSystemService("activity")).getRunningAppProcesses().iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            z = false;
                            break;
                        }
                        ActivityManager.RunningAppProcessInfo next = it.next();
                        if (next.pid == readInt) {
                            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "canMultiProcessPlugin Host:" + packageName + ",plugin:" + str + " appProcess.processName" + next.processName + ",活着");
                            z = true;
                            break;
                        }
                    }
                    if (z) {
                        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "canMultiProcessPlugin Host:" + packageName + ",plugin:" + str + " 下载进程还活着,自己不能下载安装");
                        if (lock != null) {
                            try {
                                lock.release();
                            } catch (IOException unused3) {
                            }
                        }
                        FileUtilsF.a(fileChannel);
                        FileUtilsF.a((Closeable) r5);
                        return false;
                    }
                    FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "downloadPlugin old downloader not alive=" + readInt);
                    r5.seek(0L);
                    r5.writeInt(myPid);
                    FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "canMultiProcessPlugin Host:" + packageName + ",plugin:" + str + " myProcessId=" + myPid + "开始下载");
                    if (lock != null) {
                        try {
                            lock.release();
                        } catch (IOException unused4) {
                        }
                    }
                    FileUtilsF.a(fileChannel);
                    FileUtilsF.a((Closeable) r5);
                    return true;
                } catch (Exception e2) {
                    e = e2;
                    FLogger.e(QBPluginLogExt.TAG_QBPluginServiceImpl, "downloadPlugin Error", e);
                    if (0 != 0) {
                        try {
                            fileLock.release();
                        } catch (IOException unused5) {
                        }
                    }
                    FileUtilsF.a(fileChannel);
                    FileUtilsF.a((Closeable) r5);
                    return true;
                }
            } catch (Exception e3) {
                e = e3;
                fileChannel = null;
            } catch (Throwable th2) {
                th = th2;
                h2 = 0;
                if (0 != 0) {
                    try {
                        fileLock.release();
                    } catch (IOException unused6) {
                    }
                }
                FileUtilsF.a((Closeable) h2);
                FileUtilsF.a((Closeable) r5);
                throw th;
            }
        } catch (Exception e4) {
            e = e4;
            fileChannel = null;
            r5 = 0;
        } catch (Throwable th3) {
            th = th3;
            h2 = 0;
            r5 = 0;
        }
    }

    public synchronized boolean a(IPluginRelateFunc iPluginRelateFunc, IPluginDir iPluginDir, final int i2) {
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "initPluginSystem=" + this + ",infoFrom=" + i2);
        if (!W.compareAndSet(2, 3)) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "PluginSystem Init  InitCommon not Finished or InitPluginSystem is pending, infoFrom=" + i2);
            return false;
        }
        if (E == null) {
            try {
                if (Arrays.asList(iPluginRelateFunc.getClass().getInterfaces()).contains(IPluginRelateFunc.class)) {
                    E = iPluginRelateFunc;
                } else {
                    FLogger.e(QBPluginLogExt.TAG_QBPluginServiceImpl, "object[" + iPluginRelateFunc + "] doesnot implements IPluginRelateFunc", new Throwable("relateFunc=" + iPluginRelateFunc));
                }
            } catch (Throwable th) {
                FLogger.w(QBPluginLogExt.TAG_QBPluginServiceImpl, th);
            }
        }
        if (i2 == 1) {
            D = iPluginDir;
            p();
        }
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "PluginSystem Init initApplicationContext FileMode:755 QBMode:" + TbsMode.TBSISQB());
        BrowserExecutorSupplier.postForBackgroundTasks(new BrowserExecutorSupplier.BackgroundRunable() {
            @Override
            public void doRun() {
                StringBuilder sb;
                int i3 = i2;
                if (i3 == 1) {
                    boolean c2 = QBPluginServiceImpl.this.c((String) null, i3);
                    sb = new StringBuilder();
                    sb.append("PluginSystem Init initApplicationContext SndPluginRequest: ");
                    sb.append(c2);
                } else {
                    int a2 = QBPluginServiceImpl.this.a((String) null, "initPluginSystem", (AsynGetPluginInfo) null, i3);
                    sb = new StringBuilder();
                    sb.append("PluginSystem Init initApplicationContext SndPluginRequest: ");
                    sb.append(a2);
                }
                FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, sb.toString());
            }
        });
        W.compareAndSet(3, 4);
        return true;
    }

    @Override
    public boolean a(Object obj, int i2) {
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "onFlowCtrlStartDownload: tag=" + obj + ", type=" + i2);
        FlowCtrlTag flowCtrlTag = (FlowCtrlTag) obj;
        boolean c2 = this.V.c(flowCtrlTag.f9859b.f37604a);
        PluginStatBehavior.a(flowCtrlTag.f9858a, "438(ok_" + c2 + ")", 2, 4);
        IPluginRelateFunc iPluginRelateFunc = E;
        if (iPluginRelateFunc != null) {
            iPluginRelateFunc.platformAction("QBPLUGIN_864152143_FLOWCTRL_GRANTED");
            iPluginRelateFunc.platformAction("QBPLUGIN_864152143_FLOWCTRL_GRANTED_" + flowCtrlTag.f9858a);
        }
        DownloadInfo downloadInfo = flowCtrlTag.f9859b;
        downloadInfo.H = a(downloadInfo.H, c2, flowCtrlTag.f9860c);
        if (a(flowCtrlTag.f9858a, downloadInfo) != 0) {
            TBSPluginCallbackHandler.MessageDetail messageDetail = new TBSPluginCallbackHandler.MessageDetail();
            messageDetail.f9903b = StringUtils.b(flowCtrlTag.f9859b.o, 0);
            messageDetail.f = 3011;
            messageDetail.f9902a = flowCtrlTag.f9858a;
            messageDetail.e = -1;
            messageDetail.f9905d = flowCtrlTag.f9859b.f37604a;
            Message obtainMessage = this.S.obtainMessage();
            obtainMessage.what = g;
            obtainMessage.obj = messageDetail;
            obtainMessage.arg1 = messageDetail.f9903b;
            this.S.sendMessage(obtainMessage);
        }
        return false;
    }

    public boolean a(String str) {
        boolean z;
        if (TextUtils.isEmpty(str) || this.C == null) {
            return false;
        }
        if (str.equalsIgnoreCase(WonderPluginSession.PACKAGE_NAME_VIDEO)) {
            if (this.T == 0) {
                File a2 = a(c(), str, true);
                if (a2 != null) {
                    FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "isSpecialPkg  installDir = " + a2.getAbsolutePath());
                    z = ZipPluginManager.a().a(str, a2.getAbsolutePath());
                } else {
                    z = false;
                }
                this.T = z ? 1 : 2;
            }
            if (this.T == 2) {
                return true;
            }
        }
        ArrayList<String> downloadSpecicalWhiteList = this.C.getDownloadSpecicalWhiteList();
        if (downloadSpecicalWhiteList != null && downloadSpecicalWhiteList.size() != 0) {
            return downloadSpecicalWhiteList.contains(str);
        }
        if (str.equalsIgnoreCase("com.tencent.qb.plugin.egret") || str.equalsIgnoreCase("com.tencent.qb.plugin.cocos") || str.equalsIgnoreCase("com.tencent.qb.plugin.cocos-v2") || str.equalsIgnoreCase("com.tencent.qb.plugin.cocos-v3") || str.equalsIgnoreCase("com.tencent.qb.plugin.LayaBoxPlayer") || str.equalsIgnoreCase("com.tencent.qb.plugin.cocos-js-v3") || str.equalsIgnoreCase("com.tencent.qb.plugin.doc") || str.equalsIgnoreCase("com.tencent.qb.plugin.docx") || str.equalsIgnoreCase("com.tencent.qb.plugin.epub") || str.equalsIgnoreCase("com.tencent.qb.plugin.txt") || str.equalsIgnoreCase("com.tencent.qb.plugin.pdf") || str.equalsIgnoreCase("com.tencent.qb.plugin.ppt") || str.equalsIgnoreCase("com.tencent.qb.plugin.pptx") || str.equalsIgnoreCase("com.tencent.qb.plugin.tiff") || str.equalsIgnoreCase("com.tencent.qb.plugin.xls") || str.equalsIgnoreCase("com.tencent.qb.plugin.xlsx") || str.equalsIgnoreCase("com.tencent.qb.plugin.chm")) {
            return true;
        }
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "isSpecialPkg,mIsThirdTesCallMode:" + TbsMode.thirdTbsMode() + ",packageName=" + str + ",mCheckTesProviderPluginResult=" + this.T);
        return false;
    }

    @Override
    public boolean a(String str, int i2, IGetPluginInfoCallback iGetPluginInfoCallback) throws RemoteException {
        FLogger.w(QBPluginLogExt.TAG_QBPluginServiceImpl, new Exception("尽量别调用forceRequestPluginList,可能给后台造成预料之外的压力"));
        if (iGetPluginInfoCallback != null) {
            AsynGetPluginInfo asynGetPluginInfo = new AsynGetPluginInfo();
            asynGetPluginInfo.f9855a = str;
            asynGetPluginInfo.f9856b = iGetPluginInfoCallback;
            asynGetPluginInfo.f9857c = i2;
            synchronized (this.Y) {
                this.Y.add(asynGetPluginInfo);
            }
        }
        PluginSetting.a(b()).a(i2, false);
        return d(str, "Force", i2) == 0;
    }

    @Override
    public boolean a(String str, int i2, QBPluginItemInfo qBPluginItemInfo) throws RemoteException {
        if (qBPluginItemInfo == null) {
            qBPluginItemInfo = a(str, i2);
        }
        if (qBPluginItemInfo == null) {
            return false;
        }
        boolean z = qBPluginItemInfo.mUpdateType == 1;
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "checkneedForceUpdate PluginPkgName=" + str + ",needForceUpdate=" + z);
        return z;
    }

    @Override
    public boolean a(String str, IGetPluginInfoCallback iGetPluginInfoCallback, int i2) throws RemoteException {
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + str + ",infoFrom=" + i2 + ",callback=" + iGetPluginInfoCallback);
        if (TextUtils.isEmpty(str) || iGetPluginInfoCallback == null) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + str + ",infoFrom=" + i2 + ",callback=" + iGetPluginInfoCallback + " error Nocallback");
            return false;
        }
        if (TbsMode.thirdTbsMode() && !a(str)) {
            QBPluginItemInfo qBPluginItemInfo = new QBPluginItemInfo();
            qBPluginItemInfo.mPackageName = str;
            qBPluginItemInfo.mUpdateType = 0;
            File a2 = a(c(), (String) null, str);
            if (a2 != null) {
                qBPluginItemInfo.mDownloadDir = a2.getAbsolutePath();
            }
            File a3 = a(c(), str, true);
            if (a3 != null) {
                qBPluginItemInfo.mInstallDir = a3.getAbsolutePath();
                qBPluginItemInfo.mIsInstall = a3.exists() ? 1 : 0;
                qBPluginItemInfo.mUnzipDir = a3.getAbsolutePath();
            } else {
                qBPluginItemInfo.mIsInstall = 0;
            }
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + str + ",infoFrom=" + i2 + " mIsThirdTesCallMode onRecvPluignInfo");
            PluginStatBehavior.i(str, 4, "663(thirdTbsMode)");
            iGetPluginInfoCallback.onRecvPluignInfo(str, 0, qBPluginItemInfo);
            return true;
        }
        QBPluginItemInfo c2 = QBPluginDBHelper.a(d()).c(str, i2);
        if (c2 != null && b(str) != null && !b(str).compatableId.equals(c2.mPluginCompatiID)) {
            AsynGetPluginInfo asynGetPluginInfo = new AsynGetPluginInfo();
            asynGetPluginInfo.f9855a = str;
            asynGetPluginInfo.f9856b = iGetPluginInfoCallback;
            asynGetPluginInfo.f9857c = i2;
            int a4 = a((String) null, "Visit_getPluignInfo", asynGetPluginInfo, i2);
            if (a4 >= 0) {
                FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + str + ",infoFrom=" + i2 + "  nocomapatableInfo sendRequestSuccess");
                return true;
            }
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + str + ",infoFrom=" + i2 + " nocomapatableInfo sendRequestFailed onRecvPluignInfo");
            QBPluginItemInfo c3 = QBPluginDBHelper.a(d()).c(str, i2);
            if (c3 != null) {
                PluginStatBehavior.i(str, 4, "663(10_0_v" + c3.mVersion + "_c" + c3.mPluginCompatiID + ")");
                a4 = 0;
            } else {
                PluginStatBehavior.i(str, 4, "663(10_" + a4 + "_null)");
            }
            iGetPluginInfoCallback.onRecvPluignInfo(str, a4, c3);
            return true;
        }
        if (c2 != null) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + str + ",infoFrom=" + i2 + "  localPluginInfo onRecvPluignInfo");
            PluginStatBehavior.i(str, 4, "663(20_v" + c2.mVersion + "_c" + c2.mPluginCompatiID + ")");
            iGetPluginInfoCallback.onRecvPluignInfo(str, 0, c2);
            return true;
        }
        if (c2 == null && PluginSetting.a(b()).c(i2) && i2 == 1) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + str + ",infoFrom=" + i2 + "  no localPluginInfo onRecvPluignInfo but pull the list");
            PluginStatBehavior.i(str, 4, "Syn2Svr");
            PluginStatBehavior.i(str, 4, "663(noinfo)");
            iGetPluginInfoCallback.onRecvPluignInfo(str, 0, c2);
            PluginStatBehavior.a(str, 4, 650, i2);
            return true;
        }
        AsynGetPluginInfo asynGetPluginInfo2 = new AsynGetPluginInfo();
        asynGetPluginInfo2.f9855a = str;
        asynGetPluginInfo2.f9856b = iGetPluginInfoCallback;
        asynGetPluginInfo2.f9857c = i2;
        int a5 = a((String) null, "Visit_getPluignInfo", asynGetPluginInfo2, i2);
        if (a5 >= 0) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + str + ",infoFrom=" + i2 + "  no PluginInfo sendRequestSuccess");
            return true;
        }
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginInfoAsy packageName=" + str + ",infoFrom=" + i2 + "  no PluginInfo sendRequestFaild onRecvPluignInfo");
        QBPluginItemInfo c4 = QBPluginDBHelper.a(d()).c(str, i2);
        if (c4 != null) {
            PluginStatBehavior.i(str, 4, "663(30_0_v" + c4.mVersion + "_c" + c4.mPluginCompatiID + ")");
            a5 = 0;
        } else {
            PluginStatBehavior.i(str, 4, "663(30_" + a5 + "_null)");
        }
        iGetPluginInfoCallback.onRecvPluignInfo(str, a5, c4);
        return true;
    }

    public boolean a(String str, String str2, int i2, int i3) {
        synchronized (this.z) {
            if (TextUtils.isEmpty(str)) {
                return false;
            }
            QBPluginInfo qBPluginInfo = new QBPluginInfo();
            qBPluginInfo.mPackageName = str2;
            qBPluginInfo.mLocalPath = str;
            qBPluginInfo.mVersionCode = i2;
            this.z.put(new QBPluginSystem.PluginPkgKey(str2, i3), qBPluginInfo);
            return true;
        }
    }

    public boolean a(String str, boolean z, int i2) {
        return QBPluginDBHelper.a(d()).a(str, z, i2);
    }

    @Override
    public boolean a(String str, boolean z, IQBPluginCallback iQBPluginCallback, int i2) throws RemoteException {
        QBPluginItemInfo qBPluginItemInfo;
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "stopDownloadPluginTask: packageName=" + str + " needDeleteTask=" + z + " infoFrom=" + i2);
        try {
            qBPluginItemInfo = a(str, i2);
        } catch (RemoteException unused) {
            qBPluginItemInfo = null;
        }
        if (qBPluginItemInfo == null) {
            PluginStatBehavior.i(str, 4, "622(40:" + System.currentTimeMillis() + ")");
            return false;
        }
        this.G.a(qBPluginItemInfo.mUrl);
        i(i2);
        DownloadTask b2 = this.V.b(qBPluginItemInfo.mUrl);
        int i3 = b2 == null ? -1 : b2.i();
        PluginStatBehavior.i(str, 4, "622(50:" + System.currentTimeMillis() + "_" + i3 + ")");
        if (i3 == -1) {
            return false;
        }
        f(str);
        IDownloadManager iDownloadManager = this.V;
        if (z) {
            iDownloadManager.a(i3, RemovePolicy.DELETE_TASK_AND_FILE);
            return true;
        }
        iDownloadManager.a(i3, PauseReason.MANUAL);
        return true;
    }

    @Override
    public int b(String str, int i2, int i3) throws RemoteException {
        try {
            QBPluginInfo d2 = d(str, i2, i3);
            r1 = d2 != null ? d2.mNeedUnzipFromBack ? 2 : 1 : 0;
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "CheckLocalPlugin,this:" + this + ",pluginName:" + str + ",ret=" + r1 + ",(0 none, 1 found, 2 needunzip)");
            return r1;
        } catch (NullPointerException e2) {
            FLogger.w(QBPluginLogExt.TAG_QBPluginServiceImpl, e2);
            return r1;
        }
    }

    public Context b() {
        Context context = x;
        return context != null ? context : ContextHolder.getAppContext();
    }

    @Override
    public String b(String str, int i2) throws RemoteException {
        String str2;
        QBPluginInfo d2 = d(str, 1, i2);
        if (d2 == null || TextUtils.isEmpty(d2.mLocalPath)) {
            str2 = "";
        } else {
            str2 = d2.mLocalPath + File.separator;
        }
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginPath " + str + ",basePath=" + str2);
        return str2;
    }

    @Override
    public List<QBPluginItemInfo> b(int i2, final int i3) throws RemoteException {
        BrowserExecutorSupplier.postForBackgroundTasks(new BrowserExecutorSupplier.BackgroundRunable() {
            @Override
            public void doRun() {
                QBPluginServiceImpl.this.a((String) null, "Visit_getListByType", (AsynGetPluginInfo) null, i3);
            }
        });
        return QBPluginDBHelper.a(d()).a(i2, i3);
    }

    @Override
    public void b(IQBPluginCallback iQBPluginCallback, int i2) throws RemoteException {
        if (this.t.contains(iQBPluginCallback)) {
            return;
        }
        this.t.add(iQBPluginCallback);
    }

    @Override
    public void b(Object obj, int i2) {
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "onFlowCtrlCancelled: tag=" + obj + ", type=" + i2);
        FlowCtrlTag flowCtrlTag = (FlowCtrlTag) obj;
        IPluginRelateFunc iPluginRelateFunc = E;
        if (iPluginRelateFunc != null) {
            iPluginRelateFunc.platformAction("QBPLUGIN_864152143_FLOWCTRL_CANCELLED");
            iPluginRelateFunc.platformAction("QBPLUGIN_864152143_FLOWCTRL_CANCELLED_" + flowCtrlTag.f9858a);
        }
        PluginStatBehavior.a(flowCtrlTag.f9858a, "438(cancelled)", 2, 4);
        Message obtainMessage = this.S.obtainMessage();
        obtainMessage.what = l;
        obtainMessage.obj = flowCtrlTag.f9859b.f37604a;
        this.S.sendMessage(obtainMessage);
    }

    @Override
    public boolean b(int i2) throws RemoteException {
        return a((String) null, "UserOp", (AsynGetPluginInfo) null, i2) == 0;
    }

    @Override
    public boolean b(String str, int i2, int i3, QBPluginItemInfo qBPluginItemInfo) throws RemoteException {
        if (qBPluginItemInfo == null) {
            qBPluginItemInfo = a(str, i3);
        }
        if (qBPluginItemInfo == null) {
            PluginStatBehavior.i(str, 4, "436(needUpdate:nullinfo)");
            return false;
        }
        if (b(str) != null && !b(str).compatableId.equals(qBPluginItemInfo.mPluginCompatiID)) {
            PluginStatBehavior.i(str, 4, "436(needUpdate:compat_" + qBPluginItemInfo.mPluginCompatiID + "_" + b(str).compatableId + ")");
            return true;
        }
        QBPluginInfo d2 = d(str, i2, i3);
        if (d2 == null) {
            PluginStatBehavior.i(str, 4, "436(needUpdate:localinfo_" + i2 + "_" + qBPluginItemInfo.mUpdateType + ")");
            return i2 != 1 || qBPluginItemInfo.mUpdateType > 0;
        }
        String str2 = qBPluginItemInfo.mVersion;
        PluginStatBehavior.i(str, 4, "436(needUpdate:version_" + str2 + ")");
        if (TextUtils.isEmpty(str2)) {
            return false;
        }
        int i4 = d2.mVersionCode;
        int b2 = StringUtils.b(str2, -1);
        PluginStatBehavior.i(str, 4, "436(needUpdate:install_" + i4 + "_" + d2.mNeedUnzipFromBack + ")");
        if (b2 == -1 || b2 == i4) {
            return false;
        }
        if (d2.mNeedUnzipFromBack && !TextUtils.isEmpty(d2.mLocalZipPath)) {
            File file = new File(d2.mLocalZipPath);
            if (file.exists() && PluginFileUtils.a(file, qBPluginItemInfo.mMd5)) {
                return false;
            }
        }
        return true;
    }

    @Override
    public boolean b(String str, int i2, QBPluginItemInfo qBPluginItemInfo) throws RemoteException {
        String str2;
        QBPluginItemInfo a2 = qBPluginItemInfo != null ? qBPluginItemInfo : a(str, i2);
        if (a2 == null) {
            str2 = "436(is:nullinfo)";
        } else {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "isNewVersionFileDownloaded " + str + ",checkVersionInfo=" + a2 + ",version=" + a2.mVersion);
            if (b(str, a2.mZipJarPluginType, i2, a2) && d(str, i2, qBPluginItemInfo) > 0) {
                PluginStatBehavior.i(str, 4, "436(call:10)");
                return c(str, i2, a2);
            }
            str2 = "436(is:false)";
        }
        PluginStatBehavior.i(str, 4, str2);
        return false;
    }

    public Context c() {
        return y;
    }

    public WUPRequestBase c(String str, String str2, int i2) {
        String str3;
        if (d(i2) == 1) {
            PluginStatBehavior.i("PluginList", PluginStatBehavior.a(i2), "312(" + Thread.currentThread().getId() + ")");
            PluginStatBehavior.a("PluginList", PluginStatBehavior.a(i2));
            return null;
        }
        PluginStatBehavior.b("PluginList", PluginStatBehavior.a(i2));
        PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), IReader.SET_FIND_NEXT);
        String b2 = PluginSetting.a(b()).b(i2);
        UniPluginReq uniPluginReq = new UniPluginReq();
        String a2 = QBPluginProxy.a();
        uniPluginReq.iSDKVersion = GdiMeasureImpl.b();
        if (TextUtils.isEmpty(a2)) {
            a2 = PluginSetting.a(b()).b();
        } else {
            PluginSetting.a(b()).a(a2);
        }
        uniPluginReq.strCpu = a2;
        uniPluginReq.sMd5 = b2;
        uniPluginReq.vGuid = c(i2).getByteGuid();
        uniPluginReq.sQua = c(i2).getQUA();
        if (i2 == 1) {
            str3 = "SR=QB";
        } else {
            if (i2 != 2) {
                PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), 331);
                PluginStatBehavior.a("PluginList", PluginStatBehavior.a(i2), 331);
                return null;
            }
            str3 = "SR=TBS";
        }
        uniPluginReq.sQua2ExInfo = str3;
        PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), uniPluginReq.sQua2ExInfo + IActionReportService.COMMON_SEPARATOR + uniPluginReq.sMd5 + IActionReportService.COMMON_SEPARATOR + uniPluginReq.strCpu);
        PluginStatBehavior.a("PluginList", PluginStatBehavior.a(i2), uniPluginReq.sQua + Constants.ACCEPT_TIME_SEPARATOR_SERVER + uniPluginReq.strCpu + ",req.sMd5=" + uniPluginReq.sMd5);
        PluginStatBehavior.e("PluginList", PluginStatBehavior.a(i2), str2);
        PluginStatBehavior.d("PluginList", PluginStatBehavior.a(i2), o());
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "requestPluginList  iSDKVersion:" + uniPluginReq.iSDKVersion + " strCpu: " + uniPluginReq.strCpu + " sMd5: " + uniPluginReq.sMd5 + " vGuid: " + uniPluginReq.vGuid + " sQua: " + uniPluginReq.sQua + " packageName: " + str);
        WUPRequestBase wUPRequestBase = new WUPRequestBase("uniplugin", "getPluginList", this);
        if (PluginSetting.a(x).a()) {
            wUPRequestBase.setUrl("http://14.17.41.197:18000");
        }
        wUPRequestBase.put("stReq", uniPluginReq);
        wUPRequestBase.setBindObject(str);
        wUPRequestBase.setType((byte) i2);
        return wUPRequestBase;
    }

    public void c(int i2, int i3) {
        if (i3 == 1) {
            this.v = i2;
        }
        if (i3 == 2) {
            this.w = i2;
        }
    }

    @Override
    public void c(String str, int i2, int i3) throws RemoteException {
        QBPluginDBHelper.a(d()).b(str, i2, i3);
    }

    public boolean c(String str, int i2) {
        FLogger.e(QBPluginLogExt.TAG_QBPluginServiceImpl, new Exception("尽量别调用forceRequestPluginList,可能给后台造成预料之外的压力"));
        PluginSetting.a(b()).a(i2, false);
        return d(str, "Force", i2) == 0;
    }

    public boolean c(String str, int i2, QBPluginItemInfo qBPluginItemInfo) throws RemoteException {
        PluginStatBehavior.i(str, 4, "436(nvfd:md5_" + qBPluginItemInfo.mMd5 + ")");
        boolean z = false;
        if (TextUtils.isEmpty(qBPluginItemInfo.mMd5)) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "isNewVersionFileDownloaded pkgName=" + str + ",isFileDownloaded=false,pluginList MD5 Empty");
            return false;
        }
        if (TextUtils.isEmpty(qBPluginItemInfo.mDownloadDir) || TextUtils.isEmpty(qBPluginItemInfo.mDownloadFileName)) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "isNewVersionFileDownloaded pkgName=" + str + ",isFileDownloaded=false,pluginItemInfo.mDownloadDir=" + qBPluginItemInfo.mDownloadDir + Constants.ACCEPT_TIME_SEPARATOR_SP);
            PluginStatBehavior.i(str, 4, "436(nvfd:nodownload)");
            return false;
        }
        File file = new File(qBPluginItemInfo.mDownloadDir, qBPluginItemInfo.mDownloadFileName);
        String str2 = null;
        if (file.exists()) {
            ByteBuffer a2 = FileUtilsF.a(file.getAbsolutePath(), 0L, 256);
            String byteToHexString = ByteUtils.byteToHexString(Md5Utils.a(a2.array(), 0, a2.position()));
            FileUtilsF.f().a(a2);
            str2 = byteToHexString;
        }
        PluginStatBehavior.i(str, 4, "436(nvfd:localmd5_" + str2 + ")");
        if (TextUtils.isEmpty(str2)) {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "isNewVersionFileDownloaded pkgName=" + str + ",isFileDownloaded=false,locafileMd5 Empty");
            return false;
        }
        if (!TextUtils.isEmpty(qBPluginItemInfo.mPackageSize)) {
            long a3 = StringUtils.a(qBPluginItemInfo.mPackageSize, -1L);
            if (a3 >= 0 && a3 != file.length()) {
                PluginStatBehavior.i(str, 3, "FSN" + Thread.currentThread().getId());
                PluginStatBehavior.i(str, 4, "436(nvfd:size_" + qBPluginItemInfo.mPackageSize + "_" + file.length() + ")");
                return false;
            }
        }
        if (qBPluginItemInfo.mMd5.equals(str2)) {
            z = true;
        } else {
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "isNewVersionFileDownloaded pkgName=" + str + ",pluginItemInfo.mMd5=" + qBPluginItemInfo.mMd5 + ",localFileMd5=" + str2);
        }
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "isNewVersionFileDownloaded pkgName=" + str + ",isFileDownloaded=" + z);
        StringBuilder sb = new StringBuilder();
        sb.append("FS");
        sb.append(Thread.currentThread().getId());
        PluginStatBehavior.i(str, 3, sb.toString());
        PluginStatBehavior.i(str, 4, "436(nvfd:result_" + z + ")");
        return z;
    }

    public int d(int i2) {
        if (i2 == 1) {
            return this.v;
        }
        if (i2 == 2) {
            return this.w;
        }
        return 0;
    }

    int d(String str, int i2, QBPluginItemInfo qBPluginItemInfo) throws RemoteException {
        PluginConfigInfo b2 = b(str);
        if (b2 == null) {
            PluginStatBehavior.i(str, 4, "436(compat_1_noconfig)");
            return 1;
        }
        if (qBPluginItemInfo == null) {
            qBPluginItemInfo = a(str, i2);
        }
        if (qBPluginItemInfo == null) {
            PluginStatBehavior.i(str, 4, "436(compat_0_nullinfo)");
            return 0;
        }
        PluginStatBehavior.i(str, 4, "436(compat:" + qBPluginItemInfo.mPluginCompatiID + "_" + b2.compatableId + ")");
        return b2.compatableId.equals(qBPluginItemInfo.mPluginCompatiID) ? 1 : -1;
    }

    public Context d() {
        Context context = x;
        return context != null ? context : ContextHolder.getAppContext();
    }

    Context d(String str) {
        return (!TbsMode.thirdTbsMode() || (!TextUtils.isEmpty(str) && a(str))) ? b() : c();
    }

    public QBPluginInfo d(String str, int i2, int i3) {
        boolean z;
        QBPluginInfo qBPluginInfo;
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        QBPluginSystem.PluginPkgKey pluginPkgKey = new QBPluginSystem.PluginPkgKey(str, i3);
        synchronized (this.z) {
            z = this.z.get(pluginPkgKey) == null;
        }
        if (z) {
            if (i2 == 1) {
                QBPluginInfo b2 = ZipPluginManager.a().b(str, i3);
                synchronized (this.z) {
                    if (b2 != null) {
                        this.z.put(pluginPkgKey, b2);
                    }
                }
            } else if (i2 == 2) {
                n();
            } else if (i2 == 3) {
                QBPluginInfo b3 = ZipPluginManager.a().b(str, i3);
                synchronized (this.z) {
                    if (b3 != null) {
                        this.z.put(pluginPkgKey, b3);
                    }
                }
            } else {
                QBPluginInfo a2 = ZipPluginManager.a().a(str, i3);
                synchronized (this.z) {
                    if (a2 != null) {
                        this.z.put(pluginPkgKey, a2);
                    }
                }
            }
        }
        synchronized (this.z) {
            qBPluginInfo = this.z.get(pluginPkgKey);
        }
        if (i2 == 2 && qBPluginInfo != null) {
            String str2 = qBPluginInfo.mLocalPath;
            if (str2 == null || !new File(str2).exists()) {
                qBPluginInfo = null;
            }
            synchronized (this.z) {
                this.z.remove(pluginPkgKey);
                this.z.put(pluginPkgKey, qBPluginInfo);
            }
        }
        return qBPluginInfo;
    }

    @Override
    public ArrayList<QBPluginItemInfo> a(int i2, final int i3) throws RemoteException {
        BrowserExecutorSupplier.postForBackgroundTasks(new BrowserExecutorSupplier.BackgroundRunable() {
            @Override
            public void doRun() {
                QBPluginServiceImpl.this.a((String) null, "Visit_getListByPos", (AsynGetPluginInfo) null, i3);
            }
        });
        return QBPluginDBHelper.a(d()).b(i2, i3);
    }

    void d(String str, int i2) {
        this.z.remove(new QBPluginSystem.PluginPkgKey(str, i2));
    }

    public PluginCallbackHandler e() {
        return this.S;
    }

    public void e(int i2) {
        HashMap hashMap = new HashMap();
        synchronized (B) {
            for (Map.Entry<String, PluginConfigInfo> entry : B.entrySet()) {
                hashMap.put(entry.getKey(), entry.getValue().compatableId);
            }
        }
        QBPluginDBHelper.a(d()).a(hashMap, i2);
    }

    public boolean e(String str, int i2) {
        QBPluginInfo a2;
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        JarFileInfo jarFileInfo = new JarFileInfo();
        if (!JarFileParser.a(b(), str, jarFileInfo) || jarFileInfo.h == null) {
            return false;
        }
        if (!jarFileInfo.n) {
            jarFileInfo.g = str;
        }
        if (d(jarFileInfo.h, 2, i2) != null || (a2 = PluginUtils.a(b(), jarFileInfo)) == null) {
            return false;
        }
        synchronized (this.z) {
            this.z.put(new QBPluginSystem.PluginPkgKey(a2.mPackageName, 1), a2);
        }
        return true;
    }

    public JSONObject f(int i2) throws JSONException {
        JSONObject jSONObject = new JSONObject();
        Iterator<QBPluginItemInfo> it = QBPluginDBHelper.a(d()).a(i2).iterator();
        int i3 = 0;
        while (it.hasNext()) {
            QBPluginItemInfo next = it.next();
            JSONArray jSONArray = new JSONArray();
            jSONArray.put(next.mTitle);
            jSONArray.put(next.mUrl);
            jSONArray.put(next.mIconUrl);
            jSONArray.put(next.mPackageName);
            jSONArray.put(next.mPluginType);
            jSONArray.put(next.mVersion);
            jSONArray.put(next.mPackageSize);
            jSONArray.put(next.mIsInstall);
            jSONArray.put(next.mUpdateType);
            jSONArray.put(next.mOrder);
            jSONArray.put(next.mLocation);
            jSONArray.put(next.mDetailSumary);
            jSONArray.put(next.mExt);
            jSONArray.put(next.mSignature);
            jSONArray.put(next.mDownloadDir);
            jSONArray.put(next.mInstallDir);
            jSONArray.put(next.mUnzipDir);
            jSONArray.put(next.mIsZipFileUpdate);
            jSONArray.put(next.mPluginCompatiID);
            jSONArray.put(next.mMd5);
            jSONArray.put(next.mZipJarPluginType);
            jSONArray.put(next.mDownloadFileName);
            jSONArray.put(next.mInstallVersion);
            jSONArray.put(next.mAntiHijackUrl);
            jSONArray.put(next.mInfoFrom);
            jSONArray.put(next.isNeedUpdate);
            jSONArray.put(next.mMinCompatibleVersion);
            jSONObject.put(String.valueOf(i3), jSONArray);
            i3++;
        }
        return jSONObject;
    }

    public void f() {
        Map<String, PluginConfigInfo> map;
        String str;
        PluginConfigInfo pluginConfigInfo;
        synchronized (B) {
            B.put("com.tencent.qb.plugin.screencut", new PluginConfigInfo(2, "7000", null, null));
            B.put(IPluginService.PLUGIN_REFRESH, new PluginConfigInfo(2, "7000", null, null));
            B.put("com.qq.wx.offlinevoice.synthesizer", new PluginConfigInfo(11, "7001", null, null));
            B.put("com.tencent.qb.plugin.cocos", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.cocos-js-v3", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.cocos-v2", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.cocos-v3", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.egret", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.LayaBoxPlayer", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.doc", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.docx", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.epub", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.pdf", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.ppt", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.pptx", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.tiff", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.xls", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.xlsx", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.plugin.chm", new PluginConfigInfo(1, "6100", null, null));
            B.put("com.tencent.qb.pluign.betatts", new PluginConfigInfo(1, "7400", null, null));
            B.put("com.tencent.qb.plugin.arrecog", new PluginConfigInfo(1, "8200", null, null));
            B.put("com.tencent.mtt.video.recorder.filter", new PluginConfigInfo(1, "8000", null, null));
            B.put(IArService.AR_PACKAGE_NAME, new PluginConfigInfo(1, "8200", null, null));
            B.put(IArService.AR_SLAM_PACKAGE_NAME, new PluginConfigInfo(1, "8400", null, null));
            B.put(IArService.AR_QBAR_PACKAGE_NAME, new PluginConfigInfo(1, "8801", null, null));
            B.put("com.tencent.qb.plugin.arcropper", new PluginConfigInfo(1, "9300000", null, null));
            B.put("com.tencent.qb.plugin.artext", new PluginConfigInfo(1, "9000000", null, null));
            B.put("com.tencent.qb.plugin.tflite", new PluginConfigInfo(1, "9300000", null, null));
            if (TbsMode.TBSISQB()) {
                B.put(WonderPluginSession.PACKAGE_NAME_VIDEO, new PluginConfigInfo(1, "9400", null, null));
                map = B;
                str = "com.tencent.qb.plugin.tvk.sdk";
                pluginConfigInfo = new PluginConfigInfo(1, "7400", null, null);
            } else {
                B.put(WonderPluginSession.PACKAGE_NAME_VIDEO, new PluginConfigInfo(1, "9400", null, null));
                map = B;
                str = "com.tencent.qb.plugin.tvk.sdk";
                pluginConfigInfo = new PluginConfigInfo(1, "7000", null, null);
            }
            map.put(str, pluginConfigInfo);
            a(0, (IPluginDir) null);
        }
    }

    public void f(String str) {
        b(d(str), str);
    }

    public boolean f(String str, int i2) {
        if (TextUtils.isEmpty(str) || d(str, 2, i2) == null) {
            return false;
        }
        synchronized (this.z) {
            QBPluginSystem.PluginPkgKey pluginPkgKey = new QBPluginSystem.PluginPkgKey(str, i2);
            QBPluginInfo qBPluginInfo = this.z.get(pluginPkgKey);
            if (qBPluginInfo != null) {
                File a2 = FileUtilsF.a(PluginFileUtils.a(b()), str);
                if (!TextUtils.isEmpty(qBPluginInfo.mSoName)) {
                    File file = new File(a2, qBPluginInfo.mSoName);
                    if (file.exists()) {
                        try {
                            FileUtilsF.a(file);
                        } catch (Exception unused) {
                        }
                    }
                }
                this.z.remove(pluginPkgKey);
            }
        }
        return false;
    }

    public int g(int i2) throws RemoteException {
        WUPRequestBase a2 = a("", "force", i2);
        if (a2 == null) {
            return O;
        }
        if (WUPTaskProxy.send(a2)) {
            FLogger.d(QBPluginLogExt.TAG_QBPluginServiceImpl, "forcePullPluginList  :Send Out");
            c(1, i2);
            PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), 313);
            return P;
        }
        c(3, i2);
        FLogger.w(QBPluginLogExt.TAG_QBPluginServiceImpl, "forcePullPluginList  :Send Failed");
        PluginStatBehavior.c("PluginList", PluginStatBehavior.a(i2), 314);
        PluginStatBehavior.a("PluginList", PluginStatBehavior.a(i2), 314);
        return K;
    }

    public boolean h() {
        PluginSetting a2;
        int i2;
        StringBuilder sb;
        String str;
        String str2 = "";
        if (TbsMode.TBSISQB()) {
            a2 = PluginSetting.a(b());
            i2 = 1;
        } else {
            a2 = PluginSetting.a(b());
            i2 = 2;
        }
        a2.a(i2, false);
        PluginSetting.a(b()).a(i2, "");
        QBPluginItemInfo c2 = QBPluginDBHelper.a(d()).c("com.tencent.qb.plugin.docx", i2);
        if (c2 != null && (c2.mDownloadDir != null || c2.mInstallDir != null)) {
            File file = new File(c2.mDownloadDir == null ? "" : c2.mDownloadDir);
            File file2 = new File(c2.mInstallDir == null ? "" : c2.mInstallDir);
            String[] strArr = {"com.tencent.qb.plugin.pdf", "com.tencent.qb.plugin.pptx", "com.tencent.qb.plugin.xlsx", WonderPluginSession.PACKAGE_NAME_VIDEO, "com.tencent.qb.plugin.epub", "com.tencent.qb.plugin.txt"};
            try {
                if (file.exists()) {
                    str2 = file.getParent();
                    FileUtilsF.c(file);
                } else if (!TbsMode.TBSISQB()) {
                    File h2 = FileUtils.h(x);
                    if (h2 != null) {
                        sb = new StringBuilder();
                        sb.append(h2.getAbsoluteFile());
                        sb.append("/");
                        str = PluginFileUtils.f9792a;
                        sb.append(str);
                        str2 = sb.toString();
                    }
                } else if (D != null) {
                    File qQBrowserDownloadDir = D.getQQBrowserDownloadDir();
                    sb = new StringBuilder();
                    sb.append(qQBrowserDownloadDir.getAbsoluteFile());
                    sb.append("/");
                    str = PluginFileUtils.f9792a;
                    sb.append(str);
                    str2 = sb.toString();
                }
                if (file2.exists()) {
                    try {
                        FileUtilsF.c(file2);
                    } catch (Exception unused) {
                    }
                }
                for (String str3 : strArr) {
                    File file3 = new File(str2 + "/" + str3);
                    if (file3.exists()) {
                        FileUtilsF.c(file3);
                    }
                    File file4 = new File(file2.getParent() + "/" + str3);
                    if (file4.exists()) {
                        try {
                            FileUtilsF.c(file4);
                        } catch (Exception unused2) {
                        }
                    }
                }
            } catch (Exception unused3) {
            }
        }
        return QBPluginDBHelper.a(d()).a();
    }

    public String i() {
        return QBPluginDBHelper.a(d()).c();
    }

    void i(int i2) {
        if (this.U) {
            return;
        }
        a(c(i2).getDownloadManager());
        this.U = true;
    }

    public List<QBPluginItemInfo> j(int i2) throws RemoteException {
        return QBPluginDBHelper.a(d()).a(i2);
    }

    public void j() {
        PluginCallbackHandler pluginCallbackHandler = this.S;
        if (pluginCallbackHandler != null) {
            pluginCallbackHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        Process.killProcess(Process.myPid());
                    } catch (Exception unused) {
                    }
                }
            }, MMTipsBar.DURATION_SHORT);
        }
    }

    public synchronized boolean k(int i2) {
        if (i2 < 0 || i2 > 2) {
            return false;
        }
        long currentTimeMillis = System.currentTimeMillis();
        if (s[i2] <= 0) {
            s[i2] = PluginSetting.a(b()).a(i2);
        }
        if (currentTimeMillis - s[i2] < 86400000) {
            return false;
        }
        PluginSetting.a(b()).a(i2, currentTimeMillis);
        s[i2] = currentTimeMillis;
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "24Hour need pullpluginList");
        return true;
    }

    public boolean l() {
        PluginSetting.a(b()).a(1, false);
        int d2 = d((String) null, "PushCmd", 1);
        if (d2 != 0) {
            return false;
        }
        FLogger.i("handlePluginCmd", "CMD Pull QBLIst=" + d2);
        int d3 = d((String) null, "PushCmd", 2);
        if (d3 != 0) {
            return false;
        }
        FLogger.i("handlePluginCmd", "CMD Pull TBSLIst=" + d3);
        return true;
    }

    void m() {
        this.S.removeMessages(n);
    }

    public synchronized void n() {
        if (!this.R && !this.Q) {
            this.R = true;
            HashMap<String, JarFileInfo> a2 = PluginUtils.a(b(), QBPluginDBHelper.a(d()).a(1));
            if (a2 == null) {
                return;
            }
            synchronized (this.z) {
                if (a2.size() > 0) {
                    Iterator<JarFileInfo> it = a2.values().iterator();
                    while (it.hasNext()) {
                        QBPluginInfo a3 = PluginUtils.a(b(), it.next());
                        if (a3 != null) {
                            a3.mPositionIndex = 0;
                            QBPluginSystem.PluginPkgKey pluginPkgKey = new QBPluginSystem.PluginPkgKey(a3.mPackageName, 1);
                            this.z.remove(pluginPkgKey);
                            this.z.put(pluginPkgKey, a3);
                        }
                    }
                }
            }
            try {
            } catch (RemoteException unused) {
            }
            this.R = false;
            this.Q = true;
        }
    }

    @Override
    public void onTaskCompleted(DownloadTask downloadTask) {
        String r2;
        QBPluginItemInfo a2;
        if (downloadTask == null || downloadTask == null || !downloadTask.G()) {
            return;
        }
        String v = downloadTask.v();
        int b2 = StringUtils.b(downloadTask.w(), 0);
        if (b2 == 0) {
            return;
        }
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "onTaskCompleted: pkgName=" + v + " url=" + downloadTask.j());
        Message obtainMessage = this.S.obtainMessage();
        boolean z = true;
        try {
            r2 = downloadTask.r();
            a2 = a(v, b2);
        } catch (Throwable unused) {
        }
        if (a2 != null) {
            if (TextUtils.isEmpty(r2)) {
                z = false;
            } else {
                QBPluginDBHelper.a(d()).c(v, a2.mDownloadDir, b2);
                PluginStatBehavior.d(v, 2, r2);
            }
            if (!TextUtils.isEmpty(downloadTask.m())) {
                QBPluginDBHelper.a(d()).d(v, downloadTask.m(), b2);
                PluginStatBehavior.a(v, 2, downloadTask.o());
                PluginStatBehavior.f(v, 2, downloadTask.m());
            }
            z = false;
        }
        if (z) {
            d(v, b2);
        }
        obtainMessage.what = z ? f : g;
        obtainMessage.obj = downloadTask;
        obtainMessage.arg1 = b2;
        this.S.sendMessage(obtainMessage);
        PluginStatBehavior.c(v, 4, 434);
        if (!z) {
            PluginStatBehavior.a(v, 2, ar.CTRL_INDEX);
            return;
        }
        PluginStatBehavior.i(v, 2, "40(" + System.currentTimeMillis() + ")[" + downloadTask.P() + "]");
        PluginStatBehavior.a(v, 2, 0);
    }

    @Override
    public void onTaskCreated(DownloadTask downloadTask) {
        int b2;
        if (downloadTask == null || !downloadTask.G() || (b2 = StringUtils.b(downloadTask.w(), 0)) == 0) {
            return;
        }
        Message obtainMessage = this.S.obtainMessage();
        obtainMessage.what = f9839d;
        obtainMessage.obj = downloadTask;
        obtainMessage.arg1 = b2;
        this.S.sendMessage(obtainMessage);
        PluginStatBehavior.i(downloadTask.v(), 4, "411(" + System.currentTimeMillis() + ")");
        PluginStatBehavior.i(downloadTask.v(), 2, "411(" + System.currentTimeMillis() + ")");
    }

    @Override
    public void onTaskFailed(final DownloadTask downloadTask, DownloadErrorDetail downloadErrorDetail) {
        if ((downloadTask instanceof DownloadTask) && downloadTask != null && downloadTask.G()) {
            final String v = downloadTask.v();
            int b2 = StringUtils.b(downloadTask.w(), 0);
            if (b2 == 0) {
                return;
            }
            final int i2 = downloadErrorDetail == null ? -1 : downloadErrorDetail.f37602a;
            QBPluginDBHelper.a(d()).c(v, "", b2);
            Message obtainMessage = this.S.obtainMessage();
            obtainMessage.what = g;
            obtainMessage.obj = downloadTask;
            obtainMessage.arg1 = b2;
            this.S.sendMessage(obtainMessage);
            final int aa = downloadTask.aa();
            BrowserExecutorSupplier.forTimeoutTasks().execute(new Runnable() {
                @Override
                public void run() {
                    int i3 = ConnectivityDetector.a() ? aa : 429;
                    PluginStatBehavior.i(v, 2, "414(" + System.currentTimeMillis() + Constants.ACCEPT_TIME_SEPARATOR_SP + i2 + ")");
                    if (i3 == 43) {
                        PluginStatBehavior.i(v, 2, "414(" + downloadTask.k() + ")");
                    }
                    PluginStatBehavior.a(v, 2, i3);
                }
            });
        }
    }

    @Override
    public void onTaskPaused(DownloadTask downloadTask, PauseReason pauseReason) {
        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "notifyTaskCanceled: " + downloadTask.v() + " url=" + downloadTask.j());
        Message obtainMessage = this.S.obtainMessage();
        obtainMessage.what = l;
        obtainMessage.obj = downloadTask.j();
        this.S.sendMessage(obtainMessage);
    }

    @Override
    public void onTaskProgress(DownloadTask downloadTask) {
        int b2;
        if (downloadTask == null || !downloadTask.G() || (b2 = StringUtils.b(downloadTask.w(), 0)) == 0) {
            return;
        }
        Message obtainMessage = this.S.obtainMessage();
        obtainMessage.what = h;
        obtainMessage.obj = downloadTask;
        obtainMessage.arg1 = b2;
        this.S.sendMessage(obtainMessage);
        String str = "413(" + System.currentTimeMillis() + "_" + downloadTask.V() + "_" + downloadTask.Z() + ")";
        PluginStatBehavior.i(downloadTask.v(), 4, str);
        PluginStatBehavior.i(downloadTask.v(), 2, str);
    }

    @Override
    public void onTaskRemoved(DownloadTask downloadTask) {
    }

    @Override
    public void onTaskStarted(DownloadTask downloadTask) {
        if (downloadTask == null || !downloadTask.G()) {
            return;
        }
        if (downloadTask.h(268435456)) {
            PluginStatBehavior.b(downloadTask.v(), 2);
        }
        int b2 = StringUtils.b(downloadTask.w(), 0);
        if (b2 == 0) {
            return;
        }
        Message obtainMessage = this.S.obtainMessage();
        obtainMessage.what = e;
        obtainMessage.obj = downloadTask;
        obtainMessage.arg1 = b2;
        this.S.sendMessage(obtainMessage);
        PluginStatBehavior.i(downloadTask.v(), 4, "412(" + System.currentTimeMillis() + ")");
        PluginStatBehavior.i(downloadTask.v(), 2, "412(" + System.currentTimeMillis() + ")");
    }

    @Override
    public void onTaskWaiting(DownloadTask downloadTask) {
    }

    @Override
    public void onWUPTaskFail(WUPRequestBase wUPRequestBase) {
        byte type = wUPRequestBase.getType();
        synchronized (this.I) {
            if (this.S == null) {
                c(3, type);
                return;
            }
            FLogger.w(QBPluginLogExt.TAG_QBPluginServiceImpl, "WUP failed");
            a(wUPRequestBase);
            c(3, type);
            Message obtainMessage = this.S.obtainMessage();
            obtainMessage.what = f9838c;
            obtainMessage.arg1 = wUPRequestBase.getType();
            this.S.sendMessage(obtainMessage);
            int i2 = M;
            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "onWUPTaskFail: networkisAailable,start to detect network");
            if (!Apn.isWifiMode(false) ? ConnectivityDetector.c() : ConnectivityDetector.b()) {
                PluginStatBehavior.a("PluginList", PluginStatBehavior.a(type), IReader.XLS_OPEN_AS_XLSX);
                i2 = N;
            } else {
                PluginStatBehavior.a("PluginList", PluginStatBehavior.a(type), wUPRequestBase.getErrorCode());
            }
            l(i2);
        }
    }

    @Override
    public void onWUPTaskSuccess(WUPRequestBase wUPRequestBase, WUPResponseBase wUPResponseBase) {
        FLogger.startTiming("getPluginListRequest savePluginList");
        synchronized (this.I) {
            byte type = wUPRequestBase.getType();
            if (wUPResponseBase != null && this.S != null) {
                Integer returnCode = wUPResponseBase.getReturnCode();
                if (returnCode != null && returnCode.intValue() == 0) {
                    UniPluginRsp uniPluginRsp = (UniPluginRsp) wUPResponseBase.get("stRsp");
                    PluginStatBehavior.i("PluginList", PluginStatBehavior.a(type), a(wUPResponseBase, uniPluginRsp));
                    if (!b(uniPluginRsp) && !c(uniPluginRsp)) {
                        if (!QBPluginDBHelper.a(d()).a(uniPluginRsp, d(), type)) {
                            c(3, type);
                            Message obtainMessage = this.S.obtainMessage();
                            obtainMessage.what = f9838c;
                            obtainMessage.arg1 = type;
                            obtainMessage.obj = wUPRequestBase.getBindObject();
                            this.S.sendMessage(obtainMessage);
                            PluginStatBehavior.c("PluginList", PluginStatBehavior.a(type), 320);
                            PluginStatBehavior.a("PluginList", PluginStatBehavior.a(type), 320);
                            l(-6);
                            FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getpluginlist: wup failed 4");
                            FLogger.printCostTime("MultiWUPRequestTimeCost", "getPluginListRequest savePluginList", "getPluginListRequest savePluginList");
                            return;
                        }
                        PluginSetting.a(b()).a(type, uniPluginRsp.sMd5);
                        PluginStatBehavior.f("PluginList", PluginStatBehavior.a(type), uniPluginRsp.sMd5);
                        e(type);
                        if (PluginSetting.a(b()).a(type) <= 0) {
                            PluginSetting.a(b()).a(type, System.currentTimeMillis());
                        }
                        PluginSetting.a(b()).a((int) type, true);
                        PluginStatBehavior.i("PluginList", PluginStatBehavior.a(type), "InfoFrom_" + ((int) type) + "PullList");
                        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "responsePluginList onWUPTaskSuccess  setPluginListRspSucc:true");
                        Message obtainMessage2 = this.S.obtainMessage();
                        obtainMessage2.what = f9837b;
                        obtainMessage2.obj = wUPRequestBase.getBindObject();
                        obtainMessage2.arg1 = wUPRequestBase.getType();
                        this.S.sendMessage(obtainMessage2);
                        PluginStatBehavior.c("PluginList", PluginStatBehavior.a(type), 30);
                        PluginStatBehavior.a("PluginList", PluginStatBehavior.a(type), 0);
                        c(2, type);
                        FLogger.i(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginList Success");
                        l(0);
                    }
                    PluginStatBehavior.c("PluginList", PluginStatBehavior.a(type), 317);
                    PluginStatBehavior.a("PluginList", PluginStatBehavior.a(type), 317);
                    c(2, type);
                    l(-5);
                    FLogger.printCostTime("MultiWUPRequestTimeCost", "getPluginListRequest savePluginList", "getPluginListRequest savePluginList");
                    return;
                }
                int intValue = returnCode != null ? returnCode.intValue() : -1000;
                FLogger.w(QBPluginLogExt.TAG_QBPluginServiceImpl, "getPluginList failed errorcode=" + intValue);
                Message obtainMessage3 = this.S.obtainMessage();
                obtainMessage3.what = f9838c;
                obtainMessage3.obj = wUPRequestBase.getBindObject();
                this.S.sendMessage(obtainMessage3);
                PluginStatBehavior.i("PluginList", PluginStatBehavior.a(type), "321(" + intValue + ")");
                PluginStatBehavior.a("PluginList", PluginStatBehavior.a(type), intValue);
                l(-3);
                c(2, type);
                if (intValue != -4 && intValue != -1) {
                    if (intValue == -6) {
                        m();
                    }
                }
                a(wUPRequestBase);
                FLogger.printCostTime("MultiWUPRequestTimeCost", "getPluginListRequest savePluginList", "getPluginListRequest savePluginList");
                return;
            }
            PluginStatBehavior.c("PluginList", PluginStatBehavior.a(type), 315);
            PluginStatBehavior.a("PluginList", PluginStatBehavior.a(type), 315);
            c(3, type);
            l(-4);
            FLogger.printCostTime("MultiWUPRequestTimeCost", "getPluginListRequest savePluginList", "getPluginListRequest savePluginList");
        }
    }
}