正在查看: 管控平台 v5.2.3.0. 应用的 EDULogStasPluginEntry.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 管控平台 v5.2.3.0. 应用的 EDULogStasPluginEntry.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.iflytek.edu.statistics.plugin;
import a.b.a.c.c;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import com.iflytek.edu.apm.base.IEDULogDataCollectCallback;
import com.iflytek.edu.apm.base.thread.EDULogThreadManager;
import com.iflytek.edu.statistics.EDULogStasDataCollector;
import com.iflytek.edu.statistics.EDULogStasLogEnum;
import com.iflytek.edu.statistics.config.EDUBigDataConfigManager;
import com.iflytek.edu.statistics.helper.EDULogViewIdHelper;
import com.iflytek.edu.statistics.pack.content.LogContentPackHelper;
import com.iflytek.edu.statistics.utils.EDULogBig;
import org.json.JSONObject;
public class EDULogStasPluginEntry {
static String ANDROID_PLUGIN_VERSION = "";
private static final String EDU_APP_H5_BRIDGE = "EDU_APP_H5_BRIDGE";
private static EDULogStasPluginEntry INSTANCE = null;
private static final String TAG = "EDULogStasPluginEntry";
static final String VERSION = "2.1.1.2";
private IEDULogDataCollectCallback mIEDULogDataCollectCallback;
private boolean mIsStart = false;
private final LogContentPackHelper mLogContentPackHelper = new LogContentPackHelper();
private EDULogStasPluginEntry() {
}
private static void addJavascriptInterface(View webView, Object obj, String interfaceName) {
Object invoke;
try {
Class<?> cls = webView.getClass();
try {
Object invoke2 = cls.getMethod(WebStasConstant.GET_SETTINGS, new Class[0]).invoke(webView, new Object[0]);
if (invoke2 != null && ((invoke = invoke2.getClass().getMethod(WebStasConstant.GET_JAVA_SCRIPT_ENABLED, new Class[0]).invoke(invoke2, new Object[0])) == null || !TextUtils.equals(invoke.toString(), Boolean.TRUE.toString()))) {
EDULogBig.e(TAG, "your class 【" + cls.getName() + "】 does not setJavaScriptEnabled true,can not track H5 normally");
}
} catch (Exception e) {
EDULogBig.printStackTrace(e);
}
cls.getMethod(WebStasConstant.ADD_JAVASCRIPT_INTERFACE, Object.class, String.class).invoke(webView, obj, interfaceName);
} catch (Exception e2) {
EDULogBig.printStackTrace(e2);
}
}
public static boolean enableH5Track() {
return getInstance().getCollectCallback() != null && getInstance().mLogContentPackHelper != null && EDUBigDataConfigManager.getInstance().isComponentUsable() && getInstance().mIsStart && EDUBigDataConfigManager.getInstance().isJsBridgeSwitch();
}
public static synchronized EDULogStasPluginEntry getInstance() {
EDULogStasPluginEntry eDULogStasPluginEntry;
synchronized (EDULogStasPluginEntry.class) {
if (INSTANCE == null) {
INSTANCE = new EDULogStasPluginEntry();
}
eDULogStasPluginEntry = INSTANCE;
}
return eDULogStasPluginEntry;
}
public static void loadData2(View webView, String data, String mimeType, String encoding) {
if (webView == null) {
EDULogBig.i(TAG, "WebView has not initialized.");
} else {
setupH5Bridge(webView);
}
}
public static void loadDataWithBaseURL2(View webView, String baseUrl, String data, String mimeType, String encoding, String historyUrl) {
if (webView == null) {
EDULogBig.i(TAG, "WebView has not initialized.");
} else {
setupH5Bridge(webView);
}
}
public static void loadUrl2(View webView, String url) {
Log.e(TAG, "loadUrl2 :" + url);
if (webView == null) {
EDULogBig.i(TAG, "WebView has not initialized.");
} else {
setupH5Bridge(webView);
}
}
public static void postUrl2(View webView, String url, byte[] postData) {
if (webView == null) {
EDULogBig.i(TAG, "WebView has not initialized.");
} else {
setupH5Bridge(webView);
}
}
private void processAutoPageEndEvent(final JSONObject eventJson) {
EDULogThreadManager.getInstance().getCusThreadRun("EDULOGSTAS", new c.a() {
@Override
public final void dealWithCallBack() {
EDULogStasPluginEntry.this.a(eventJson);
}
});
}
private void processAutoPageStartEvent(final JSONObject eventJson) {
EDULogThreadManager.getInstance().getCusThreadRun("EDULOGSTAS", new c.a() {
@Override
public final void dealWithCallBack() {
EDULogStasPluginEntry.this.b(eventJson);
}
});
}
private void processPageEndEvent(final JSONObject eventJson) {
EDULogThreadManager.getInstance().getCusThreadRun("EDULOGSTAS", new c.a() {
@Override
public final void dealWithCallBack() {
EDULogStasPluginEntry.this.c(eventJson);
}
});
}
private void processPageStartEvent(final JSONObject eventJson) {
EDULogThreadManager.getInstance().getCusThreadRun("EDULOGSTAS", new c.a() {
@Override
public final void dealWithCallBack() {
EDULogStasPluginEntry.this.d(eventJson);
}
});
}
private void processTrackEvent(final JSONObject eventJson) {
EDULogThreadManager.getInstance().getCusThreadRun("EDULOGSTAS", new c.a() {
@Override
public final void dealWithCallBack() {
EDULogStasPluginEntry.this.e(eventJson);
}
});
}
private static void setupH5Bridge(View webView) {
boolean enableH5Track = enableH5Track();
EDULogBig.d(TAG, "jsBridge埋点是否可用:" + enableH5Track);
if (enableH5Track) {
setupWebView(webView);
} else {
EDULogBig.d(TAG, "stasCollect jsBridgeSwitch disable");
}
}
private static void setupWebView(View webView) {
if (webView != null) {
addJavascriptInterface(webView, new AppWebViewInterface(EDULogStasDataCollector.getApplicationContext(), null, false, webView), EDU_APP_H5_BRIDGE);
}
}
public void a(final JSONObject eventJson) {
String optString = eventJson.optString(WebStasConstant.VIEW_PATH);
final JSONObject packJsViewAutoExit = this.mLogContentPackHelper.packJsViewAutoExit(optString, EDULogViewIdHelper.getInstance().getViewIdByPath(optString), eventJson);
a.b.a.c.c.a().f(new Runnable() {
@Override
public void run() {
EDULogStasPluginEntry.this.getCollectCallback().onLogCallback(EDULogStasLogEnum.ACTIVITY_EXIT.logTypeForStore, packJsViewAutoExit);
}
});
}
public void b(final JSONObject eventJson) {
String optString = eventJson.optString(WebStasConstant.VIEW_PATH);
final JSONObject packJsViewAutoEnter = this.mLogContentPackHelper.packJsViewAutoEnter(optString, EDULogViewIdHelper.getInstance().putView(optString), eventJson);
a.b.a.c.c.a().f(new Runnable() {
@Override
public void run() {
EDULogStasPluginEntry.this.getCollectCallback().onLogCallback(EDULogStasLogEnum.ACTIVITY_ENTER.logTypeForStore, packJsViewAutoEnter);
}
});
}
public void c(final JSONObject eventJson) {
String optString = eventJson.optString(WebStasConstant.VIEW_PATH);
final JSONObject packJsViewManualExit = this.mLogContentPackHelper.packJsViewManualExit(optString, EDULogViewIdHelper.getInstance().getViewIdByPath(optString), eventJson);
a.b.a.c.c.a().f(new Runnable() {
@Override
public void run() {
EDULogStasPluginEntry.this.getCollectCallback().onLogCallback(EDULogStasLogEnum.VIEW_EXIT.logTypeForStore, packJsViewManualExit);
}
});
}
public void clearCallback() {
this.mIEDULogDataCollectCallback = null;
}
public void d(final JSONObject eventJson) {
String optString = eventJson.optString(WebStasConstant.VIEW_PATH);
final JSONObject packJsViewManualEnter = this.mLogContentPackHelper.packJsViewManualEnter(optString, EDULogViewIdHelper.getInstance().putView(optString), eventJson);
a.b.a.c.c.a().f(new Runnable() {
@Override
public void run() {
EDULogStasPluginEntry.this.getCollectCallback().onLogCallback(EDULogStasLogEnum.VIEW_ENTER.logTypeForStore, packJsViewManualEnter);
}
});
}
public void e(final JSONObject eventJson) {
final JSONObject packJsCustomLog = this.mLogContentPackHelper.packJsCustomLog(eventJson);
a.b.a.c.c.a().f(new Runnable() {
@Override
public void run() {
EDULogStasPluginEntry.this.getCollectCallback().onLogCallback(EDULogStasLogEnum.CUSTOM.logTypeForStore, packJsCustomLog);
}
});
}
public IEDULogDataCollectCallback getCollectCallback() {
return this.mIEDULogDataCollectCallback;
}
public int jsBridgeEvent(String jsData) {
if (jsData == null) {
return 1;
}
try {
JSONObject jSONObject = new JSONObject(jsData);
String optString = jSONObject.optString("type");
char c = 65535;
switch (optString.hashCode()) {
case -803573812:
if (optString.equals(WebStasConstant.PAGE_END)) {
c = 1;
break;
}
break;
case -221844956:
if (optString.equals(WebStasConstant.AUTO_PAGE_START)) {
c = 2;
break;
}
break;
case 110621003:
if (optString.equals("track")) {
c = 4;
break;
}
break;
case 872788755:
if (optString.equals(WebStasConstant.PAGE_START)) {
c = 0;
break;
}
break;
case 2100311837:
if (optString.equals(WebStasConstant.AUTO_PAGE_END)) {
c = 3;
break;
}
break;
}
if (c == 0) {
processPageStartEvent(jSONObject);
} else if (c == 1) {
processPageEndEvent(jSONObject);
} else if (c == 2) {
processAutoPageStartEvent(jSONObject);
} else if (c == 3) {
processAutoPageEndEvent(jSONObject);
} else {
if (c != 4) {
return 2;
}
processTrackEvent(jSONObject);
}
return 0;
} catch (Exception e) {
EDULogBig.printStackTrace(e);
return 1;
}
}
public void registeCollectionCallback(IEDULogDataCollectCallback callback) {
EDULogBig.d(TAG, "registDataCallback");
if (callback == null) {
EDULogBig.d(TAG, "IEDULogDataCollectCallback can not null");
} else {
this.mIEDULogDataCollectCallback = callback;
}
}
public void setStart(boolean start) {
EDULogBig.d(TAG, "setStart:" + start);
this.mIsStart = start;
}
}