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

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


package com.tencent.mtt.search.data.entrance;

import android.text.TextUtils;
import android.util.SparseArray;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.taf.JceInputStream;
import com.taf.JceOutputStream;
import com.taf.JceSynchronizedPool;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.FileUtils;
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.mtt.R;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.wup.GUIDManager;
import com.tencent.mtt.base.wup.WUPRequest;
import com.tencent.mtt.qbinfo.IQConfigure;
import com.tencent.mtt.qbinfo.QBInfoUtils;
import com.tencent.mtt.qbinfo.QUAUtils;
import com.tencent.mtt.search.facade.IOnHotwordChangedListener;
import com.tencent.mtt.search.network.MTT.SmartBox_VerticalHotWords;
import com.tencent.mtt.search.network.MTT.SmartBox_VerticalHotWordsReq;
import com.tencent.mtt.search.network.MTT.SmartBox_VerticalHotWordsRsp;
import com.tencent.mtt.search.network.MTT.SmartBox_VerticalItem;
import com.tencent.mtt.search.network.MTT.SmartBox_VerticalPageItem;
import com.tencent.mtt.search.network.MTT.SmartBox_VerticalReq;
import com.tencent.mtt.search.network.MTT.SmartBox_VerticalRsp;
import com.tencent.mtt.search.searchEngine.SettingUtils;
import com.tencent.mtt.setting.PublicSettingManager;
import com.xiaomi.mipush.sdk.Constants;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

public class SearchEntranceManager implements IWUPRequestCallBack {
    private static SearchEntranceManager e;
    private ArrayList<SearchEntranceInfo> f;
    private OnSearchEntranceChangedListener h;
    private SparseArray<SmartBox_VerticalHotWords> g = null;

    final Object f70140a = new Object();

    final Object f70141b = new Object();

    final Object f70142c = new Object();

    public CopyOnWriteArrayList<String> f70143d = new CopyOnWriteArrayList<>();
    private int j = -1;
    private int k = -1;
    private CopyOnWriteArrayList<IOnHotwordChangedListener> i = new CopyOnWriteArrayList<>();

    public interface OnSearchEntranceChangedListener {
        void h();
    }

