liuxue
2021-07-29 7e2df20ccc7cdfb528d309369460a4f3d66afdf1
SdkProject/library/src/main/java/com/secondworld/sdk/command/CmdInit.java
@@ -3,7 +3,8 @@
import android.app.AlertDialog;
import com.secondworld.sdk.GameApp;
import com.secondworld.sdk.GameAppProxy;
import com.secondworld.sdk.PlatformDiff;
import com.secondworld.sdk.UnityMsgHandler;
import com.secondworld.sdk.utils.CodeA2U;
import com.secondworld.sdk.utils.CodeU2A;
@@ -11,6 +12,7 @@
import com.secondworld.sdk.utils.LogUtil;
import com.unity3d.player.UnityPlayer;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
@@ -28,7 +30,9 @@
    }
    @Override
    public void process(JSONObject json) {
    public void process(JSONObject json) throws JSONException {
        GameAppProxy.appId = json.getString("appID");
        long size = DeviceUtil.getTotalRAMSize() / 1024 / 1024;
        LogUtil.debug("CmdInit", "内存:" + size + " mb");
        if (size < 1024) {
@@ -38,25 +42,24 @@
            _builder.setCancelable(false);
            _builder.setMessage("您的设备运行内存不满足要求,无法正常运行游戏");
            _builder.setPositiveButton("确定", (dialogInterface, i) -> {
                GameApp.I.appExit();
                GameAppProxy.appExit();
            });
            _builder.show();
            return;
        }
        //发送设备信息
        Map<String, Object> _msgStruct = new HashMap<>();
        _msgStruct.put("code", CodeA2U.DeviceInfo);
        _msgStruct.put("userAgent", System.getProperty("http.agent"));
        _msgStruct.put("mac", DeviceUtil.getLocalMac());
        _msgStruct.put("imei", "");
        _msgStruct.put("android_id", DeviceUtil.getAndroidId());
        _msgStruct.put("unique_id", DeviceUtil.getUniqueID());
        _msgStruct.put("memoryTotal", size);
        UnityMsgHandler.sendMessageToUnity(_msgStruct);
        UnityMsgHandler.sendMessageToUnity(CodeA2U.DeviceInfo,_msgStruct);
        //通知sdk初始化完成
        _msgStruct.clear();
        _msgStruct.put("code", CodeA2U.SdkInitComplete);
        UnityMsgHandler.sendMessageToUnity(_msgStruct);
        _msgStruct.put("channelPlatform", PlatformDiff.I.platformName());
        UnityMsgHandler.sendMessageToUnity(CodeA2U.SdkInitComplete,_msgStruct);
        LogUtil.debug("CmdInit", "Sdk初始化完成");
    }
}