SDKManager.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Rokid.MRC
  5. {
  6. public class SDKManager : Singleton<SDKManager>
  7. {
  8. public const string MRC_PLUGING = "com.rokid.mrcplugin.glass.MRCPlugin";
  9. public const string GET_WIFI_NAME = "getWifiName";
  10. public const string OPEN_WIFI = "openWifi";
  11. public const string KEEP_Screen_ON = "keepScreenOn";
  12. public const string REMOVE_Screen_ON = "removeScreenOn";
  13. public const string Get_Connected_Device_IP = "getConnectedDeviceIp";
  14. public const string Get_Device_Name = "getDeviceName";
  15. #if UNITY_ANDROID && !UNITY_EDITOR
  16. private AndroidJavaClass androidJava;
  17. public override void Init()
  18. {
  19. base.Init();
  20. androidJava = new AndroidJavaClass(MRC_PLUGING);
  21. }
  22. public string GetCurConnectedWifiName()
  23. {
  24. string wifiName = androidJava != null ? androidJava.CallStatic<string>(GET_WIFI_NAME) : "WifiName";
  25. return wifiName;
  26. }
  27. public void OpenWifiSetting()
  28. {
  29. androidJava?.CallStatic(OPEN_WIFI);
  30. }
  31. public void KeepScreenOn()
  32. {
  33. androidJava?.CallStatic(KEEP_Screen_ON);
  34. }
  35. public void RemoveScreenOn()
  36. {
  37. androidJava?.CallStatic(REMOVE_Screen_ON);
  38. }
  39. public string GetConnectedDeviceIP()
  40. {
  41. string ip = androidJava != null ? androidJava.CallStatic<string>(Get_Connected_Device_IP) : "192.168.0.1";
  42. return ip;
  43. }
  44. public string GetDeviceName()
  45. {
  46. return androidJava != null ? androidJava.CallStatic<string>(Get_Device_Name) : "DeviceName";
  47. }
  48. #else
  49. public void KeepScreenOn()
  50. {
  51. Debug.Log("SDKManager KeepScreenOn");
  52. }
  53. public void RemoveScreenOn()
  54. {
  55. Debug.Log("SDKManager RemoveScreenOn");
  56. }
  57. public string GetConnectedDeviceIP()
  58. {
  59. return "127.0.0.1";
  60. }
  61. public override void Init()
  62. {
  63. base.Init();
  64. Debug.Log("SDKManager Init");
  65. }
  66. public string GetCurConnectedWifiName()
  67. {
  68. return "";
  69. }
  70. public void OpenWifiSetting()
  71. {
  72. Debug.Log("SDKManager OpenWiFiSetting");
  73. }
  74. public string GetDeviceName()
  75. {
  76. return SystemInfo.deviceModel;
  77. }
  78. #endif
  79. }
  80. }