三只羊.apk(点击下载) / e.java


package io.dcloud.e.b;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import com.taobao.weex.common.Constants;
import com.taobao.weex.common.WXConfig;
import com.taobao.weex.el.parse.Operators;
import com.taobao.weex.performance.WXInstanceApm;
import com.taobao.weex.ui.component.WXBasicComponentType;
import io.dcloud.WebAppActivity;
import io.dcloud.common.DHInterface.IActivityHandler;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.DHInterface.IBoot;
import io.dcloud.common.DHInterface.ICallBack;
import io.dcloud.common.DHInterface.IConfusionMgr;
import io.dcloud.common.DHInterface.IDCloudWebviewClientListener;
import io.dcloud.common.DHInterface.IFeature;
import io.dcloud.common.DHInterface.IFrameView;
import io.dcloud.common.DHInterface.IMgr;
import io.dcloud.common.DHInterface.IOnCreateSplashView;
import io.dcloud.common.DHInterface.IPdrModule;
import io.dcloud.common.DHInterface.ISysEventListener;
import io.dcloud.common.DHInterface.IWebviewStateListener;
import io.dcloud.common.DHInterface.ReceiveSystemEventVoucher;
import io.dcloud.common.adapter.io.DHFile;
import io.dcloud.common.adapter.io.UnicodeInputStream;
import io.dcloud.common.adapter.ui.AdaFrameView;
import io.dcloud.common.adapter.ui.webview.WebViewFactory;
import io.dcloud.common.adapter.util.AndroidResources;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.adapter.util.Logger;
import io.dcloud.common.adapter.util.MessageHandler;
import io.dcloud.common.adapter.util.MobilePhoneModel;
import io.dcloud.common.adapter.util.PermissionUtil;
import io.dcloud.common.adapter.util.PlatformUtil;
import io.dcloud.common.adapter.util.SP;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.constant.DOMException;
import io.dcloud.common.constant.IntentConst;
import io.dcloud.common.core.permission.PermissionControler;
import io.dcloud.common.util.ADUtils;
import io.dcloud.common.util.AppRuntime;
import io.dcloud.common.util.AppStatus;
import io.dcloud.common.util.AppStatusBarManager;
import io.dcloud.common.util.AppStreamUtil;
import io.dcloud.common.util.Base64;
import io.dcloud.common.util.BaseInfo;
import io.dcloud.common.util.CreateShortResultReceiver;
import io.dcloud.common.util.IOUtil;
import io.dcloud.common.util.JSONUtil;
import io.dcloud.common.util.LoadAppUtils;
import io.dcloud.common.util.Md5Utils;
import io.dcloud.common.util.NetworkTypeUtil;
import io.dcloud.common.util.PdrUtil;
import io.dcloud.common.util.StringUtil;
import io.dcloud.common.util.TestUtil;
import io.dcloud.common.util.ThreadPool;
import io.dcloud.common.util.XmlUtil;
import io.dcloud.common.util.Zip4JUtil;
import io.dcloud.common.util.ZipUtils;
import io.dcloud.e.c.g;
import io.dcloud.feature.internal.sdk.SDK;
import io.src.dcloud.adapter.DCloudAdapterUtil;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* access modifiers changed from: package-private */
public class e extends f implements IApp, ISysEventListener {
    public static String r = "webapp";
    String A = "";
    private String A0 = "fast";
    private String A1 = "none";
    String B = "";
    ArrayList<String> B0 = null;
    private String B1 = AbsoluteConst.INSTALL_OPTIONS_FORCE;
    String C = "";
    HashMap<ISysEventListener.SysEventType, ArrayList<ISysEventListener>> C0 = null;
    private String C1 = null;
    String D = null;
    JSONObject D0 = null;
    private String D1 = null;
    String E = "";
    JSONObject E0 = null;
    boolean E1 = true;
    String F = null;
    JSONObject F0 = null;
    HashMap<String, Integer> F1 = null;
    String G = null;
    JSONObject G0 = null;
    String G1 = null;
    String H = null;
    JSONObject H0 = null;
    boolean H1 = false;
    String I = null;
    JSONObject I0 = null;
    String J = null;
    JSONObject J0 = null;
    String K = null;
    JSONObject K0 = null;
    String L = null;
    JSONObject L0 = null;
    boolean M = true;
    String M0 = null;
    boolean N = true;
    String N0 = null;
    boolean O = true;
    Intent O0 = null;
    boolean P = false;
    IApp.IAppStatusListener P0 = null;
    boolean Q = false;
    String Q0 = null;
    boolean R = true;
    private String R0;
    boolean S = false;
    private String S0 = "none";
    private String T = null;
    boolean T0 = false;
    boolean U = false;
    private boolean U0 = false;
    private byte V = 1;
    private boolean V0 = false;
    private boolean W = false;
    private String W0 = "default";
    private boolean X = false;
    private String X0 = null;
    private boolean Y = true;
    private String Y0 = null;
    private boolean Z = true;
    private String Z0 = null;
    private int a0 = 10000;
    private String a1 = "";
    private int b0 = 0;
    protected boolean b1 = false;
    private int c0 = 0;
    private boolean c1 = false;
    private String d0 = null;
    private boolean d1 = false;
    private String e0 = null;
    private String e1 = null;
    private String f0;
    private String f1 = null;
    private String g0;
    private boolean g1 = false;
    private String h0;
    long h1 = 0;
    private String i0;
    boolean i1 = true;
    boolean j0 = false;
    boolean j1 = false;
    private String k0 = null;
    boolean k1 = false;
    String l0 = null;
    ArrayList<String> l1 = new ArrayList<>();
    String m0 = null;
    ArrayList<String> m1 = new ArrayList<>();
    String n0 = null;
    String n1 = null;
    boolean o0 = false;
    String o1 = null;
    String p0 = "accept";
    private String p1 = "";
    String q0 = "file:///android_asset/data/dcloud_error.html";
    private boolean q1 = false;
    String r0 = null;
    private String r1 = null;
    g s = null;
    private String s0 = null;
    private boolean s1 = false;
    BaseInfo.BaseAppInfo t = null;
    String t0 = null;
    private int t1 = 1;
    byte u = 1;
    private String u0 = "-1";
    private IConfusionMgr u1;
    boolean v = false;
    private JSONObject v0 = null;
    private String v1;
    boolean w = false;
    private String w0 = "";
    IWebviewStateListener w1 = null;
    boolean x = false;
    private boolean x0 = true;
    boolean x1 = false;
    a y = null;
    private boolean y0 = false;
    JSONObject y1 = null;
    String z = null;
    private String z0 = AbsoluteConst.UNI_V3;
    private boolean z1 = false;

    /* access modifiers changed from: package-private */
    public class a implements Runnable {
        a() {
        }

