导航菜单

页面标题

页面副标题

RummyCircle v11000.89 - KrakenUnityBridge.java 源代码

正在查看: RummyCircle v11000.89 应用的 KrakenUnityBridge.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.games24x7.dynamicrc.unitymodule.comm.bridge;

import android.annotation.SuppressLint;
import android.util.Log;
import com.games24x7.coregame.KrakenApplication;
import com.games24x7.coregame.common.CommonConfig;
import com.games24x7.coregame.common.communication.nativecomm.NativeCommunicationInterface;
import com.games24x7.coregame.common.utility.crashlytics.CrashlyticsUtility;
import com.games24x7.coregame.common.utility.log.Logger;
import com.games24x7.coregame.common.utility.runtimevars.RunTimeVarsUtility;
import com.games24x7.coregame.common.utility.zk.ZKUtil;
import com.games24x7.dynamicrc.unitymodule.comm.interfaces.IUnityCallback;
import com.games24x7.dynamicrc.unitymodule.comm.unitycomm.NativeUnityCommController;
import com.games24x7.dynamicrc.unitymodule.comm.unitycomm.SendDataToUnity;
import com.games24x7.dynamicrc.unitymodule.unity.interfaces.BaseUnityGameController;
import com.games24x7.pgeventbus.event.PGEvent;
import com.google.gson.d;
import com.unity3d.player.UnityPlayer;
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
import kotlin.text.o;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Dispatchers;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;

@Metadata
@SuppressLint({"StaticFieldLeak", "HardwareIds"})
public final class KrakenUnityBridge implements NativeCommunicationInterface.Bridge {

    @NotNull
    public static final KrakenUnityBridge INSTANCE;

    @NotNull
    private static final String TAG = "KrakenUnityBridge";
    private static volatile NativeCommunicationInterface.Controller communicationController = null;

    @NotNull
    private static final CoroutineScope coroutineScope;

    @NotNull
    private static final d gson;
    private static IUnityCallback iUnityCallback = null;
    private static volatile boolean isIUnityCallBackAlive = false;
    private static boolean isModulesReInitialized = false;
    private static BaseUnityGameController mBaseUnityGameController = null;

    @NotNull
    private static String threadMode = null;
    private static final boolean useIUnityCallback = true;
    private static ExecutorService workerPool;

    static {
        KrakenUnityBridge krakenUnityBridge = new KrakenUnityBridge();
        INSTANCE = krakenUnityBridge;
        isIUnityCallBackAlive = useIUnityCallback;
        coroutineScope = CoroutineScopeKt.CoroutineScope(Dispatchers.getIO());
        gson = new d();
        isModulesReInitialized = useIUnityCallback;
        threadMode = "main";
        krakenUnityBridge.setupNativeController();
        threadMode = RunTimeVarsUtility.INSTANCE.getStringRunTimeVar("threadMode", "main");
        Logger.d$default(Logger.INSTANCE, TAG, "THREAD MODE :: " + threadMode, false, 4, (Object) null);
        workerPool = Executors.newSingleThreadExecutor();
    }

    private KrakenUnityBridge() {
    }

    public static final void removeUnityCallback() {
        Logger.d$default(Logger.INSTANCE, TAG, ">>>>>>>>> removeUnityCallback >>>>>>", false, 4, (Object) null);
        iUnityCallback = null;
    }