    private SearchEntranceManager() {
        this.f = null;
        this.f = new ArrayList<>();
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_l), MttResources.l(R.string.b_l), 1, "", MttResources.l(R.string.b_e), "https://smartbox.html5.qq.com/search?t=1&ch=001411&searchFrom=32&q=", null, 1));
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_4), MttResources.l(R.string.b_4), 3, "", MttResources.l(R.string.b_9), "https://ag.qq.com/search?t=3&ch=001411&q=", null, 0));
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_m), MttResources.l(R.string.b_m), 2, "", MttResources.l(R.string.b_f), "https://so.html5.qq.com/page/real/search_result?ver=0&t=2&tabId=360&entryScene=QB_novel_box&q=", null, 0));
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_k), MttResources.l(R.string.b_k), 4, "", MttResources.l(R.string.b_d), "https://qbs.html5.qq.com/n?t=4&ch=001411&q=", null, 0));
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_p), MttResources.l(R.string.b_p), 6, "", MttResources.l(R.string.b_i), "https://smartbox.html5.qq.com/search?t=6&ch=001411&searchFrom=32&q=", null, 0));
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_8), MttResources.l(R.string.b_8), 5, "", MttResources.l(R.string.b_c), "https://ag.qq.com/community/searchStart?t=5&keyword=", null, 1));
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_n), MttResources.l(R.string.b_n), 7, "", MttResources.l(R.string.b_g), "https://smartbox.html5.qq.com/search?t=7&ch=001411&q=", null, 0));
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_7), MttResources.l(R.string.b_7), 8, "", MttResources.l(R.string.b_b), "https://smartbox.html5.qq.com/search?t=8&ch=001411&q=", null, 0));
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_6), MttResources.l(R.string.b_6), 9, "", MttResources.l(R.string.b_a), "https://cartoonactivity.html5.qq.com/search?t=9&ch=001411&q=", null, 0));
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_q), MttResources.l(R.string.b_q), 10, "", MttResources.l(R.string.b_j), "https://smartbox.html5.qq.com/search?t=10&ch=001411&q=", null, 0));
        SearchEntranceInfo searchEntranceInfo = new SearchEntranceInfo();
        searchEntranceInfo.n = true;
        searchEntranceInfo.g = 1;
        searchEntranceInfo.h = 0;
        searchEntranceInfo.f70136a = "小程序";
        searchEntranceInfo.f70139d = "搜索小程序";
        searchEntranceInfo.i = 1;
        searchEntranceInfo.e = "https://so.html5.qq.com/page/real/search_result?ver=0&t=21&tabId=317&q=";
        searchEntranceInfo.m = "小程序";
        searchEntranceInfo.j = "https://search.imtt.qq.com/imgUpload/db_mtt_smartbox.t_conf_special/20200612_ti3vszymdo3x.png";
        searchEntranceInfo.k = "https://search.imtt.qq.com/imgUpload/db_mtt_smartbox.t_conf_special/20200611_nna97folkwx3.png";
        searchEntranceInfo.l = "https://search.imtt.qq.com/imgUpload/db_mtt_smartbox.t_conf_special/20200611_9j4v3u9icjlogox3.png";
        searchEntranceInfo.f70137b = 21;
        this.f.add(searchEntranceInfo);
        SearchEntranceInfo searchEntranceInfo2 = new SearchEntranceInfo();
        searchEntranceInfo2.f70136a = "影视";
        searchEntranceInfo2.f70137b = 24;
        searchEntranceInfo2.g = 1;
        searchEntranceInfo2.i = 0;
        searchEntranceInfo2.h = 0;
        searchEntranceInfo2.n = false;
        searchEntranceInfo2.f70139d = "输入电影、电视剧、综艺名称";
        searchEntranceInfo2.m = "影视";
        searchEntranceInfo2.e = "https://so.html5.qq.com/page/real/search_result?ver=0&tabId=453&t=24&noTab=1&q=";
        searchEntranceInfo2.j = "https://search.imtt.qq.com/imgUpload/db_mtt_smartbox.t_conf_special/20200612_ti3vszymdo3x.png";
        searchEntranceInfo2.k = "https://search.imtt.qq.com/imgUpload/db_mtt_smartbox.t_conf_special/20200611_nna97folkwx3.png";
        searchEntranceInfo2.l = "https://search.imtt.qq.com/imgUpload/db_mtt_smartbox.t_conf_special/20200611_9j4v3u9icjlogox3.png";
        this.f.add(searchEntranceInfo2);
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_5), MttResources.l(R.string.b_5), 11, "", MttResources.l(R.string.b__), "https://quan.qq.com/search/circle?t=11&q=", null, 0));
        this.f.add(new SearchEntranceInfo(MttResources.l(R.string.b_o), MttResources.l(R.string.b_o), 14, "", MttResources.l(R.string.b_h), "https://smartbox.html5.qq.com/search?t=14&ch=001411&q=", null, 0));
        k();
        g();
        e();
    }

    public static SearchEntranceManager a() {
        if (e == null) {
            synchronized (SearchEntranceManager.class) {
                if (e == null) {
                    e = new SearchEntranceManager();
                }
            }
        }
        return e;
    }

    private void a(SearchEntranceInfo searchEntranceInfo) {
        String str;
        if (TextUtils.isEmpty(searchEntranceInfo.e)) {
            switch (searchEntranceInfo.f70137b) {
                case 1:
                    str = "https://smartbox.html5.qq.com/search?t=1&ch=001411&searchFrom=32&q=";
                    searchEntranceInfo.e = str;
                    return;
                case 2:
                    str = "https://so.html5.qq.com/page/real/search_result?ver=0&t=2&tabId=360&entryScene=QB_novel_box&q=";
                    searchEntranceInfo.e = str;
                    return;
                case 3:
                    str = "https://ag.qq.com/search?t=3&ch=001411&q=";
                    searchEntranceInfo.e = str;
                    return;
                case 4:
                    str = "https://qbs.html5.qq.com/n?t=4&ch=001411&q=";
                    searchEntranceInfo.e = str;
                    return;
                case 5:
                default:
                    return;
                case 6:
                    str = "https://smartbox.html5.qq.com/search?t=6&ch=001411&searchFrom=32&q=";
                    searchEntranceInfo.e = str;
                    return;
                case 7:
                    str = "https://smartbox.html5.qq.com/search?t=7&ch=001411&q=";
                    searchEntranceInfo.e = str;
                    return;
                case 8:
                    str = "https://smartbox.html5.qq.com/search?t=8&ch=001411&q=";
                    searchEntranceInfo.e = str;
                    return;
                case 9:
                    str = "https://cartoonactivity.html5.qq.com/search?t=9&ch=001411&q=";
                    searchEntranceInfo.e = str;
                    return;
                case 10:
                    str = "https://smartbox.html5.qq.com/search?t=10&ch=001411&q=";
                    searchEntranceInfo.e = str;
                    return;
                case 11:
                    str = "https://quan.qq.com/search/circle?t=11&q=";
                    searchEntranceInfo.e = str;
                    return;
            }
        }
    }

    private void a(final SmartBox_VerticalHotWordsRsp smartBox_VerticalHotWordsRsp) {
        if (c(smartBox_VerticalHotWordsRsp)) {
            return;
        }
        BrowserExecutorSupplier.postForIoTasks(new BrowserExecutorSupplier.BackgroundRunable() {
            @Override
            public void doRun() {
                SearchEntranceManager.this.b(smartBox_VerticalHotWordsRsp);
            }
        });
    }

    private void a(SmartBox_VerticalHotWordsRsp smartBox_VerticalHotWordsRsp, SparseArray<SmartBox_VerticalHotWords> sparseArray) {
        if (sparseArray == null || sparseArray.size() <= 0) {
            return;
        }
        HashMap hashMap = new HashMap();
        for (int i = 0; i < sparseArray.size(); i++) {
            Integer valueOf = Integer.valueOf(sparseArray.keyAt(i));
            hashMap.put(valueOf, sparseArray.get(valueOf.intValue()));
        }
        SmartBox_VerticalHotWords smartBox_VerticalHotWords = sparseArray.get(3);
        if (smartBox_VerticalHotWords == null || smartBox_VerticalHotWords.vecEntrance == null || smartBox_VerticalHotWords.vecEntrance.size() <= 0) {
            PublicSettingManager.a().setInt("key_search_hotword_app_showidx", -1);
        }
        smartBox_VerticalHotWordsRsp.mapHotWords = hashMap;
        a(smartBox_VerticalHotWordsRsp);
        h();
    }

    public void b(SmartBox_VerticalHotWordsRsp smartBox_VerticalHotWordsRsp) {
        JceOutputStream acquireout;
        byte[] byteArray;
        FileOutputStream fileOutputStream;
        synchronized (this.f70141b) {
            File file = new File(SettingUtils.a(), "search_hotwords");
            FileOutputStream fileOutputStream2 = null;
            try {
                try {
                    try {
                        if (!file.exists()) {
                            file.createNewFile();
                        }
                        acquireout = JceSynchronizedPool.getInstance().acquireout();
                        acquireout.setServerEncoding("UTF-8");
                        smartBox_VerticalHotWordsRsp.writeTo(acquireout);
                        byteArray = acquireout.toByteArray();
                        fileOutputStream = new FileOutputStream(file);
                    } catch (Exception unused) {
                    }
                } catch (Throwable th) {
                    th = th;
                }
            } catch (IOException unused2) {
            }
            try {
                fileOutputStream.write(byteArray, 0, byteArray.length);
                fileOutputStream.flush();
                JceSynchronizedPool.getInstance().releaseOut(acquireout);
                fileOutputStream.close();
            } catch (Exception unused3) {
                fileOutputStream2 = fileOutputStream;
                PublicSettingManager.a().setString("key_search_hotword_auth", "");
                if (fileOutputStream2 != null) {
                    fileOutputStream2.close();
                }
            } catch (Throwable th2) {
                th = th2;
                fileOutputStream2 = fileOutputStream;
                if (fileOutputStream2 != null) {
                    try {
                        fileOutputStream2.close();
                    } catch (IOException unused4) {
                    }
                }
                throw th;
            }
        }
    }

    private void b(SmartBox_VerticalRsp smartBox_VerticalRsp) {
        if (smartBox_VerticalRsp.vecItem == null || smartBox_VerticalRsp.vecItem.size() == 0) {
            return;
        }
        PublicSettingManager.a().setString("key_search_entrance_auth" + IQConfigure.f, smartBox_VerticalRsp.sAuth);
        Iterator<SmartBox_VerticalItem> it = smartBox_VerticalRsp.vecItem.iterator();
        String str = "";
        while (it.hasNext()) {
            str = str + it.next().iVerticalType + Constants.ACCEPT_TIME_SEPARATOR_SP;
        }
        if (!TextUtils.isEmpty(str)) {
            str = str.substring(0, str.lastIndexOf(Constants.ACCEPT_TIME_SEPARATOR_SP));
        }
        PublicSettingManager.a().setString("key_search_entrance_type", str);
        PublicSettingManager.a().setBoolean("need_show_bubble_on_entrance", true);
        PublicSettingManager.a().setBoolean("search_need_show_search_entrance", smartBox_VerticalRsp.iHide == 0);
        a(smartBox_VerticalRsp);
        c(smartBox_VerticalRsp);
        f();
    }

    private void c(final SmartBox_VerticalRsp smartBox_VerticalRsp) {
        if (smartBox_VerticalRsp == null || smartBox_VerticalRsp.vecItem == null || smartBox_VerticalRsp.vecItem.size() == 0) {
            return;
        }
        BrowserExecutorSupplier.postForIoTasks(new BrowserExecutorSupplier.BackgroundRunable() {
            @Override
            public void doRun() {
                JceOutputStream acquireout;
                byte[] byteArray;
                FileOutputStream fileOutputStream;
                synchronized (SearchEntranceManager.this.f70140a) {
                    File file = new File(SettingUtils.a(), "search_entrance_items");
                    FileOutputStream fileOutputStream2 = null;
                    try {
                        try {
                            try {
                                if (!file.exists()) {
                                    file.createNewFile();
                                }
                                acquireout = JceSynchronizedPool.getInstance().acquireout();
                                acquireout.setServerEncoding("UTF-8");
                                smartBox_VerticalRsp.writeTo(acquireout);
                                byteArray = acquireout.toByteArray();
                                fileOutputStream = new FileOutputStream(file);
                            } catch (Exception unused) {
                            }
                        } catch (Throwable th) {
                            th = th;
                        }
                    } catch (IOException unused2) {
                    }
                    try {
                        fileOutputStream.write(byteArray, 0, byteArray.length);
                        fileOutputStream.flush();
                        JceSynchronizedPool.getInstance().releaseOut(acquireout);
                        fileOutputStream.close();
                    } catch (Exception unused3) {
                        fileOutputStream2 = fileOutputStream;
                        PublicSettingManager.a().setString("key_search_entrance_auth" + IQConfigure.f, "");
                        PublicSettingManager.a().setString("key_search_entrance_type", "");
                        if (fileOutputStream2 != null) {
                            fileOutputStream2.close();
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        fileOutputStream2 = fileOutputStream;
                        if (fileOutputStream2 != null) {
                            try {
                                fileOutputStream2.close();
                            } catch (IOException unused4) {
                            }
                        }
                        throw th;
                    }
                }
            }
        });
    }

    private boolean c(SmartBox_VerticalHotWordsRsp smartBox_VerticalHotWordsRsp) {
        return smartBox_VerticalHotWordsRsp == null || smartBox_VerticalHotWordsRsp.mapHotWords == null || smartBox_VerticalHotWordsRsp.mapHotWords.size() == 0;
    }

    private void h() {
        this.j = -1;
    }

    private boolean i() {
        int i = PublicSettingManager.a().getInt("key_search_hotword_app_showidx", 0);
        return i >= PublicSettingManager.a().getInt("search_app_entrance_total_num", 0) || i == -1;
    }

    private void j() {
        Iterator<IOnHotwordChangedListener> it = this.i.iterator();
        while (it.hasNext()) {
            it.next().ds_();
        }
    }

    private void k() {
        BrowserExecutorSupplier.postForIoTasks(new BrowserExecutorSupplier.BackgroundRunable() {
            @Override
            public void doRun() {
                FileInputStream fileInputStream;
                synchronized (SearchEntranceManager.this.f70140a) {
                    File file = new File(SettingUtils.a(), "search_entrance_items");
                    if (file.exists()) {
                        FileInputStream fileInputStream2 = null;
                        try {
                            try {
                                try {
                                    fileInputStream = new FileInputStream(file);
                                } catch (IOException unused) {
                                }
                            } catch (Exception unused2) {
                            }
                        } catch (Throwable th) {
                            th = th;
                        }
                        try {
                            ByteBuffer a2 = FileUtils.a((InputStream) fileInputStream);
                            JceInputStream jceInputStream = new JceInputStream(a2);
                            jceInputStream.setServerEncoding("UTF-8");
                            SmartBox_VerticalRsp smartBox_VerticalRsp = new SmartBox_VerticalRsp();
                            smartBox_VerticalRsp.readFrom(jceInputStream);
                            FileUtils.h().a(a2);
                            if (smartBox_VerticalRsp.vecItem != null && smartBox_VerticalRsp.vecItem.size() > 0) {
                                SearchEntranceManager.this.a(smartBox_VerticalRsp);
                            }
                            fileInputStream.close();
                        } catch (Exception unused3) {
                            fileInputStream2 = fileInputStream;
                            PublicSettingManager.a().setString("key_search_entrance_type", "");
                            PublicSettingManager.a().setString("key_search_entrance_auth" + IQConfigure.f, "");
                            if (fileInputStream2 != null) {
                                fileInputStream2.close();
                            }
                        } catch (Throwable th2) {
                            th = th2;
                            fileInputStream2 = fileInputStream;
                            if (fileInputStream2 != null) {
                                try {
                                    fileInputStream2.close();
                                } catch (IOException unused4) {
                                }
                            }
                            throw th;
                        }
                    }
                }
            }
        });
    }

    public SearchEntranceInfo a(int i) {
        ArrayList<SearchEntranceInfo> arrayList = this.f;
        if (arrayList == null) {
            return null;
        }
        Iterator<SearchEntranceInfo> it = arrayList.iterator();
        while (it.hasNext()) {
            SearchEntranceInfo next = it.next();
            if (next.f70137b == i) {
                return next;
            }
        }
        return null;
    }

    public void a(OnSearchEntranceChangedListener onSearchEntranceChangedListener) {
        this.h = onSearchEntranceChangedListener;
    }

    public void a(IOnHotwordChangedListener iOnHotwordChangedListener) {
        if (this.i.contains(iOnHotwordChangedListener)) {
            return;
        }
        this.i.add(iOnHotwordChangedListener);
    }

    void a(SmartBox_VerticalHotWordsRsp smartBox_VerticalHotWordsRsp, boolean z, boolean z2) {
        if (c(smartBox_VerticalHotWordsRsp)) {
            return;
        }
        synchronized (this.f70142c) {
            if (z && z2) {
                SparseArray<SmartBox_VerticalHotWords> sparseArray = new SparseArray<>();
                for (Map.Entry<Integer, SmartBox_VerticalHotWords> entry : smartBox_VerticalHotWordsRsp.mapHotWords.entrySet()) {
                    SmartBox_VerticalHotWords value = entry.getValue();
                    if (value != null) {
                        sparseArray.append(entry.getKey().intValue(), value);
                    }
                }
                PublicSettingManager.a().setInt("key_search_hotword_app_showidx", 0);
                SmartBox_VerticalHotWords smartBox_VerticalHotWords = sparseArray.get(3);
                if (smartBox_VerticalHotWords != null && smartBox_VerticalHotWords.vecEntrance != null) {
                    PublicSettingManager.a().setInt("search_app_entrance_total_num", smartBox_VerticalHotWords.vecEntrance.size());
                }
                this.g = sparseArray;
                j();
                if (this.k == 0) {
                    a(smartBox_VerticalHotWordsRsp, sparseArray);
                }
                return;
            }
            if (z) {
                if (this.g != null && this.g.size() > 0 && this.g.get(3) != null) {
                    SmartBox_VerticalHotWords smartBox_VerticalHotWords2 = this.g.get(3);
                    SmartBox_VerticalHotWords smartBox_VerticalHotWords3 = smartBox_VerticalHotWordsRsp.mapHotWords.get(3);
                    if (smartBox_VerticalHotWords3 == null) {
                        smartBox_VerticalHotWordsRsp.mapHotWords.put(3, smartBox_VerticalHotWords2);
                    } else {
                        smartBox_VerticalHotWords3.vecEntrance = new ArrayList<>();
                        if (smartBox_VerticalHotWords2 != null && smartBox_VerticalHotWords2.vecEntrance != null) {
                            smartBox_VerticalHotWords3.vecEntrance.addAll(smartBox_VerticalHotWords2.vecEntrance);
                        }
                    }
                }
                SparseArray<SmartBox_VerticalHotWords> sparseArray2 = new SparseArray<>();
                for (Map.Entry<Integer, SmartBox_VerticalHotWords> entry2 : smartBox_VerticalHotWordsRsp.mapHotWords.entrySet()) {
                    SmartBox_VerticalHotWords value2 = entry2.getValue();
                    if (value2 != null) {
                        sparseArray2.append(entry2.getKey().intValue(), value2);
                    }
                }
                this.g = sparseArray2;
                j();
                if (this.k == 0) {
                    a(smartBox_VerticalHotWordsRsp, sparseArray2);
                }
                return;
            }
            if (this.g != null && this.g.size() > 0) {
                SmartBox_VerticalHotWords smartBox_VerticalHotWords4 = smartBox_VerticalHotWordsRsp.mapHotWords.get(3);
                if (smartBox_VerticalHotWords4 != null && smartBox_VerticalHotWords4.vecEntrance != null && smartBox_VerticalHotWords4.vecEntrance.size() >= 0) {
                    SmartBox_VerticalHotWords smartBox_VerticalHotWords5 = this.g.get(3);
                    if (smartBox_VerticalHotWords5.vecEntrance == null) {
                        smartBox_VerticalHotWords5.vecEntrance = new ArrayList<>();
                    }
                    if (smartBox_VerticalHotWords5.vecEntrance.size() <= 0) {
                        Iterator<SmartBox_VerticalPageItem> it = smartBox_VerticalHotWords4.vecEntrance.iterator();
                        while (it.hasNext()) {
                            smartBox_VerticalHotWords5.vecEntrance.add(it.next());
                        }
                    }
                }
                return;
            }
            SparseArray<SmartBox_VerticalHotWords> sparseArray3 = new SparseArray<>();
            for (Map.Entry<Integer, SmartBox_VerticalHotWords> entry3 : smartBox_VerticalHotWordsRsp.mapHotWords.entrySet()) {
                SmartBox_VerticalHotWords value3 = entry3.getValue();
                if (value3 != null) {
                    sparseArray3.append(entry3.getKey().intValue(), value3);
                }
            }
            this.g = sparseArray3;
            j();
            if (this.j == 1 || this.j == 2) {
                a(smartBox_VerticalHotWordsRsp, this.g);
            }
        }
    }

    void a(SmartBox_VerticalRsp smartBox_VerticalRsp) {
        if (smartBox_VerticalRsp == null || smartBox_VerticalRsp.vecItem == null || smartBox_VerticalRsp.vecItem.size() == 0) {
            return;
        }
        if (TextUtils.equals(PublicSettingManager.a().getString("key_search_entrance_auth" + IQConfigure.f, ""), smartBox_VerticalRsp.sAuth)) {
            ArrayList<SmartBox_VerticalItem> arrayList = smartBox_VerticalRsp.vecItem;
            ArrayList<SearchEntranceInfo> arrayList2 = new ArrayList<>();
            HashMap hashMap = new HashMap();
            Iterator<SmartBox_VerticalItem> it = arrayList.iterator();
            while (it.hasNext()) {
                SmartBox_VerticalItem next = it.next();
                if (next != null) {
                    SearchEntranceInfo searchEntranceInfo = new SearchEntranceInfo();
                    searchEntranceInfo.f70136a = next.sName;
                    searchEntranceInfo.f70139d = next.sDescMsg;
                    searchEntranceInfo.f70137b = next.iVerticalType;
                    searchEntranceInfo.f70138c = next.sUrl;
                    searchEntranceInfo.e = next.sSearchUrl;
                    searchEntranceInfo.f = next.stBubble;
                    searchEntranceInfo.g = next.iHide;
                    searchEntranceInfo.i = next.iUseHippy;
                    searchEntranceInfo.j = next.sIcon;
                    searchEntranceInfo.h = next.iBoxStyle;
                    searchEntranceInfo.m = next.sBoxLabel;
                    searchEntranceInfo.k = next.sBackgroudPic;
                    searchEntranceInfo.l = next.sBackgroudTitlePic;
                    searchEntranceInfo.n = next.bAddEntryInfo;
                    arrayList2.add(searchEntranceInfo);
                    hashMap.put(searchEntranceInfo.f70136a, searchEntranceInfo);
                }
            }
            ArrayList<SearchEntranceInfo> arrayList3 = this.f;
            if (arrayList3 != null) {
                Iterator<SearchEntranceInfo> it2 = arrayList3.iterator();
                while (it2.hasNext()) {
                    SearchEntranceInfo searchEntranceInfo2 = (SearchEntranceInfo) hashMap.get(it2.next().f70136a);
                    if (searchEntranceInfo2 != null) {
                        a(searchEntranceInfo2);
                    }
                }
            }
            this.f = arrayList2;
            if (this.f70143d == null) {
                this.f70143d = new CopyOnWriteArrayList<>();
            }
            if (smartBox_VerticalRsp.vecUrl != null) {
                this.f70143d.addAll(smartBox_VerticalRsp.vecUrl);
            }
            OnSearchEntranceChangedListener onSearchEntranceChangedListener = this.h;
            if (onSearchEntranceChangedListener != null) {
                onSearchEntranceChangedListener.h();
            }
        }
    }

    public SmartBox_VerticalHotWords b(int i) {
        SparseArray<SmartBox_VerticalHotWords> sparseArray = this.g;
        if (sparseArray != null) {
            return sparseArray.get(i);
        }
        return null;
    }

    public String b() {
        return "https://smartbox.html5.qq.com/search?";
    }

    public void b(IOnHotwordChangedListener iOnHotwordChangedListener) {
        this.i.remove(iOnHotwordChangedListener);
    }

    public ArrayList<SearchEntranceInfo> c() {
        return this.f;
    }

    public CopyOnWriteArrayList<String> d() {
        return this.f70143d;
    }

    public void e() {
        WUPRequest wUPRequest = new WUPRequest("smartboxsearch", "getVerticalInfo");
        SmartBox_VerticalReq smartBox_VerticalReq = new SmartBox_VerticalReq();
        smartBox_VerticalReq.sAuth = PublicSettingManager.a().getString("key_search_entrance_auth" + IQConfigure.f, "");
        smartBox_VerticalReq.sGuid = GUIDManager.a().f();
        smartBox_VerticalReq.sQua = QBInfoUtils.d();
        smartBox_VerticalReq.sQua2 = QUAUtils.a();
        wUPRequest.put(HiAnalyticsConstant.Direction.REQUEST, smartBox_VerticalReq);
        wUPRequest.setRequestCallBack(this);
        WUPTaskProxy.send(wUPRequest);
    }

    public void f() {
        String[] split;
        try {
            String string = PublicSettingManager.a().getString("key_search_entrance_type", "");
            if (!TextUtils.isEmpty(string) && (split = string.split(Constants.ACCEPT_TIME_SEPARATOR_SP)) != null && split.length > 0) {
                ArrayList<Integer> arrayList = new ArrayList<>();
                for (String str : split) {
                    arrayList.add(Integer.valueOf(Integer.parseInt(str)));
                }
                WUPRequest wUPRequest = new WUPRequest("smartboxsearch", "getVerticalHotWords");
                SmartBox_VerticalHotWordsReq smartBox_VerticalHotWordsReq = new SmartBox_VerticalHotWordsReq();
                smartBox_VerticalHotWordsReq.sAuth = PublicSettingManager.a().getString("key_search_hotword_auth", "");
                smartBox_VerticalHotWordsReq.sGuid = GUIDManager.a().f();
                smartBox_VerticalHotWordsReq.sQua = QBInfoUtils.d();
                smartBox_VerticalHotWordsReq.sQua2 = QUAUtils.a();
                smartBox_VerticalHotWordsReq.vecVerticalType = arrayList;
                smartBox_VerticalHotWordsReq.bVerApp = i();
                wUPRequest.put(HiAnalyticsConstant.Direction.REQUEST, smartBox_VerticalHotWordsReq);
                wUPRequest.setRequestCallBack(this);
                wUPRequest.setBindObject(Boolean.valueOf(smartBox_VerticalHotWordsReq.bVerApp));
                WUPTaskProxy.send(wUPRequest);
            }
        } catch (Exception unused) {
        }
    }

    public void g() {
        BrowserExecutorSupplier.postForIoTasks(new BrowserExecutorSupplier.BackgroundRunable() {
            @Override
            public void doRun() {
                FileInputStream fileInputStream;
                synchronized (SearchEntranceManager.this.f70141b) {
                    File file = new File(SettingUtils.a(), "search_hotwords");
                    if (file.exists()) {
                        FileInputStream fileInputStream2 = null;
                        try {
                            try {
                                try {
                                    fileInputStream = new FileInputStream(file);
                                } catch (Throwable th) {
                                    th = th;
                                    fileInputStream = fileInputStream2;
                                }
                            } catch (Exception unused) {
                            }
                        } catch (IOException unused2) {
                        }
                        try {
                            ByteBuffer a2 = FileUtils.a((InputStream) fileInputStream);
                            JceInputStream jceInputStream = new JceInputStream(a2);
                            jceInputStream.setServerEncoding("UTF-8");
                            SmartBox_VerticalHotWordsRsp smartBox_VerticalHotWordsRsp = new SmartBox_VerticalHotWordsRsp();
                            smartBox_VerticalHotWordsRsp.readFrom(jceInputStream);
                            FileUtils.h().a(a2);
                            if (smartBox_VerticalHotWordsRsp.mapHotWords != null && smartBox_VerticalHotWordsRsp.mapHotWords.size() > 0) {
                                SearchEntranceManager.this.a(smartBox_VerticalHotWordsRsp, false, false);
                            }
                            fileInputStream.close();
                        } catch (Exception unused3) {
                            fileInputStream2 = fileInputStream;
                            PublicSettingManager.a().setString("key_search_hotword_auth", "");
                            if (fileInputStream2 != null) {
                                fileInputStream2.close();
                            }
                            SearchEntranceManager.this.k = 0;
                        } catch (Throwable th2) {
                            th = th2;
                            if (fileInputStream != null) {
                                try {
                                    fileInputStream.close();
                                } catch (IOException unused4) {
                                }
                            }
                            throw th;
                        }
                    }
                    SearchEntranceManager.this.k = 0;
                }
            }
        });
    }

    @Override
    public void onWUPTaskFail(WUPRequestBase wUPRequestBase) {
    }

    @Override
    public void onWUPTaskSuccess(WUPRequestBase wUPRequestBase, WUPResponseBase wUPResponseBase) {
        if (wUPResponseBase != null) {
            Object obj = wUPResponseBase.get(HiAnalyticsConstant.Direction.RESPONSE);
            if (obj instanceof SmartBox_VerticalRsp) {
                b((SmartBox_VerticalRsp) obj);
                return;
            }
            if (obj instanceof SmartBox_VerticalHotWordsRsp) {
                SmartBox_VerticalHotWordsRsp smartBox_VerticalHotWordsRsp = (SmartBox_VerticalHotWordsRsp) obj;
                this.j = 0;
                if (smartBox_VerticalHotWordsRsp.mapHotWords == null || smartBox_VerticalHotWordsRsp.mapHotWords.size() == 0) {
                    return;
                }
                PublicSettingManager.a().setString("key_search_hotword_auth", smartBox_VerticalHotWordsRsp.sAuth);
                a(smartBox_VerticalHotWordsRsp, true, ((Boolean) wUPRequestBase.getBindObject()).booleanValue());
                if (((Boolean) wUPRequestBase.getBindObject()).booleanValue()) {
                    this.j = 2;
                } else {
                    this.j = 1;
                }
            }
        }
    }
}