using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Rokid.MRC
{
    public class SDKManager : Singleton<SDKManager>
    {
        public const string MRC_PLUGING = "com.rokid.mrcplugin.glass.MRCPlugin";
        public const string GET_WIFI_NAME = "getWifiName";
        public const string OPEN_WIFI = "openWifi";

        public const string KEEP_Screen_ON = "keepScreenOn";
        public const string REMOVE_Screen_ON = "removeScreenOn";

        public const string Get_Connected_Device_IP = "getConnectedDeviceIp";

        public const string Get_Device_Name = "getDeviceName";

#if UNITY_ANDROID && !UNITY_EDITOR

        private AndroidJavaClass androidJava;

        public override void Init()
        {
            base.Init();
            androidJava = new AndroidJavaClass(MRC_PLUGING);
        }

        public string GetCurConnectedWifiName()
        {
            string wifiName = androidJava != null ? androidJava.CallStatic<string>(GET_WIFI_NAME) : "WifiName";
            return wifiName;
        }

        public void OpenWifiSetting()
        {
            androidJava?.CallStatic(OPEN_WIFI);
        }

        public void KeepScreenOn()
        {
            androidJava?.CallStatic(KEEP_Screen_ON);
        }

        public void RemoveScreenOn()
        {
            androidJava?.CallStatic(REMOVE_Screen_ON);
        }

        public string GetConnectedDeviceIP()
        {
            string ip = androidJava != null ? androidJava.CallStatic<string>(Get_Connected_Device_IP) : "192.168.0.1";
            return ip;
        }

        public string GetDeviceName()
        {
            return androidJava != null ? androidJava.CallStatic<string>(Get_Device_Name) : "DeviceName";
        }
#else

        public void KeepScreenOn()
        {
            Debug.Log("SDKManager KeepScreenOn");
        }

        public void RemoveScreenOn()
        {
            Debug.Log("SDKManager RemoveScreenOn");
        }

        public string GetConnectedDeviceIP()
        {
            return "127.0.0.1";
        }

        public override void Init()
        {
            base.Init();
            Debug.Log("SDKManager Init");
        }

        public string GetCurConnectedWifiName()
        {
            return "";
        }

        public void OpenWifiSetting()
        {
            Debug.Log("SDKManager OpenWiFiSetting");
        }

        public string GetDeviceName()
        {
            return SystemInfo.deviceModel;
        }

#endif
    }
}