    public static final void requestNative(@NotNull final String str, @NotNull final String str2, @NotNull final String str3) {
        Intrinsics.checkNotNullParameter(str, "eventInfo");
        Intrinsics.checkNotNullParameter(str2, "payload");
        Intrinsics.checkNotNullParameter(str3, "callbackInfo");
        Logger.e$default(Logger.INSTANCE, TAG, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> requestNative >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> :: \n EventInfo is :: " + str + " \n Callback is :: " + str3 + " \n :: payload is :: " + str2, false, 4, (Object) null);
        if (RunTimeVarsUtility.INSTANCE.getBooleanRunTimeVar("manageWebviewInDifferentThread", useIUnityCallback)) {
            try {
                if (!StringsKt.E(str, "UNITY_CREATE_WEBVIEW", false)) {
                    if (o.f(new JSONObject(str).optString("type"), "webview", useIUnityCallback)) {
                    }
                }
                ExecutorService executorService = workerPool;
                if (executorService != null) {
                    executorService.submit(new Runnable() {
                        @Override
                        public final void run() {
                            KrakenUnityBridge.requestNative$lambda$1(str, str2, str3);
                        }
                    });
                    return;
                }
                return;
            } catch (Exception e) {
                e.printStackTrace();
                Log.e(TAG, "requestNative :: Got exception :: " + Unit.a);
            }
        }
        NativeCommunicationInterface.Controller controller = communicationController;
        if (controller != null) {
            controller.requestNative(str, str2, str3);
        } else {
            Intrinsics.q("communicationController");
            throw null;
        }
    }

    public static final void requestNative$lambda$1(String str, String str2, String str3) {
        Intrinsics.checkNotNullParameter(str, "$eventInfo");
        Intrinsics.checkNotNullParameter(str2, "$payload");
        Intrinsics.checkNotNullParameter(str3, "$callbackInfo");
        Logger.e$default(Logger.INSTANCE, TAG, "Requesting Native in different Thread ::Communication in thread :: " + Thread.currentThread().getName(), false, 4, (Object) null);
        NativeCommunicationInterface.Controller controller = communicationController;
        if (controller != null) {
            controller.requestNative(str, str2, str3);
        } else {
            Intrinsics.q("communicationController");
            throw null;
        }
    }

    @NotNull
    public static final String requestNativeConfigSync() {
        Logger logger = Logger.INSTANCE;
        Logger.e$default(logger, TAG, "requestNativeConfigSync :: >>>>>>>>>>>>>>>>>>>>>>>>>>>> Sync Request from Unity >>>>>>>>>>>>>>>>>>>>>>>> \n", false, 4, (Object) null);
        ZKUtil zKUtil = ZKUtil.INSTANCE;
        String rcZkConfigStr = zKUtil.getRcZkConfigStr();
        String str = ((!(o.i(rcZkConfigStr) ^ useIUnityCallback) || Intrinsics.a(rcZkConfigStr, "{}")) && (rcZkConfigStr = zKUtil.getRcZKDataFromSP()) == null) ? "{}" : rcZkConfigStr;
        Logger.e$default(logger, TAG, "requestNativeConfigSync :: <<<<<<<<<<<<<<<<<<<<<<<<<<<< Sync Request Response To Unity <<<<<<<<<<<<<<<<<<<<<<<<<<<<  \n", false, 4, (Object) null);
        return str;
    }

    @NotNull
    public static final String requestNativeSync(@NotNull String str, @NotNull String str2, @NotNull String str3) {
        Intrinsics.checkNotNullParameter(str, "eventInfo");
        Intrinsics.checkNotNullParameter(str2, "payload");
        Intrinsics.checkNotNullParameter(str3, "callbackInfo");
        Logger logger = Logger.INSTANCE;
        Logger.e$default(logger, TAG, "requestNativeSync :: >>>>>>>>>>>>>>>>>>>>>>>>>>>> Sync Request from Unity >>>>>>>>>>>>>>>>>>>>>>>> \n EventInfo :: " + str + " \n CallbackInfo :: " + str3 + " \n Payload :: " + str2, false, 4, (Object) null);
        d dVar = gson;
        NativeCommunicationInterface.Controller controller = communicationController;
        if (controller == null) {
            Intrinsics.q("communicationController");
            throw null;
        }
        String str4 = dVar.s(controller.requestNativeSync(str, str2, str3)).toString();
        Logger.e$default(logger, TAG, "requestNativeSync :: <<<<<<<<<<<<<<<<<<<<<<<<<<<< Sync Request Response To Unity <<<<<<<<<<<<<<<<<<<<<<<<<<<<  \n Response is :: " + str4, false, 4, (Object) null);
        return str4;
    }

    private final void sendMessageToUnity(String str, String str2, String str3) {
        try {
            UnityPlayer.UnitySendMessage(str, str2, str3);
        } catch (Exception e) {
            Logger.d$default(Logger.INSTANCE, TAG, "Exception handling : \nInterfaceName =  " + str + "  : \nMethodName =  " + str2 + " \n : Exception is : " + e.getMessage(), false, 4, (Object) null);
        }
    }

    public static final void setUnityCallback(IUnityCallback iUnityCallback2) {
        Logger.d$default(Logger.INSTANCE, TAG, ">>>>>>>>> setUnityCallback >>>>>>> :: " + iUnityCallback2, false, 4, (Object) null);
        iUnityCallback = iUnityCallback2;
        if (iUnityCallback2 != null) {
            SendDataToUnity.INSTANCE.setCallback(iUnityCallback2);
        }
    }

    private final void setupNativeController() {
        communicationController = new NativeUnityCommController(this, KrakenApplication.Companion.getApplicationContext(), new CommonConfig("https://www.google.com"));
    }

    private final void storeEvent(String str, String str2) {
        BuildersKt.launch$default(coroutineScope, (CoroutineContext) null, (CoroutineStart) null, new KrakenUnityBridge$storeEvent$1(str, str2, null), 3, (Object) null);
    }

    @NotNull
    public final String getThreadMode() {
        return threadMode;
    }

    @NotNull
    public final BaseUnityGameController getUnityGameController() {
        BaseUnityGameController baseUnityGameController = mBaseUnityGameController;
        if (baseUnityGameController != null) {
            return baseUnityGameController;
        }
        Intrinsics.q("mBaseUnityGameController");
        throw null;
    }

    public final boolean isIUnityCallBackAlive() {
        return isIUnityCallBackAlive;
    }

    public final boolean isModulesReInitialized() {
        return isModulesReInitialized;
    }

    public void onCallbackFromNative(@NotNull PGEvent pGEvent) {
        Intrinsics.checkNotNullParameter(pGEvent, "pgEvent");
        Logger logger = Logger.INSTANCE;
        d dVar = gson;
        Logger.e$default(logger, TAG, "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Sending Response To Unity :: \n <<<<<<<< Result PgEvent is :: " + dVar.s(pGEvent), false, 4, (Object) null);
        if (!isIUnityCallBackAlive && RunTimeVarsUtility.INSTANCE.getBooleanRunTimeVar("iUnity_alive_check_required", false)) {
            Logger.e$default(logger, TAG, "IUnity Callback is null and iUnity Alive check is also marked true on Zk. Retuning from Here", false, 4, (Object) null);
            CrashlyticsUtility.logException$default(CrashlyticsUtility.INSTANCE, new Exception("IUnity Callback is null and iUnity Alive check is also marked true on Zk. So Not sending the message now on..."), (String) null, (HashMap) null, 6, (Object) null);
            return;
        }
        String str = threadMode;
        Unit unit = null;
        if (!Intrinsics.a(str, "threadpool")) {
            if (Intrinsics.a(str, "main")) {
                IUnityCallback iUnityCallback2 = iUnityCallback;
                if (iUnityCallback2 != null) {
                    BuildersKt.launch$default(coroutineScope, Dispatchers.getMain(), (CoroutineStart) null, new KrakenUnityBridge$onCallbackFromNative$2(iUnityCallback2, pGEvent, null), 2, (Object) null);
                    return;
                } else {
                    Logger.e$default(logger, TAG, "No unity callback registered", false, 4, (Object) null);
                    return;
                }
            }
            return;
        }
        if (iUnityCallback != null) {
            SendDataToUnity sendDataToUnity = SendDataToUnity.INSTANCE;
            String s = dVar.s(pGEvent);
            Intrinsics.checkNotNullExpressionValue(s, "gson.toJson(pgEvent)");
            sendDataToUnity.addToQueue(s);
            unit = Unit.a;
        }
        if (unit == null) {
            Logger.e$default(logger, TAG, "No iUnity callback registered", false, 4, (Object) null);
        }
    }

    public final void printLog() {
        Logger.e$default(Logger.INSTANCE, TAG, "printLog :: ", false, 4, (Object) null);
    }

    public final void reInitializeNativeModule() {
        if (!isModulesReInitialized) {
            Logger.e$default(Logger.INSTANCE, TAG, "reInitializeNativeModule :: Re-Initialize Modules for Unity", false, 4, (Object) null);
            isModulesReInitialized = useIUnityCallback;
            NativeCommunicationInterface.Controller controller = communicationController;
            if (controller == null) {
                Intrinsics.q("communicationController");
                throw null;
            }
            controller.unregisterEventBus();
            setupNativeController();
        }
        if (isIUnityCallBackAlive) {
            return;
        }
        Logger.e$default(Logger.INSTANCE, TAG, "reInitializeNativeModule :: IUnity Callback is Alive Now...", false, 4, (Object) null);
        isIUnityCallBackAlive = useIUnityCallback;
    }

    public final void setCurrentUnityGameController(@NotNull BaseUnityGameController baseUnityGameController) {
        Intrinsics.checkNotNullParameter(baseUnityGameController, "baseUnityGameController");
        mBaseUnityGameController = baseUnityGameController;
    }

    public final void setIUnityCallBackAlive(boolean z) {
        isIUnityCallBackAlive = z;
    }

    public final void setModulesReInitialized(boolean z) {
        isModulesReInitialized = z;
    }

    public final void setThreadMode(@NotNull String str) {
        Intrinsics.checkNotNullParameter(str, "<set-?>");
        threadMode = str;
    }

    public final void unregisterEventBus() {
        NativeCommunicationInterface.Controller controller = communicationController;
        if (controller != null) {
            controller.unregisterEventBus();
        } else {
            Intrinsics.q("communicationController");
            throw null;
        }
    }
}