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


package io.dcloud.e.b;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import android.widget.CheckBox;
import com.dcloud.android.widget.dialog.DCloudAlertDialog;
import io.dcloud.PdrR;
import io.dcloud.WebAppActivity;
import io.dcloud.base.R;
import io.dcloud.common.DHInterface.AbsMgr;
import io.dcloud.common.DHInterface.IActivityHandler;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.DHInterface.ICallBack;
import io.dcloud.common.DHInterface.ICore;
import io.dcloud.common.DHInterface.IDCloudWebviewClientListener;
import io.dcloud.common.DHInterface.IMgr;
import io.dcloud.common.DHInterface.ISysEventListener;
import io.dcloud.common.DHInterface.IWebview;
import io.dcloud.common.DHInterface.IWebviewStateListener;
import io.dcloud.common.adapter.io.DHFile;
import io.dcloud.common.adapter.ui.webview.WebResUtil;
import io.dcloud.common.adapter.ui.webview.WebViewFactory;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.adapter.util.Logger;
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.DataInterface;
import io.dcloud.common.constant.IntentConst;
import io.dcloud.common.constant.StringConst;
import io.dcloud.common.util.AppRuntime;
import io.dcloud.common.util.BaseInfo;
import io.dcloud.common.util.CheckSignatureUtil;
import io.dcloud.common.util.DataUtil;
import io.dcloud.common.util.DialogUtil;
import io.dcloud.common.util.ErrorDialogUtil;
import io.dcloud.common.util.IOUtil;
import io.dcloud.common.util.JSONUtil;
import io.dcloud.common.util.PdrUtil;
import io.dcloud.common.util.StringUtil;
import io.dcloud.common.util.ThreadPool;
import io.dcloud.feature.internal.sdk.SDK;
import io.src.dcloud.adapter.DCloudAdapterUtil;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.json.JSONException;
import org.json.JSONObject;

public final class a extends AbsMgr implements IMgr.AppEvent {
    private static String a;
    d b = null;
    ArrayList<String> c = new ArrayList<>(1);
    ArrayList<e> d = new ArrayList<>(1);
    c e = null;
    Class[] f = new Class[0];
    private AlertDialog g;
    JSONObject h = null;
    private AlertDialog i;
    private AlertDialog j;

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

