整点视频 v3.3.0版本的 MD5 值为:cba0457dc37421eed445b30f92de25d3
以下内容为反编译后的 LivePluginHelper.java 源代码,内容仅作参考
package com.bytedance.android.openliveplugin;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.net.Uri;
import android.util.Log;
import android.util.Pair;
import android.widget.Toast;
import com.bytedance.android.live.base.api.ILiveHostContextParam;
import com.bytedance.android.live.base.api.ILiveInitCallback;
import com.bytedance.android.live.base.api.IOuterLiveRoomService;
import com.bytedance.android.live.base.api.IOuterLiveService;
import com.bytedance.android.live.base.api.JavaCallsUtils;
import com.bytedance.android.live.base.api.callback.CommonCallback;
import com.bytedance.android.live.base.api.callback.EmptyCallback;
import com.bytedance.android.openliveplugin.stub.logger.TTLogger;
import com.bytedance.pangle.GlobalParam;
import com.bytedance.pangle.Zeus;
import com.bytedance.pangle.ZeusPluginStateListener;
import com.bytedance.pangle.plugin.PluginManager;
import com.bytedance.sdk.openadsdk.R;
import com.sigmob.sdk.base.mta.PointCategory;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import org.json.JSONException;
import org.json.JSONObject;
public class LivePluginHelper {
public static final String LIVE_PLUGIN_PACKAGE_NAME = "com.byted.live.lite";
private static IOuterLiveRoomService liveRoomService;
private static ArrayList<ILiveInitCallback> mLiveInitListeners;
private static EmptyCallback sInstallCallback;
public static final ScheduledExecutorService sExecutor = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory());
private static volatile boolean hasLiveInitFinish = false;
private static boolean hasInitZeus = false;
private static boolean runInLiveProcess = false;
private static HashMap<String, String> customTagMap = null;
private static boolean apmEnable = true;
private static boolean stopAppLogOnEnterBackground = false;
private static WeakReference<Activity> hostActivity = null;
private static final ILiveInitCallback loadingLiveInitCallback = new ILiveInitCallback() {
@Override
public void onLiveInitFailed(String str) {
if (!LiveLoadingDialog.dismiss() || LivePluginHelper.hostActivity.get() == null) {
return;
}
Toast.makeText((Context) LivePluginHelper.hostActivity.get(), R.string.live_in_loading_failed, 1).show();
}
@Override
public void onLiveInitFinish() {
if (LiveLoadingDialog.dismiss()) {
LivePluginHelper.trulyEnterCommerceOrderList();
}
}
};
private static class DefaultThreadFactory implements ThreadFactory {
private final ThreadGroup group;
private final String namePrefix;
private final AtomicInteger threadNumber;
DefaultThreadFactory() {
this.threadNumber = new AtomicInteger(1);
this.group = new ThreadGroup("tob_douyin_live_group");
this.namePrefix = "tob_douyin_live_thread_init";
}
DefaultThreadFactory(String str) {
this.threadNumber = new AtomicInteger(1);
this.group = new ThreadGroup("tob_douyin_live_group");
this.namePrefix = str;
}
@Override
public Thread newThread(Runnable runnable) {
ThreadGroup threadGroup = this.group;
Thread thread = new Thread(threadGroup, runnable, this.namePrefix + this.threadNumber.getAndIncrement(), 0L);
if (thread.isDaemon()) {
thread.setDaemon(false);
}
if (thread.getPriority() != 10) {
thread.setPriority(10);
}
return thread;
}
}
public static class LiveInitCallbackWrapper implements ILiveInitCallback {
public static LiveInitCallbackWrapper INSTANCE = new LiveInitCallbackWrapper();
private LiveInitCallbackWrapper() {
}
@Override
public void onLiveInitFailed(String str) {
Iterator it = LivePluginHelper.mLiveInitListeners.iterator();
while (it.hasNext()) {
ILiveInitCallback iLiveInitCallback = (ILiveInitCallback) it.next();
if (iLiveInitCallback != null) {
try {
iLiveInitCallback.onLiveInitFailed(str);
} catch (Throwable th) {
th.printStackTrace();
}
}
}
}
@Override
public void onLiveInitFinish() {
LivePluginHelper.logVersionInfo();
TTLogger.d("live init : LiveInitCallbackWrapper onLiveInitFinish called.");
LivePluginHelper.initLiveCommerce();
boolean unused = LivePluginHelper.hasLiveInitFinish = true;
Iterator it = LivePluginHelper.mLiveInitListeners.iterator();
while (it.hasNext()) {
ILiveInitCallback iLiveInitCallback = (ILiveInitCallback) it.next();
if (iLiveInitCallback != null) {
try {
iLiveInitCallback.onLiveInitFinish();
} catch (Throwable th) {
th.printStackTrace();
}
}
}
}
}
private static void adaptEventBus() {
JavaCallsUtils.callStaticMethodWithClassLoader("com.bytedance.android.openlive.OpenLiveBackdoor", "tryAdaptEventBus", PluginManager.getInstance().getPlugin("com.byted.live.lite").mClassLoader, "com.bytedance.pangle.activity", "com.bytedance.pangle.wrapper");
}
public static void addCustomTag(String str, String str2) {
if (customTagMap == null) {
customTagMap = new HashMap<>();
}
customTagMap.put(str, str2);
}
public static void addInitListener(ILiveInitCallback iLiveInitCallback) {
if (mLiveInitListeners == null) {
mLiveInitListeners = new ArrayList<>();
}
if (iLiveInitCallback == LiveInitCallbackWrapper.INSTANCE || mLiveInitListeners.contains(iLiveInitCallback) || iLiveInitCallback == null) {
return;
}
mLiveInitListeners.add(iLiveInitCallback);
}
public static void enterCommerceOrderList(Activity activity) {
hostActivity = new WeakReference<>(activity);
if (isLiveInited()) {
trulyEnterCommerceOrderList();
return;
}
Zeus.registerPluginStateListener(new ZeusPluginStateListener() {
@Override
public void onPluginStateChange(String str, int i, Object... objArr) {
if ("com.byted.live.lite".equals(str)) {
if ((i == 4 || i == 7 || i == 10) && LiveLoadingDialog.dismiss() && LivePluginHelper.hostActivity.get() != null) {
Toast.makeText((Context) LivePluginHelper.hostActivity.get(), R.string.live_in_loading_failed, 1).show();
}
}
}
});
addInitListener(loadingLiveInitCallback);
LiveLoadingDialog.show(hostActivity.get());
}
public static boolean getApmEnable() {
return apmEnable;
}
public static String getLiveArgsJsonStr() {
return (String) JavaCallsUtils.callStaticMethodWithClassLoader("com.bytedance.android.openlive.OpenLiveBackdoor", "getLiveArgsJsonStr", PluginManager.getInstance().getPlugin("com.byted.live.lite").mClassLoader, new Object[0]);
}
public static IOuterLiveRoomService getLiveRoomService() {
if (liveRoomService == null) {
liveRoomService = (IOuterLiveRoomService) JavaCallsUtils.callStaticMethodWithClassLoader("com.bytedance.android.openlive.OpenLiveBackdoor", "getOuterLiveRoomService", PluginManager.getInstance().getPlugin("com.byted.live.lite").mClassLoader, new Object[0]);
}
return liveRoomService;
}
public static boolean getStopAppLogOnEnterBackground() {
return stopAppLogOnEnterBackground;
}
public static void init(Application application) {
if (application == null) {
return;
}
GlobalParam.getInstance().init();
Zeus.init(application, true);
Zeus.installFromDownloadDir();
Zeus.fetchPlugin("com.byted.live.lite");
}
public static void init(Application application, String str, ILiveHostContextParam.Builder builder, ILiveInitCallback iLiveInitCallback) {
init(application, str, builder, iLiveInitCallback, true);
}
public static void init(Application application, String str, ILiveHostContextParam.Builder builder, ILiveInitCallback iLiveInitCallback, boolean z) {
init(application, str, builder, iLiveInitCallback, z, false);
}
public static void init(Application application, String str, ILiveHostContextParam.Builder builder, ILiveInitCallback iLiveInitCallback, boolean z, boolean z2) {
if (!hasInitZeus) {
initZeus(application, z);
}
initLive(application, str, builder, iLiveInitCallback, z2);
}
public static void initLive(final Application application, final String str, final ILiveHostContextParam.Builder builder, final ILiveInitCallback iLiveInitCallback, final boolean z) {
runInLiveProcess = z;
sExecutor.execute(new Runnable() {
@Override
public void run() {
TTLogger.d("live init : async start init live ~~~");
if (LivePluginHelper.prepare(new Runnable() {
@Override
public void run() {
TTLogger.d("live init : runnable real init live ---- ");
AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
LivePluginHelper.realInitLivePlugin(application, str, builder, iLiveInitCallback, z);
}
})) {
TTLogger.d("live init : prepared-start real init live ---- ");
LivePluginHelper.realInitLivePlugin(application, str, builder, iLiveInitCallback, z);
}
}
});
}
public static void initLiveCommerce() {
try {
adaptEventBus();
JavaCallsUtils.callStaticMethodWithClassLoader("com.bytedance.android.ecom.live.adapter.ECLiveAdapter", PointCategory.INIT, PluginManager.getInstance().getPlugin("com.byted.live.lite").mClassLoader, new Object[0]);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void initZeus(Application application, boolean z) {
if (application == null || hasInitZeus) {
return;
}
hasInitZeus = true;
if (customTagMap != null) {
GlobalParam.getInstance().setCustomTag("com.byted.live.lite", customTagMap);
customTagMap = null;
}
if (!apmEnable) {
GlobalParam.getInstance().setApmFlag(false, false, false, false);
GlobalParam.getInstance().closeCrashMonitor(true);
}
GlobalParam.getInstance().init();
Zeus.init(application, true);
Zeus.installFromDownloadDir();
if (z) {
Zeus.fetchPlugin("com.byted.live.lite");
}
TTLogger.d("live init : initZeus with fetchPlugin = ".concat(String.valueOf(z)));
}
public static boolean isLiveInited() {
return hasLiveInitFinish;
}
public static boolean isRunInLiveProcess() {
return runInLiveProcess;
}
public static void logEventV3(String str, JSONObject jSONObject) {
JavaCallsUtils.callStaticMethodWithClassLoader("com.bytedance.android.openlive.OpenLiveBackdoor", "onEventV3", PluginManager.getInstance().getPlugin("com.byted.live.lite").mClassLoader, str, jSONObject);
}
public static void logVersionInfo() {
Object callStaticMethodWithClassLoader = JavaCallsUtils.callStaticMethodWithClassLoader("com.bytedance.android.openlive.plugin.LivePluginApplication", "getPluginVersion", PluginManager.getInstance().getPlugin("com.byted.live.lite").mClassLoader, new Object[0]);
if (callStaticMethodWithClassLoader == null) {
return;
}
try {
Pair pair = (Pair) callStaticMethodWithClassLoader;
long longValue = ((Long) pair.first).longValue();
Log.i("live init", "version_info: lib_version_name=2.1.1.3-tob-tob-265124218; sdkApiVersionName=2.1.1.3-tob-tob-265124218; pluginVersionCode=" + longValue + "; pluginVersionName=" + ((String) pair.second));
} catch (Throwable th) {
th.printStackTrace();
}
}
public static boolean prepare(final Runnable runnable) {
TTLogger.d("live init : prepare ---- ");
if (!Zeus.isPluginInstalled("com.byted.live.lite")) {
TTLogger.d("live init : prepare live plugin is not installed !!! ");
Zeus.registerPluginStateListener(new ZeusPluginStateListener() {
@Override
public void onPluginStateChange(String str, int i, Object... objArr) {
if (runnable != null && "com.byted.live.lite".equals(str) && i == 6) {
if (LivePluginHelper.sInstallCallback != null) {
LivePluginHelper.sInstallCallback.invoke();
}
TTLogger.d("live init : prepare on live plugin install success !!! ");
LivePluginHelper.sExecutor.execute(new Runnable() {
@Override
public void run() {
if (Zeus.isPluginLoaded("com.byted.live.lite")) {
TTLogger.d("live init : prepare onPluginStateChange start load live plugin v1 !!! ");
runnable.run();
} else if (Zeus.loadPlugin("com.byted.live.lite")) {
TTLogger.d("live init : prepare onPluginStateChange start load live plugin v2 !!! ");
runnable.run();
}
}
});
}
}
});
return false;
}
EmptyCallback emptyCallback = sInstallCallback;
if (emptyCallback != null) {
emptyCallback.invoke();
}
if (Zeus.isPluginLoaded("com.byted.live.lite")) {
TTLogger.d("live init : prepare live plugin is load !!! ");
return Zeus.isPluginLoaded("com.byted.live.lite");
}
TTLogger.d("live init : prepare start load live plugin !!! ");
return Zeus.loadPlugin("com.byted.live.lite");
}
public static void realInitLivePlugin(final Application application, final String str, final ILiveHostContextParam.Builder builder, final ILiveInitCallback iLiveInitCallback, final boolean z) {
sExecutor.execute(new Runnable() {
@Override
public void run() {
JavaCallsUtils.callStaticMethodWithClassLoader("com.bytedance.android.openlive.plugin.LivePluginInitEntrance", "initLiveInPlugin", PluginManager.getInstance().getPlugin("com.byted.live.lite").mClassLoader, application, str, builder, Boolean.valueOf(z), iLiveInitCallback);
}
});
}
public static void setApmEnable(boolean z) {
apmEnable = z;
}
public static void setBoeValue(String str) {
JavaCallsUtils.callStaticMethodWithClassLoader("com.bytedance.android.openlive.OpenLiveBackdoor", "setBoeValue", PluginManager.getInstance().getPlugin("com.byted.live.lite").mClassLoader, str);
}
public static void setHostVersionCodeTag(long j) {
addCustomTag("internal_host_version_code", String.valueOf(j));
}
public static void setInstallCallback(EmptyCallback emptyCallback) {
sInstallCallback = emptyCallback;
}
public static void setPpeValue(String str) {
JavaCallsUtils.callStaticMethodWithClassLoader("com.bytedance.android.openlive.OpenLiveBackdoor", "setPpeValue", PluginManager.getInstance().getPlugin("com.byted.live.lite").mClassLoader, str);
}
public static void setStopAppLogOnEnterBackground(boolean z) {
stopAppLogOnEnterBackground = z;
}
public static void trulyEnterCommerceOrderList() {
TTLogger.d("trulyEnterCommerceOrderList start");
if (liveRoomService == null) {
getLiveRoomService();
}
if (liveRoomService == null) {
return;
}
try {
TTLogger.d("callExpandMethod enterCommercePage");
liveRoomService.callExpandMethod("enterCommercePage", new JSONObject().put("request_page", "order_list"), new CommonCallback<String, String>() {
@Override
public void onFail(String str) {
TTLogger.d("get enterCommercePage fail, error msg = ".concat(String.valueOf(str)));
}
@Override
public void onSuccess(String str) {
TTLogger.d("get enterCommercePage success, result = ".concat(String.valueOf(str)));
((IOuterLiveService) LivePluginHelper.liveRoomService).handleSchema((Context) LivePluginHelper.hostActivity.get(), Uri.parse(str));
}
}, 2000L);
} catch (JSONException e) {
e.printStackTrace();
}
}
}