        public void run() {
            try {
                DHFile.deleteFile(BaseInfo.sBaseWap2AppTemplatePath + "wap2app_temp/");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class b implements Runnable {
        b() {
        }

        public void run() {
            try {
                DHFile.deleteFile(BaseInfo.sBaseWap2AppTemplatePath + "wap2app_temp/");
                DHFile.deleteFile(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template.zip");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class c implements Runnable {
        final /* synthetic */ ICallBack a;

        class a implements MessageHandler.IMessages {
            a() {
            }

            @Override // io.dcloud.common.adapter.util.MessageHandler.IMessages
            public void execute(Object obj) {
                c.this.a.onCallBack(0, null);
            }
        }

        c(ICallBack iCallBack) {
            this.a = iCallBack;
        }

        public void run() {
            String str = BaseInfo.sCacheFsAppsPath + e.this.p + DeviceInfo.sSeparatorChar + BaseInfo.APP_WWW_FS_DIR;
            long currentTimeMillis = System.currentTimeMillis();
            Logger.d(e.r, e.this.p + " copy resoure begin!!!");
            DHFile.delete(str);
            DHFile.copyDir(e.this.k0, str);
            long currentTimeMillis2 = System.currentTimeMillis();
            Logger.d(e.r, e.this.p + " copy resoure end!!! useTime=" + (currentTimeMillis2 - currentTimeMillis));
            e.this.V = (byte) 0;
            e.this.setAppDataPath(str);
            e eVar = e.this;
            BaseInfo.BaseAppInfo baseAppInfo = eVar.t;
            if (baseAppInfo != null) {
                baseAppInfo.saveToBundleData(eVar.getActivity());
            }
            MessageHandler.sendMessage(new a(), null);
        }
    }

    /* access modifiers changed from: package-private */
    public class d implements Runnable {
        final /* synthetic */ String a;

        d(String str) {
            this.a = str;
        }

        public void run() {
            TestUtil.PointTime.commitTid(e.this.getActivity(), this.a, null, e.this.N0, 1);
        }
    }

    /* access modifiers changed from: package-private */
    /* renamed from: io.dcloud.e.b.e$e  reason: collision with other inner class name */
    public class RunnableC0031e implements Runnable {
        RunnableC0031e() {
        }

        public void run() {
            try {
                DHFile.deleteFile(e.this.obtainAppTempPath());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    static /* synthetic */ class f {
        static final /* synthetic */ int[] a;

        /* JADX WARNING: Can't wrap try/catch for region: R(18:0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|(3:17|18|20)) */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x003e */
        /* JADX WARNING: Missing exception handler attribute for start block: B:13:0x0049 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:15:0x0054 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:17:0x0060 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0012 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x001d */
        /* JADX WARNING: Missing exception handler attribute for start block: B:7:0x0028 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:9:0x0033 */
        static {
            int[] iArr = new int[IApp.ConfigProperty.ThridInfo.values().length];
            a = iArr;
            iArr[IApp.ConfigProperty.ThridInfo.OverrideUrlJsonData.ordinal()] = 1;
            a[IApp.ConfigProperty.ThridInfo.OverrideResourceJsonData.ordinal()] = 2;
            a[IApp.ConfigProperty.ThridInfo.SecondWebviewJsonData.ordinal()] = 3;
            a[IApp.ConfigProperty.ThridInfo.LaunchWebviewJsonData.ordinal()] = 4;
            a[IApp.ConfigProperty.ThridInfo.TitleNViewJsonData.ordinal()] = 5;
            a[IApp.ConfigProperty.ThridInfo.SitemapJsonData.ordinal()] = 6;
            a[IApp.ConfigProperty.ThridInfo.URDJsonData.ordinal()] = 7;
            a[IApp.ConfigProperty.ThridInfo.DirectPageJsonData.ordinal()] = 8;
            try {
                a[IApp.ConfigProperty.ThridInfo.Tabbar.ordinal()] = 9;
            } catch (NoSuchFieldError unused) {
            }
        }
    }

    e(a aVar, String str, byte b2) {
        this.y = aVar;
        this.p = str;
        b(b2);
        this.u1 = io.dcloud.e.c.b.c();
        this.s = new g();
        this.B0 = new ArrayList<>(2);
        this.s1 = AppRuntime.isUniApp(str);
    }

    private void d() {
    }

    private void e() {
        JSONObject jSONObject = this.K0;
        if (jSONObject != null) {
            try {
                String optString = jSONObject.optString("webviewid");
                if (TextUtils.isEmpty(optString)) {
                    this.K0.put("webviewid", IntentConst.DIRECT_PAGE);
                }
                if (this.p.equals(optString)) {
                    this.J0 = this.K0.optJSONObject("titleNView");
                    return;
                }
                JSONObject jSONObject2 = null;
                if (this.K0.has("titleNView")) {
                    jSONObject2 = this.K0.optJSONObject("titleNView");
                }
                if (jSONObject2 == null) {
                    jSONObject2 = new JSONObject();
                    this.K0.put("titleNView", jSONObject2);
                }
                jSONObject2.put("autoBackButton", true);
                if (!jSONObject2.has("homeButton")) {
                    jSONObject2.put("homeButton", true);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    private boolean e(String str) {
        return false;
    }

    private void f() {
        try {
            int rename = DHFile.rename(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/", BaseInfo.sBaseWap2AppTemplatePath + "wap2app_temp/");
            DHFile.copyDir("data/wap2app", BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/");
            if (rename == 1) {
                ThreadPool.self().addThreadTask(new a());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private JSONObject h() {
        try {
            InputStream obtainResInStream = obtainResInStream("_www/__template.json");
            if (obtainResInStream == null) {
                return null;
            }
            JSONObject a2 = a(obtainResInStream);
            IOUtil.close(obtainResInStream);
            return a2;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    private JSONObject i() {
        b bVar;
        ThreadPool threadPool;
        JSONObject jSONObject = null;
        try {
            boolean z2 = true;
            boolean z3 = false;
            if (BaseInfo.sCoverApkRuning) {
                if (new File(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/" + "__template.json").exists()) {
                    InputStream inputStream = PlatformUtil.getInputStream(BaseInfo.sBaseConfigTemplatePath);
                    JSONObject a2 = a(inputStream);
                    String optString = a2.optString("version");
                    IOUtil.close(inputStream);
                    InputStream inputStream2 = DHFile.getInputStream(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/" + "__template.json");
                    JSONObject a3 = a(inputStream2);
                    String optString2 = a3.optString("version");
                    IOUtil.close(inputStream2);
                    BaseInfo.mWap2appTemplateFiles.clear();
                    BaseInfo.mW2AE.clear();
                    if (BaseInfo.BaseAppInfo.compareVersion(optString, optString2)) {
                        f();
                        z3 = true;
                        jSONObject = a2;
                    } else {
                        jSONObject = a3;
                    }
                }
            }
            if (DHFile.isExist(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template.zip")) {
                DHFile.rename(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/", BaseInfo.sBaseWap2AppTemplatePath + "wap2app_temp/");
                try {
                    ZipUtils.upZipFile(new File(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template.zip"), BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/");
                    threadPool = ThreadPool.self();
                    bVar = new b();
                } catch (IOException e) {
                    e.printStackTrace();
                    threadPool = ThreadPool.self();
                    bVar = new b();
                    z2 = z3;
                } catch (Throwable th) {
                    ThreadPool.self().addThreadTask(new b());
                    throw th;
                }
                threadPool.addThreadTask(bVar);
            } else {
                if (!new File(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/" + "__template.json").exists()) {
                    f();
                } else {
                    z2 = z3;
                }
            }
            if (!z2 && !TextUtils.isEmpty(BaseInfo.sWap2AppTemplateVersion) && BaseInfo.mWap2appTemplateFiles.size() != 0 && this.u1.getData("__w2a__template__") != null) {
                return jSONObject;
            }
            if (!DHFile.isExist(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/" + "__template.json")) {
                return jSONObject;
            }
            InputStream inputStream3 = DHFile.getInputStream(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/" + "__template.json");
            JSONObject a4 = a(inputStream3);
            IOUtil.close(inputStream3);
            BaseInfo.mWap2appTemplateFiles.clear();
            BaseInfo.mW2AE.clear();
            this.u1.removeData("__w2a__template__");
            return a4;
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    private void l() {
        String[] split;
        this.F1 = new HashMap<>();
        String string = SP.getOrCreateBundle(getActivity(), this.p + "_" + 1).getString("Authorize", null);
        this.G1 = string;
        if (!(string == null || (split = string.split("&")) == null || split.length <= 0)) {
            for (String str : split) {
                if (!TextUtils.isEmpty(str)) {
                    String[] split2 = str.split("=");
                    this.F1.put(split2[0], Integer.valueOf(Integer.parseInt(split2[1])));
                }
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:19:0x0066  */
    /* JADX WARNING: Removed duplicated region for block: B:57:0x01ae  */
    /* JADX WARNING: Removed duplicated region for block: B:60:0x01bc  */
    private void x() {
        boolean z2;
        Context activity;
        String handleEncryption;
        if (BaseInfo.isWap2AppAppid(this.p)) {
            JSONObject i = i();
            String optString = i == null ? BaseInfo.sWap2AppTemplateVersion : i.optString("version");
            try {
                JSONObject h = h();
                if (h != null) {
                    String optString2 = h.optString("version");
                    if (!TextUtils.isEmpty(optString2) && BaseInfo.BaseAppInfo.compareVersion(optString2, optString)) {
                        DHFile.deleteFile(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/");
                        BaseInfo.mWap2appTemplateFiles.clear();
                        BaseInfo.mW2AE.clear();
                        optString = optString2;
                        i = h;
                        z2 = true;
                        if (BaseInfo.mWap2appTemplateFiles.size() == 0) {
                            if (i == null || !i.has("files")) {
                                String[] list = new File(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/").list();
                                if (list != null) {
                                    for (String str : list) {
                                        BaseInfo.mWap2appTemplateFiles.add(str);
                                    }
                                }
                            } else {
                                JSONArray optJSONArray = i.optJSONArray("files");
                                int length = optJSONArray.length();
                                boolean z3 = obtainRunningAppMode() == 1;
                                for (int i2 = 0; i2 < length; i2++) {
                                    String optString3 = optJSONArray.optString(i2);
                                    BaseInfo.mWap2appTemplateFiles.add(optString3);
                                    if (z2) {
                                        if (z3) {
                                            DHFile.copyAssetsFile(BaseInfo.sBaseResAppsPath + this.p + "/www/" + optString3, BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/" + optString3);
                                        } else {
                                            DHFile.copyFile(BaseInfo.sCacheFsAppsPath + this.p + "/www/" + optString3, BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/" + optString3, true, false);
                                        }
                                    }
                                }
                                if (z2 && !BaseInfo.mWap2appTemplateFiles.contains("__template.json")) {
                                    if (z3) {
                                        DHFile.copyAssetsFile(BaseInfo.sBaseResAppsPath + this.p + "/www/__template.json", BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/" + "__template.json");
                                    } else {
                                        DHFile.copyFile(BaseInfo.sCacheFsAppsPath + this.p + "/www/__template.json", BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/" + "__template.json", true, false);
                                    }
                                }
                            }
                        }
                        if ((z2 || this.u1.getData("__w2a__template__") == null) && i != null && i.has(IApp.ConfigProperty.CONFIG_CONFUSION)) {
                            byte[] decode2bytes = Base64.decode2bytes(i.optString(IApp.ConfigProperty.CONFIG_CONFUSION));
                            activity = getActivity();
                            if (activity == null) {
                                activity = DeviceInfo.sApplicationContext;
                            }
                            handleEncryption = this.u1.handleEncryption(activity, decode2bytes);
                            if (PdrUtil.isEmpty(handleEncryption)) {
                                handleEncryption = "{}";
                            }
                            this.u1.removeData("__w2a__template__");
                            this.u1.recordEncryptionResources("__w2a__template__", new JSONObject(handleEncryption));
                        }
                        BaseInfo.sTemplateModifyTime = new File(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/__template.json").lastModified();
                        BaseInfo.sWap2AppTemplateVersion = optString;
                        this.D = optString;
                    }
                }
                z2 = false;
                if (BaseInfo.mWap2appTemplateFiles.size() == 0) {
                }
                byte[] decode2bytes2 = Base64.decode2bytes(i.optString(IApp.ConfigProperty.CONFIG_CONFUSION));
                activity = getActivity();
                if (activity == null) {
                }
                handleEncryption = this.u1.handleEncryption(activity, decode2bytes2);
                if (PdrUtil.isEmpty(handleEncryption)) {
                }
                this.u1.removeData("__w2a__template__");
                this.u1.recordEncryptionResources("__w2a__template__", new JSONObject(handleEncryption));
                BaseInfo.sTemplateModifyTime = new File(BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/__template.json").lastModified();
                BaseInfo.sWap2AppTemplateVersion = optString;
                this.D = optString;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void addAllFeaturePermission() {
        PermissionControler.registerRootPermission(this.p);
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void addFeaturePermission(String str) {
        this.B0.add(str.toLowerCase(Locale.ENGLISH));
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void applyMani() {
        try {
            a(DHFile.getInputStream(DHFile.createFileHandler(a(BaseInfo.sConfigXML))), this.p, null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void applySmartUpdate() {
        a(false);
    }

    /* access modifiers changed from: package-private */
    public void b(InputStream inputStream) {
    }

    /* access modifiers changed from: package-private */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x0053 A[Catch:{ Exception -> 0x00e1, all -> 0x00df }] */
    /* JADX WARNING: Removed duplicated region for block: B:20:0x0058 A[Catch:{ Exception -> 0x00e1, all -> 0x00df }] */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x005b A[Catch:{ Exception -> 0x00e1, all -> 0x00df }] */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x00a2  */
    public boolean b(String str, JSONObject jSONObject) {
        boolean z2;
        boolean z3 = false;
        InputStream inputStream = null;
        try {
            this.p = str;
            this.u1.removeData(str);
            k();
            if (this.V != 0) {
                HashMap<String, BaseInfo.BaseAppInfo> hashMap = BaseInfo.mBaseAppInfoSet;
                if (hashMap == null || hashMap.containsKey(this.p)) {
                    if (this.V == 1) {
                        inputStream = PlatformUtil.getResInputStream(a(BaseInfo.sConfigXML));
                    }
                    if (!BaseInfo.isWap2AppAppid(this.p)) {
                        x();
                        z2 = false;
                    } else {
                        z2 = true;
                    }
                    if (inputStream == null) {
                        z3 = a(inputStream, str, jSONObject);
                        if (z2) {
                            x();
                        }
                        g gVar = this.s;
                        if (gVar != null && gVar.a) {
                            Logger.i("WebApp", "InstallError---msg=" + this.s.b);
                        }
                        IActivityHandler iActivityHandler = DCloudAdapterUtil.getIActivityHandler(getActivity());
                        if (iActivityHandler != null) {
                            iActivityHandler.updateSplash(this.t0);
                        }
                        this.v = true;
                        IOUtil.close(inputStream);
                        return z3;
                    } else if (BaseInfo.isWap2AppAppid(this.p) && !TextUtils.isEmpty(this.n1)) {
                        IOUtil.close(inputStream);
                        return true;
                    } else if (!q() || TextUtils.isEmpty(this.r0)) {
                        g gVar2 = this.s;
                        gVar2.a = true;
                        if (gVar2.c) {
                            gVar2.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGTU_WWW_MANIFEST_NOT_EXIST, DOMException.MSG_RUNTIME_WGTU_WWW_MANIFEST_NOT_EXIST);
                        } else {
                            gVar2.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGT_MANIFEST_NOT_EXIST, DOMException.MSG_RUNTIME_WGT_MANIFEST_NOT_EXIST);
                        }
                        IOUtil.close(inputStream);
                        return false;
                    } else {
                        IOUtil.close(inputStream);
                        return true;
                    }
                }
            }
            inputStream = DHFile.getInputStream(DHFile.createFileHandler(a(BaseInfo.sConfigXML)));
            if (inputStream == null && (inputStream = PlatformUtil.getResInputStream(a(BaseInfo.sConfigXML))) != null) {
                this.V = 1;
            }
            if (!BaseInfo.isWap2AppAppid(this.p)) {
            }
            if (inputStream == null) {
            }
        } catch (Exception e) {
            Logger.w("parseConfig", e);
        } catch (Throwable th) {
            IOUtil.close((InputStream) null);
            throw th;
        }
    }

    /* access modifiers changed from: package-private */
    public void c() {
        Activity activity = this.a;
        if (activity != null && (activity instanceof WebAppActivity)) {
            ((WebAppActivity) activity).onAppActive(this.p);
            ((WebAppActivity) this.a).onAppActive(this);
        }
        diyStatusBarState();
        setStatus((byte) 3);
        this.b.onAppActive(this);
        callSysEventListener(ISysEventListener.SysEventType.onWebAppForeground, IntentConst.obtainArgs(obtainWebAppIntent(), this.p));
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean callSysEventListener(ISysEventListener.SysEventType sysEventType, Object obj) {
        HashMap<ISysEventListener.SysEventType, ArrayList<ISysEventListener>> hashMap = this.C0;
        boolean z2 = false;
        if (hashMap == null) {
            return false;
        }
        ArrayList<ISysEventListener> arrayList = hashMap.get(sysEventType);
        ArrayList<ISysEventListener> arrayList2 = this.C0.get(ISysEventListener.SysEventType.AllSystemEvent);
        ArrayList arrayList3 = new ArrayList();
        if (arrayList != null) {
            arrayList3.addAll(arrayList);
        }
        if (arrayList2 != null) {
            arrayList3.addAll(arrayList2);
        }
        for (int size = arrayList3.size() - 1; size >= 0; size--) {
            ISysEventListener iSysEventListener = (ISysEventListener) arrayList3.get(size);
            if (a(iSysEventListener, sysEventType) && (z2 || iSysEventListener.onExecute(sysEventType, obj)) && !a(sysEventType)) {
                break;
            }
        }
        return z2;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean checkIsCustomPath() {
        return this.o0;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void checkOrLoadlaunchWebview() {
        a aVar = this.y;
        if (aVar != null) {
            AdaFrameView adaFrameView = (AdaFrameView) aVar.processEvent(IMgr.MgrType.WindowMgr, 46, obtainAppId());
            Logger.d("Direct_page", "checkOrLoadlaunchWebview " + manifestBeParsed() + ";adaFrameView=" + adaFrameView);
            this.x1 = manifestBeParsed() ^ true;
            if (adaFrameView != null && manifestBeParsed()) {
                adaFrameView.obtainWebView().checkIfNeedLoadOriginalUrl();
            }
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean checkPrivateDir(String str) {
        return str.startsWith(obtainAppDataPath()) || str.startsWith(BaseInfo.REL_PRIVATE_WWW_DIR);
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String checkPrivateDirAndCopy2Temp(String str) {
        if (obtainRunningAppMode() == 1 && checkPrivateDir(str)) {
            String str2 = "/" + BaseInfo.APP_WWW_FS_DIR;
            String substring = str.substring(str.indexOf(str2) + str2.length());
            String str3 = this.k0 + substring;
            str = obtainAppTempPath() + substring;
            if (!DHFile.exists(str)) {
                DHFile.copyAssetsFile(str3, str);
            }
        }
        return str;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean checkSchemeWhite(String str) {
        if (!q()) {
            return true;
        }
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        Iterator<String> it = this.m1.iterator();
        while (it.hasNext()) {
            String next = it.next();
            if (!TextUtils.equals(next, Operators.MUL)) {
                if (str.startsWith(next + ":")) {
                }
            }
            return true;
        }
        return false;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean checkWhiteUrl(String str) {
        if (!TextUtils.isEmpty(str)) {
            return this.l1.contains(Operators.MUL) || this.l1.contains(str);
        }
        return false;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void clearRuntimeArgs() {
        this.E = "";
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String convert2AbsFullPath(String str, String str2) {
        boolean z2 = true;
        try {
            if (!PdrUtil.isEmpty(str2) && ((this.V == 1 && PlatformUtil.isResFileExists(str2)) || DHFile.isExist(str2))) {
                return str2;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (PdrUtil.isEmpty(str2)) {
            return str2;
        }
        int indexOf = str2.indexOf(Operators.CONDITION_IF_STRING);
        if (indexOf > 0) {
            str2 = str2.substring(0, indexOf);
        }
        if (str2.startsWith("_documents/")) {
            return BaseInfo.sDocumentFullPath + str2.substring(11);
        } else if (str2.startsWith(BaseInfo.REL_PUBLIC_DOCUMENTS_DIR)) {
            return BaseInfo.sDocumentFullPath + str2.substring(10);
        } else if (str2.startsWith(AbsoluteConst.MINI_SERVER_APP_DOC)) {
            return obtainAppDocPath() + str2.substring(5);
        } else if (str2.startsWith(BaseInfo.REL_PRIVATE_DOC_DIR)) {
            return obtainAppDocPath() + str2.substring(4);
        } else if (str2.startsWith("_downloads/")) {
            return BaseInfo.sDownloadFullPath + str2.substring(11);
        } else if (str2.startsWith(BaseInfo.REL_PUBLIC_DOWNLOADS_DIR)) {
            return BaseInfo.sDownloadFullPath + str2.substring(10);
        } else if (str2.startsWith(AbsoluteConst.MINI_SERVER_APP_WWW)) {
            byte b2 = this.V;
            if (b2 == 1) {
                return BaseInfo.sBaseResAppsPath + this.p + "/" + BaseInfo.APP_WWW_FS_DIR + str2.substring(5);
            } else if (b2 != 0) {
                return str2;
            } else {
                return this.k0 + str2.substring(5);
            }
        } else if (str2.startsWith(BaseInfo.REL_PRIVATE_WWW_DIR)) {
            byte b3 = this.V;
            if (b3 == 1) {
                return BaseInfo.sBaseResAppsPath + this.p + "/" + BaseInfo.APP_WWW_FS_DIR + str2.substring(4);
            } else if (b3 != 0) {
                return str2;
            } else {
                return this.k0 + str2.substring(4);
            }
        } else if (str2.startsWith(DeviceInfo.FILE_PROTOCOL)) {
            return str2.substring(7);
        } else {
            if (str2.startsWith("content://") || str2.startsWith(DeviceInfo.sDeviceRootDir)) {
                return str2;
            }
            if (str2.startsWith("http://localhost")) {
                String substring = str2.substring(16);
                return convert2AbsFullPath(null, substring.substring(substring.indexOf("/") + 1));
            }
            if (!str2.startsWith("/") && str != null) {
                z2 = false;
            } else if (str2.startsWith("/")) {
                str2 = str2.substring(1);
            }
            if (str != null) {
                if (str.startsWith(SDK.ANDROID_ASSET)) {
                    str = str.substring(22);
                } else if (str.startsWith(DeviceInfo.FILE_PROTOCOL)) {
                    str = str.substring(7);
                }
            }
            if (str != null && !z2) {
                return PdrUtil.standardizedURL(str, str2);
            }
            if (!z2) {
                return str2;
            }
            String obtainAppDataPath = obtainAppDataPath();
            if (str != null && !PdrUtil.isEquals(str, obtainAppDataPath) && str.contains("/www/")) {
                obtainAppDataPath = str.substring(0, str.indexOf("/www/") + 5);
            }
            return obtainAppDataPath + b(str2);
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String convert2LocalFullPath(String str, String str2) {
        InputStream inputStream;
        String convert2AbsFullPath = convert2AbsFullPath(str, str2);
        byte b2 = this.V;
        if (b2 == 1 || DeviceInfo.isPrivateDirectory) {
            if (b2 == 1) {
                inputStream = PlatformUtil.getResInputStream(convert2AbsFullPath);
            } else {
                inputStream = PlatformUtil.getInputStream(convert2AbsFullPath);
            }
            if (inputStream != null) {
                convert2AbsFullPath = obtainAppTempPath() + System.currentTimeMillis();
                try {
                    DHFile.writeFile(inputStream, convert2AbsFullPath);
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        } else if (b2 == 0) {
            return convert2AbsFullPath;
        }
        return convert2AbsFullPath;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String convert2RelPath(String str) {
        try {
            int length = obtainAppDataPath().length();
            int length2 = obtainAppDocPath().length();
            int length3 = BaseInfo.sDocumentFullPath.length();
            int length4 = BaseInfo.sDownloadFullPath.length();
            if (str.startsWith(obtainAppDataPath())) {
                return BaseInfo.REL_PRIVATE_WWW_DIR + str.substring(length - 1);
            }
            int i = length - 1;
            if (str.startsWith(obtainAppDataPath().substring(0, i))) {
                return BaseInfo.REL_PRIVATE_WWW_DIR + str.substring(i, str.length());
            } else if (str.startsWith(obtainAppDocPath())) {
                return BaseInfo.REL_PRIVATE_DOC_DIR + str.substring(length2 - 1);
            } else {
                int i2 = length2 - 1;
                if (str.startsWith(obtainAppDocPath().substring(0, i2))) {
                    return BaseInfo.REL_PRIVATE_DOC_DIR + str.substring(i2);
                } else if (str.startsWith(BaseInfo.sDocumentFullPath)) {
                    return BaseInfo.REL_PUBLIC_DOCUMENTS_DIR + str.substring(length3 - 1);
                } else {
                    int i3 = length3 - 1;
                    if (str.startsWith(BaseInfo.sDocumentFullPath.substring(0, i3))) {
                        return BaseInfo.REL_PUBLIC_DOCUMENTS_DIR + str.substring(i3);
                    } else if (str.startsWith(BaseInfo.sDownloadFullPath)) {
                        return BaseInfo.REL_PUBLIC_DOWNLOADS_DIR + str.substring(length4 - 1);
                    } else {
                        int i4 = length4 - 1;
                        if (!str.startsWith(BaseInfo.sDownloadFullPath.substring(0, i4))) {
                            return str;
                        }
                        return BaseInfo.REL_PUBLIC_DOWNLOADS_DIR + str.substring(i4);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            return str;
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String convert2WebviewFullPath(String str, String str2) {
        if (PdrUtil.isEmpty(str2)) {
            return str2;
        }
        if (this.U) {
            if (str2.startsWith(DeviceInfo.HTTP_PROTOCOL)) {
                return str2;
            }
            return this.s0 + str2;
        } else if (str2.startsWith(DeviceInfo.FILE_PROTOCOL) || str2.startsWith(DeviceInfo.HTTP_PROTOCOL) || str2.startsWith(DeviceInfo.HTTPS_PROTOCOL)) {
            return str2;
        } else {
            try {
                if (DHFile.isExist(str2)) {
                    return "file:///" + b(str2);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (str2.startsWith(DeviceInfo.sDeviceRootDir)) {
                return DeviceInfo.FILE_PROTOCOL + str2;
            }
            boolean z2 = true;
            if (str2.startsWith("/")) {
                str2 = str2.substring(1);
            } else {
                z2 = false;
            }
            if (str2.startsWith(BaseInfo.REL_PRIVATE_WWW_DIR)) {
                return obtainWebviewBaseUrl() + b(str2.substring(4));
            } else if (str2.startsWith(BaseInfo.REL_PUBLIC_DOCUMENTS_DIR)) {
                return DeviceInfo.FILE_PROTOCOL + BaseInfo.sDocumentFullPath + b(str2.substring(10));
            } else if (str2.startsWith(BaseInfo.REL_PRIVATE_DOC_DIR)) {
                return DeviceInfo.FILE_PROTOCOL + obtainAppDocPath() + b(str2.substring(4));
            } else if (str2.startsWith(BaseInfo.REL_PUBLIC_DOWNLOADS_DIR)) {
                return DeviceInfo.FILE_PROTOCOL + BaseInfo.sDownloadFullPath + b(str2.substring(10));
            } else if (str != null && !z2) {
                return PdrUtil.standardizedURL(str, str2);
            } else {
                String obtainWebviewBaseUrl = obtainWebviewBaseUrl();
                if (str != null && !PdrUtil.isEquals(str, obtainWebviewBaseUrl) && str.contains("/www/")) {
                    obtainWebviewBaseUrl = str.substring(0, str.indexOf("/www/") + 5);
                }
                return obtainWebviewBaseUrl + b(str2);
            }
        }
    }

    /* access modifiers changed from: package-private */
    public JSONObject d(String str) {
        if (this.y1 == null) {
            m();
        }
        if (this.y1 == null || TextUtils.isEmpty(str)) {
            return null;
        }
        return PdrUtil.getSitemapParameters(this.y1, obtainAppId(), str);
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void deleteAppTemp() {
        ThreadPool.self().addThreadTask(new RunnableC0031e(), true);
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void diyStatusBarState() {
        AppStatusBarManager appStatusBarManager = this.m;
        if (appStatusBarManager != null) {
            if (this.i) {
                appStatusBarManager.setFullScreen(getActivity(), this.i);
            } else {
                int i = 0;
                if (appStatusBarManager.checkImmersedStatusBar(getActivity(), this.b1)) {
                    BaseInfo.isImmersive = true;
                    this.m.setImmersive(getActivity(), true);
                } else {
                    BaseInfo.isImmersive = false;
                    this.m.setImmersive(getActivity(), false);
                }
                if (Build.VERSION.SDK_INT >= 21 && getActivity() != null) {
                    if (!PdrUtil.isEmpty(this.X0)) {
                        if (this.X0.startsWith("#")) {
                            i = PdrUtil.stringToColor(this.X0);
                        }
                        this.m.setStatusBarColor(getActivity(), i);
                    } else {
                        this.m.setStatusBarColor(getActivity(), BaseInfo.mDeStatusBarBackground);
                    }
                }
                this.m.setStatusBarMode(getActivity(), this.a1);
            }
            if (this.m.isFullScreenOrImmersive()) {
                updateScreenInfo(2);
            }
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String forceShortCut() {
        return this.B1;
    }

    /* access modifiers changed from: package-private */
    public boolean g(String str) {
        setRuntimeArgs(str);
        setStatus((byte) 3);
        Object processEvent = this.y.processEvent(IMgr.MgrType.WindowMgr, 41, new Object[]{this, convert2WebviewFullPath(null, this.r0), Boolean.valueOf(this.T0)});
        if (processEvent == null) {
            return true;
        }
        return Boolean.parseBoolean(String.valueOf(processEvent));
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public IConfusionMgr getConfusionMgr() {
        return this.u1;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String getDirectPage() {
        return this.n1;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public IApp.IAppStatusListener getIAppStatusListener() {
        return this.P0;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String getOriginalDirectPage() {
        return this.o1;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String getPathByType(byte b2) {
        if (b2 == 0) {
            return obtainAppDataPath();
        }
        if (b2 == 1) {
            return obtainAppDocPath();
        }
        if (b2 == 2) {
            return BaseInfo.sDocumentFullPath;
        }
        if (b2 == 3) {
            return BaseInfo.sDownloadFullPath;
        }
        if (b2 != -1) {
            return null;
        }
        return BaseInfo.sBaseResAppsPath + this.p + "/" + BaseInfo.APP_WWW_FS_DIR;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String getPopGesture() {
        return this.S0;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public int getQuitModel() {
        return this.t1;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String getSystemInfo() {
        try {
            if (DeviceInfo.sSystemInfo == null) {
                return null;
            }
            JSONObject jSONObject = new JSONObject(DeviceInfo.sSystemInfo.toString());
            jSONObject.put("uniCompileVersion", this.u0);
            jSONObject.put("uniRuntimeVersion", BaseInfo.uniVersionV3);
            jSONObject.put("browserName", WebViewFactory.isOther() ? "x5webview" : "chrome");
            jSONObject.put("appId", BaseInfo.sCurrentAppOriginalAppid);
            jSONObject.put(WXConfig.appName, this.t0);
            if (SDK.isUniMP) {
                jSONObject.put(WXConfig.appVersion, this.A);
                jSONObject.put("appVersionCode", this.B);
            } else {
                jSONObject.put(WXConfig.appVersion, b(getActivity()));
                jSONObject.put("appVersionCode", a((Context) getActivity()));
            }
            jSONObject.put("appWgtVersion", this.A);
            return jSONObject.toString();
        } catch (Exception unused) {
            return null;
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean isOnAppRunningMode() {
        return this.V == 1;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean isUniApp() {
        return this.s1;
    }

    public float j() {
        return (!PermissionControler.checkPermission(this.p, IFeature.F_DEVICE.toLowerCase(Locale.ENGLISH)) || getActivity() == null || NetworkTypeUtil.getNetworkType(getActivity()) != 4) ? 0.0f : 1000.0f;
    }

    /* access modifiers changed from: package-private */
    public void k() {
        if (PdrUtil.isEmpty(this.k0) || !DeviceInfo.startsWithSdcard(this.k0)) {
            setAppDataPath(BaseInfo.sCacheFsAppsPath + this.p + "/" + BaseInfo.REAL_PRIVATE_WWW_DIR);
        }
        if (PdrUtil.isEmpty(this.C1) || !DeviceInfo.startsWithSdcard(this.C1)) {
            setAppDocPath(BaseInfo.sBaseFsAppsPath + this.p + "/" + BaseInfo.REAL_PRIVATE_DOC_DIR);
        }
        if (PdrUtil.isEmpty(this.D1) || !DeviceInfo.startsWithSdcard(this.D1)) {
            this.D1 = BaseInfo.sCacheFsAppsPath + this.p + "/" + BaseInfo.APP_WEB_CHACHE;
        }
    }

    /* access modifiers changed from: package-private */
    public void m() {
        File file = new File(c(this.p));
        if (file.exists()) {
            try {
                JSONObject jSONObject = new JSONObject(IOUtil.toString(new FileInputStream(file)));
                this.y1 = jSONObject;
                this.C = jSONObject.optString("version");
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            byte[] fileContent = PlatformUtil.getFileContent("data/sitemap/" + this.p + ".json", 0);
            if (fileContent != null) {
                DHFile.writeFile(fileContent, 0, c(this.p));
                m();
            }
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean manifestBeParsed() {
        return this.v || SDK.IntegratedMode.WEBVIEW == BaseInfo.sRuntimeMode;
    }

    public boolean n() {
        if (!q() || !this.v) {
            return true;
        }
        return this.P;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean needRefreshApp() {
        return this.k1;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean needReload() {
        return this.j1;
    }

    public boolean o() {
        String str;
        if (PdrUtil.isEmpty(BaseInfo.uniVersionV3)) {
            String str2 = "uni-jsframework-dev.js";
            if (!BaseInfo.SyncDebug || PlatformUtil.getResInputStream(str2) == null || SDK.isUniMPSDK()) {
                str2 = "uni-jsframework.js";
            }
            try {
                str = new JSONObject(new BufferedReader(new InputStreamReader(getActivity().getAssets().open(str2))).readLine().substring(2)).optString("version");
                BaseInfo.uniVersionV3 = str;
            } catch (IOException | JSONException unused) {
                str = "";
            }
        } else {
            str = BaseInfo.uniVersionV3;
        }
        if ((PdrUtil.isEmpty(this.w0) || !this.w0.contains(str) || this.x0) && !this.y0 && this.v && !this.u0.equals("-1") && !this.u0.trim().equals(str) && !PdrUtil.isEmpty(str) && this.s1) {
            return true;
        }
        return false;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAdaptationJs() {
        if (this.T == null && !PdrUtil.isEmpty(this.K)) {
            byte[] fileContent = PlatformUtil.getFileContent(a(this.K), obtainRunningAppMode() == 1 ? 0 : 2);
            if (fileContent != null) {
                this.T = new String(fileContent);
            } else {
                this.T = "";
            }
        }
        return this.T;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAppDataPath() {
        String str = this.k0;
        if (str != null) {
            return str;
        }
        return this.p + "/www/";
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAppDocPath() {
        return this.C1;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAppId() {
        return this.p;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAppInfo() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("appid", this.p);
            jSONObject.put("versionName", this.A);
            jSONObject.put("name", this.t0);
            jSONObject.put("versionCode", this.B);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return jSONObject.toString();
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAppLog() {
        return BaseInfo.sBaseFsAppsPath + this.p + "/log/";
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAppName() {
        return this.t0;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public byte obtainAppStatus() {
        return this.u;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAppTempPath() {
        return BaseInfo.sBaseFsAppsPath + this.p + "/temp/";
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAppVersionName() {
        return this.A;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAppWebCachePath() {
        return this.D1;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainAuthority(String str) {
        String str2 = BaseInfo.sGlobalAuthority;
        if ((str2 != null && TextUtils.equals(Operators.MUL, str2)) || !q() || TextUtils.isEmpty(str) || e(this.p)) {
            return IApp.AUTHORITY_AUTHORIZED;
        }
        JSONObject jSONObject = this.I0;
        if (jSONObject == null) {
            return IApp.AUTHORITY_UNDETERMINED;
        }
        Iterator<String> keys = jSONObject.keys();
        while (keys.hasNext()) {
            String next = keys.next();
            if (str.equalsIgnoreCase(next)) {
                return this.I0.optString(next, IApp.AUTHORITY_UNDETERMINED);
            }
        }
        return IApp.AUTHORITY_UNDETERMINED;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainConfigProperty(String str) {
        String str2;
        if (PdrUtil.isEquals(str, "adid")) {
            str2 = this.N0;
        } else if (PdrUtil.isEquals(str, "launchError")) {
            str2 = this.M0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_AUTOCLOSE)) {
            str2 = String.valueOf(this.Y);
        } else if (PdrUtil.isEquals(str, "timeout")) {
            str2 = String.valueOf(this.a0);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_DELAY)) {
            str2 = String.valueOf(this.b0);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_SPLASHSCREEN)) {
            str2 = String.valueOf(this.W);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_WAITING)) {
            str2 = String.valueOf(this.X);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_H5PLUS)) {
            str2 = String.valueOf(this.R);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_funSetUA)) {
            str2 = String.valueOf(this.S);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_USER_AGENT)) {
            str2 = this.L;
        } else if (PdrUtil.isEquals(str, "error")) {
            str2 = this.q0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_FULLSCREEN)) {
            str2 = String.valueOf(this.i);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_UNTRUSTEDCA)) {
            str2 = this.p0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_LOADED_TIME)) {
            str2 = this.Q0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_RAM_CACHE_MODE)) {
            str2 = this.R0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_JSERROR)) {
            str2 = this.N + "";
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_CRASH)) {
            str2 = this.M + "";
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_USE_ENCRYPTION)) {
            str2 = this.U0 + "";
        } else if (PdrUtil.isEquals(str, "w2a_delay")) {
            str2 = String.valueOf(this.c0);
        } else if (PdrUtil.isEquals(str, "w2a_autoclose")) {
            str2 = String.valueOf(this.Z);
        } else if (PdrUtil.isEquals(str, "wap2app_running_mode")) {
            str2 = this.O + "";
        } else if (PdrUtil.isEquals(str, "injection")) {
            str2 = this.i1 + "";
        } else if (PdrUtil.isEquals(str, "event")) {
            str2 = this.d0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_TARGET)) {
            str2 = this.e0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_LPLUSERQUIRE)) {
            str2 = this.f0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_SPLUSERQUIRE)) {
            str2 = this.g0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_LGEOLOCATION)) {
            str2 = this.h0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_SGEOLOCATION)) {
            str2 = this.i0;
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_BC)) {
            str2 = this.X0 + "";
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_MODE)) {
            str2 = this.a1;
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_IMMERSED)) {
            str2 = this.b1 + "";
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_LAUNCH_ISSTATUS)) {
            str2 = String.valueOf(this.c1);
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_LAUNCH_STATUSBAR_COLOR)) {
            str2 = this.e1;
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_SECOND_ISATATUS)) {
            str2 = String.valueOf(this.d1);
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_SECOND_STATUSBAR_COLOR)) {
            str2 = this.f1;
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_MAP_COORD_TYPE)) {
            str2 = this.p1;
        } else if (PdrUtil.isEquals(str, AbsoluteConst.UNIAPP_WEEX_JS_SERVICE)) {
            str2 = String.valueOf(this.g1);
        } else if (PdrUtil.isEquals(str, AbsoluteConst.APP_UNIAPP_VERSION)) {
            str2 = this.u0;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_UNIAPP_CONTROL)) {
            str2 = this.s1 ? this.z0 : "h5+";
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.UNI_NVUE_DATA)) {
            JSONObject jSONObject = this.v0;
            if (jSONObject == null) {
                return null;
            }
            return jSONObject.toString();
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_CONCATENATE)) {
            return this.Q + "";
        } else if (PdrUtil.isEquals(str, AbsoluteConst.NVUE_LAUNCH_MODE)) {
            return this.A0;
        } else {
            if (PdrUtil.isEquals(str, AbsoluteConst.JSON_KEY_DEBUG_REFRESH)) {
                return this.r1;
            }
            if (PdrUtil.isEquals(str, IApp.ConfigProperty.UNI_RESTART_TO_DIRECT)) {
                return String.valueOf(this.q1);
            }
            if (PdrUtil.isEquals(str, AbsoluteConst.APP_IS_UNIAPP)) {
                return String.valueOf(this.s1);
            }
            if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_USE_V3_ENCRYPTION)) {
                return String.valueOf(this.V0);
            }
            if (PdrUtil.isEquals(str, IntentConst.UNIMP_RUN_EXTRA_INFO)) {
                return this.v1;
            }
            return null;
        }
        return str2;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public IWebviewStateListener obtainLaunchPageStateListener() {
        return this.w1;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public Object obtainMgrData(IMgr.MgrType mgrType, int i, Object[] objArr) {
        return this.y.processEvent(mgrType, i, objArr);
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainOriginalAppId() {
        return this.z;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public InputStream obtainResInStream(String str, String str2) {
        String convert2AbsFullPath = convert2AbsFullPath(str, str2);
        byte b2 = this.V;
        if (b2 != 1) {
            if (b2 == 0) {
                try {
                    return DHFile.getInputStream(DHFile.createFileHandler(convert2AbsFullPath));
                } catch (IOException e) {
                    Logger.w("WebApp.obtainResInStream", e);
                }
            }
            return null;
        } else if (!PdrUtil.isDeviceRootDir(convert2AbsFullPath)) {
            return PlatformUtil.getResInputStream(convert2AbsFullPath);
        } else {
            try {
                return DHFile.getInputStream(DHFile.createFileHandler(convert2AbsFullPath));
            } catch (IOException e2) {
                Logger.w("WebApp.obtainResInStream", e2);
            }
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public byte obtainRunningAppMode() {
        return this.V;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainRuntimeArgs(boolean z2) {
        if (z2) {
            return JSONObject.quote(this.E);
        }
        return this.E;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public AppStatusBarManager obtainStatusBarMgr() {
        return this.m;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public JSONObject obtainThridInfo(IApp.ConfigProperty.ThridInfo thridInfo) {
        switch (f.a[thridInfo.ordinal()]) {
            case 1:
                return this.D0;
            case 2:
                return this.F0;
            case 3:
                return this.G0;
            case 4:
                return this.H0;
            case 5:
                return this.J0;
            case 6:
                m();
                return this.y1;
            case 7:
                return this.y.h;
            case 8:
                return this.K0;
            case 9:
                return this.E0;
            default:
                return null;
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainVersionSitemap() {
        return this.C;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public Intent obtainWebAppIntent() {
        return this.O0;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String obtainWebviewBaseUrl() {
        return a(this.V);
    }

    @Override // io.dcloud.common.DHInterface.ISysEventListener
    public boolean onExecute(ISysEventListener.SysEventType sysEventType, Object obj) {
        byte b2 = this.u;
        if (b2 == 3) {
            return callSysEventListener(sysEventType, obj);
        }
        if (b2 == 1 && (sysEventType == ISysEventListener.SysEventType.onWebAppStop || sysEventType == ISysEventListener.SysEventType.onStop)) {
            s();
        }
        return false;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void onSplashClosed() {
        diyStatusBarState();
    }

    public boolean p() {
        return this.u == 3;
    }

    public boolean q() {
        Intent obtainWebAppIntent = obtainWebAppIntent();
        if (obtainWebAppIntent != null) {
            boolean z2 = this.H1;
            this.H1 = obtainWebAppIntent.getBooleanExtra(IntentConst.IS_STREAM_APP, z2) | z2;
        }
        return this.H1;
    }

    public boolean r() {
        Logger.d(Logger.AppMgr_TAG, this.p + " onStop");
        IApp.IAppStatusListener iAppStatusListener = this.P0;
        if (iAppStatusListener != null) {
            return iAppStatusListener.onStop();
        }
        return true;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void registerSysEventListener(ISysEventListener iSysEventListener, ISysEventListener.SysEventType sysEventType) {
        if (this.C0 == null) {
            this.C0 = new HashMap<>(1);
        }
        ArrayList<ISysEventListener> arrayList = this.C0.get(sysEventType);
        if (arrayList == null) {
            arrayList = new ArrayList<>();
            this.C0.put(sysEventType, arrayList);
        }
        arrayList.add(iSysEventListener);
    }

    public void s() {
        this.l1.clear();
        this.m1.clear();
        Activity activity = this.a;
        if (activity != null && (activity instanceof WebAppActivity)) {
            ((WebAppActivity) activity).onAppStop(this.p);
        }
        Logger.d(Logger.AppMgr_TAG, "webapp.onStoped");
        BaseInfo.s_Runing_App_Count--;
        callSysEventListener(ISysEventListener.SysEventType.onWebAppStop, this);
        d();
        PermissionUtil.removeTempPermission(this.a, this.p);
        b();
        deleteAppTemp();
        PermissionControler.unregisterRootPermission(this.p);
        this.y.e(this);
        if (getIAppStatusListener() != null) {
            getIAppStatusListener().onStoped(false, null);
        }
        this.y.processEvent(IMgr.MgrType.WindowMgr, 25, this);
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setAppDataPath(String str) {
        if (this.V == 1) {
            if (str.startsWith(BaseInfo.sBaseResAppsPath)) {
                this.k0 = str;
                return;
            }
            this.k0 = BaseInfo.sBaseResAppsPath + this.p + "/" + BaseInfo.APP_WWW_FS_DIR;
        } else if (new File(str).exists()) {
            this.k0 = str;
        } else if (!str.startsWith(DeviceInfo.sCacheRootDir)) {
            this.k0 = DeviceInfo.sCacheRootDir + "/" + str;
        } else {
            this.k0 = str;
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setAppDocPath(String str) {
        this.C1 = PdrUtil.appendByDeviceRootDir(str);
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setConfigProperty(String str, String str2) {
        if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_AUTOCLOSE)) {
            this.Y = PdrUtil.parseBoolean(str2, this.Y, false);
        } else if (PdrUtil.isEquals(str, "commit")) {
            a();
        } else if (PdrUtil.isEquals(str, "timeout")) {
            this.a0 = PdrUtil.parseInt(str2, this.a0);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_DELAY)) {
            this.b0 = PdrUtil.parseInt(str2, this.b0);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_SPLASHSCREEN)) {
            this.W = PdrUtil.parseBoolean(str2, this.W, false);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_WAITING)) {
            this.X = PdrUtil.parseBoolean(str2, this.X, false);
        } else if (PdrUtil.isEquals(str, "name")) {
            this.t0 = str2;
        } else if (PdrUtil.isEquals(str, "name")) {
            this.G = str2;
        } else if (PdrUtil.isEquals(str, "email")) {
            this.H = str2;
        } else if (PdrUtil.isEquals(str, "url")) {
            this.J = str2;
        } else if (PdrUtil.isEquals(str, "name")) {
            this.A = str2;
            BaseInfo.sLastAppVersionName = str2;
        } else if (PdrUtil.isEquals(str, "code")) {
            this.B = str2;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_RUNMODE_LIBERATE)) {
            this.j0 = PdrUtil.parseBoolean(str2, this.W, false);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_H5PLUS)) {
            this.R = PdrUtil.parseBoolean(str2, true, false);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_funSetUA)) {
            this.S = PdrUtil.parseBoolean(str2, true, false);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_USER_AGENT)) {
            this.L = str2;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_FULLSCREEN)) {
            this.i = PdrUtil.parseBoolean(str2, this.i, false);
        } else if (PdrUtil.isEquals(str, "webcache_path")) {
            this.D1 = str2;
        } else if (PdrUtil.isEquals(str, "wap2app_running_mode")) {
            this.O = PdrUtil.parseBoolean(str2, false, false);
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.CONFIG_LOADED_TIME)) {
            this.Q0 = str2;
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_BC)) {
            this.X0 = str2;
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_MODE)) {
            this.a1 = str2;
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_IMMERSED)) {
            this.b1 = Boolean.valueOf(str2).booleanValue();
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_LAUNCH_ISSTATUS)) {
            this.c1 = Boolean.valueOf(str2).booleanValue();
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_LAUNCH_STATUSBAR_COLOR)) {
            this.e1 = str2;
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_SECOND_ISATATUS)) {
            this.d1 = Boolean.valueOf(str2).booleanValue();
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSONKEY_STATUSBAR_SECOND_STATUSBAR_COLOR)) {
            this.f1 = str2;
        } else if (PdrUtil.isEquals(str, AbsoluteConst.UNIAPP_WEEX_JS_SERVICE)) {
            this.g1 = Boolean.valueOf(str2).booleanValue();
        } else if (PdrUtil.isEquals(str, AbsoluteConst.JSON_KEY_DEBUG_REFRESH)) {
            this.r1 = str2;
        } else if (PdrUtil.isEquals(str, IApp.ConfigProperty.UNI_RESTART_TO_DIRECT)) {
            this.q1 = Boolean.valueOf(str2).booleanValue();
        } else if (PdrUtil.isEquals(str, IntentConst.UNIMP_RUN_EXTRA_INFO)) {
            this.v1 = str2;
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setDirectPage(String str) {
        this.n1 = str;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setHideNavBarState(boolean z2) {
        this.q = z2;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setIAppStatusListener(IApp.IAppStatusListener iAppStatusListener) {
        this.P0 = iAppStatusListener;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setLaunchPageStateListener(IWebviewStateListener iWebviewStateListener) {
        this.w1 = iWebviewStateListener;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setNeedRefreshApp(boolean z2) {
        this.k1 = z2;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setQuitModel(int i) {
        this.t1 = i;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setRuntimeArgs(String str) {
        if (!PdrUtil.isEmpty(str)) {
            this.E = str;
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setStatus(byte b2) {
        this.u = b2;
        if (b2 == 3) {
            this.h1 = System.currentTimeMillis();
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void setWebAppActivity(Activity activity) {
        this.a = activity;
        a(activity);
    }

    /* JADX WARNING: Removed duplicated region for block: B:46:0x012e A[SYNTHETIC, Splitter:B:46:0x012e] */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x0154 A[Catch:{ JSONException -> 0x01b5 }] */
    /* JADX WARNING: Removed duplicated region for block: B:69:0x01b1 A[Catch:{ JSONException -> 0x01b5 }] */
    @Override // io.dcloud.common.DHInterface.IApp
    public void setWebAppIntent(Intent intent) {
        String str;
        JSONObject d2;
        JSONObject optJSONObject;
        char c2 = 1;
        boolean booleanExtra = intent.getBooleanExtra(IntentConst.EXE_NEW_INTENT, true);
        if (booleanExtra || this.O0 == null) {
            this.O0 = new Intent(intent);
            if (TextUtils.isEmpty(this.t0)) {
                this.t0 = this.O0.getStringExtra(IntentConst.NAME);
            }
            String stringExtra = this.O0.getStringExtra(IntentConst.FIRST_WEB_URL);
            if (!TextUtils.equals(this.r0, "__no__")) {
                this.r0 = stringExtra;
            }
            String stringExtra2 = this.O0.getStringExtra(IntentConst.DIRECT_PAGE);
            if (!TextUtils.isEmpty(stringExtra2)) {
                try {
                    URL url = new URL(stringExtra2);
                    String query = url.getQuery();
                    if (query != null) {
                        String str2 = "__html5plusWebviewParameter";
                        if (query.contains("webviewParameter") || query.contains(str2)) {
                            if (query.contains("webviewParameter")) {
                                str2 = "webviewParameter";
                            }
                            this.n1 = url.getProtocol() + "://" + url.getHost() + url.getPath();
                            String[] split = query.split("&");
                            if (split != null) {
                                boolean z2 = true;
                                int i = 0;
                                String str3 = null;
                                while (i < split.length) {
                                    String[] split2 = split[i].split("=");
                                    if (str2.equals(split2[0])) {
                                        str3 = URLDecoder.decode(split2[c2]);
                                    } else {
                                        if (z2) {
                                            try {
                                                this.n1 += Operators.CONDITION_IF_STRING;
                                                z2 = false;
                                            } catch (Exception e) {
                                                e.printStackTrace();
                                            }
                                        } else if (i < split.length) {
                                            this.n1 += "&";
                                        }
                                        this.n1 += split2[0] + "=" + split2[1];
                                    }
                                    i++;
                                    c2 = 1;
                                }
                                str = str3;
                                String str4 = this.n1;
                                this.o1 = str4;
                                this.O0.putExtra(IntentConst.DIRECT_PAGE, str4);
                                d2 = d(this.n1);
                                this.K0 = d2;
                                if (d2 == null) {
                                    try {
                                        if (!TextUtils.isEmpty(str)) {
                                            this.K0 = new JSONObject(str);
                                        } else {
                                            this.K0 = new JSONObject();
                                        }
                                    } catch (JSONException e2) {
                                        e2.printStackTrace();
                                    }
                                }
                                if (this.p.equals(this.K0.optString("webviewid"))) {
                                    if (!new File(a(BaseInfo.sConfigXML)).exists()) {
                                        String optString = this.K0.optString(IApp.ConfigProperty.CONFIG_LAUNCH_PATH);
                                        if (TextUtils.isEmpty(optString)) {
                                            optString = this.n1;
                                        }
                                        this.m0 = optString;
                                    }
                                    if (this.K0.has(AbsoluteConst.JSONKEY_STATUSBAR) && (optJSONObject = this.K0.optJSONObject(AbsoluteConst.JSONKEY_STATUSBAR)) != null && optJSONObject.optBoolean(AbsoluteConst.JSONKEY_STATUSBAR_IMMERSED, true)) {
                                        this.c1 = true;
                                        if (optJSONObject.has("background")) {
                                            this.e1 = optJSONObject.optString("background", this.X0);
                                        }
                                    }
                                    this.O0.removeExtra(IntentConst.DIRECT_PAGE);
                                    this.J0 = this.K0.optJSONObject("titleNView");
                                } else {
                                    e();
                                }
                            }
                            str = null;
                            String str42 = this.n1;
                            this.o1 = str42;
                            this.O0.putExtra(IntentConst.DIRECT_PAGE, str42);
                            d2 = d(this.n1);
                            this.K0 = d2;
                            if (d2 == null) {
                            }
                            if (this.p.equals(this.K0.optString("webviewid"))) {
                            }
                        }
                    }
                    this.n1 = stringExtra2;
                    str = null;
                    String str422 = this.n1;
                    this.o1 = str422;
                    this.O0.putExtra(IntentConst.DIRECT_PAGE, str422);
                    d2 = d(this.n1);
                    this.K0 = d2;
                    if (d2 == null) {
                    }
                    if (this.p.equals(this.K0.optString("webviewid"))) {
                    }
                } catch (MalformedURLException e3) {
                    e3.printStackTrace();
                } catch (Exception e4) {
                    e4.printStackTrace();
                }
            }
        }
        if (q() && BaseInfo.isWap2AppAppid(this.p) && !booleanExtra && intent.getBooleanExtra(IntentConst.WEBAPP_ACTIVITY_JUST_DOWNLOAD, false) && this.E1) {
            this.y.processEvent(IMgr.MgrType.WindowMgr, 50, this);
            this.E1 = false;
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String shortcutQuit() {
        return this.A1;
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void showSplash() {
        Activity activity = getActivity();
        if (activity instanceof IOnCreateSplashView) {
            activity.setIntent(this.O0);
            ((IOnCreateSplashView) activity).onCreateSplash(activity);
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public boolean startFromShortCut() {
        return this.z1;
    }

    /* access modifiers changed from: package-private */
    public void t() {
        PermissionControler.registerPermission(this.p, this.B0);
    }

    public String toString() {
        return this.t0 + Operators.SUB + this.p + Operators.SUB + super.toString();
    }

    public void u() {
        b(false);
        setStatus((byte) 1);
        AppStatus.setAppStatus(this.p, 0);
        this.y.processEvent(IMgr.MgrType.FeatureMgr, 3, this.p);
        Logger.d(Logger.AppMgr_TAG, this.p + " will active change to unrunning");
        this.y.processEvent(null, 0, this);
        WebViewFactory.sUsePermissionWebviews.clear();
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void unregisterSysEventListener(ISysEventListener iSysEventListener, ISysEventListener.SysEventType sysEventType) {
        ArrayList<ISysEventListener> arrayList;
        HashMap<ISysEventListener.SysEventType, ArrayList<ISysEventListener>> hashMap = this.C0;
        if (hashMap != null && (arrayList = hashMap.get(sysEventType)) != null) {
            arrayList.remove(iSysEventListener);
            if (arrayList.isEmpty()) {
                this.C0.remove(sysEventType);
            }
        }
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public void updateDirectPage(String str) {
        if (TextUtils.isEmpty(str)) {
            str = this.n1;
        }
        JSONObject d2 = d(str);
        if (d2 != null) {
            this.K0 = d2;
            if (d2 != null) {
                e();
                this.y.processEvent(IMgr.MgrType.WindowMgr, 48, this);
            }
        }
    }

    public String v() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("appid", this.p);
            jSONObject.put("version", this.A);
            jSONObject.put("name", this.t0);
            jSONObject.put("versionCode", this.B);
            jSONObject.put("description", this.F);
            jSONObject.put("author", this.G);
            jSONObject.put("email", this.H);
            jSONObject.put(IApp.ConfigProperty.CONFIG_LICENSE, this.I);
            jSONObject.put("licensehref", this.J);
            jSONObject.put(IApp.ConfigProperty.CONFIG_FEATURES, new JSONArray((Collection) this.B0));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return jSONObject.toString();
    }

    /* access modifiers changed from: package-private */
    public void w() {
        b(true);
    }

    /* access modifiers changed from: package-private */
    /* JADX WARNING: Code restructure failed: missing block: B:345:0x08c2, code lost:
        if (r9.equalsIgnoreCase(r11) != false) goto L_0x08c4;
     */
    /* JADX WARNING: Removed duplicated region for block: B:164:0x0397  */
    /* JADX WARNING: Removed duplicated region for block: B:282:0x0671  */
    /* JADX WARNING: Removed duplicated region for block: B:289:0x06be  */
    /* JADX WARNING: Removed duplicated region for block: B:293:0x06e0  */
    /* JADX WARNING: Removed duplicated region for block: B:294:0x06f8  */
    /* JADX WARNING: Removed duplicated region for block: B:298:0x0710  */
    /* JADX WARNING: Removed duplicated region for block: B:305:0x075d  */
    /* JADX WARNING: Removed duplicated region for block: B:308:0x0785  */
    /* JADX WARNING: Removed duplicated region for block: B:309:0x07a1  */
    /* JADX WARNING: Removed duplicated region for block: B:350:0x08cb  */
    /* JADX WARNING: Removed duplicated region for block: B:36:0x00b1  */
    /* JADX WARNING: Removed duplicated region for block: B:50:0x00ee  */
    /* JADX WARNING: Removed duplicated region for block: B:65:0x011a  */
    /* JADX WARNING: Removed duplicated region for block: B:70:0x0155  */
    public boolean a(InputStream inputStream, String str, JSONObject jSONObject) {
        String str2;
        boolean z2;
        String string;
        boolean z3;
        String str3;
        String str4;
        String str5;
        String str6;
        String str7;
        boolean z4;
        boolean z5;
        String str8;
        JSONObject jSONObject2;
        JSONObject jSONObject3;
        String str9;
        Context context;
        String str10;
        String str11;
        JSONObject jSONObject4;
        boolean z6;
        JSONObject jSONObject5;
        JSONObject jSONObject6;
        boolean z7;
        String str12;
        JSONObject jSONObject7;
        String str13;
        boolean z8;
        String str14;
        boolean z9;
        String str15;
        boolean z10;
        String str16;
        JSONObject jSONObject8;
        boolean z11;
        boolean z12;
        String str17;
        int i;
        int i2;
        boolean z13;
        boolean z14;
        JSONObject jSONObject9;
        String str18;
        boolean z15;
        String str19;
        boolean z16;
        boolean z17;
        boolean z18;
        boolean z19;
        boolean z20;
        boolean z21;
        JSONArray names;
        boolean z22;
        boolean z23;
        JSONObject jSONObject10;
        boolean z24;
        boolean z25;
        int i3;
        boolean z26;
        int i4;
        StringBuilder sb;
        int i5;
        JSONObject jSONObject11;
        JSONArray jSONArray;
        JSONArray jSONArray2;
        JSONObject jSONObject12;
        JSONObject jSONObject13;
        String str20;
        JSONObject jSONObject14;
        String str21;
        Context context2;
        UnicodeInputStream unicodeInputStream = inputStream;
        String str22 = str;
        this.j1 = false;
        g gVar = this.s;
        boolean z27 = gVar != null && gVar.d;
        this.m1.addAll(AppStreamUtil.AppStreamSchemeWhiteDefaultList);
        Context activity = getActivity();
        if (activity == null) {
            activity = DeviceInfo.sApplicationContext;
        }
        if (unicodeInputStream != null) {
            try {
                if (!this.s1) {
                    unicodeInputStream = new UnicodeInputStream(unicodeInputStream, Charset.defaultCharset().name());
                }
                byte[] bytes = IOUtil.getBytes(unicodeInputStream);
                str2 = this.u1.handleEncryption(activity, bytes);
                if (str2 != null) {
                    this.U0 = true;
                } else {
                    this.U0 = false;
                    str2 = new String(bytes);
                }
            } catch (IOException e) {
                e.printStackTrace();
                Logger.e("parseConfig error=" + e.getMessage());
            }
            if (this.U0 || !z27 || !BaseInfo.SyncDebug || BaseInfo.isBase(activity) || !z27) {
                JSONObject jSONObject15 = new JSONObject(str2);
                JSONObject jSONObject16 = JSONUtil.getJSONObject(jSONObject15, "version");
                String string2 = JSONUtil.getString(jSONObject16, "name");
                String string3 = JSONUtil.getString(jSONObject16, "code");
                BaseInfo.sLastAppVersionName = string2;
                String str23 = this.p0;
                String appSignatureSHA1 = LoadAppUtils.getAppSignatureSHA1(activity);
                if (!z27) {
                    z2 = jSONObject != null ? Boolean.parseBoolean(JSONUtil.getString(jSONObject, AbsoluteConst.INSTALL_OPTIONS_FORCE)) : false;
                    if (!z2 && !TextUtils.isEmpty(this.A) && !BaseInfo.BaseAppInfo.compareVersion(string2, this.A)) {
                        if (gVar.c) {
                            gVar.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGTU_WWW_MANIFEST_VERSION_NOT_MATCH, DOMException.MSG_RUNTIME_WGTU_WWW_MANIFEST_VERSION_NOT_MATCH);
                        } else {
                            gVar.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGT_MANIFEST_VERSION_NOT_MATCH, DOMException.MSG_RUNTIME_WGT_MANIFEST_VERSION_NOT_MATCH);
                        }
                        gVar.a = true;
                        return false;
                    }
                } else {
                    z2 = false;
                }
                string = JSONUtil.getString(jSONObject15, "id");
                BaseInfo.sCurrentAppOriginalAppid = string;
                if (BaseInfo.ISDEBUG || (context2 = DeviceInfo.sApplicationContext) == null || !BaseInfo.isBase(context2)) {
                    z3 = !PdrUtil.isEquals(str22, string) && PdrUtil.isEquals(this.p, string);
                    if (z3) {
                        gVar.a = true;
                        if (gVar.c) {
                            gVar.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGTU_WWW_MANIFEST_ERROR_MALFORMED, DOMException.MSG_RUNTIME_WGTU_WWW_MANIFEST_APPID_NOT_MATCH);
                        } else {
                            gVar.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGT_MANIFEST_APPID_NOT_MATCH, DOMException.MSG_RUNTIME_WGT_MANIFEST_APPID_NOT_MATCH);
                        }
                        Log.e("Appmgr", "appid config is wrong pExpectAppid=" + str22 + ";appid=" + string);
                        return false;
                    }
                    str22 = string;
                } else {
                    z3 = true;
                }
                String string4 = JSONUtil.getString(jSONObject15, "name");
                if (!g.c()) {
                    StringBuilder sb2 = new StringBuilder();
                    sb2.append(appSignatureSHA1);
                    str5 = str23;
                    str4 = string4;
                    str3 = string;
                    sb2.append(getConfusionMgr().decodeString(getConfusionMgr().getS5DS(), true, 60));
                    appSignatureSHA1 = sb2.toString();
                } else {
                    str4 = string4;
                    str3 = string;
                    str5 = str23;
                }
                String string5 = JSONUtil.getString(jSONObject15, "description");
                JSONObject jSONObject17 = JSONUtil.getJSONObject(jSONObject15, IApp.ConfigProperty.CONFIG_DEVELOPER);
                String string6 = JSONUtil.getString(jSONObject17, "name");
                String string7 = JSONUtil.getString(jSONObject17, "email");
                JSONUtil.getString(jSONObject17, "url");
                JSONObject jSONObject18 = JSONUtil.getJSONObject(jSONObject15, IApp.ConfigProperty.CONFIG_LICENSE);
                String string8 = JSONUtil.getString(jSONObject18, "url");
                JSONUtil.getString(jSONObject18, "description");
                String string9 = JSONUtil.getString(jSONObject15, IApp.ConfigProperty.CONFIG_LAUNCH_PATH);
                String string10 = JSONUtil.getString(jSONObject15, IApp.ConfigProperty.CONFIG_LAUNCH_PATH_W2A);
                boolean z28 = this.j1 || (!TextUtils.isEmpty(this.l0) && !TextUtils.equals(string9, this.l0));
                this.j1 = z28;
                this.j1 = z28 || (!TextUtils.isEmpty(this.n0) && !TextUtils.equals(string10, this.n0));
                String string11 = JSONUtil.getString(jSONObject15, IApp.ConfigProperty.CONFIG_BASEURL);
                boolean z29 = !PdrUtil.isEmpty(this.s0);
                JSONObject jSONObject19 = JSONUtil.getJSONObject(jSONObject15, IApp.ConfigProperty.CONFIG_PLUS);
                if (jSONObject19.has(IApp.ConfigProperty.CONFIG_CONFUSION)) {
                    str7 = string9;
                    JSONObject jSONObject20 = JSONUtil.getJSONObject(jSONObject19, IApp.ConfigProperty.CONFIG_CONFUSION);
                    if (jSONObject20 == null) {
                        str6 = string5;
                        if (jSONObject19.optString(IApp.ConfigProperty.CONFIG_CONFUSION).startsWith("BQ81KwABAA")) {
                            this.U0 = true;
                            this.V0 = true;
                        }
                        if (this.u1.recordEncryptionV3Resources(this.p, jSONObject19.optString(IApp.ConfigProperty.CONFIG_CONFUSION))) {
                            this.U0 = true;
                            this.V0 = true;
                        }
                    } else {
                        str6 = string5;
                        if (this.U0) {
                            this.u1.recordEncryptionResources(this.p, jSONObject20);
                        }
                    }
                } else {
                    str6 = string5;
                    str7 = string9;
                }
                PermissionUtil.isCheckPermissionDisabled = JSONUtil.getBoolean(jSONObject19, "checkPermissionDenied");
                JSONObject jSONObject21 = JSONUtil.getJSONObject(jSONObject19, AbsoluteConst.UNI_TABBAR_KEY);
                JSONObject jSONObject22 = JSONUtil.getJSONObject(jSONObject19, AbsoluteConst.JSONKEY_STATUSBAR);
                String str24 = "none";
                if (jSONObject22 != null) {
                    if (jSONObject22.has("background")) {
                        str8 = string2;
                        String optString = jSONObject22.optString("background");
                        if (!PdrUtil.isEmpty(optString)) {
                            this.X0 = optString;
                        }
                    } else {
                        str8 = string2;
                    }
                    if (jSONObject22.has("style")) {
                        z5 = z2;
                        this.a1 = jSONObject22.optString("style", this.a1);
                    } else {
                        z5 = z2;
                    }
                    if (jSONObject22.has(AbsoluteConst.JSONKEY_STATUSBAR_IMMERSED)) {
                        z4 = z27;
                        if (Build.VERSION.SDK_INT >= 19) {
                            String optString2 = jSONObject22.optString(AbsoluteConst.JSONKEY_STATUSBAR_IMMERSED);
                            this.n = optString2;
                            if (optString2.equals("supportedDevice") || this.n.equals("suggestedDevice")) {
                                this.b1 = true;
                            } else if (this.n.equals(str24)) {
                                this.b1 = false;
                            } else {
                                this.b1 = jSONObject22.optBoolean(AbsoluteConst.JSONKEY_STATUSBAR_IMMERSED, this.b1);
                            }
                        }
                    } else {
                        z4 = z27;
                    }
                } else {
                    z5 = z2;
                    z4 = z27;
                    str8 = string2;
                }
                JSONObject jSONObject23 = JSONUtil.getJSONObject(jSONObject19, IApp.ConfigProperty.CONFIG_LAUNCHWEBVIEW);
                String str25 = null;
                if (jSONObject23 != null) {
                    JSONObject jSONObject24 = JSONUtil.getJSONObject(jSONObject23, IApp.ConfigProperty.CONFIG_OVERRIDEURL);
                    JSONArray jSONArray3 = JSONUtil.getJSONArray(jSONObject23, IApp.ConfigProperty.CONFIG_OVERRIDE_RESOURCE);
                    str10 = appSignatureSHA1;
                    if (jSONArray3 != null) {
                        jSONObject12 = new JSONObject();
                        context = activity;
                        try {
                            jSONObject12.put(WXInstanceApm.VALUE_ERROR_CODE_DEFAULT, jSONArray3);
                        } catch (JSONException e2) {
                            e2.printStackTrace();
                        }
                    } else {
                        context = activity;
                        jSONObject12 = null;
                    }
                    boolean optBoolean = jSONObject23.optBoolean("injection", this.i1);
                    String optString3 = jSONObject23.optString("plusrequire", "normal");
                    if (jSONObject23.has("titleNView")) {
                        jSONObject13 = JSONUtil.getJSONObject(jSONObject23, "titleNView");
                    } else {
                        jSONObject13 = jSONObject23.has("navigationbar") ? JSONUtil.getJSONObject(jSONObject23, "navigationbar") : null;
                    }
                    if (jSONObject23.has("replacewebapi")) {
                        jSONObject3 = jSONObject13;
                        JSONObject optJSONObject = jSONObject23.optJSONObject("replacewebapi");
                        if (optJSONObject != null && optJSONObject.has("geolocation")) {
                            str21 = optJSONObject.optString("geolocation", str24);
                        }
                        str20 = str24;
                        if (this.b1 || !jSONObject23.has(AbsoluteConst.JSONKEY_STATUSBAR)) {
                            jSONObject14 = jSONObject12;
                        } else {
                            this.c1 = true;
                            JSONObject optJSONObject2 = jSONObject23.optJSONObject(AbsoluteConst.JSONKEY_STATUSBAR);
                            if (optJSONObject2 == null || !optJSONObject2.has("background")) {
                                jSONObject14 = jSONObject12;
                            } else {
                                jSONObject14 = jSONObject12;
                                this.e1 = optJSONObject2.optString("background", this.X0);
                            }
                        }
                        jSONObject5 = jSONObject24;
                        z6 = optBoolean;
                        str11 = str20;
                        jSONObject2 = jSONObject23;
                        str9 = optString3;
                        jSONObject4 = jSONObject14;
                    } else {
                        jSONObject3 = jSONObject13;
                        if (jSONObject23.has("geolocation")) {
                            str21 = jSONObject23.optString("geolocation", str24);
                        }
                        str20 = str24;
                        if (this.b1) {
                        }
                        jSONObject14 = jSONObject12;
                        jSONObject5 = jSONObject24;
                        z6 = optBoolean;
                        str11 = str20;
                        jSONObject2 = jSONObject23;
                        str9 = optString3;
                        jSONObject4 = jSONObject14;
                    }
                    str20 = str21;
                    if (this.b1) {
                    }
                    jSONObject14 = jSONObject12;
                    jSONObject5 = jSONObject24;
                    z6 = optBoolean;
                    str11 = str20;
                    jSONObject2 = jSONObject23;
                    str9 = optString3;
                    jSONObject4 = jSONObject14;
                } else {
                    str10 = appSignatureSHA1;
                    context = activity;
                    jSONObject2 = jSONObject23;
                    str11 = str24;
                    str9 = "normal";
                    jSONObject5 = null;
                    jSONObject4 = null;
                    jSONObject3 = null;
                    z6 = true;
                }
                if (jSONObject19.has("appWhitelist")) {
                    JSONArray optJSONArray = jSONObject19.optJSONArray("appWhitelist");
                    z7 = z6;
                    jSONObject6 = jSONObject4;
                    int i6 = 0;
                    while (i6 < optJSONArray.length()) {
                        String optString4 = optJSONArray.optString(i6);
                        if (!TextUtils.isEmpty(optString4)) {
                            jSONArray2 = optJSONArray;
                            if (!this.l1.contains(optString4)) {
                                this.l1.add(optString4);
                            }
                        } else {
                            jSONArray2 = optJSONArray;
                        }
                        i6++;
                        optJSONArray = jSONArray2;
                    }
                } else {
                    z7 = z6;
                    jSONObject6 = jSONObject4;
                }
                if (jSONObject19.has("schemeWhitelist")) {
                    JSONArray optJSONArray2 = jSONObject19.optJSONArray("schemeWhitelist");
                    int i7 = 0;
                    while (i7 < optJSONArray2.length()) {
                        String optString5 = optJSONArray2.optString(i7);
                        if (!TextUtils.isEmpty(optString5)) {
                            jSONArray = optJSONArray2;
                            if (!this.m1.contains(optString5)) {
                                this.m1.add(optString5);
                            }
                        } else {
                            jSONArray = optJSONArray2;
                        }
                        i7++;
                        optJSONArray2 = jSONArray;
                    }
                }
                JSONObject jSONObject25 = JSONUtil.getJSONObject(jSONObject19, IApp.ConfigProperty.CONFIG_SECONDWEBVIEW);
                if (jSONObject25 != null) {
                    str12 = jSONObject25.optString("plusrequire", "normal");
                    if (jSONObject25.has("replacewebapi")) {
                        JSONObject optJSONObject3 = jSONObject25.optJSONObject("replacewebapi");
                        if (optJSONObject3 != null && optJSONObject3.has("geolocation")) {
                            str24 = optJSONObject3.optString("geolocation", str24);
                        }
                    } else if (jSONObject25.has("geolocation")) {
                        str24 = jSONObject25.optString("geolocation", str24);
                    }
                    if (this.b1 && jSONObject25.has(AbsoluteConst.JSONKEY_STATUSBAR)) {
                        this.d1 = true;
                        JSONObject optJSONObject4 = jSONObject25.optJSONObject(AbsoluteConst.JSONKEY_STATUSBAR);
                        if (optJSONObject4 != null && optJSONObject4.has("background")) {
                            this.f1 = optJSONObject4.optString("background", this.X0);
                        }
                    }
                } else {
                    str12 = "normal";
                }
                if (BaseInfo.isBase(this.y.getContext())) {
                    this.R0 = JSONUtil.getString(jSONObject19, IApp.ConfigProperty.CONFIG_RAM_CACHE_MODE);
                }
                this.T0 = jSONObject19.optBoolean(AbsoluteConst.JSON_KEY_HARDWARE_ACCELERATED, MobilePhoneModel.checkPhoneBanAcceleration(Build.BRAND) || (BaseInfo.isWap2AppAppid(this.p) && q()));
                this.S0 = jSONObject19.optString("popGesture", this.S0);
                JSONObject jSONObject26 = JSONUtil.getJSONObject(jSONObject19, IApp.ConfigProperty.CONFIG_CACHE);
                if (jSONObject26 != null) {
                    String string12 = JSONUtil.getString(jSONObject26, "mode");
                    if (TextUtils.isEmpty(string12)) {
                        string12 = this.W0;
                    }
                    this.W0 = string12;
                }
                JSONObject jSONObject27 = JSONUtil.getJSONObject(jSONObject19, IApp.ConfigProperty.CONFIG_CERS);
                boolean parseBoolean = PdrUtil.parseBoolean(JSONUtil.getString(jSONObject27, IApp.ConfigProperty.CONFIG_CRASH), this.M, false);
                boolean parseBoolean2 = PdrUtil.parseBoolean(JSONUtil.getString(jSONObject27, IApp.ConfigProperty.CONFIG_JSERROR), this.N, false);
                JSONObject optJSONObject5 = jSONObject19.optJSONObject("compatible");
                if (optJSONObject5 == null || !jSONObject19.has("uni-app")) {
                    jSONObject7 = jSONObject25;
                    str13 = str12;
                    if (jSONObject19.has("uni-app")) {
                        JSONObject optJSONObject6 = jSONObject19.optJSONObject("uni-app");
                        if (!a(optJSONObject6, gVar)) {
                            return false;
                        }
                        this.s1 = true;
                        this.u0 = optJSONObject6.optString("compilerVersion");
                        this.z0 = AbsoluteConst.UNI_V3;
                        this.v0 = optJSONObject6.optJSONObject("nvue");
                        this.A0 = optJSONObject6.optString(AbsoluteConst.NVUE_LAUNCH_MODE, "normal");
                    } else {
                        this.s1 = false;
                    }
                } else {
                    JSONObject optJSONObject7 = jSONObject19.optJSONObject("uni-app");
                    if (!a(optJSONObject7, gVar)) {
                        return false;
                    }
                    str13 = str12;
                    this.s1 = true;
                    this.z0 = AbsoluteConst.UNI_V3;
                    jSONObject7 = jSONObject25;
                    this.y0 = optJSONObject5.optBoolean("ignoreVersion", false);
                    String optString6 = optJSONObject5.optString("compilerVersion");
                    this.w0 = optJSONObject5.optString("runtimeVersion");
                    this.u0 = optJSONObject7.optString("compilerVersion");
                    this.A0 = optJSONObject7.optString(AbsoluteConst.NVUE_LAUNCH_MODE, "normal");
                    if (!PdrUtil.isEmpty(optString6) && optString6.trim().equals(this.u0)) {
                        this.x0 = false;
                    }
                }
                if (SDK.isUniMPSDK()) {
                    z8 = true;
                } else {
                    String string13 = JSONUtil.getString(jSONObject19, IApp.ConfigProperty.CONFIG_RUNMODE);
                    if (TextUtils.isEmpty(string13) && this.s1) {
                        string13 = IApp.ConfigProperty.CONFIG_RUNMODE_LIBERATE;
                    }
                    z8 = PdrUtil.isEquals(string13, IApp.ConfigProperty.CONFIG_RUNMODE_LIBERATE);
                }
                JSONObject jSONObject28 = JSONUtil.getJSONObject(jSONObject19, IApp.ConfigProperty.CONFIG_USER_AGENT);
                String string14 = JSONUtil.getString(jSONObject28, "value");
                boolean parseBoolean3 = PdrUtil.parseBoolean(JSONUtil.getString(jSONObject28, IApp.ConfigProperty.CONFIG_CONCATENATE), this.Q, false);
                JSONObject jSONObject29 = JSONUtil.getJSONObject(jSONObject19, IApp.ConfigProperty.CONFIG_USER_AGENT_ANDROID);
                String string15 = JSONUtil.getString(jSONObject29, "value");
                boolean parseBoolean4 = PdrUtil.parseBoolean(JSONUtil.getString(jSONObject29, IApp.ConfigProperty.CONFIG_CONCATENATE), parseBoolean3, false);
                String str26 = !PdrUtil.isEmpty(string15) ? string15 : string14;
                JSONObject jSONObject30 = JSONUtil.getJSONObject(jSONObject19, IApp.ConfigProperty.CONFIG_SPLASHSCREEN);
                if (jSONObject30 != null) {
                    SharedPreferences orCreateBundle = SP.getOrCreateBundle(getActivity(), "pdr");
                    StringBuilder sb3 = new StringBuilder();
                    jSONObject8 = jSONObject5;
                    sb3.append(this.p);
                    sb3.append(SP.UPDATE_SPLASH_AUTOCLOSE);
                    if (orCreateBundle.contains(sb3.toString())) {
                        z25 = orCreateBundle.getBoolean(this.p + SP.UPDATE_SPLASH_AUTOCLOSE, true);
                    } else if (!JSONUtil.isNull(jSONObject30, IApp.ConfigProperty.CONFIG_AUTOCLOSE)) {
                        z25 = Boolean.parseBoolean(String.valueOf(JSONUtil.getString(jSONObject30, IApp.ConfigProperty.CONFIG_AUTOCLOSE)));
                    } else {
                        z25 = false;
                        z24 = true;
                        if (!z24) {
                            z26 = z24;
                            StringBuilder sb4 = new StringBuilder();
                            z10 = parseBoolean4;
                            sb4.append(this.p);
                            sb4.append(SP.UPDATE_SPLASH_DELAY);
                            if (orCreateBundle.contains(sb4.toString())) {
                                i4 = orCreateBundle.getInt(this.p + SP.UPDATE_SPLASH_DELAY, 0);
                            } else if (!JSONUtil.isNull(jSONObject30, IApp.ConfigProperty.CONFIG_DELAY)) {
                                i4 = PdrUtil.parseInt(JSONUtil.getString(jSONObject30, IApp.ConfigProperty.CONFIG_DELAY), this.b0);
                            }
                            i3 = i4;
                            sb = new StringBuilder();
                            z9 = z8;
                            sb.append(this.p);
                            sb.append(SP.UPDATE_SPLASH_AUTOCLOSE_W2A);
                            if (orCreateBundle.contains(sb.toString())) {
                                z25 = orCreateBundle.getBoolean(this.p + SP.UPDATE_SPLASH_AUTOCLOSE_W2A, z25);
                            } else if (!JSONUtil.isNull(jSONObject30, IApp.ConfigProperty.CONFIG_AUTOCLOSE_W2A)) {
                                z25 = Boolean.parseBoolean(String.valueOf(JSONUtil.getString(jSONObject30, IApp.ConfigProperty.CONFIG_AUTOCLOSE_W2A)));
                            }
                            if (z25) {
                                if (orCreateBundle.contains(this.p + SP.UPDATE_SPLASH_DELAY_W2A)) {
                                    i4 = orCreateBundle.getInt(this.p + SP.UPDATE_SPLASH_DELAY_W2A, i4);
                                } else if (!JSONUtil.isNull(jSONObject30, IApp.ConfigProperty.CONFIG_DELAY_W2A)) {
                                    i4 = PdrUtil.parseInt(JSONUtil.getString(jSONObject30, IApp.ConfigProperty.CONFIG_DELAY_W2A), this.c0);
                                }
                                i5 = (int) (((float) i4) + j());
                            } else {
                                i5 = i4;
                            }
                            boolean parseBoolean5 = PdrUtil.parseBoolean(JSONUtil.getString(jSONObject30, IApp.ConfigProperty.CONFIG_WAITING), this.X, false);
                            str17 = JSONUtil.getString(jSONObject30, "event");
                            String optString7 = jSONObject30.optString(IApp.ConfigProperty.CONFIG_TARGET, "default");
                            jSONObject11 = JSONUtil.getJSONObject(jSONObject30, "ads");
                            if (jSONObject11 != null) {
                                String optString8 = jSONObject11.optString("background", "#ffffff");
                                String optString9 = jSONObject11.optString("image", "");
                                z11 = parseBoolean5;
                                i = i3;
                                z13 = true;
                                str15 = optString8;
                                z12 = z26;
                                str16 = optString9;
                                i2 = i5;
                                z14 = z25;
                                str14 = optString7;
                            } else {
                                i2 = i5;
                                z11 = parseBoolean5;
                                z12 = z26;
                                i = i3;
                                z14 = z25;
                                z13 = true;
                                str14 = optString7;
                                str16 = null;
                                str15 = null;
                            }
                        } else {
                            z10 = parseBoolean4;
                            z26 = z24;
                        }
                        i4 = 0;
                        i3 = 0;
                        sb = new StringBuilder();
                        z9 = z8;
                        sb.append(this.p);
                        sb.append(SP.UPDATE_SPLASH_AUTOCLOSE_W2A);
                        if (orCreateBundle.contains(sb.toString())) {
                        }
                        if (z25) {
                        }
                        boolean parseBoolean52 = PdrUtil.parseBoolean(JSONUtil.getString(jSONObject30, IApp.ConfigProperty.CONFIG_WAITING), this.X, false);
                        str17 = JSONUtil.getString(jSONObject30, "event");
                        String optString72 = jSONObject30.optString(IApp.ConfigProperty.CONFIG_TARGET, "default");
                        jSONObject11 = JSONUtil.getJSONObject(jSONObject30, "ads");
                        if (jSONObject11 != null) {
                        }
                    }
                    z24 = z25;
                    if (!z24) {
                    }
                    i4 = 0;
                    i3 = 0;
                    sb = new StringBuilder();
                    z9 = z8;
                    sb.append(this.p);
                    sb.append(SP.UPDATE_SPLASH_AUTOCLOSE_W2A);
                    if (orCreateBundle.contains(sb.toString())) {
                    }
                    if (z25) {
                    }
                    boolean parseBoolean522 = PdrUtil.parseBoolean(JSONUtil.getString(jSONObject30, IApp.ConfigProperty.CONFIG_WAITING), this.X, false);
                    str17 = JSONUtil.getString(jSONObject30, "event");
                    String optString722 = jSONObject30.optString(IApp.ConfigProperty.CONFIG_TARGET, "default");
                    jSONObject11 = JSONUtil.getJSONObject(jSONObject30, "ads");
                    if (jSONObject11 != null) {
                    }
                } else {
                    jSONObject8 = jSONObject5;
                    z9 = z8;
                    z10 = parseBoolean4;
                    str17 = null;
                    str16 = null;
                    str15 = null;
                    str14 = null;
                    z14 = false;
                    z13 = false;
                    i2 = 0;
                    i = 0;
                    z12 = true;
                    z11 = false;
                }
                JSONObject jSONObject31 = JSONUtil.getJSONObject(jSONObject19, "error");
                String string16 = (jSONObject31 == null || JSONUtil.isNull(jSONObject31, "url")) ? "file:///android_asset/data/dcloud_error.html" : JSONUtil.getString(jSONObject31, "url");
                JSONObject jSONObject32 = JSONUtil.getJSONObject(jSONObject19, IApp.ConfigProperty.CONFIG_SSL);
                String string17 = (jSONObject32 == null || JSONUtil.isNull(jSONObject32, IApp.ConfigProperty.CONFIG_UNTRUSTEDCA)) ? str5 : JSONUtil.getString(jSONObject32, IApp.ConfigProperty.CONFIG_UNTRUSTEDCA);
                JSONObject jSONObject33 = JSONUtil.getJSONObject(jSONObject19, IApp.ConfigProperty.CONFIG_STREAM);
                boolean isWap2AppAppid = BaseInfo.isWap2AppAppid(this.p);
                this.P = isWap2AppAppid;
                if (jSONObject33 != null) {
                    this.P = jSONObject33.optBoolean(IApp.ConfigProperty.CONFIG_COMPETENT, isWap2AppAppid);
                    this.B1 = jSONObject33.optString(IApp.ConfigProperty.CONFIG_SHORTCUT);
                    this.A1 = jSONObject33.optString("shortcutQuit");
                    jSONObject9 = jSONObject33.optJSONObject(IApp.ConfigProperty.CONFIG_AUTHORITY);
                } else {
                    jSONObject9 = null;
                }
                if (!this.P) {
                    BaseInfo.createAppTestFile(str22);
                } else {
                    BaseInfo.removeTestFile(str22);
                }
                Logger.i(r, this.p + " app competent=" + this.P);
                if (this.s1 || g.c()) {
                    str18 = string17;
                    z15 = z3;
                } else {
                    String metaValue = AndroidResources.getMetaValue(getConfusionMgr().decryptStr("lkdg}lWixxcmq"));
                    if (g.b()) {
                        if (io.dcloud.e.c.h.a.c(context, str22)) {
                            str18 = string17;
                        }
                        str18 = string17;
                        z15 = false;
                        if (!z15) {
                            setStatus((byte) 4);
                            return false;
                        }
                    } else {
                        if (!TextUtils.isEmpty(metaValue)) {
                            StringBuilder sb5 = new StringBuilder();
                            sb5.append(str22);
                            String packageName = context.getPackageName();
                            str18 = string17;
                            sb5.append(packageName.toLowerCase(Locale.ENGLISH));
                            String md5 = Md5Utils.md5(sb5.toString() + str10);
                            if (!TextUtils.isEmpty(md5)) {
                            }
                            z15 = false;
                            if (!z15) {
                            }
                        }
                        str18 = string17;
                        z15 = false;
                        if (!z15) {
                        }
                    }
                    z15 = true;
                    if (!z15) {
                    }
                }
                JSONObject jSONObject34 = JSONUtil.getJSONObject(jSONObject19, "ads");
                String string18 = JSONUtil.getString(jSONObject19, "adid");
                JSONObject jSONObject35 = JSONUtil.getJSONObject(jSONObject19, "wap2app");
                if (jSONObject35 != null) {
                    str19 = string18;
                    str25 = jSONObject35.optString("launchError", "tip");
                } else {
                    str19 = string18;
                }
                Intent intent = this.O0;
                if (intent != null && intent.hasExtra(IntentConst.UNIMP_DIRECT_DATA)) {
                    this.q1 = true;
                    this.r1 = this.O0.getStringExtra(IntentConst.UNIMP_DIRECT_DATA);
                    this.O0.removeExtra(IntentConst.UNIMP_DIRECT_DATA);
                }
                this.v1 = IntentConst.obtainIntentStringExtra(this.O0, IntentConst.UNIMP_RUN_EXTRA_INFO, true);
                if (jSONObject19.has("arguments")) {
                    setRuntimeArgs(JSONUtil.getString(jSONObject19, "arguments"));
                } else {
                    Intent intent2 = this.O0;
                    if (intent2 != null && intent2.hasExtra(IntentConst.UNIMP_RUN_ARGUMENTS)) {
                        setRuntimeArgs(this.O0.getStringExtra(IntentConst.UNIMP_RUN_ARGUMENTS));
                    }
                }
                boolean parseBoolean6 = PdrUtil.parseBoolean(JSONUtil.getString(jSONObject15, IApp.ConfigProperty.CONFIG_FULLSCREEN), this.i, false);
                Logger.i(r, this.p + " app fullScreen=" + parseBoolean6);
                ArrayList<String> arrayList = new ArrayList<>();
                boolean q = q();
                JSONObject jSONObject36 = JSONUtil.getJSONObject(jSONObject15, "permissions");
                if (jSONObject36 == null || (names = jSONObject36.names()) == null) {
                    z18 = z14;
                    z16 = z13;
                    z20 = parseBoolean6;
                    z17 = z12;
                    z19 = z11;
                    z21 = z15;
                } else {
                    z20 = parseBoolean6;
                    StringBuffer stringBuffer = new StringBuffer();
                    boolean z30 = z15;
                    z18 = z14;
                    z19 = z11;
                    int i8 = 0;
                    while (i8 < names.length()) {
                        String lowerCase = JSONUtil.getString(names, i8).toLowerCase(Locale.ENGLISH);
                        arrayList.add(lowerCase);
                        if (lowerCase.equals("push")) {
                            z23 = z12;
                            z22 = z13;
                            PlatformUtil.APS_COVER = PdrUtil.parseBoolean(JSONUtil.getString(JSONUtil.getJSONObject(jSONObject36, lowerCase), IApp.ConfigProperty.CONFIG_COVER), PlatformUtil.APS_COVER, false);
                        } else {
                            z22 = z13;
                            z23 = z12;
                            if (lowerCase.equals("webview")) {
                                arrayList.add(AbsoluteConst.F_UI);
                            } else if (lowerCase.equals(AbsoluteConst.F_UI)) {
                                arrayList.add("webview");
                                arrayList.add("nativeui");
                                arrayList.add("navigator");
                            } else if (lowerCase.equals("maps") && (jSONObject10 = JSONUtil.getJSONObject(jSONObject36, IFeature.F_MAPS)) != null && jSONObject10.has(AbsoluteConst.JSONKEY_MAP_COORD_TYPE)) {
                                this.p1 = JSONUtil.getString(jSONObject10, AbsoluteConst.JSONKEY_MAP_COORD_TYPE);
                            }
                        }
                        if (z4 && !z5 && !q && !PermissionControler.checkSafePermission(str22, lowerCase) && !((Boolean) this.y.processEvent(IMgr.MgrType.FeatureMgr, 9, lowerCase)).booleanValue()) {
                            if (stringBuffer.length() > 0) {
                                stringBuffer.append(",");
                            }
                            stringBuffer.append(lowerCase);
                            z30 = false;
                        }
                        i8++;
                        names = names;
                        z12 = z23;
                        z13 = z22;
                    }
                    z16 = z13;
                    z17 = z12;
                    if (z30 || !z4) {
                        z21 = z30;
                    } else {
                        gVar.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_5PRUNTIME_LACK_MODULE, StringUtil.format(DOMException.MSG_RUNTIME_5PRUNTIME_LACK_MODULE, stringBuffer));
                        gVar.a = true;
                        return false;
                    }
                }
                if (z21) {
                    BaseInfo.BaseAppInfo baseAppInfo = this.t;
                    if (baseAppInfo != null) {
                        baseAppInfo.mAppVer = this.A;
                    }
                    this.A = str8;
                    this.B = string3;
                    this.B0 = arrayList;
                    this.p = str22;
                    this.z = str3;
                    this.t0 = str4;
                    this.M = parseBoolean;
                    this.N = parseBoolean2;
                    this.F = str6;
                    this.G = string6;
                    this.H = string7;
                    this.J = string8;
                    this.l0 = str7;
                    this.n0 = string10;
                    this.s0 = string11;
                    this.L = str26;
                    this.q0 = string16;
                    this.W = z16;
                    this.Y = z17;
                    this.Z = z18;
                    this.j0 = z9;
                    this.X = z19;
                    this.Q = z10;
                    this.i = z20;
                    this.U = z29;
                    this.p0 = str18;
                    BaseInfo.untrustedca = str18;
                    this.b0 = i;
                    this.c0 = i2;
                    this.d0 = str17;
                    this.e0 = str14;
                    this.D0 = jSONObject8;
                    this.F0 = jSONObject6;
                    this.i1 = z7;
                    this.G0 = jSONObject7;
                    this.H0 = jSONObject2;
                    this.J0 = jSONObject3;
                    this.I0 = jSONObject9;
                    this.L0 = jSONObject34;
                    this.N0 = str19;
                    this.f0 = str9;
                    this.g0 = str13;
                    this.h0 = str11;
                    this.i0 = str24;
                    this.Y0 = str15;
                    this.Z0 = str16;
                    this.M0 = str25;
                    this.E0 = jSONObject21;
                    l();
                    gVar.b = v();
                }
                gVar.a = !z21;
                return z21;
            }
            gVar.a = true;
            gVar.b = DOMException.toJSON((int) DOMException.CODE_BASE_DEBUG_WGT_INSTALL_ERROR_MALFORMED, DOMException.MSG_BASE_DEBUG_WGT_INSTALL_NOT_CONFUSION);
            return false;
        }
        str2 = "";
        if (this.U0) {
        }
        try {
            JSONObject jSONObject152 = new JSONObject(str2);
            JSONObject jSONObject162 = JSONUtil.getJSONObject(jSONObject152, "version");
            String string22 = JSONUtil.getString(jSONObject162, "name");
            String string32 = JSONUtil.getString(jSONObject162, "code");
            BaseInfo.sLastAppVersionName = string22;
            String str232 = this.p0;
            String appSignatureSHA12 = LoadAppUtils.getAppSignatureSHA1(activity);
            if (!z27) {
            }
            string = JSONUtil.getString(jSONObject152, "id");
            BaseInfo.sCurrentAppOriginalAppid = string;
            if (BaseInfo.ISDEBUG) {
            }
            if (!PdrUtil.isEquals(str22, string)) {
            }
            if (z3) {
            }
        } catch (Exception e3) {
            e3.printStackTrace();
            gVar.a = true;
            if (gVar.c) {
                gVar.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGTU_WWW_MANIFEST_ERROR_MALFORMED, DOMException.MSG_RUNTIME_WGTU_WWW_MANIFEST_ERROR_MALFORMED);
                return false;
            }
            gVar.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGT_MANIFEST_ERROR_MALFORMED, DOMException.MSG_RUNTIME_WGT_MANIFEST_ERROR_MALFORMED);
            return false;
        }
    }

    public void g() {
        ArrayList<String> arrayList = this.B0;
        if (arrayList != null) {
            arrayList.clear();
            this.B0 = null;
        }
        HashMap<ISysEventListener.SysEventType, ArrayList<ISysEventListener>> hashMap = this.C0;
        if (hashMap != null) {
            hashMap.clear();
            this.C0 = null;
        }
        this.u1.removeData(this.p);
        this.y = null;
        this.t = null;
        this.g1 = false;
    }

    private static PackageInfo c(Context context) {
        try {
            return context.getPackageManager().getPackageInfo(context.getPackageName(), 16384);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    /* access modifiers changed from: package-private */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x00bb  */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x00f0  */
    public boolean c(String str, JSONObject jSONObject) {
        String str2;
        Exception e;
        String obtainAppDataPath = obtainAppDataPath();
        StringBuilder sb = new StringBuilder();
        boolean z2 = false;
        sb.append(obtainAppDataPath.substring(0, obtainAppDataPath.length() - 1));
        sb.append("_backup");
        String sb2 = sb.toString();
        byte b2 = this.V;
        if (b2 == 1) {
            try {
                str2 = BaseInfo.sCacheFsAppsPath + this.p + File.separatorChar + BaseInfo.APP_WWW_FS_DIR;
                try {
                    DHFile.deleteFile(str2);
                    sb2 = str2.substring(0, str2.length() - 1) + "_backup";
                } catch (Exception e2) {
                    e = e2;
                }
            } catch (Exception e3) {
                e = e3;
                str2 = obtainAppDataPath;
                e.printStackTrace();
                g gVar = this.s;
                gVar.a = true;
                gVar.b = StringUtil.format(DOMException.JSON_ERROR_INFO, 10, e.getMessage());
                if (z2) {
                }
                return z2;
            }
        } else {
            if (b2 == 0) {
                new File(obtainAppDataPath).renameTo(new File(sb2));
            }
            str2 = obtainAppDataPath;
        }
        File file = new File(str);
        if (Zip4JUtil.isEncryptedZip(file)) {
            Zip4JUtil.upZipFileWithPassword(file, str2, jSONObject.getString(Constants.Value.PASSWORD));
        } else {
            ZipUtils.upZipFile(file, str2);
        }
        b((byte) 0);
        setAppDataPath(str2);
        z2 = b(this.p, jSONObject);
        if (z2) {
            Logger.e(Logger.AppMgr_TAG, "unZipWebApp failed pFilePath=" + str);
            b(b2);
            setAppDataPath(obtainAppDataPath);
            try {
                DHFile.deleteFile(str2);
            } catch (IOException e4) {
                e4.printStackTrace();
            }
            if (b2 == 0) {
                new File(sb2).renameTo(new File(str2));
            }
        } else {
            if (b2 == 0) {
                try {
                    DHFile.deleteFile(sb2);
                } catch (IOException e5) {
                    e5.printStackTrace();
                }
            }
            BaseInfo.BaseAppInfo baseAppInfo = new BaseInfo.BaseAppInfo(this.p, this.A);
            this.t = baseAppInfo;
            baseAppInfo.saveToBundleData(getActivity());
        }
        return z2;
    }

    /* access modifiers changed from: package-private */
    public boolean f(String str) {
        if (!this.v && this.x) {
            return false;
        }
        Logger.e("Webapp start " + this.p);
        Activity activity = this.a;
        if (activity != null && (activity instanceof WebAppActivity)) {
            ((WebAppActivity) activity).onAppStart(this.p);
            ((WebAppActivity) this.a).onAppStart(this);
        }
        BaseInfo.s_Runing_App_Count++;
        this.w = true;
        this.x = !this.v;
        setRuntimeArgs(str);
        return a(5);
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public InputStream obtainResInStream(String str) {
        return obtainResInStream(null, str);
    }

    private String c(String str) {
        return BaseInfo.sBaseFsSitMapPath + str + "/_sitemap.json";
    }

    @Override // io.dcloud.common.DHInterface.IApp
    public String convert2AbsFullPath(String str) {
        return convert2AbsFullPath(null, str);
    }

    /* access modifiers changed from: package-private */
    public void b(byte b2) {
        this.V = b2;
    }

    private static String b(String str) {
        return (str == null || str.length() <= 0 || str.charAt(0) != '/') ? str : b(str.substring(1));
    }

    /* access modifiers changed from: package-private */
    public void b(boolean z2) {
        this.b.onAppUnActive(this);
        if (z2) {
            callSysEventListener(ISysEventListener.SysEventType.onWebAppPause, this);
            callSysEventListener(ISysEventListener.SysEventType.onWebAppBackground, this);
        }
        IApp.IAppStatusListener iAppStatusListener = this.P0;
        if (iAppStatusListener != null) {
            iAppStatusListener.onPause(this, null);
        }
        setStatus((byte) 2);
    }

    private void b() {
        if (!q() && io.dcloud.e.c.h.a.c(getActivity())) {
            ThreadPool.self().addThreadTask(new d(obtainAppId()));
        }
    }

    public static String b(Context context) {
        return c(context).versionName;
    }

    private JSONObject a(InputStream inputStream) {
        try {
            if (!this.s1) {
                inputStream = new UnicodeInputStream(inputStream, Charset.defaultCharset().name());
            }
            return new JSONObject(new String(IOUtil.getBytes(inputStream)));
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    /* access modifiers changed from: package-private */
    @Override // io.dcloud.e.b.f
    public void a(Activity activity) {
        super.a(activity);
        AppStatusBarManager appStatusBarManager = this.m;
        if (appStatusBarManager != null) {
            appStatusBarManager.checkImmersedStatusBar(activity, this.b1);
            this.m.isFullScreen = isFullScreen();
        }
        this.l.mJsonViewOption = JSONUtil.createJSONObject("{}");
        this.f = PdrUtil.parseInt(SP.getBundleData(getActivity(), BaseInfo.PDR, "StatusBarHeight"), 0);
        updateScreenInfo(4);
        this.z1 = false;
        IActivityHandler iActivityHandler = DCloudAdapterUtil.getIActivityHandler(getActivity());
        if (!q() && iActivityHandler != null) {
            HashMap hashMap = new HashMap();
            hashMap.put(CreateShortResultReceiver.KEY_VERSIONNAME, this.A);
            hashMap.put("appid", this.p);
            hashMap.put("name", this.t0);
            hashMap.put("adid", this.N0);
            hashMap.put("bg", this.Y0);
            hashMap.put(WXBasicComponentType.IMG, convert2AbsFullPath(this.Z0));
            io.dcloud.a.a(getActivity(), this.p, "save", hashMap);
        }
        Intent intent = activity.getIntent();
        if (intent != null) {
            Bundle extras = intent.getExtras();
            if (extras != null && extras.containsKey(IntentConst.FROM_SHORT_CUT_STRAT) && extras.getBoolean(IntentConst.FROM_SHORT_CUT_STRAT)) {
                this.z1 = true;
            }
            if (extras != null && extras.containsKey(IntentConst.WEBAPP_ACTIVITY_CREATE_SHORTCUT)) {
                this.B1 = extras.getString(IntentConst.WEBAPP_ACTIVITY_CREATE_SHORTCUT);
            }
            if (extras != null && extras.containsKey("shortcutQuit")) {
                this.A1 = extras.getString("shortcutQuit");
            }
            if (extras != null && extras.containsKey(IntentConst.START_FORCE_SHORT_QUIT)) {
                this.A1 = extras.getString(IntentConst.START_FORCE_SHORT_QUIT);
            }
            if (intent.hasExtra(IntentConst.START_FORCE_SHORT)) {
                this.B1 = intent.getStringExtra(IntentConst.START_FORCE_SHORT);
            }
            if (TextUtils.isEmpty(this.B1)) {
                String launchType = BaseInfo.getLaunchType(intent);
                this.B1 = AbsoluteConst.INSTALL_OPTIONS_FORCE;
                if (launchType.equals("scheme")) {
                    this.B1 = "query";
                } else if (this.P) {
                    this.B1 = AbsoluteConst.INSTALL_OPTIONS_FORCE;
                } else {
                    SharedPreferences orCreateBundle = SP.getOrCreateBundle(activity, "pdr");
                    String string = orCreateBundle.getString(AbsoluteConst.TEST_RUN + this.p, null);
                    if (TextUtils.isEmpty(string) || !string.equals("__am=t")) {
                        this.B1 = "none";
                    } else {
                        this.B1 = AbsoluteConst.INSTALL_OPTIONS_FORCE;
                    }
                }
            }
        }
        try {
            ADUtils.runThreadCheckADDownload(activity);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /* access modifiers changed from: package-private */
    public String a(String str) {
        return this.k0 + str;
    }

    /* access modifiers changed from: package-private */
    public void a(ICallBack iCallBack) {
        if ((BaseInfo.ISDEBUG || this.j0) && this.V == 1) {
            ThreadPool.self().addThreadTask(new c(iCallBack), true);
        } else {
            iCallBack.onCallBack(0, null);
        }
    }

    private boolean a(int i) {
        PermissionUtil.sUseStreamAppPermissionDialogCount = 0;
        WebViewFactory.sUsePermissionWebviews.clear();
        PermissionUtil.removeTempPermission(this.a, this.p);
        String str = r;
        Logger.e(str, "start0 mAppid===" + this.p);
        BaseInfo.sCurrentAppOriginalAppid = this.z;
        BaseInfo.putStartupTimeData(this.p, String.valueOf(System.currentTimeMillis()));
        BaseInfo.sProcessId = (long) Process.myPid();
        String str2 = r;
        StringBuilder sb = new StringBuilder();
        sb.append(this.p);
        sb.append(this.V == 1 ? " APP_RUNNING_MODE" : " FS_RUNNING_MODE");
        Logger.i(str2, sb.toString());
        t();
        setStatus((byte) 3);
        IApp.IAppStatusListener iAppStatusListener = this.P0;
        if (iAppStatusListener != null) {
            iAppStatusListener.onStart();
        }
        String str3 = r;
        Logger.i(str3, "mLaunchPath=" + this.l0);
        Logger.i("download_manager", "webapp start task begin success appid=" + this.p + " mLaunchPath=" + this.l0);
        String str4 = TestUtil.START_STREAM_APP;
        StringBuilder sb2 = new StringBuilder();
        sb2.append("webapp start appid=");
        sb2.append(this.p);
        TestUtil.print(str4, sb2.toString());
        BaseInfo.setLoadingLaunchePage(true, "start0");
        String stringExtra = getActivity().getIntent().getStringExtra(IntentConst.WEBAPP_ACTIVITY_LAUNCH_PATH);
        if (stringExtra != null && !"".equals(stringExtra.trim())) {
            getActivity().getIntent().removeExtra(IntentConst.WEBAPP_ACTIVITY_LAUNCH_PATH);
            if (!"about:blank".equals(stringExtra)) {
                stringExtra = convert2WebviewFullPath(null, stringExtra);
            }
            this.o0 = true;
        } else if (!BaseInfo.isWap2AppAppid(this.p) || TextUtils.isEmpty(this.n0)) {
            stringExtra = convert2WebviewFullPath(null, this.l0);
        } else {
            stringExtra = convert2WebviewFullPath(null, this.n0);
        }
        if (a((IApp) this) && !new File(a(BaseInfo.sConfigXML)).exists()) {
            stringExtra = TextUtils.isEmpty(this.m0) ? this.o1 : this.m0;
        }
        Uri data = getActivity().getIntent().getData();
        if (data != null && data.toString().endsWith(".html")) {
            stringExtra = data.toString();
        }
        if (this.q1) {
            stringExtra = convert2WebviewFullPath(null, "__uniappview.html");
        }
        Object processEvent = this.y.processEvent(IMgr.MgrType.WindowMgr, i, new Object[]{this, stringExtra, Boolean.valueOf(this.T0), this.W0});
        if (processEvent == null) {
            return true;
        }
        return Boolean.parseBoolean(String.valueOf(processEvent));
    }

    private boolean a(IApp iApp) {
        return !TextUtils.isEmpty(iApp.getOriginalDirectPage()) && !iApp.obtainWebAppIntent().hasExtra(IntentConst.DIRECT_PAGE);
    }

    /* access modifiers changed from: package-private */
    public boolean a(boolean z2) {
        if (z2) {
            this.r1 = null;
            this.y.processEvent(IMgr.MgrType.WindowMgr, 76, this);
        }
        setAppDataPath(BaseInfo.sCacheFsAppsPath + this.p + DeviceInfo.sSeparatorChar + BaseInfo.REAL_PRIVATE_WWW_DIR);
        boolean b2 = b(this.p, null);
        if (!b2) {
            return b2;
        }
        setConfigProperty(IApp.ConfigProperty.CONFIG_funSetUA, String.valueOf(false));
        PermissionUtil.clearUseRejectedCache();
        showSplash();
        this.y.processEvent(IMgr.MgrType.FeatureMgr, 3, this.p);
        callSysEventListener(ISysEventListener.SysEventType.onWebAppReStart, null);
        this.g1 = false;
        TestUtil.record(AbsoluteConst.RUN_5AP_TIME_KEY);
        return a(10);
    }

    private void a() {
        IPdrModule a2;
        if (!this.s1) {
            if (!SDK.isUniMPSDK()) {
                io.dcloud.e.c.a.f().a(this.a);
            }
            if (!q() && (a2 = io.dcloud.e.c.e.a().a("commit")) != null) {
                Object[] objArr = new Object[3];
                objArr[0] = this;
                objArr[1] = this.N0;
                JSONObject jSONObject = this.y.h;
                objArr[2] = jSONObject != null ? jSONObject.optString("version") : "0.1";
                a2.execute("start_up", objArr);
            }
        }
    }

    public static int a(Context context) {
        return c(context).versionCode;
    }

    /* access modifiers changed from: package-private */
    public IFrameView a(IWebviewStateListener iWebviewStateListener) {
        t();
        return (IFrameView) this.y.processEvent(IMgr.MgrType.WindowMgr, 17, new Object[]{this, convert2WebviewFullPath(null, this.l0), iWebviewStateListener});
    }

    /* access modifiers changed from: package-private */
    public IFrameView a(IWebviewStateListener iWebviewStateListener, IDCloudWebviewClientListener iDCloudWebviewClientListener) {
        t();
        return (IFrameView) this.y.processEvent(IMgr.MgrType.WindowMgr, 17, new Object[]{this, convert2WebviewFullPath(null, this.l0), iWebviewStateListener, iDCloudWebviewClientListener});
    }

    private boolean a(ISysEventListener iSysEventListener, ISysEventListener.SysEventType sysEventType) {
        if (!(iSysEventListener instanceof IBoot) || PdrUtil.parseBoolean(String.valueOf(this.y.processEvent(null, 1, iSysEventListener)), false, false)) {
            return true;
        }
        return !(sysEventType == ISysEventListener.SysEventType.onStart || sysEventType == ISysEventListener.SysEventType.onStop || sysEventType == ISysEventListener.SysEventType.onPause || sysEventType == ISysEventListener.SysEventType.onResume) || (iSysEventListener instanceof ReceiveSystemEventVoucher);
    }

    public static boolean a(ISysEventListener.SysEventType sysEventType) {
        return (sysEventType == ISysEventListener.SysEventType.onKeyDown || sysEventType == ISysEventListener.SysEventType.onKeyUp || sysEventType == ISysEventListener.SysEventType.onKeyLongPress) ? false : true;
    }

    /* access modifiers changed from: package-private */
    /* JADX WARNING: Code restructure failed: missing block: B:46:0x0195, code lost:
        r14 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:47:0x0198, code lost:
        r15 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:49:?, code lost:
        io.dcloud.common.adapter.util.Logger.w(r15);
        io.dcloud.common.adapter.io.DHFile.delete(r3);
        r13.s.b = io.dcloud.common.constant.DOMException.toJSON((int) io.dcloud.common.constant.DOMException.CODE_RUNTIME_WGT_OR_WGTU_ERROR_MALFORMED, io.dcloud.common.constant.DOMException.MSG_RUNTIME_WGT_OR_WGTU_ERROR_MALFORMED);
        r13.s.a = true;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:50:0x01af, code lost:
        io.dcloud.common.util.IOUtil.close((java.io.InputStream) null);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:51:0x01b2, code lost:
        return false;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:52:0x01b3, code lost:
        r15 = e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:53:0x01b4, code lost:
        r7 = null;
        r10 = null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:54:0x01b7, code lost:
        io.dcloud.common.adapter.io.DHFile.delete(r3);
        r13.s.b = io.dcloud.common.constant.DOMException.toJSON(-4, io.dcloud.common.constant.DOMException.MSG_FILE_NOT_EXIST);
        r13.s.a = true;
        io.dcloud.common.util.IOUtil.close((java.io.InputStream) null);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:56:0x01cc, code lost:
        return false;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Removed duplicated region for block: B:46:0x0195 A[ExcHandler: all (th java.lang.Throwable), Splitter:B:1:0x008b] */
    /* JADX WARNING: Removed duplicated region for block: B:61:0x01de A[SYNTHETIC, Splitter:B:61:0x01de] */
    /* JADX WARNING: Removed duplicated region for block: B:74:0x0208 A[Catch:{ Exception -> 0x028f }, LOOP:0: B:73:0x0206->B:74:0x0208, LOOP_END] */
    /* JADX WARNING: Removed duplicated region for block: B:77:0x022f A[Catch:{ Exception -> 0x028f }] */
    /* JADX WARNING: Removed duplicated region for block: B:79:0x023f A[SYNTHETIC, Splitter:B:79:0x023f] */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x02ac  */
    public boolean a(String str, JSONObject jSONObject) {
        boolean z2;
        String str2;
        Object[] objArr;
        ArrayList<XmlUtil.DHNode> elements;
        int size;
        int i;
        IOException e;
        InputStream inputStream;
        Exception e2;
        XmlUtil.DHNode dHNode;
        g gVar = this.s;
        gVar.c = true;
        gVar.d = true;
        String str3 = BaseInfo.sCacheFsAppsPath + this.p + DeviceInfo.sSeparatorChar + BaseInfo.APP_WWW_FS_DIR;
        String str4 = str3.substring(0, str3.length() - 1) + "_unzip" + File.separatorChar;
        String str5 = str3.substring(0, str3.length() - 1) + "_backup" + File.separatorChar;
        String str6 = str3.substring(0, str3.length() - 1) + "_backup1" + File.separatorChar;
        File file = new File(str);
        XmlUtil.DHNode dHNode2 = null;
        String str7 = null;
        InputStream inputStream2 = null;
        try {
            DHFile.delete(str4);
            ZipUtils.upZipFile(file, str4);
            inputStream = DHFile.getInputStream(DHFile.createFileHandler(str4 + BaseInfo.WGTU_UPDATE_XML));
            if (inputStream == null) {
                try {
                    this.s.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGTU_UPDATE_NOT_EXIST, DOMException.MSG_RUNTIME_WGTU_UPDATE_NOT_EXIST);
                    this.s.a = true;
                    IOUtil.close(inputStream);
                    return false;
                } catch (Exception e3) {
                    e2 = e3;
                    e2.printStackTrace();
                    this.s.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGTU_UPDATE_ERROR_MALFORMED, DOMException.MSG_RUNTIME_WGTU_UPDATE_ERROR_MALFORMED);
                    this.s.a = true;
                    IOUtil.close(inputStream);
                    return false;
                }
            } else {
                XmlUtil.DHNode XML_Parser = XmlUtil.XML_Parser(inputStream);
                if (XML_Parser != null) {
                    try {
                        String attributeValue = XmlUtil.getAttributeValue(XML_Parser, "appid");
                        String attributeValue2 = XmlUtil.getAttributeValue(XmlUtil.getElement(XML_Parser, AbsoluteConst.XML_BASIS), "version");
                        if (!BaseInfo.ISDEBUG) {
                            if (!this.p.equalsIgnoreCase(attributeValue)) {
                                this.s.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGTU_UPDATE_APPID_NOT_MATCH, DOMException.MSG_RUNTIME_WGTU_UPDATE_APPID_NOT_MATCH);
                                z2 = false;
                                dHNode = null;
                                IOUtil.close(inputStream);
                                str2 = str7;
                                dHNode2 = dHNode;
                                if (!z2) {
                                    try {
                                        DHFile.deleteFile(str5);
                                        byte b2 = this.V;
                                        if (b2 == 1) {
                                            DHFile.copyDir(this.k0, str5);
                                        } else if (b2 == 0) {
                                            DHFile.copyFile(str3, str5, true, false);
                                            objArr = 1;
                                            elements = XmlUtil.getElements(dHNode2, AbsoluteConst.XML_ITEM);
                                            if (elements != null && !elements.isEmpty()) {
                                                size = elements.size();
                                                for (i = 0; i < size; i++) {
                                                    DHFile.deleteFile(str5 + XmlUtil.getAttributeValue(elements.get(i), AbsoluteConst.XML_PATH));
                                                }
                                            }
                                            if (1 == DHFile.copyFile(str2, str5, true, false)) {
                                                DHFile.deleteFile(str5);
                                                this.s.b = DOMException.toJSON(-5, DOMException.MSG_IO_ERROR);
                                                this.s.a = true;
                                                return false;
                                            }
                                            try {
                                                DHFile.deleteFile(str4);
                                                if (objArr != null) {
                                                    DHFile.rename(str3, str6.substring(str6.substring(0, str6.length() - 1).lastIndexOf(47) + 1));
                                                }
                                                DHFile.rename(str5, BaseInfo.APP_WWW_FS_DIR);
                                                if (objArr != null) {
                                                    DHFile.deleteFile(str6);
                                                }
                                                b((byte) 0);
                                                setAppDataPath(str3);
                                                BaseInfo.BaseAppInfo baseAppInfo = new BaseInfo.BaseAppInfo(this.p, this.A);
                                                this.t = baseAppInfo;
                                                baseAppInfo.saveToBundleData(getActivity());
                                            } catch (IOException e4) {
                                                e4.printStackTrace();
                                                this.s.b = DOMException.toJSON(-5, DOMException.MSG_IO_ERROR);
                                                this.s.a = true;
                                                return false;
                                            }
                                        }
                                        objArr = null;
                                        elements = XmlUtil.getElements(dHNode2, AbsoluteConst.XML_ITEM);
                                        size = elements.size();
                                        while (i < size) {
                                        }
                                        if (1 == DHFile.copyFile(str2, str5, true, false)) {
                                        }
                                    } catch (Exception e5) {
                                        e5.printStackTrace();
                                        try {
                                            DHFile.deleteFile(str4);
                                        } catch (IOException e6) {
                                            e6.printStackTrace();
                                        }
                                        this.s.b = DOMException.toJSON(-99, DOMException.MSG_UNKNOWN_ERROR);
                                        this.s.a = true;
                                        return false;
                                    }
                                } else {
                                    this.s.a = true;
                                    try {
                                        DHFile.deleteFile(str4);
                                    } catch (IOException e7) {
                                        e7.printStackTrace();
                                    }
                                }
                                return false;
                            }
                        }
                        if (!this.A.equals(attributeValue2)) {
                            if (!jSONObject.optBoolean(AbsoluteConst.INSTALL_OPTIONS_FORCE)) {
                                this.s.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGTU_UPDATE_VERSION_NOT_MATCH, DOMException.MSG_RUNTIME_WGTU_UPDATE_VERSION_NOT_MATCH);
                                z2 = false;
                                dHNode = null;
                                IOUtil.close(inputStream);
                                str2 = str7;
                                dHNode2 = dHNode;
                                if (!z2) {
                                }
                                return false;
                            }
                        }
                        str2 = str4 + BaseInfo.APP_WWW_FS_DIR;
                    } catch (IOException e8) {
                        e = e8;
                        str2 = null;
                        try {
                            e.printStackTrace();
                            this.s.b = DOMException.toJSON(-5, DOMException.MSG_IO_ERROR);
                            IOUtil.close(inputStream);
                            z2 = false;
                            if (!z2) {
                            }
                            return false;
                        } catch (Throwable th) {
                            Throwable th2 = th;
                            inputStream2 = inputStream;
                            IOUtil.close(inputStream2);
                            throw th2;
                        }
                    }
                    try {
                        String str8 = str2 + BaseInfo.sConfigXML;
                        if (DHFile.isExist(str8)) {
                            InputStream inputStream3 = DHFile.getInputStream(DHFile.createFileHandler(str8));
                            z2 = a(inputStream3, this.p, jSONObject);
                            IOUtil.close(inputStream3);
                            dHNode = XmlUtil.getElement(XML_Parser, AbsoluteConst.XML_REMOVE);
                            str7 = str2;
                            IOUtil.close(inputStream);
                            str2 = str7;
                            dHNode2 = dHNode;
                            if (!z2) {
                            }
                            return false;
                        }
                        this.s.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGTU_WWW_MANIFEST_NOT_EXIST, DOMException.MSG_RUNTIME_WGTU_WWW_MANIFEST_NOT_EXIST);
                        this.s.a = true;
                        IOUtil.close(inputStream);
                        return false;
                    } catch (IOException e9) {
                        e = e9;
                        e.printStackTrace();
                        this.s.b = DOMException.toJSON(-5, DOMException.MSG_IO_ERROR);
                        IOUtil.close(inputStream);
                        z2 = false;
                        if (!z2) {
                        }
                        return false;
                    }
                } else {
                    throw new Exception();
                }
            }
        } catch (Exception e10) {
            e2 = e10;
            inputStream = null;
            e2.printStackTrace();
            this.s.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_WGTU_UPDATE_ERROR_MALFORMED, DOMException.MSG_RUNTIME_WGTU_UPDATE_ERROR_MALFORMED);
            this.s.a = true;
            IOUtil.close(inputStream);
            return false;
        } catch (Throwable th3) {
        }
    }

    private String a(byte b2) {
        byte b3 = this.V;
        if (b3 == 1) {
            return BaseInfo.sBaseResAppsFullPath + this.p + "/" + BaseInfo.APP_WWW_FS_DIR;
        } else if (b3 != 0) {
            return null;
        } else {
            return DeviceInfo.FILE_PROTOCOL + this.k0;
        }
    }

    public void a(String str, int i) {
        this.F1.put(str, Integer.valueOf(i));
        if (TextUtils.isEmpty(this.G1)) {
            this.G1 = str + "=" + i;
        } else {
            this.G1 += "&" + str + "=" + i;
        }
        SP.getOrCreateBundle(getActivity(), this.p + "_" + 1).edit().putString("Authorize", this.G1).commit();
    }

    /* JADX WARNING: Code restructure failed: missing block: B:7:0x001d, code lost:
        if (r4.equals(io.dcloud.common.constant.AbsoluteConst.UNI_V3) != false) goto L_0x001f;
     */
    /* JADX WARNING: Removed duplicated region for block: B:10:0x0022  */
    private boolean a(JSONObject jSONObject, g gVar) {
        boolean z2;
        if (jSONObject != null && jSONObject.has(IApp.ConfigProperty.CONFIG_UNIAPP_CONTROL)) {
            z2 = false;
            String optString = jSONObject.optString(IApp.ConfigProperty.CONFIG_UNIAPP_CONTROL);
            if (!TextUtils.isEmpty(optString)) {
            }
            if (!z2) {
                gVar.a = true;
                gVar.b = DOMException.toJSON((int) DOMException.CODE_RUNTIME_COMPONENTS_MODE_NOT_SUPPORT, DOMException.MSG_RUNTIME_COMPONENTS_MODE_NOT_SUPPORT);
            }
            return z2;
        }
        z2 = true;
        if (!z2) {
        }
        return z2;
    }
}