        @Override // io.dcloud.common.DHInterface.ICallBack
        public Object onCallBack(int i, Object obj) {
            String unused = a.a = String.valueOf(obj);
            return null;
        }
    }

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

        b(Context context) {
            this.a = context;
        }

        public void run() {
            String str = "uni-jsframework-dev.js";
            if (!BaseInfo.SyncDebug || PlatformUtil.getResInputStream(str) == null || SDK.isUniMPSDK()) {
                str = "uni-jsframework.js";
            }
            try {
                BaseInfo.uniVersionV3 = new JSONObject(new BufferedReader(new InputStreamReader(this.a.getAssets().open(str))).readLine().substring(2)).optString("version");
            } catch (Exception unused) {
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class c implements DialogInterface.OnClickListener {
        final /* synthetic */ Activity a;
        final /* synthetic */ String b;
        final /* synthetic */ e c;
        final /* synthetic */ CheckBox d;
        final /* synthetic */ String e;
        final /* synthetic */ e f;
        final /* synthetic */ e g;
        final /* synthetic */ boolean h;

        c(Activity activity, String str, e eVar, CheckBox checkBox, String str2, e eVar2, e eVar3, boolean z) {
            this.a = activity;
            this.b = str;
            this.c = eVar;
            this.d = checkBox;
            this.e = str2;
            this.f = eVar2;
            this.g = eVar3;
            this.h = z;
        }

        public void onClick(DialogInterface dialogInterface, int i2) {
            if (i2 == -2) {
                a.this.g.dismiss();
                IActivityHandler iActivityHandler = DCloudAdapterUtil.getIActivityHandler(this.a);
                if (iActivityHandler != null) {
                    iActivityHandler.closeAppStreamSplash(this.b);
                    BaseInfo.setLoadingLaunchePage(false, "closeSplashScreen0");
                    if (a.this.e.e() == 0) {
                        this.a.finish();
                        return;
                    }
                    e eVar = this.c;
                    if (eVar != null) {
                        eVar.w();
                    }
                    Intent intent = new Intent("android.intent.action.MAIN");
                    intent.addCategory("android.intent.category.HOME");
                    this.a.startActivity(intent);
                }
            } else if (i2 != -3 && i2 == -1) {
                if (this.d.isChecked()) {
                    Activity activity = this.a;
                    SP.setBundleData(activity, "pdr", AbsoluteConst.TEST_RUN + this.b, "__am=t");
                }
                a.this.a(this.a, this.b, this.e, this.c, this.f, this.g, this.h);
                a.this.g.dismiss();
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class d implements DialogInterface.OnClickListener {
        final /* synthetic */ Activity a;

        d(Activity activity) {
            this.a = activity;
        }

        public void onClick(DialogInterface dialogInterface, int i) {
            Intent intent = new Intent();
            intent.setAction("android.intent.action.VIEW");
            intent.setData(Uri.parse("https://ask.dcloud.net.cn/article/35627"));
            this.a.startActivity(intent);
        }
    }

    /* access modifiers changed from: package-private */
    public class e implements DialogInterface.OnClickListener {
        final /* synthetic */ Activity a;

        e(Activity activity) {
            this.a = activity;
        }

        public void onClick(DialogInterface dialogInterface, int i) {
            Intent intent = new Intent();
            intent.setAction("android.intent.action.VIEW");
            intent.setData(Uri.parse("https://ask.dcloud.net.cn/article/35877"));
            this.a.startActivity(intent);
        }
    }

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

        f(e eVar) {
            this.a = eVar;
        }

        @Override // io.dcloud.common.DHInterface.ICallBack
        public Object onCallBack(int i, Object obj) {
            if (AppRuntime.hasPrivacyForNotShown(this.a.getActivity())) {
                return null;
            }
            ((AbsMgr) a.this).mCore.onRestart(this.a.getActivity());
            return null;
        }
    }

    /* access modifiers changed from: package-private */
    public class g implements ICallBack {
        final /* synthetic */ e a;
        final /* synthetic */ boolean b;
        final /* synthetic */ String c;
        final /* synthetic */ ICallBack d;

        g(e eVar, boolean z, String str, ICallBack iCallBack) {
            this.a = eVar;
            this.b = z;
            this.c = str;
            this.d = iCallBack;
        }

        @Override // io.dcloud.common.DHInterface.ICallBack
        public Object onCallBack(int i, Object obj) {
            if (!this.a.a(this.b)) {
                Logger.e(Logger.AppMgr_TAG, "reboot " + this.c + " app failed !!!");
            } else {
                this.d.onCallBack(0, null);
            }
            return null;
        }
    }

    /* access modifiers changed from: package-private */
    public class h implements ICallBack {
        final /* synthetic */ e a;
        final /* synthetic */ String b;
        final /* synthetic */ String c;
        final /* synthetic */ boolean d;

        /* renamed from: io.dcloud.e.b.a$h$a  reason: collision with other inner class name */
        class C0029a implements ICallBack {
            C0029a() {
            }

            @Override // io.dcloud.common.DHInterface.ICallBack
            public Object onCallBack(int i, Object obj) {
                h hVar = h.this;
                a.this.a((a) hVar.a, (e) hVar.b, hVar.c, (String) hVar.d);
                return null;
            }
        }

        h(e eVar, String str, String str2, boolean z) {
            this.a = eVar;
            this.b = str;
            this.c = str2;
            this.d = z;
        }

        @Override // io.dcloud.common.DHInterface.ICallBack
        public Object onCallBack(int i, Object obj) {
            if (!WebViewFactory.isOther() || WebViewFactory.isOtherInitialised() || WebViewFactory.isIsLoadOtherTimeOut()) {
                a.this.a((a) this.a, (e) this.b, this.c, (String) this.d);
                return null;
            }
            WebViewFactory.setOtherCallBack(new C0029a());
            return null;
        }
    }

    class i implements Runnable {
        i() {
        }

        public void run() {
            try {
                DHFile.deleteFile(StringConst.STREAMAPP_KEY_ROOTPATH + "splash_temp/");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public a(ICore iCore) {
        super(iCore, Logger.AppMgr_TAG, IMgr.MgrType.AppMgr);
        if (iCore != null) {
            a(iCore.obtainContext());
        }
        c();
        b();
        d();
        a();
        this.e = new c(this);
    }

    private void d(e eVar) {
        Object newInstance = PlatformUtil.newInstance("android.app.ActivityManager$TaskDescription", new Class[]{String.class, Bitmap.class}, new Object[]{eVar.obtainAppName(), BitmapFactory.decodeResource(getContext().getResources(), getContext().getApplicationInfo().icon)});
        PlatformUtil.invokeMethod(eVar.getActivity(), "setTaskDescription", new Class[]{newInstance.getClass()}, newInstance);
    }

    /* access modifiers changed from: package-private */
    public e c(String str) {
        return a((Activity) null, str);
    }

    @Override // io.dcloud.common.DHInterface.AbsMgr
    public void dispose() {
        ArrayList<e> arrayList = this.d;
        if (arrayList != null) {
            Iterator<e> it = arrayList.iterator();
            while (it.hasNext()) {
                it.next().g();
            }
        }
        this.d.clear();
        this.c.clear();
        c cVar = this.e;
        if (cVar != null) {
            cVar.a();
        }
        this.e = null;
        ThreadPool.self().addThreadTask(new i());
    }

    /* access modifiers changed from: package-private */
    public void e(e eVar) {
        this.e.b(eVar.p);
        b(eVar);
    }

    @Override // io.dcloud.common.DHInterface.IMgr
    public Object processEvent(IMgr.MgrType mgrType, int i2, Object obj) {
        e eVar;
        e eVar2;
        Throwable th;
        e eVar3;
        boolean z;
        Object valueOf;
        String str;
        e eVar4;
        e eVar5;
        byte b2;
        e b3;
        Intent intent;
        String str2;
        Object obj2 = null;
        try {
            if (checkMgrId(mgrType)) {
                byte b4 = 2;
                boolean z2 = true;
                switch (i2) {
                    case 0:
                        Object[] objArr = (Object[]) obj;
                        Activity activity = (Activity) objArr[0];
                        String valueOf2 = String.valueOf(objArr[1]);
                        String valueOf3 = String.valueOf(objArr[2]);
                        Log.i("ylyl", " AppMGr START_APP " + valueOf2);
                        Logger.e("appMgr", "START_APP" + valueOf2);
                        e a2 = a(activity, valueOf2);
                        boolean isEmpty = TextUtils.isEmpty(a2.r0);
                        e b5 = this.e.b();
                        e a3 = this.e.a(activity, a2);
                        if (a3 == null || a3 != a2 || a2.v) {
                            if (a2.q()) {
                                boolean z3 = a3 == null;
                                String bundleData = SP.getBundleData(activity, "pdr", AbsoluteConst.TEST_RUN + valueOf2);
                                if (!TextUtils.isEmpty(bundleData)) {
                                    if (bundleData.equals("popped")) {
                                        SP.removeBundleData(activity, "pdr", AbsoluteConst.TEST_RUN + valueOf2);
                                    }
                                    z3 = false;
                                }
                                boolean booleanExtra = !a2.v ? activity.getIntent().getBooleanExtra(IntentConst.IS_START_FIRST_WEB, false) : false;
                                if (a2.n() || !z3 || booleanExtra || a2.u != 1) {
                                    a(activity, valueOf2, valueOf3, b5, a2, a3, isEmpty);
                                } else {
                                    AlertDialog alertDialog = this.g;
                                    if (alertDialog != null && alertDialog.isShowing()) {
                                        this.g.dismiss();
                                    }
                                    DCloudAlertDialog initDialogTheme = DialogUtil.initDialogTheme(activity, true);
                                    this.g = initDialogTheme;
                                    initDialogTheme.setCanceledOnTouchOutside(false);
                                    String string = activity.getString(R.string.dcloud_common_app_test_tips);
                                    CheckBox checkBox = new CheckBox(activity);
                                    checkBox.setText(R.string.dcloud_common_app_trust_tips);
                                    checkBox.setTextColor(-65536);
                                    this.g.setMessage(string);
                                    this.g.setView(checkBox, DeviceInfo.getDeivceSuitablePixel(activity, 20), 0, 0, 0);
                                    c cVar = new c(activity, valueOf2, b5, checkBox, valueOf3, a2, a3, isEmpty);
                                    this.g.setButton(-2, activity.getResources().getString(17039360), cVar);
                                    this.g.setButton(-1, activity.getResources().getString(17039370), cVar);
                                    Logger.e("yl", "test show ");
                                    this.g.show();
                                }
                            } else {
                                a(activity, valueOf2, valueOf3, b5, a2, a3, isEmpty);
                                if (a2.o()) {
                                    AlertDialog alertDialog2 = this.i;
                                    if (alertDialog2 != null && alertDialog2.isShowing()) {
                                        this.i.dismiss();
                                    }
                                    AlertDialog create = new AlertDialog.Builder(activity, PdrR.FEATURE_LOSS_STYLE).setTitle("HTML5+ Runtime").setIcon(17301659).setMessage(StringUtil.format(activity.getString(R.string.dcloud_common_app_tips1), a2.obtainConfigProperty(AbsoluteConst.APP_UNIAPP_VERSION), BaseInfo.uniVersionV3)).setPositiveButton(activity.getString(R.string.dcloud_common_view_details), new d(activity)).setNegativeButton(activity.getString(R.string.dcloud_common_ignore), (DialogInterface.OnClickListener) null).create();
                                    this.i = create;
                                    create.setCanceledOnTouchOutside(false);
                                    this.i.show();
                                }
                                if (!PlatformUtil.checkClass("io.dcloud.feature.weex.WeexFeature") && BaseInfo.isUniAppAppid(a2) && BaseInfo.isWeexUniJs(a2)) {
                                    AlertDialog alertDialog3 = this.j;
                                    if (alertDialog3 != null && alertDialog3.isShowing()) {
                                        this.j.dismiss();
                                    }
                                    AlertDialog create2 = new AlertDialog.Builder(activity, PdrR.FEATURE_LOSS_STYLE).setTitle("HTML5+ Runtime").setIcon(17301659).setMessage(activity.getString(R.string.dcloud_common_app_tips2)).setPositiveButton(activity.getString(R.string.dcloud_common_view_details), new e(activity)).setNegativeButton(activity.getString(R.string.dcloud_common_ignore), (DialogInterface.OnClickListener) null).create();
                                    this.j = create2;
                                    create2.setCanceledOnTouchOutside(false);
                                    this.j.show();
                                }
                            }
                        }
                        return a2;
                    case 1:
                        Object[] objArr2 = (Object[]) obj;
                        if (objArr2[2] instanceof IApp) {
                            eVar3 = (e) objArr2[2];
                        } else {
                            eVar3 = a(String.valueOf(objArr2[2]), false);
                        }
                        if (BaseInfo.sRuntimeMode == null && eVar3 == null && !e.a((ISysEventListener.SysEventType) objArr2[0])) {
                            z = false;
                        } else {
                            z = this.e.a(eVar3, (ISysEventListener.SysEventType) objArr2[0], objArr2[1]);
                        }
                        if (!z && eVar3 != null && ((ISysEventListener.SysEventType) objArr2[0]).equals(ISysEventListener.SysEventType.onKeyUp)) {
                            int intValue = ((Integer) ((Object[]) objArr2[1])[0]).intValue();
                            String str3 = (String) objArr2[2];
                            if (intValue == 4) {
                                processEvent(IMgr.MgrType.WindowMgr, 20, eVar3);
                                valueOf = Boolean.valueOf(z2);
                                obj2 = valueOf;
                                break;
                            }
                        }
                        z2 = z;
                        valueOf = Boolean.valueOf(z2);
                        obj2 = valueOf;
                    case 2:
                        String valueOf4 = String.valueOf(obj);
                        if (PdrUtil.isDeviceRootDir(valueOf4)) {
                            int indexOf = valueOf4.indexOf(BaseInfo.sBaseFsAppsPath);
                            if (indexOf >= 0) {
                                String substring = valueOf4.substring(indexOf + BaseInfo.sBaseFsAppsPath.length());
                                str = substring.substring(0, substring.indexOf("/"));
                            } else {
                                str = null;
                            }
                            if (!TextUtils.isEmpty(str)) {
                                obj2 = WebResUtil.getEncryptionInputStream(valueOf4, c(str));
                            }
                            if (obj2 == null) {
                                valueOf = DHFile.getInputStream(DHFile.createFileHandler(valueOf4));
                                obj2 = valueOf;
                                break;
                            }
                        } else {
                            e c2 = c(this.e.b().p);
                            if (valueOf4.startsWith(AbsoluteConst.MINI_SERVER_APP_WWW)) {
                                if (c2 != null) {
                                    valueOf = c2.obtainResInStream(valueOf4);
                                    obj2 = valueOf;
                                }
                            } else if (valueOf4.startsWith(AbsoluteConst.MINI_SERVER_APP_DOC)) {
                                valueOf = DHFile.getInputStream(DHFile.createFileHandler(c2.obtainAppDocPath() + valueOf4.substring(5)));
                                obj2 = valueOf;
                            }
                        }
                        break;
                    case 3:
                        String valueOf5 = String.valueOf(obj);
                        if ("snc:CID".equals(valueOf5)) {
                            eVar4 = this.e.b();
                        } else {
                            eVar4 = a(valueOf5, true);
                        }
                        if (!(eVar4.getActivity() instanceof WebAppActivity)) {
                            a(eVar4, valueOf5, false);
                            break;
                        } else {
                            WebAppActivity webAppActivity = (WebAppActivity) eVar4.getActivity();
                            if (webAppActivity != null && !webAppActivity.isFinishing()) {
                                if (!io.dcloud.common.ui.b.a().c(webAppActivity.getContext())) {
                                    a(eVar4, valueOf5, false);
                                    break;
                                } else {
                                    Intent launchIntentForPackage = webAppActivity.getApplication().getPackageManager().getLaunchIntentForPackage(webAppActivity.getApplication().getPackageName());
                                    launchIntentForPackage.addFlags(67108864);
                                    webAppActivity.getApplication().startActivity(launchIntentForPackage);
                                    Process.killProcess(Process.myPid());
                                    break;
                                }
                            } else {
                                a(eVar4, valueOf5, false);
                                break;
                            }
                        }
                        break;
                    case 4:
                        Object[] objArr3 = (Object[]) obj;
                        String valueOf6 = String.valueOf(objArr3[0]);
                        JSONObject jSONObject = (JSONObject) objArr3[1];
                        IWebview iWebview = (IWebview) objArr3[2];
                        String string2 = JSONUtil.getString(jSONObject, "appid");
                        if (Boolean.parseBoolean(JSONUtil.getString(jSONObject, AbsoluteConst.INSTALL_OPTIONS_RECOGNISE)) && !TextUtils.isEmpty(valueOf6)) {
                            Locale locale = Locale.ENGLISH;
                            if (!valueOf6.toLowerCase(locale).endsWith(".wgtu") && !valueOf6.toLowerCase(locale).endsWith(".wgt") && !CheckSignatureUtil.check(valueOf6)) {
                                return new Object[]{Boolean.TRUE, StringUtil.format(DOMException.JSON_ERROR_INFO, 10, iWebview.getContext().getString(R.string.dcloud_common_app_check_failed))};
                            }
                        }
                        if (PdrUtil.isEmpty(string2)) {
                            string2 = iWebview.obtainFrameView().obtainApp().obtainAppId();
                        }
                        long currentTimeMillis = System.currentTimeMillis();
                        Logger.d(Logger.AppMgr_TAG, "install begin _filePath = " + valueOf6 + ";_mayBeAppid = " + string2);
                        e a4 = a(valueOf6, string2, jSONObject);
                        StringBuilder sb = new StringBuilder();
                        sb.append("install end useTime=");
                        sb.append(System.currentTimeMillis() - currentTimeMillis);
                        Logger.d(Logger.AppMgr_TAG, sb.toString());
                        eVar = new Object[]{Boolean.valueOf(a4.s.a), a4.s.b};
                        return eVar;
                    case 5:
                        e c3 = c(String.valueOf(obj));
                        if (c3 != null) {
                            valueOf = c3.v();
                            obj2 = valueOf;
                            break;
                        }
                        break;
                    case 6:
                        valueOf = c(String.valueOf(obj));
                        obj2 = valueOf;
                        break;
                    case 7:
                        String str4 = (String) obj;
                        if (this.b == null) {
                            this.b = new d(this);
                        }
                        this.b.a(str4);
                        Logger.d(Logger.AppMgr_TAG, "data=" + str4);
                        break;
                    case 8:
                        String[] strArr = (String[]) obj;
                        valueOf = a(strArr[0], strArr[1], strArr[2], Byte.parseByte(strArr[3]));
                        obj2 = valueOf;
                        break;
                    case 9:
                        Object[] objArr4 = (Object[]) obj;
                        IApp iApp = (IApp) objArr4[0];
                        IWebviewStateListener iWebviewStateListener = (IWebviewStateListener) objArr4[1];
                        if (objArr4.length > 2) {
                            IDCloudWebviewClientListener iDCloudWebviewClientListener = (IDCloudWebviewClientListener) objArr4[2];
                            if (!PdrUtil.isEmpty(iDCloudWebviewClientListener)) {
                                valueOf = ((e) iApp).a(iWebviewStateListener, iDCloudWebviewClientListener);
                            }
                        } else {
                            valueOf = ((e) iApp).a(iWebviewStateListener);
                        }
                        obj2 = valueOf;
                        break;
                    case 10:
                        if (obj instanceof String) {
                            eVar5 = a(String.valueOf(obj), false);
                        } else if (obj instanceof e) {
                            eVar5 = (e) obj;
                        } else {
                            eVar5 = obj instanceof Map ? a((String) ((Map) obj).get("appid"), false) : null;
                        }
                        if (eVar5 != null) {
                            eVar5.u();
                            break;
                        }
                        break;
                    case 11:
                        if (this.e.b() != null) {
                            eVar = this.e.b().p;
                            return eVar;
                        }
                        break;
                    case 12:
                        e a5 = a((String) obj, false);
                        if (a5 != null) {
                            byte b6 = a5.u;
                            if (b6 == 3) {
                                if (a5.p()) {
                                    b4 = a5.u;
                                }
                                a5.u = b4;
                                b2 = Byte.valueOf(b4);
                            } else {
                                b2 = Byte.valueOf(b6);
                            }
                        } else {
                            b2 = (byte) 1;
                        }
                        eVar = b2;
                        return eVar;
                    case 13:
                        e eVar6 = (e) obj;
                        if (eVar6 == null) {
                            return AbsoluteConst.FALSE;
                        }
                        eVar = Boolean.valueOf(eVar6.r());
                        return eVar;
                    case 14:
                        String valueOf7 = String.valueOf(obj);
                        if (valueOf7.endsWith("/")) {
                            valueOf7 = valueOf7.substring(0, valueOf7.length() - 1);
                        }
                        String substring2 = valueOf7.substring(valueOf7.lastIndexOf("/") + 1);
                        if (b(substring2)) {
                            b3 = c(substring2);
                        } else {
                            b3 = b(valueOf7, substring2);
                        }
                        e eVar7 = b3;
                        if (!eVar7.s.a) {
                            try {
                                c(eVar7);
                                eVar = eVar7;
                            } catch (Throwable th2) {
                                th = th2;
                                eVar2 = eVar7;
                                break;
                            }
                            return eVar;
                        }
                        break;
                    case 16:
                        Object[] objArr5 = (Object[]) obj;
                        ((e) ((IApp) objArr5[0])).a((String) objArr5[1], 1);
                        break;
                    case 19:
                        valueOf = this.e.c();
                        obj2 = valueOf;
                        break;
                    case 20:
                    case 21:
                        if (obj instanceof String) {
                            str2 = (String) obj;
                            intent = null;
                        } else {
                            Object[] objArr6 = (Object[]) obj;
                            Activity activity2 = (Activity) objArr6[0];
                            intent = (Intent) objArr6[1];
                            str2 = (String) objArr6[2];
                        }
                        e a6 = this.e.a(str2);
                        obj2 = Boolean.TRUE;
                        if (a6 == null) {
                            valueOf = Boolean.FALSE;
                            obj2 = valueOf;
                            break;
                        } else {
                            e b7 = this.e.b();
                            if (b7 != a6) {
                                if (b7 != null) {
                                    b7.w();
                                }
                                if (intent != null) {
                                    a6.setWebAppIntent(intent);
                                } else {
                                    intent = a6.obtainWebAppIntent();
                                }
                                if (21 == i2) {
                                    intent.putExtra(IntentConst.IS_WEBAPP_REPLY, true);
                                }
                                a6.getActivity().setIntent(intent);
                                Logger.d(Logger.AppMgr_TAG, str2 + " will unactive change to active STREAM_START_APP");
                                if (a6.u == 2) {
                                    a6.c();
                                    break;
                                }
                            }
                        }
                        break;
                    case 24:
                        valueOf = a;
                        obj2 = valueOf;
                        break;
                    case 27:
                        e b8 = this.e.b();
                        if (b8 == null) {
                            Logger.e(Logger.AppMgr_TAG, "not app!!!");
                            break;
                        } else {
                            a(b8, (String) null, true);
                            break;
                        }
                    case 28:
                        if (this.e.b() != null) {
                            valueOf = this.e.b();
                        } else {
                            valueOf = a((String) obj, false);
                        }
                        obj2 = valueOf;
                        break;
                }
            } else {
                obj2 = this.mCore.dispatchEvent(mgrType, i2, obj);
            }
            return obj2;
        } catch (Throwable th3) {
            th = th3;
            eVar2 = null;
            Logger.w("AppMgr.processEvent", th);
            eVar = eVar2;
            return eVar;
        }
    }

    /* access modifiers changed from: package-private */
    public void b() {
        g gVar;
        HashMap<String, BaseInfo.BaseAppInfo> hashMap = BaseInfo.mBaseAppInfoSet;
        if (!(hashMap == null || hashMap.isEmpty())) {
            Set<String> keySet = BaseInfo.mBaseAppInfoSet.keySet();
            int size = keySet.size();
            String[] strArr = new String[size];
            keySet.toArray(strArr);
            for (int i2 = 0; i2 < size; i2++) {
                String str = strArr[i2];
                BaseInfo.BaseAppInfo baseAppInfo = BaseInfo.mBaseAppInfoSet.get(str);
                if (!BaseInfo.mUnInstalledAppInfoSet.containsKey(str) && !b(str)) {
                    e b2 = b(BaseInfo.sBaseResAppsPath + str, str);
                    if (!(b2 == null || (gVar = b2.s) == null)) {
                        if (!gVar.a) {
                            b2.t = baseAppInfo;
                            c(b2);
                        } else {
                            Logger.e("AppMgr", str + "  app error," + b2.s);
                        }
                    }
                }
            }
        }
    }

    /* access modifiers changed from: package-private */
    public void c(e eVar) {
        this.c.add(eVar.obtainAppId());
        this.d.add(eVar);
    }

    private void a() {
        if (PdrUtil.isEmpty(a)) {
            DataUtil.datToJsString(BaseInfo.sUniNViewServiceJsPath, new C0028a());
        }
    }

    /* access modifiers changed from: package-private */
    public void c() {
        g gVar;
        HashMap<String, BaseInfo.BaseAppInfo> hashMap = BaseInfo.mInstalledAppInfoSet;
        if (!(hashMap == null || hashMap.isEmpty())) {
            Set<String> keySet = BaseInfo.mInstalledAppInfoSet.keySet();
            int size = keySet.size();
            String[] strArr = new String[size];
            keySet.toArray(strArr);
            boolean z = false;
            for (int i2 = 0; i2 < size; i2++) {
                String str = strArr[i2];
                if (!BaseInfo.mUnInstalledAppInfoSet.containsKey(str) && !b(str)) {
                    e b2 = b(BaseInfo.sCacheFsAppsPath + str, str);
                    if (b2 == null || (gVar = b2.s) == null || gVar.a) {
                        BaseInfo.mInstalledAppInfoSet.get(str).clearBundleData();
                        BaseInfo.mInstalledAppInfoSet.remove(str);
                        z = true;
                    } else {
                        b2.deleteAppTemp();
                        if (SDK.isUniMPSDK()) {
                            b2.j0 = true;
                        } else {
                            b2.j0 = false;
                        }
                        c(b2);
                    }
                }
            }
            if (z) {
                BaseInfo.saveInstalledAppInfo(getContext());
            }
        }
    }

    private void a(Context context) {
        if (TextUtils.isEmpty(BaseInfo.uniVersionV3)) {
            ThreadPool.self().addThreadTask(new b(context), true);
        }
    }

    /* access modifiers changed from: package-private */
    public void d() {
        File file = new File(BaseInfo.sURDFilePath);
        if (!file.exists()) {
            if (!file.getParentFile().exists()) {
                file.getParentFile().mkdirs();
            }
            DHFile.copyAssetsFile("data/dcloud_url.json", file.getAbsolutePath());
        }
        if (file.exists()) {
            try {
                this.h = new JSONObject(new String(DHFile.readAll(file)));
            } catch (JSONException e2) {
                e2.printStackTrace();
            }
        }
    }

    private void a(e eVar, String str, boolean z) {
        if (eVar != null) {
            String obtainConfigProperty = eVar.obtainConfigProperty(IApp.ConfigProperty.CONFIG_UNIAPP_CONTROL);
            f fVar = new f(eVar);
            if (TextUtils.isEmpty(obtainConfigProperty) || !obtainConfigProperty.equals(AbsoluteConst.UNI_V3)) {
                if (!eVar.a(z)) {
                    Logger.e(Logger.AppMgr_TAG, "reboot " + str + " app failed !!!");
                    return;
                }
                fVar.onCallBack(0, null);
            } else if (eVar.getActivity() != null) {
                BaseInfo.isFirstRun = false;
                eVar.showSplash();
                AppRuntime.restartWeex(eVar.getActivity().getApplication(), new g(eVar, z, str, fVar), eVar.p);
            }
        } else {
            Logger.e(Logger.AppMgr_TAG, "not found " + str + " app!!!");
        }
    }

    /* access modifiers changed from: package-private */
    public void b(e eVar) {
        this.c.remove(eVar.p);
        this.d.remove(eVar);
    }

    private boolean b(String str) {
        return this.c.contains(str);
    }

    private e b(String str, String str2) {
        return a(str, str2);
    }

    private void a(e eVar) {
        if (SDK.isUniMPSDK() && SDK.isEnableBackground) {
            d(eVar);
        }
    }

    public void a(Activity activity, String str, String str2, e eVar, e eVar2, e eVar3, boolean z) {
        Log.i("ylyl", "startOneApp " + str);
        BaseInfo.sLastRunApp = str;
        BaseInfo.CmtInfo cmitInfo = BaseInfo.getCmitInfo(str);
        if (cmitInfo.needUpdate) {
            cmitInfo.templateVersion = eVar2.D;
            cmitInfo.rptCrs = eVar2.M;
            cmitInfo.rptJse = eVar2.N;
            cmitInfo.plusLauncher = BaseInfo.getLaunchType(eVar2.obtainWebAppIntent());
            cmitInfo.sfd = DataInterface.getStreamappFrom(eVar2.obtainWebAppIntent());
            cmitInfo.needUpdate = false;
        }
        if (io.dcloud.e.c.g.c() || eVar2.u != 4) {
            if (eVar2.u == 3) {
                eVar2.u = eVar2.p() ? eVar2.u : 2;
            }
            if (!(eVar == null || eVar == eVar2 || eVar == eVar3)) {
                eVar.w();
            }
            byte b2 = eVar2.u;
            if (b2 == 1 || ((z && !eVar2.w) || ((eVar2.x && eVar2.v) || !z))) {
                Logger.d(Logger.AppMgr_TAG, str + " will unrunning change to active");
                eVar2.a(activity);
                processEvent(IMgr.MgrType.WindowMgr, 4, new Object[]{eVar2, str});
                eVar2.a(new h(eVar2, str, str2, z));
            } else if (b2 == 2) {
                Logger.d(Logger.AppMgr_TAG, str + " will unactive change to active");
                eVar2.c();
            } else {
                Logger.d(Logger.AppMgr_TAG, str + " is active");
            }
            if (SDK.isUniMPSDK() && Build.VERSION.SDK_INT >= 21) {
                a(eVar2);
            }
            if (eVar3 != null && eVar3 != eVar2) {
                eVar3.u();
                return;
            }
            return;
        }
        ErrorDialogUtil.checkAppKeyErrorTips(activity);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(e eVar, String str, String str2, boolean z) {
        if (this.e != null) {
            boolean f2 = z ? eVar.f(str2) : eVar.g(str2);
            if (!eVar.w && eVar.v) {
                eVar.f(str2);
            }
            if (f2) {
                this.e.a(str, eVar);
                return;
            }
            Logger.e(Logger.AppMgr_TAG, str + " run failed!!!");
        }
    }

    /* access modifiers changed from: package-private */
    public e a(Activity activity, String str) {
        return a(activity, str, true);
    }

    private e a(String str, boolean z) {
        return a((Activity) null, str, z);
    }

    private e a(Activity activity, String str, boolean z) {
        int indexOf;
        e eVar = (!this.c.contains(str) || (indexOf = this.c.indexOf(str)) < 0) ? null : this.d.get(indexOf);
        if (eVar == null && z) {
            eVar = new e(this, str, (byte) 0);
            eVar.setAppDataPath(BaseInfo.sCacheFsAppsPath + str + DeviceInfo.sSeparatorChar + BaseInfo.REAL_PRIVATE_WWW_DIR);
            if (eVar.a == null) {
                eVar.a = activity;
            }
            if (activity != null) {
                eVar.setWebAppIntent(activity.getIntent());
            }
            eVar.b(str, null);
            if (eVar.s.a) {
                eVar.p = str;
            }
            c(eVar);
        } else if (!(eVar == null || activity == null)) {
            if (eVar.a == null) {
                eVar.a = activity;
            }
            if (eVar.a.getIntent() == null) {
                eVar.a.setIntent(eVar.obtainWebAppIntent());
            } else if (eVar.manifestBeParsed()) {
                eVar.setWebAppIntent(eVar.a.getIntent());
            }
            if (!eVar.v) {
                eVar.b(str, null);
            }
        }
        return eVar;
    }

    /* access modifiers changed from: package-private */
    public e a(String str, String str2, String str3, byte b2) {
        e a2 = a(str, false);
        if (a2 == null) {
            a2 = new e(this, str, b2);
            a2.u = 3;
            a2.p = str;
            if (!PdrUtil.isEmpty(str2)) {
                a2.setAppDataPath(str2);
            }
            a2.l0 = str3;
            c(a2);
            this.e.a(str, a2);
        }
        return a2;
    }

    /* access modifiers changed from: package-private */
    public e a(String str, String str2) {
        return a(str, str2, (JSONObject) null);
    }

    /* access modifiers changed from: package-private */
    public e a(String str, String str2, JSONObject jSONObject) {
        Exception e2;
        PackageInfo packageInfo;
        e a2 = a(str2, false);
        if (a2 != null) {
            try {
                a2.s.a();
            } catch (Exception e3) {
                e2 = e3;
                e2.printStackTrace();
                Logger.e(Logger.AppMgr_TAG, "installWebApp " + str + " is Illegal path");
                return a2;
            }
        }
        InputStream inputStream = null;
        boolean z = true;
        if (DHFile.isExist(str) || PdrUtil.isDeviceRootDir(str)) {
            boolean isFile = new File(str).isFile();
            if (!isFile) {
                if (a2 != null) {
                    a2.b((byte) 0);
                } else {
                    a2 = new e(this, str2, (byte) 0);
                }
                a2.setAppDataPath(str + DeviceInfo.sSeparatorChar + BaseInfo.REAL_PRIVATE_WWW_DIR);
                a2.b(str2, jSONObject);
            } else if (isFile && str.toLowerCase(Locale.ENGLISH).endsWith(".wgtu")) {
                if (a2 != null) {
                    z = false;
                }
                if (z) {
                    a2 = new e(this, str2, (byte) 0);
                }
                a2.a(str, jSONObject);
                g gVar = a2.s;
                gVar.c = false;
                gVar.d = false;
            } else if (isFile && str.toLowerCase(Locale.ENGLISH).endsWith(".wgt")) {
                boolean z2 = a2 == null;
                a2.s.d = true;
                if (z2) {
                    e eVar = new e(this, str2, (byte) 0);
                    try {
                        eVar.p = str2;
                        eVar.setAppDataPath(BaseInfo.sCacheFsAppsPath + str2 + DeviceInfo.sSeparatorChar + BaseInfo.REAL_PRIVATE_WWW_DIR);
                        a2 = eVar;
                    } catch (Exception e4) {
                        e2 = e4;
                        a2 = eVar;
                        e2.printStackTrace();
                        Logger.e(Logger.AppMgr_TAG, "installWebApp " + str + " is Illegal path");
                        return a2;
                    }
                }
                boolean c2 = a2.c(str, jSONObject);
                a2.s.d = false;
                if (c2 && z2) {
                    c(a2);
                }
            } else if (!isFile || !str.toLowerCase(Locale.ENGLISH).endsWith(".apk")) {
                g gVar2 = a2.s;
                gVar2.a = true;
                gVar2.b = StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf((int) DOMException.CODE_RUNTIME_WGT_OR_WGTU_ERROR_MALFORMED), DOMException.MSG_RUNTIME_WGT_OR_WGTU_ERROR_MALFORMED);
            } else {
                try {
                    packageInfo = PlatformUtil.parseApkInfo(getContext(), str);
                } catch (Exception e5) {
                    e5.printStackTrace();
                    a2.s.b = StringUtil.format(DOMException.JSON_ERROR_INFO, 10, e5.getMessage());
                    packageInfo = null;
                }
                if (packageInfo == null) {
                    a2.s.a = true;
                } else {
                    a2.s.a = false;
                    String str3 = packageInfo.versionName;
                    String str4 = packageInfo.packageName;
                    String charSequence = getContext().getPackageManager().getApplicationLabel(packageInfo.applicationInfo).toString();
                    if (charSequence == null) {
                        charSequence = "";
                    }
                    a2.s.b = StringUtil.format("{pname:'%s',version:'%s',name:'%s'}", str4, str3, charSequence);
                    PlatformUtil.openFileBySystem(getContext(), str, null, null, null);
                }
            }
        } else {
            boolean contains = str.substring(str.lastIndexOf(47)).contains(".wgt");
            if (contains) {
                inputStream = PlatformUtil.getResInputStream(str);
            }
            if (a2 == null) {
                a2 = new e(this, str2, (byte) 1);
            }
            if (contains || inputStream != null) {
                a2.b(inputStream);
            } else {
                a2.setAppDataPath(str + DeviceInfo.sSeparatorChar + BaseInfo.REAL_PRIVATE_WWW_DIR);
                a2.b(str2, jSONObject);
            }
        }
        IOUtil.close(inputStream);
        return a2;
    }
}