零距离 v1.0版本的 MD5 值为:250cd43fb2f0f5dc8d41b0026cf86adf
以下内容为反编译后的 b.java 源代码,内容仅作参考
package io.dcloud.i;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Process;
import android.text.TextUtils;
import io.dcloud.base.R;
import io.dcloud.common.DHInterface.AbsMgr;
import io.dcloud.common.DHInterface.BaseFeature;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.DHInterface.IBoot;
import io.dcloud.common.DHInterface.ICore;
import io.dcloud.common.DHInterface.IFeature;
import io.dcloud.common.DHInterface.IFrameView;
import io.dcloud.common.DHInterface.IMgr;
import io.dcloud.common.DHInterface.IWaiter;
import io.dcloud.common.DHInterface.IWebview;
import io.dcloud.common.adapter.io.DHFile;
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.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.permission.PermissionControler;
import io.dcloud.common.util.BaseInfo;
import io.dcloud.common.util.DataUtil;
import io.dcloud.common.util.ErrorDialogUtil;
import io.dcloud.common.util.JSUtil;
import io.dcloud.common.util.PdrUtil;
import io.dcloud.common.util.StringUtil;
import io.dcloud.feature.internal.sdk.SDK;
import io.dcloud.feature.nativeObj.BannerLayout;
import io.src.dcloud.adapter.DCloudAdapterUtil;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
public class b extends AbsMgr implements IMgr.FeatureEvent {
private HashMap<String, HashMap<String, String>> a;
private HashMap<String, String> b;
private HashMap<String, IFeature> c;
private HashMap<String, String> d;
private HashMap<String, IBoot> e;
private String f;
private ArrayList<String> g;
HashMap<String, String> h;
c i;
public b(ICore iCore) {
super(iCore, "featuremgr", IMgr.MgrType.FeatureMgr);
this.a = null;
this.b = null;
this.c = null;
this.d = null;
this.e = null;
this.f = null;
this.g = new ArrayList<>();
this.h = new HashMap<>();
this.i = null;
b();
if (c()) {
return;
}
c();
}
private String a(IApp iApp, IFrameView iFrameView) {
HashMap<String, String> hashMap = this.h;
String str = hashMap.get(iApp.obtainAppId() + "_" + iApp.obtainAppVersionName());
if (str == null) {
str = a(iApp, iFrameView.obtainWebView());
if (Build.VERSION.SDK_INT > 19) {
HashMap<String, String> hashMap2 = this.h;
hashMap2.put(iApp.obtainAppId() + "_" + iApp.obtainAppVersionName(), str);
}
}
return str;
}
private String b(IApp iApp) {
String metaValue = AndroidResources.getMetaValue("DCLOUD_UNIPUSH");
return (PdrUtil.isEmpty(metaValue) || !Boolean.valueOf(metaValue).booleanValue()) ? "" : "window.__isUniPush__ = true;";
}
private void c(String str) {
if (this.c.get(str) == null) {
try {
IFeature iFeature = (IFeature) Class.forName(str).newInstance();
this.c.put(str, iFeature);
iFeature.init(this, str);
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException unused) {
}
}
}
HashMap<String, IBoot> d() {
IBoot iBoot;
InstantiationException e;
IllegalAccessException e2;
ClassNotFoundException e3;
ClassCastException e4;
HashMap<String, IBoot> hashMap = this.e;
HashMap<String, String> hashMap2 = this.d;
PdrUtil.loadProperties2HashMap(hashMap2, this.b, this.a, BaseInfo.s_properties);
Set<String> keySet = hashMap2.keySet();
if (keySet != null) {
hashMap = new HashMap<>(2);
this.e = hashMap;
for (String str : keySet) {
IBoot b = a.b(this, str);
if (b == null) {
try {
iBoot = (IBoot) Class.forName(hashMap2.get(str)).newInstance();
try {
if (iBoot instanceof BaseFeature) {
((BaseFeature) iBoot).init(this, str);
}
} catch (ClassCastException e5) {
e4 = e5;
Logger.e(Logger.MAIN_TAG, "FeatureMgr.loadBootOptions " + e4.getMessage());
b = iBoot;
if (b != null) {
}
} catch (ClassNotFoundException e6) {
e3 = e6;
Logger.e(Logger.MAIN_TAG, "FeatureMgr.loadBootOptions " + e3.getMessage());
b = iBoot;
if (b != null) {
}
} catch (IllegalAccessException e7) {
e2 = e7;
Logger.d(Logger.MAIN_TAG, "FeatureMgr.loadBootOptions " + e2.getMessage());
b = iBoot;
if (b != null) {
}
} catch (InstantiationException e8) {
e = e8;
Logger.d(Logger.MAIN_TAG, "FeatureMgr.loadBootOptions " + e.getMessage());
b = iBoot;
if (b != null) {
}
}
} catch (ClassCastException e9) {
iBoot = b;
e4 = e9;
} catch (ClassNotFoundException e10) {
iBoot = b;
e3 = e10;
} catch (IllegalAccessException e11) {
iBoot = b;
e2 = e11;
} catch (InstantiationException e12) {
iBoot = b;
e = e12;
}
b = iBoot;
}
if (b != null) {
hashMap.put(str, b);
}
}
}
HashMap<String, IBoot> a = a(hashMap);
a(this.b.values().iterator());
for (HashMap<String, String> hashMap3 : this.a.values()) {
a(hashMap3.values().iterator());
}
return a;
}
@Override
public void dispose() {
HashMap<String, IFeature> hashMap = this.c;
if (hashMap != null) {
Collection<IFeature> values = hashMap.values();
if (values != null) {
for (IFeature iFeature : values) {
iFeature.dispose(null);
}
}
this.c.clear();
this.c = null;
}
}
@Override
public Object processEvent(IMgr.MgrType mgrType, int i, Object obj) {
Activity activity;
Object doForFeature;
try {
if (!checkMgrId(mgrType)) {
doForFeature = this.mCore.dispatchEvent(mgrType, i, obj);
} else {
switch (i) {
case 0:
this.c = new HashMap<>(1);
this.b = new HashMap<>(1);
this.a = new HashMap<>(1);
this.e = new HashMap<>();
this.d = new HashMap<>(1);
return d();
case 1:
Object[] objArr = (Object[]) obj;
if (AbsoluteConst.UNI_SYNC_EXEC_METHOD.equalsIgnoreCase(String.valueOf(objArr[2]))) {
doForFeature = a(objArr);
break;
} else {
doForFeature = b(objArr);
break;
}
case 2:
Object[] objArr2 = (Object[]) obj;
String a = a((IApp) objArr2[0], (IFrameView) objArr2[1]);
if (a == null) {
Process.killProcess(Process.myPid());
return a;
}
return a;
case 3:
a(String.valueOf(obj));
return null;
case 4:
doForFeature = this.a.get(String.valueOf(obj));
break;
case 5:
String[] strArr = (String[]) obj;
String str = strArr[0];
String str2 = strArr[1];
String str3 = strArr[2];
if (!PdrUtil.isEmpty(str) && !PdrUtil.isEmpty(str2)) {
this.b.put(str.toLowerCase(), str2);
}
if (PdrUtil.isEmpty(str3)) {
return null;
}
this.g.add(str3);
return null;
case 6:
case 7:
default:
return null;
case 8:
String[] strArr2 = (String[]) obj;
doForFeature = Boolean.valueOf(PermissionControler.checkPermission(strArr2[0], strArr2[1]));
break;
case 9:
doForFeature = Boolean.valueOf(b(String.valueOf(obj)));
break;
case 10:
try {
Object[] objArr3 = (Object[]) obj;
if (objArr3[0] instanceof IWebview) {
activity = ((IWebview) objArr3[0]).getActivity();
} else {
activity = objArr3[0] instanceof IApp ? ((IApp) objArr3[0]).getActivity() : null;
}
IFeature b = b(String.valueOf(objArr3[1]), activity);
if (b instanceof IWaiter) {
doForFeature = ((IWaiter) b).doForFeature(String.valueOf(objArr3[2]), objArr3[3]);
break;
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
case 11:
c((String) ((Object[]) obj)[0]);
return null;
}
}
return doForFeature;
} catch (Throwable th) {
Logger.w("FeatureMgr.processEvent", th);
return null;
}
}
private synchronized String b(Object[] objArr) {
return a(objArr);
}
IFeature b(String str, Activity activity) {
String str2;
ClassNotFoundException e;
IFeature iFeature;
IFeature iFeature2;
if (str.contains(JSUtil.COMMA)) {
String[] split = str.split(JSUtil.COMMA);
String str3 = split[0];
str2 = split[1];
str = str3;
} else {
str2 = null;
}
IFeature iFeature3 = this.c.get(str);
if (iFeature3 != null) {
return iFeature3;
}
String str4 = this.b.get(str);
if (!PdrUtil.isEmpty(str4)) {
str2 = str4;
}
if (str2 != null && this.e.containsKey(str)) {
IBoot iBoot = this.e.get(str);
if ((iBoot instanceof BaseFeature) && str2.equals(iBoot.getClass().getName())) {
iFeature3 = (BaseFeature) iBoot;
}
}
if (iFeature3 != null) {
this.c.put(str, iFeature3);
return iFeature3;
} else if (str2 != null) {
try {
iFeature3 = a.a(this, str);
if (iFeature3 == null) {
iFeature = (IFeature) Class.forName(str2).newInstance();
try {
this.c.put(str, iFeature);
iFeature.init(this, str);
iFeature3 = iFeature;
} catch (ClassNotFoundException e2) {
e = e2;
e.printStackTrace();
try {
iFeature2 = (IFeature) a(str, activity);
if (iFeature2 != null) {
try {
this.c.put(str, iFeature2);
iFeature2.init(this, str);
return iFeature2;
} catch (Exception e3) {
e = e3;
e.printStackTrace();
return iFeature2;
}
}
return iFeature2;
} catch (Exception e4) {
e = e4;
iFeature2 = iFeature;
}
} catch (IllegalAccessException e5) {
e = e5;
iFeature3 = iFeature;
e.printStackTrace();
return iFeature3;
} catch (InstantiationException e6) {
e = e6;
iFeature3 = iFeature;
e.printStackTrace();
return iFeature3;
}
} else {
this.c.put(str, iFeature3);
}
return iFeature3;
} catch (ClassNotFoundException e7) {
IFeature iFeature4 = iFeature3;
e = e7;
iFeature = iFeature4;
} catch (IllegalAccessException e8) {
e = e8;
} catch (InstantiationException e9) {
e = e9;
}
} else {
try {
IFeature iFeature5 = (IFeature) a(str, activity);
if (iFeature5 != null) {
try {
this.c.put(str, iFeature5);
iFeature5.init(this, str);
} catch (Exception e10) {
e = e10;
iFeature3 = iFeature5;
e.printStackTrace();
return iFeature3;
}
}
return iFeature5;
} catch (Exception e11) {
e = e11;
}
}
}
public String a(IWebview iWebview) {
StringBuffer stringBuffer = new StringBuffer();
String webviewUUID = iWebview.getWebviewUUID();
if (PdrUtil.isEmpty(webviewUUID)) {
webviewUUID = String.valueOf(iWebview.obtainFrameView().hashCode());
}
stringBuffer.append("window.__HtMl_Id__= '" + webviewUUID + "';");
if (PdrUtil.isEmpty(iWebview.obtainFrameId())) {
stringBuffer.append("window.__WebVieW_Id__= undefined;");
} else {
stringBuffer.append("window.__WebVieW_Id__= '" + iWebview.obtainFrameId() + "';");
}
stringBuffer.append("try{window.plus.__tag__='_plus_all_'}catch(e){}");
return stringBuffer.toString();
}
public boolean c() {
try {
if (BaseInfo.ISDEBUG && DHFile.isExist("/sdcard/dcloud/all.js")) {
this.f = new String(PlatformUtil.getFileContent("/sdcard/dcloud/all.js", 2));
} else {
this.f = new String(PlatformUtil.getFileContent(DCloudAdapterUtil.getRuntimeJsPath(), 1));
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
private String a(IApp iApp, IWebview iWebview) {
StringBuffer stringBuffer = new StringBuffer(AbsoluteConst.PROTOCOL_JAVASCRIPT);
stringBuffer.append("function ");
stringBuffer.append(AbsoluteConst.LOAD_PLUS_FUN_NAME);
stringBuffer.append("(){try{");
int i = Build.VERSION.SDK_INT;
if (i <= 19) {
stringBuffer.append(a(iWebview));
}
if (TextUtils.isEmpty(this.f) || this.f.length() < 400) {
return null;
}
stringBuffer.append("window._____isDebug_____=" + BaseInfo.ISDEBUG + ";");
stringBuffer.append("window._____platform_____=1;");
stringBuffer.append("window._____platform_os_version_____=" + i + ";");
stringBuffer.append(this.f);
if (PermissionControler.checkPermission(iApp.obtainAppId(), IFeature.F_DEVICE.toLowerCase()) || !iApp.manifestBeParsed()) {
if (PdrUtil.isEmpty(DeviceInfo.DEVICESTATUS_JS)) {
try {
DeviceInfo.initGsmCdmaCell();
} catch (SecurityException e) {
e.printStackTrace();
}
DeviceInfo.getDevicestatus_js(iApp);
}
stringBuffer.append(DeviceInfo.DEVICESTATUS_JS);
}
SDK.IntegratedMode integratedMode = BaseInfo.sRuntimeMode;
StringBuilder sb = new StringBuilder();
sb.append("window.__NWin_Enable__=");
sb.append(integratedMode == SDK.IntegratedMode.WEBVIEW ? String.valueOf(false) : String.valueOf(true));
sb.append(";");
stringBuffer.append(sb.toString());
if (PermissionControler.checkPermission(iApp.obtainAppId(), IFeature.F_RUNTIME) || !iApp.manifestBeParsed()) {
String obtainConfigProperty = iApp.obtainConfigProperty(IApp.ConfigProperty.CONFIG_LOADED_TIME);
stringBuffer.append(StringUtil.format(AbsoluteConst.JS_RUNTIME_BASE, BaseInfo.ISAMU ? StringUtil.format(AbsoluteConst.JS_RUNTIME_VERSIONs, iApp.obtainAppVersionName(), "1.9.9.81128", iApp.obtainAppId(), obtainConfigProperty) : StringUtil.format(AbsoluteConst.JS_RUNTIME_VERSIONs, AndroidResources.mApplicationInfo.versionName, "1.9.9.81128", iApp.obtainAppId(), obtainConfigProperty)));
stringBuffer.append(StringUtil.format(AbsoluteConst.JS_RUNTIME_BASE, StringUtil.format(AbsoluteConst.JS_RUNTIME_ARGUMENTS, DataUtil.utf8ToUnicode(iApp.obtainRuntimeArgs(true)))));
String launcherData = BaseInfo.getLauncherData(iApp.obtainAppId());
if (!PdrUtil.isEmpty(iApp.obtainWebAppIntent())) {
String stringExtra = iApp.obtainWebAppIntent().getStringExtra(IntentConst.FROM_STREAM_OPEN_FLAG);
if (!TextUtils.isEmpty(stringExtra) && !TextUtils.equals(stringExtra, iApp.obtainAppId())) {
launcherData = launcherData + ":" + stringExtra;
}
}
stringBuffer.append(StringUtil.format(AbsoluteConst.JS_RUNTIME_BASE, StringUtil.format(AbsoluteConst.JS_RUNTIME_LAUNCHER, launcherData)));
stringBuffer.append(StringUtil.format(AbsoluteConst.JS_RUNTIME_BASE, StringUtil.format(AbsoluteConst.JS_RUNTIME_CHANNEL, BaseInfo.getAnalysisChannel())));
String bundleData = SP.getBundleData(iApp.getActivity(), "pdr", iApp.obtainAppId() + AbsoluteConst.LAUNCHTYPE);
if (TextUtils.isEmpty(bundleData)) {
bundleData = BannerLayout.CIRCULAR_INDICATOR;
}
stringBuffer.append(StringUtil.format(AbsoluteConst.JS_RUNTIME_BASE, StringUtil.format(AbsoluteConst.JS_RUNTIME_ORIGIN, bundleData)));
stringBuffer.append(StringUtil.format(AbsoluteConst.JS_RUNTIME_BASE, StringUtil.format(AbsoluteConst.JS_RUNTIME_STARTUPTIME, String.valueOf(BaseInfo.getStartupTimeData(iApp.obtainAppId())))));
stringBuffer.append(StringUtil.format(AbsoluteConst.JS_RUNTIME_BASE, StringUtil.format(AbsoluteConst.JS_RUNTIME_PROCESSID, Long.valueOf(BaseInfo.sProcessId))));
stringBuffer.append(StringUtil.format(AbsoluteConst.JS_RUNTIME_BASE, StringUtil.format("p.runtime.versionCode = %d;", Integer.valueOf(AndroidResources.versionCode))));
if (BaseInfo.isUniAppAppid(iApp)) {
stringBuffer.append(StringUtil.format(AbsoluteConst.JS_RUNTIME_BASE, StringUtil.format("p.runtime.uniVersion = '%s';", BaseInfo.uniVersionV3)));
}
}
if (PermissionControler.checkPermission(iApp.obtainAppId(), IFeature.F_NAVIGATOR)) {
DeviceInfo.updateStatusBarHeight(iWebview.getActivity());
stringBuffer.append(String.format(Locale.UK, AbsoluteConst.JS_NAVIGATOR_STATUSBAR_HEIGHT, Float.valueOf(DeviceInfo.sStatusBarHeight / iWebview.getScale())));
}
int size = this.g.size();
for (int i2 = 0; i2 < size; i2++) {
stringBuffer.append(this.g.get(i2));
}
stringBuffer.append(a());
stringBuffer.append("}catch(e){console.log('__load__plus__ function error=' + e);}}");
stringBuffer.append(AbsoluteConst.EXECUTE_LOAD_FUNS_FUN);
stringBuffer.append(a(iApp));
stringBuffer.append(b(iApp));
return stringBuffer.toString();
}
private void b() {
try {
this.i = (c) Class.forName("io.dcloud.feature.d").getConstructor(Context.class).newInstance(getContext());
} catch (Exception unused) {
Logger.e("fmgr no dp");
}
}
private boolean b(String str) {
return this.b.containsKey(str);
}
private String a(IApp iApp) {
if (BaseInfo.isUniNViewBackgroud()) {
String str = (String) processEvent(IMgr.MgrType.FeatureMgr, 10, new Object[]{iApp, "weex,io.dcloud.feature.weex.WeexFeature", "getUniNViewModules", null});
if (!PdrUtil.isEmpty(str)) {
return "window.__NATIVE_PLUGINS__ = " + str + ";window.__NATIVE_PLUGINS_REGISTERED__ = true;";
}
}
return "";
}
private String a() {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(";Object.defineProperty(plus.screen,\"resolutionHeight\",{get:function(){var e=window,l=e.__html5plus__&&e.__html5plus__.isReady?e.__html5plus__:n.plus&&n.plus.isReady?n.plus:window.plus;return l.bridge.execSync(\"Device\",\"s.resolutionHeight\",[])}}),Object.defineProperty(plus.screen,\"resolutionWidth\",{get:function(){var e=window,l=e.__html5plus__&&e.__html5plus__.isReady?e.__html5plus__:n.plus&&n.plus.isReady?n.plus:window.plus;return l.bridge.execSync(\"Device\",\"s.resolutionWidth\",[])}}),Object.defineProperty(plus.display,\"resolutionHeight\",{get:function(){var e=window,l=e.__html5plus__&&e.__html5plus__.isReady?e.__html5plus__:n.plus&&n.plus.isReady?n.plus:window.plus;return l.bridge.execSync(\"Device\",\"d.resolutionHeight\",[])}}),Object.defineProperty(plus.display,\"resolutionWidth\",{get:function(){var e=window,l=e.__html5plus__&&e.__html5plus__.isReady?e.__html5plus__:n.plus&&n.plus.isReady?n.plus:window.plus;return l.bridge.execSync(\"Device\",\"d.resolutionWidth\",[])}});");
stringBuffer.append(";plus.webview.__test__('save');");
if (Build.VERSION.SDK_INT > 19) {
stringBuffer.append("plus.webview.__test__('update');");
}
return stringBuffer.toString();
}
private String a(Object[] objArr) {
IWebview iWebview = (IWebview) objArr[0];
String lowerCase = String.valueOf(objArr[1]).toLowerCase();
String valueOf = String.valueOf(objArr[2]);
JSONArray jSONArray = (JSONArray) objArr[3];
String str = null;
r6 = null;
String[] jsonArrayToStringArr = null;
str = null;
str = null;
str = null;
if (iWebview != null && iWebview.obtainApp() != null && iWebview.obtainFrameView() != null && iWebview.obtainFrameView().obtainWebView() != null) {
IFeature b = b(lowerCase, iWebview.getActivity());
if (b != null) {
if (b instanceof BaseFeature) {
BaseFeature baseFeature = (BaseFeature) b;
if (!baseFeature.isOldMode()) {
return baseFeature.execute(iWebview, valueOf, jSONArray);
}
}
if (jSONArray != null) {
try {
jsonArrayToStringArr = JSUtil.jsonArrayToStringArr(jSONArray);
} catch (JSONException e) {
e.printStackTrace();
}
}
return b.execute(iWebview, valueOf, jsonArrayToStringArr);
}
str = "";
if (iWebview.obtainFrameView().getFrameType() != 3 && !PermissionControler.checkSafePermission(iWebview.obtainApp().obtainAppId(), lowerCase)) {
String format = StringUtil.format(getContext().getString(R.string.dcloud_feature_error_tips), lowerCase);
Logger.e("featuremgr", "not found " + lowerCase + " feature plugin ; action=" + valueOf + ";" + format);
a(iWebview, lowerCase);
}
}
return str;
}
private Object a(String str, Activity activity) {
c cVar = this.i;
if (cVar != null) {
return cVar.a(str, activity);
}
return null;
}
private HashMap<String, IBoot> a(HashMap<String, IBoot> hashMap) {
if (this.i == null) {
return hashMap;
}
if (hashMap == null) {
hashMap = new HashMap<>();
}
Set<String> keySet = this.i.a().keySet();
if (keySet != null) {
for (String str : keySet) {
Object a = this.i.a(str);
if (a != null) {
if (a instanceof BaseFeature) {
((BaseFeature) a).init(this, str);
}
hashMap.put(str, (IBoot) a);
}
}
}
return hashMap;
}
private void a(Iterator<String> it) {
if (SDK.isUniMPSDK()) {
return;
}
while (it.hasNext()) {
String valueOf = String.valueOf(PlatformUtil.invokeMethod(it.next(), "getJsContent"));
if (!PdrUtil.isEmpty(valueOf)) {
this.g.add(valueOf);
}
}
}
public void a(String str) {
Collection<IFeature> values;
HashMap<String, IFeature> hashMap = this.c;
if (hashMap != null && (values = hashMap.values()) != null) {
for (IFeature iFeature : values) {
try {
iFeature.dispose(str);
} catch (Exception e) {
e.printStackTrace();
}
}
}
HashMap<String, String> hashMap2 = this.h;
if (hashMap2 != null) {
String str2 = null;
Iterator<String> it = hashMap2.keySet().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
String next = it.next();
if (next.startsWith(str + "_")) {
str2 = next;
break;
}
}
if (TextUtils.isEmpty(str2)) {
return;
}
this.h.remove(str2);
}
}
public void a(IWebview iWebview, String str) {
Dialog lossDialog = ErrorDialogUtil.getLossDialog(iWebview, StringUtil.format(iWebview.getContext().getString(R.string.dcloud_feature_error_tips2) + "http://ask.dcloud.net.cn/article/283", str), "http://ask.dcloud.net.cn/article/283", str);
if (lossDialog != null) {
lossDialog.show();
}
}
}