派享便利 v1.0.3版本的 MD5 值为:1fc1776275e6607636a3a1f946b1f976
以下内容为反编译后的 c.java 源代码,内容仅作参考
package io.dcloud.g.b;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import io.dcloud.common.DHInterface.AbsMgr;
import io.dcloud.common.DHInterface.IActivityHandler;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.DHInterface.IBoot;
import io.dcloud.common.DHInterface.ICore;
import io.dcloud.common.DHInterface.IMgr;
import io.dcloud.common.DHInterface.IOnCreateSplashView;
import io.dcloud.common.DHInterface.ISysEventListener;
import io.dcloud.common.adapter.ui.webview.WebViewFactory;
import io.dcloud.common.adapter.util.AndroidResources;
import io.dcloud.common.adapter.util.AsyncTaskHandler;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.adapter.util.DownloadUtil;
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.PlatformUtil;
import io.dcloud.common.adapter.util.SP;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.constant.IntentConst;
import io.dcloud.common.core.ui.l;
import io.dcloud.common.util.BaseInfo;
import io.dcloud.common.util.NetTool;
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.db.DCStorage;
import io.dcloud.common.util.net.NetMgr;
import io.dcloud.feature.internal.sdk.SDK;
import io.src.dcloud.adapter.DCloudAdapterUtil;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import org.json.JSONObject;
public class c implements ICore {
private static c i;
boolean a = false;
Context b = null;
AbsMgr c = null;
AbsMgr d = null;
AbsMgr e = null;
AbsMgr f = null;
private ICore.ICoreStatusListener g = null;
HashMap<String, IBoot> h = null;
public class a implements Runnable {
final Context a;
a(c cVar, Context context) {
this.a = context;
}
@Override
public void run() {
try {
JSONObject jSONObject = new JSONObject(new String(NetTool.httpGet(StringUtil.format("https://service.dcloud.net.cn/sta/so?p=a&pn=%s&ver=%s&appid=%s", this.a.getPackageName(), this.a.getPackageManager().getPackageInfo(this.a.getPackageName(), 0).versionName, BaseInfo.sDefaultBootApp), false), "utf-8"));
if (jSONObject.has("ret") && jSONObject.optInt("ret") == 0) {
SP.setBundleData(this.a, BaseInfo.PDR, AbsoluteConst.XML_NS, AbsoluteConst.TRUE);
}
} catch (Exception unused) {
}
}
}
public class b implements MessageHandler.IMessages {
final IApp a;
final Activity b;
final String c;
b(IApp iApp, Activity activity, String str) {
this.a = iApp;
this.b = activity;
this.c = str;
}
@Override
public void execute(Object obj) {
IApp iApp = this.a;
if (iApp != null) {
c.this.a(this.b, iApp);
}
Object dispatchEvent = c.this.dispatchEvent(IMgr.MgrType.WindowMgr, 32, new Object[]{this.b, this.c});
if ((dispatchEvent instanceof Boolean ? ((Boolean) dispatchEvent).booleanValue() : false) || !TextUtils.equals(BaseInfo.sLastRunApp, this.c)) {
return;
}
BaseInfo.sLastRunApp = null;
this.b.finish();
}
}
class C0078c implements AsyncTaskHandler.IAsyncTaskListener {
final String a;
final Activity b;
final String c;
C0078c(String str, Activity activity, String str2) {
this.a = str;
this.b = activity;
this.c = str2;
}
@Override
public void onCancel() {
}
@Override
public void onExecuteBegin() {
}
@Override
public void onExecuteEnd(Object obj) {
c cVar = c.this;
Activity activity = this.b;
cVar.a(activity, this.a, this.c, activity instanceof IOnCreateSplashView ? (IOnCreateSplashView) activity : null);
if (!SDK.isUniMPSDK() || obj == null) {
return;
}
Activity activity2 = this.b;
if (activity2 instanceof IActivityHandler) {
((IActivityHandler) activity2).onAsyncStartAppEnd(this.a, obj);
}
}
@Override
public Object onExecuting() {
try {
String str = TextUtils.isEmpty(this.a) ? BaseInfo.sDefaultBootApp : this.a;
DCStorage dCStorage = DCStorage.getDCStorage(this.b);
if (dCStorage != null) {
dCStorage.checkSPstorageToDB(this.b, str);
}
} catch (Exception unused) {
}
if (SDK.isUniMPSDK()) {
Activity activity = this.b;
if (activity instanceof IActivityHandler) {
return ((IActivityHandler) activity).onAsyncStartAppStart(this.a);
}
}
return 0;
}
}
public static class d {
static final int[] a;
static final int[] b;
static {
int[] iArr = new int[IMgr.MgrType.values().length];
b = iArr;
try {
iArr[IMgr.MgrType.AppMgr.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
b[IMgr.MgrType.NetMgr.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
b[IMgr.MgrType.FeatureMgr.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
b[IMgr.MgrType.WindowMgr.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
int[] iArr2 = new int[ISysEventListener.SysEventType.values().length];
a = iArr2;
try {
iArr2[ISysEventListener.SysEventType.onStart.ordinal()] = 1;
} catch (NoSuchFieldError unused5) {
}
try {
a[ISysEventListener.SysEventType.onStop.ordinal()] = 2;
} catch (NoSuchFieldError unused6) {
}
try {
a[ISysEventListener.SysEventType.onPause.ordinal()] = 3;
} catch (NoSuchFieldError unused7) {
}
try {
a[ISysEventListener.SysEventType.onResume.ordinal()] = 4;
} catch (NoSuchFieldError unused8) {
}
}
}
private c() {
}
private void b(Context context) {
TestUtil.record("core", Thread.currentThread());
this.f = new io.dcloud.i.b(this);
this.h = (HashMap) dispatchEvent(IMgr.MgrType.FeatureMgr, 0, this.b);
BaseInfo.parseControl(context, this, this.g);
Logger.initLogger(context);
DeviceInfo.init(context);
this.d = new io.dcloud.g.a.a(this);
this.c = new l(this);
this.e = new NetMgr(this);
this.a = true;
try {
a(context);
} catch (Exception e) {
Logger.e("initSDKData " + e.getLocalizedMessage());
}
}
public boolean c(Activity activity) {
DownloadUtil.getInstance(activity).stop();
PlatformUtil.invokeMethod("io.dcloud.feature.apsqh.QHNotifactionReceiver", "doSaveNotifications", null, new Class[]{Context.class}, new Object[]{activity.getBaseContext()});
try {
ISysEventListener.SysEventType sysEventType = ISysEventListener.SysEventType.onStop;
onActivityExecute(activity, sysEventType, null);
this.a = false;
BaseInfo.setLoadingLaunchePage(false, "onStop");
a(activity, sysEventType, (Object) null);
i = null;
this.c.dispose();
this.c = null;
this.d.dispose();
this.d = null;
this.e.dispose();
this.e = null;
this.f.dispose();
this.f = null;
Logger.e(Logger.MAIN_TAG, "core exit");
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
@Override
public Object dispatchEvent(IMgr.MgrType mgrType, int i2, Object obj) {
AbsMgr absMgr;
if (mgrType == null) {
return a(i2, obj);
}
try {
if (i == null) {
i = this;
}
int i3 = d.b[mgrType.ordinal()];
if (i3 == 1) {
AbsMgr absMgr2 = i.d;
if (absMgr2 != null) {
return absMgr2.processEvent(mgrType, i2, obj);
}
} else if (i3 == 2) {
AbsMgr absMgr3 = i.e;
if (absMgr3 != null) {
return absMgr3.processEvent(mgrType, i2, obj);
}
} else if (i3 == 3) {
AbsMgr absMgr4 = i.f;
if (absMgr4 != null) {
return absMgr4.processEvent(mgrType, i2, obj);
}
} else if (i3 == 4 && (absMgr = i.c) != null) {
return absMgr.processEvent(mgrType, i2, obj);
}
} catch (Exception e) {
Logger.w("Core.dispatchEvent", e);
}
return null;
}
@Override
public Context obtainContext() {
return this.b;
}
@Override
public boolean onActivityExecute(Activity activity, ISysEventListener.SysEventType sysEventType, Object obj) {
String str;
Bundle extras;
if (obj instanceof IApp) {
str = ((IApp) obj).obtainAppId();
} else {
str = BaseInfo.sRuntimeMode != null ? null : BaseInfo.sDefaultBootApp;
Intent intent = activity.getIntent();
if (intent != null && (extras = intent.getExtras()) != null && extras.containsKey("appid")) {
str = extras.getString("appid");
}
}
Object dispatchEvent = dispatchEvent(IMgr.MgrType.AppMgr, 1, new Object[]{sysEventType, obj, str});
ISysEventListener.SysEventType sysEventType2 = ISysEventListener.SysEventType.onKeyUp;
if (sysEventType.equals(sysEventType2) && dispatchEvent != null && !((Boolean) dispatchEvent).booleanValue() && ((Integer) ((Object[]) obj)[0]).intValue() == 4) {
if (sysEventType.equals(sysEventType2)) {
if (activity instanceof IActivityHandler) {
((IActivityHandler) activity).closeAppStreamSplash(str);
}
a(activity, activity.getIntent(), (IApp) null, str);
}
return true;
}
return Boolean.parseBoolean(String.valueOf(dispatchEvent));
}
@Override
public void setmCoreListener(ICore.ICoreStatusListener iCoreStatusListener) {
this.g = iCoreStatusListener;
}
public static c a(Context context, ICore.ICoreStatusListener iCoreStatusListener) {
if (i == null) {
i = new c();
}
c cVar = i;
cVar.b = context;
cVar.g = iCoreStatusListener;
SDK.initSDK(cVar);
return i;
}
public void a(Activity activity, Bundle bundle, SDK.IntegratedMode integratedMode) {
DownloadUtil.getInstance(activity);
WebViewFactory.resetSysWebViewState();
a();
BaseInfo.sRuntimeMode = integratedMode;
if (integratedMode != null) {
BaseInfo.USE_ACTIVITY_HANDLE_KEYEVENT = true;
}
if (this.a) {
return;
}
DCloudAdapterUtil.getIActivityHandler(activity);
b(activity.getApplicationContext());
Logger.i("Core onInit mode=" + integratedMode);
a(activity, ISysEventListener.SysEventType.onStart, bundle);
Logger.i("Core onInit mCoreListener=" + this.g);
try {
SDK.IntegratedMode integratedMode2 = BaseInfo.sRuntimeMode;
if (integratedMode2 != null && integratedMode2 != SDK.IntegratedMode.RUNTIME) {
ICore.ICoreStatusListener iCoreStatusListener = this.g;
if (iCoreStatusListener != null) {
iCoreStatusListener.onCoreInitEnd(this);
}
}
ICore.ICoreStatusListener iCoreStatusListener2 = this.g;
if (iCoreStatusListener2 != null) {
iCoreStatusListener2.onCoreInitEnd(this);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void b(Activity activity) {
ISysEventListener.SysEventType sysEventType = ISysEventListener.SysEventType.onResume;
a(activity, sysEventType, (Object) null);
this.e.onExecute(sysEventType, null);
onActivityExecute(activity, sysEventType, null);
}
private void a(Context context) {
if (BaseInfo.sRuntimeMode == null || BaseInfo.s_Is_DCloud_Packaged || !BaseInfo.existsBase() || !TextUtils.isEmpty(SP.getBundleData(context, BaseInfo.PDR, AbsoluteConst.XML_NS)) || SDK.isUniMPSDK()) {
return;
}
ThreadPool.self().addThreadTask(new a(this, context));
}
public void a(Activity activity, IApp iApp) {
onActivityExecute(activity, ISysEventListener.SysEventType.onWebAppStop, iApp);
}
public void a(Activity activity, Intent intent, IApp iApp, String str) {
ICore.ICoreStatusListener iCoreStatusListener = this.g;
boolean z = iCoreStatusListener != null ? !iCoreStatusListener.onCoreStop() : true;
if (iApp != null) {
dispatchEvent(IMgr.MgrType.AppMgr, 13, iApp);
}
if (z) {
IActivityHandler iActivityHandler = DCloudAdapterUtil.getIActivityHandler(activity);
TextUtils.equals(activity.getIntent().getStringExtra("appid"), str);
if (iActivityHandler != null && iApp == null) {
if (MobilePhoneModel.HUAWEI.equalsIgnoreCase(Build.MANUFACTURER) && Build.VERSION.SDK_INT >= 24) {
if (iApp != null) {
a(activity, iApp);
}
Object dispatchEvent = dispatchEvent(IMgr.MgrType.WindowMgr, 32, new Object[]{activity, str});
if (!(dispatchEvent instanceof Boolean ? ((Boolean) dispatchEvent).booleanValue() : false)) {
activity.finish();
}
} else {
MessageHandler.sendMessage(new b(iApp, activity, str), 10, null);
}
} else {
activity.finish();
}
}
BaseInfo.sGlobalFullScreen = false;
}
public IApp a(Activity activity, String str, String str2, IOnCreateSplashView iOnCreateSplashView) {
return a(activity, str, str2, iOnCreateSplashView, false);
}
boolean a(Intent intent, String str) {
String str2 = BaseInfo.sCacheFsAppsPath + str + "/www/";
if (new File(str2).exists()) {
File file = new File(str2 + "/manifest.json");
if (file.exists() && file.length() > 0) {
return true;
}
}
if (intent.hasExtra(IntentConst.DIRECT_PAGE) && BaseInfo.isWap2AppAppid(str)) {
return true;
}
return !intent.getBooleanExtra(IntentConst.WEBAPP_ACTIVITY_HAS_STREAM_SPLASH, false);
}
public IApp a(Activity activity, String str, String str2, IOnCreateSplashView iOnCreateSplashView, boolean z) {
TestUtil.record("GET_STATUS_BY_APPID");
Logger.d("syncStartApp " + str);
IMgr.MgrType mgrType = IMgr.MgrType.AppMgr;
Object dispatchEvent = dispatchEvent(mgrType, 12, str);
byte parseByte = dispatchEvent != null ? Byte.parseByte(String.valueOf(dispatchEvent)) : (byte) 1;
TestUtil.print("GET_STATUS_BY_APPID");
boolean a2 = a(activity.getIntent(), str);
if (1 == parseByte) {
Logger.d("syncStartApp " + str + " STATUS_UN_RUNNING");
if (iOnCreateSplashView != null) {
Logger.d("syncStartApp " + str + " ShowSplash");
iOnCreateSplashView.onCreateSplash(activity);
}
}
if (a2) {
try {
String str3 = TestUtil.START_APP_SET_ROOTVIEW;
TestUtil.record(str3, "启动" + str);
IApp iApp = (IApp) dispatchEvent(mgrType, 0, new Object[]{activity, str, str2});
iApp.setOnCreateSplashView(iOnCreateSplashView);
if (z && (3 == parseByte || 2 == parseByte)) {
onActivityExecute(activity, ISysEventListener.SysEventType.onNewIntent, str2);
}
return iApp;
} catch (Exception unused) {
Logger.d("syncStartApp appid=" + str);
return null;
}
}
return null;
}
public void a(Activity activity, String str, String str2) {
AsyncTaskHandler.executeThreadTask(new C0078c(str, activity, str2));
}
private void a(Context context, ISysEventListener.SysEventType sysEventType, Object obj) {
Collection<IBoot> values;
HashMap<String, IBoot> hashMap = this.h;
if (hashMap == null || (values = hashMap.values()) == null) {
return;
}
for (IBoot iBoot : values) {
if (iBoot != null) {
try {
int i2 = d.a[sysEventType.ordinal()];
if (i2 == 1) {
iBoot.onStart(context, (Bundle) obj, new String[]{BaseInfo.sDefaultBootApp});
} else if (i2 == 2) {
iBoot.onStop();
} else if (i2 == 3) {
iBoot.onPause();
} else if (i2 == 4) {
iBoot.onResume();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
public void a(Activity activity) {
ISysEventListener.SysEventType sysEventType = ISysEventListener.SysEventType.onPause;
a(activity, sysEventType, (Object) null);
if (this.a) {
AbsMgr absMgr = this.e;
if (absMgr != null) {
absMgr.onExecute(sysEventType, null);
}
onActivityExecute(activity, sysEventType, null);
}
System.gc();
}
private Object a(int i2, Object obj) {
Activity activity;
IApp iApp;
Intent intent;
String str;
if (i2 != -1) {
if (i2 != 0) {
if (i2 != 1) {
if (i2 != 2) {
return null;
}
Object[] objArr = (Object[]) obj;
a((Activity) objArr[0], (String) objArr[1], (String) objArr[2], (IOnCreateSplashView) objArr[3]);
return null;
}
return Boolean.valueOf(this.h.containsValue((IBoot) obj));
}
if (obj instanceof IApp) {
iApp = (IApp) obj;
activity = iApp.getActivity();
intent = iApp.obtainWebAppIntent();
str = iApp.obtainAppId();
} else if (obj instanceof Object[]) {
Object[] objArr2 = (Object[]) obj;
activity = (Activity) objArr2[0];
intent = (Intent) objArr2[1];
str = (String) objArr2[2];
iApp = null;
} else {
activity = null;
iApp = null;
intent = null;
str = null;
}
if (!SDK.isUniMPSDK()) {
io.dcloud.g.b.a.f().g();
}
a(activity, intent, iApp, str);
return null;
}
return BaseInfo.sRuntimeMode;
}
private void a() {
String metaValue = AndroidResources.getMetaValue("DCLOUD_LOCALE");
if (PdrUtil.isEmpty(metaValue) || metaValue.equalsIgnoreCase("default")) {
return;
}
String[] split = metaValue.split("_");
String str = "";
String lowerCase = (split.length <= 0 || split[0] == null) ? "" : split[0].toLowerCase();
if (split.length > 1 && split[1] != null) {
str = split[1].toUpperCase();
}
Locale.setDefault(new Locale(lowerCase, str));
}
}