PXR_SystemPlugin.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /*******************************************************************************
  2. Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
  3. NOTICE:All information contained herein is, and remains the property of
  4. PICO Technology Co., Ltd. The intellectual and technical concepts
  5. contained herein are proprietary to PICO Technology Co., Ltd. and may be
  6. covered by patents, patents in process, and are protected by trade secret or
  7. copyright law. Dissemination of this information or reproduction of this
  8. material is strictly forbidden unless prior written permission is obtained from
  9. PICO Technology Co., Ltd.
  10. *******************************************************************************/
  11. #if (UNITY_ANDROID && !UNITY_EDITOR)
  12. #define PICO_PLATFORM
  13. #endif
  14. using System;
  15. using UnityEngine;
  16. namespace Unity.XR.PXR
  17. {
  18. public partial class PXR_EnterprisePlugin
  19. {
  20. #if PICO_PLATFORM
  21. private static AndroidJavaClass sysActivity;
  22. private static AndroidJavaClass batteryReceiver;
  23. private static AndroidJavaClass audioReceiver;
  24. #endif
  25. public static void UPxr_InitSystem()
  26. {
  27. #if PICO_PLATFORM
  28. sysActivity = new AndroidJavaClass("com.psmart.aosoperation.SysActivity");
  29. batteryReceiver = new AndroidJavaClass("com.psmart.aosoperation.BatteryReceiver");
  30. audioReceiver = new AndroidJavaClass("com.psmart.aosoperation.AudioReceiver");
  31. #endif
  32. }
  33. public static bool UPxr_StopBatteryReceiver()
  34. {
  35. #if PICO_PLATFORM
  36. try
  37. {
  38. batteryReceiver.CallStatic("pxr_StopReceiver", currentActivity);
  39. return true;
  40. }
  41. catch (Exception e)
  42. {
  43. PLog.e(TAG, "UPxr_StopBatteryReceiver Error :" + e.ToString());
  44. return false;
  45. }
  46. #else
  47. return true;
  48. #endif
  49. }
  50. public static bool UPxr_StartBatteryReceiver(string objName)
  51. {
  52. #if PICO_PLATFORM
  53. try
  54. {
  55. batteryReceiver.CallStatic("pxr_StartReceiver", currentActivity, objName);
  56. return true;
  57. }
  58. catch (Exception e)
  59. {
  60. PLog.e(TAG, "UPxr_StartBatteryReceiver Error :" + e.ToString());
  61. return false;
  62. }
  63. #else
  64. return true;
  65. #endif
  66. }
  67. public static bool UPxr_InitAudioDevice()
  68. {
  69. #if PICO_PLATFORM
  70. try
  71. {
  72. if (sysActivity != null)
  73. {
  74. sysActivity.CallStatic("pxr_InitAudioDevice", currentActivity);
  75. return true;
  76. }
  77. else
  78. return false;
  79. }
  80. catch (Exception e)
  81. {
  82. PLog.e(TAG, "UPxr_InitAudioDevice Error :" + e.ToString());
  83. return false;
  84. }
  85. #else
  86. return true;
  87. #endif
  88. }
  89. public static bool UPxr_SetBrightness(int brightness)
  90. {
  91. #if PICO_PLATFORM
  92. try
  93. {
  94. sysActivity.CallStatic("pxr_SetScreen_Brightness", brightness, currentActivity);
  95. return true;
  96. }
  97. catch (Exception e)
  98. {
  99. PLog.e(TAG, "UPxr_SetBrightness Error :" + e.ToString());
  100. return false;
  101. }
  102. #else
  103. return true;
  104. #endif
  105. }
  106. public static int UPxr_GetCurrentBrightness()
  107. {
  108. #if PICO_PLATFORM
  109. int currentlight = 0;
  110. try
  111. {
  112. currentlight = sysActivity.CallStatic<int>("pxr_GetScreen_Brightness", currentActivity);
  113. }
  114. catch (Exception e)
  115. {
  116. PLog.e(TAG, "UPxr_GetCurrentBrightness Error :" + e.ToString());
  117. }
  118. return currentlight;
  119. #else
  120. return 0;
  121. #endif
  122. }
  123. public static int[] UPxr_GetScreenBrightnessLevel()
  124. {
  125. int[] currentlight = { 0 };
  126. #if PICO_PLATFORM
  127. try
  128. {
  129. currentlight = sysActivity.CallStatic<int[]>("getScreenBrightnessLevel");
  130. }
  131. catch (Exception e)
  132. {
  133. PLog.e(TAG, "UPxr_GetScreenBrightnessLevel Error :" + e.ToString());
  134. }
  135. #endif
  136. return currentlight;
  137. }
  138. public static void UPxr_SetScreenBrightnessLevel(int vrBrightness, int level)
  139. {
  140. #if PICO_PLATFORM
  141. try
  142. {
  143. sysActivity.CallStatic("setScreenBrightnessLevel",vrBrightness,level);
  144. }
  145. catch (Exception e)
  146. {
  147. PLog.e(TAG, "UPxr_SetScreenBrightnessLevel Error :" + e.ToString());
  148. }
  149. #endif
  150. }
  151. public static bool UPxr_StartAudioReceiver(string startreceivre)
  152. {
  153. #if PICO_PLATFORM
  154. try
  155. {
  156. audioReceiver.CallStatic("pxr_StartReceiver", currentActivity, startreceivre);
  157. return true;
  158. }
  159. catch (Exception e)
  160. {
  161. PLog.e(TAG, "UPxr_StartAudioReceiver Error :" + e.ToString());
  162. return false;
  163. }
  164. #else
  165. return true;
  166. #endif
  167. }
  168. public static bool UPxr_StopAudioReceiver()
  169. {
  170. #if PICO_PLATFORM
  171. try
  172. {
  173. audioReceiver.CallStatic("pxr_StopReceiver", currentActivity);
  174. return true;
  175. }
  176. catch (Exception e)
  177. {
  178. PLog.e(TAG, "UPxr_StopAudioReceiver Error :" + e.ToString());
  179. return false;
  180. }
  181. #else
  182. return true;
  183. #endif
  184. }
  185. public static int UPxr_GetMaxVolumeNumber()
  186. {
  187. #if PICO_PLATFORM
  188. int maxvolm = 0;
  189. try
  190. {
  191. maxvolm = sysActivity.CallStatic<int>("pxr_GetMaxAudionumber");
  192. }
  193. catch (Exception e)
  194. {
  195. PLog.e(TAG,"UPxr_GetMaxVolumeNumber Error :" + e.ToString());
  196. }
  197. return maxvolm;
  198. #else
  199. return 0;
  200. #endif
  201. }
  202. public static int UPxr_GetCurrentVolumeNumber()
  203. {
  204. #if PICO_PLATFORM
  205. int currentvolm = 0;
  206. try
  207. {
  208. currentvolm = sysActivity.CallStatic<int>("pxr_GetAudionumber");
  209. }
  210. catch (Exception e)
  211. {
  212. PLog.e(TAG, "UPxr_GetCurrentVolumeNumber Error :" + e.ToString());
  213. }
  214. return currentvolm;
  215. #else
  216. return 0;
  217. #endif
  218. }
  219. public static bool UPxr_VolumeUp()
  220. {
  221. #if PICO_PLATFORM
  222. try
  223. {
  224. sysActivity.CallStatic("pxr_UpAudio");
  225. return true;
  226. }
  227. catch (Exception e)
  228. {
  229. PLog.e(TAG, "UPxr_VolumeUp Error :" + e.ToString());
  230. return false;
  231. }
  232. #else
  233. return true;
  234. #endif
  235. }
  236. public static bool UPxr_VolumeDown()
  237. {
  238. #if PICO_PLATFORM
  239. try
  240. {
  241. sysActivity.CallStatic("pxr_DownAudio");
  242. return true;
  243. }
  244. catch (Exception e)
  245. {
  246. PLog.e(TAG, "UPxr_VolumeDown Error :" + e.ToString());
  247. return false;
  248. }
  249. #else
  250. return true;
  251. #endif
  252. }
  253. public static bool UPxr_SetVolumeNum(int volume)
  254. {
  255. #if PICO_PLATFORM
  256. try
  257. {
  258. sysActivity.CallStatic("pxr_ChangeAudio", volume);
  259. return true;
  260. }
  261. catch (Exception e)
  262. {
  263. PLog.e(TAG, "UPxr_SetVolumeNum Error :" + e.ToString());
  264. return false;
  265. }
  266. #else
  267. return true;
  268. #endif
  269. }
  270. }
  271. }
粤ICP备19079148号