StandardSystemInformationService.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using SRF;
  6. using SRF.Service;
  7. using UnityEngine;
  8. using UnityEngine.SceneManagement;
  9. namespace SRDebugger.Services.Implementation
  10. {
  11. [Service(typeof(ISystemInformationService))]
  12. public class StandardSystemInformationService : ISystemInformationService
  13. {
  14. public StandardSystemInformationService()
  15. {
  16. this.CreateDefaultSet();
  17. }
  18. public IEnumerable<string> GetCategories()
  19. {
  20. return this._info.Keys;
  21. }
  22. public IList<InfoEntry> GetInfo(string category)
  23. {
  24. IList<InfoEntry> result;
  25. if (!this._info.TryGetValue(category, out result))
  26. {
  27. UnityEngine.Debug.LogError("[SystemInformationService] Category not found: {0}".Fmt(new object[]
  28. {
  29. category
  30. }));
  31. return new InfoEntry[0];
  32. }
  33. return result;
  34. }
  35. public void Add(InfoEntry info, string category = "Default")
  36. {
  37. IList<InfoEntry> list;
  38. if (!this._info.TryGetValue(category, out list))
  39. {
  40. list = new List<InfoEntry>();
  41. this._info.Add(category, list);
  42. }
  43. if (list.Any((InfoEntry p) => p.Title == info.Title))
  44. {
  45. throw new ArgumentException("An InfoEntry object with the same title already exists in that category.", "info");
  46. }
  47. list.Add(info);
  48. }
  49. public Dictionary<string, Dictionary<string, object>> CreateReport(bool includePrivate = false)
  50. {
  51. Dictionary<string, Dictionary<string, object>> dictionary = new Dictionary<string, Dictionary<string, object>>();
  52. foreach (KeyValuePair<string, IList<InfoEntry>> keyValuePair in this._info)
  53. {
  54. Dictionary<string, object> dictionary2 = new Dictionary<string, object>();
  55. foreach (InfoEntry infoEntry in keyValuePair.Value)
  56. {
  57. if (!infoEntry.IsPrivate || includePrivate)
  58. {
  59. dictionary2.Add(infoEntry.Title, infoEntry.Value);
  60. }
  61. }
  62. dictionary.Add(keyValuePair.Key, dictionary2);
  63. }
  64. return dictionary;
  65. }
  66. private void CreateDefaultSet()
  67. {
  68. this._info.Add("System", new InfoEntry[]
  69. {
  70. InfoEntry.Create("Operating System", SystemInfo.operatingSystem, false),
  71. InfoEntry.Create("Device Name", SystemInfo.deviceName, true),
  72. InfoEntry.Create("Device Type", SystemInfo.deviceType, false),
  73. InfoEntry.Create("Device Model", SystemInfo.deviceModel, false),
  74. InfoEntry.Create("CPU Type", SystemInfo.processorType, false),
  75. InfoEntry.Create("CPU Count", SystemInfo.processorCount, false),
  76. InfoEntry.Create("System Memory", SRFileUtil.GetBytesReadable((long)SystemInfo.systemMemorySize * 1024L * 1024L), false)
  77. });
  78. this._info.Add("Unity", new InfoEntry[]
  79. {
  80. InfoEntry.Create("Version", Application.unityVersion, false),
  81. InfoEntry.Create("Debug", UnityEngine.Debug.isDebugBuild, false),
  82. InfoEntry.Create("Unity Pro", Application.HasProLicense(), false),
  83. InfoEntry.Create("Genuine", "{0} ({1})".Fmt(new object[]
  84. {
  85. (!Application.genuine) ? "No" : "Yes",
  86. (!Application.genuineCheckAvailable) ? "Untrusted" : "Trusted"
  87. }), false),
  88. InfoEntry.Create("System Language", Application.systemLanguage, false),
  89. InfoEntry.Create("Platform", Application.platform, false),
  90. InfoEntry.Create("IL2CPP", "No", false),
  91. InfoEntry.Create("SRDebugger Version", "1.6.2", false)
  92. });
  93. Dictionary<string, IList<InfoEntry>> info = this._info;
  94. string key = "Display";
  95. InfoEntry[] array = new InfoEntry[4];
  96. array[0] = InfoEntry.Create("Resolution", () => Screen.width + "x" + Screen.height, false);
  97. array[1] = InfoEntry.Create("DPI", () => Screen.dpi, false);
  98. array[2] = InfoEntry.Create("Fullscreen", () => Screen.fullScreen, false);
  99. array[3] = InfoEntry.Create("Orientation", () => Screen.orientation, false);
  100. info.Add(key, array);
  101. Dictionary<string, IList<InfoEntry>> info2 = this._info;
  102. string key2 = "Runtime";
  103. InfoEntry[] array2 = new InfoEntry[4];
  104. array2[0] = InfoEntry.Create("Play Time", () => Time.unscaledTime, false);
  105. array2[1] = InfoEntry.Create("Level Play Time", () => Time.timeSinceLevelLoad, false);
  106. array2[2] = InfoEntry.Create("Current Level", delegate()
  107. {
  108. Scene activeScene = SceneManager.GetActiveScene();
  109. return "{0} (Index: {1})".Fmt(new object[]
  110. {
  111. activeScene.name,
  112. activeScene.buildIndex
  113. });
  114. }, false);
  115. array2[3] = InfoEntry.Create("Quality Level", () => string.Concat(new object[]
  116. {
  117. QualitySettings.names[QualitySettings.GetQualityLevel()],
  118. " (",
  119. QualitySettings.GetQualityLevel(),
  120. ")"
  121. }), false);
  122. info2.Add(key2, array2);
  123. TextAsset textAsset = (TextAsset)Resources.Load("UnityCloudBuildManifest.json");
  124. Dictionary<string, object> dictionary = (!(textAsset != null)) ? null : (Json.Deserialize(textAsset.text) as Dictionary<string, object>);
  125. if (dictionary != null)
  126. {
  127. List<InfoEntry> list = new List<InfoEntry>(dictionary.Count);
  128. foreach (KeyValuePair<string, object> keyValuePair in dictionary)
  129. {
  130. if (keyValuePair.Value != null)
  131. {
  132. string value = keyValuePair.Value.ToString();
  133. list.Add(InfoEntry.Create(StandardSystemInformationService.GetCloudManifestPrettyName(keyValuePair.Key), value, false));
  134. }
  135. }
  136. this._info.Add("Build", list);
  137. }
  138. this._info.Add("Features", new InfoEntry[]
  139. {
  140. InfoEntry.Create("Location", SystemInfo.supportsLocationService, false),
  141. InfoEntry.Create("Accelerometer", SystemInfo.supportsAccelerometer, false),
  142. InfoEntry.Create("Gyroscope", SystemInfo.supportsGyroscope, false),
  143. InfoEntry.Create("Vibration", SystemInfo.supportsVibration, false)
  144. });
  145. this._info.Add("Graphics", new InfoEntry[]
  146. {
  147. InfoEntry.Create("Device Name", SystemInfo.graphicsDeviceName, false),
  148. InfoEntry.Create("Device Vendor", SystemInfo.graphicsDeviceVendor, false),
  149. InfoEntry.Create("Device Version", SystemInfo.graphicsDeviceVersion, false),
  150. InfoEntry.Create("Max Tex Size", SystemInfo.maxTextureSize, false),
  151. InfoEntry.Create("NPOT Support", SystemInfo.npotSupport, false),
  152. InfoEntry.Create("Render Textures", "{0} ({1})".Fmt(new object[]
  153. {
  154. (!SystemInfo.supportsRenderTextures) ? "No" : "Yes",
  155. SystemInfo.supportedRenderTargetCount
  156. }), false),
  157. InfoEntry.Create("3D Textures", SystemInfo.supports3DTextures, false),
  158. InfoEntry.Create("Compute Shaders", SystemInfo.supportsComputeShaders, false),
  159. InfoEntry.Create("Image Effects", SystemInfo.supportsImageEffects, false),
  160. InfoEntry.Create("Cubemaps", SystemInfo.supportsRenderToCubemap, false),
  161. InfoEntry.Create("Shadows", SystemInfo.supportsShadows, false),
  162. InfoEntry.Create("Stencil", SystemInfo.supportsStencil, false),
  163. InfoEntry.Create("Sparse Textures", SystemInfo.supportsSparseTextures, false)
  164. });
  165. }
  166. private static string GetCloudManifestPrettyName(string name)
  167. {
  168. if (name != null)
  169. {
  170. if (name == "scmCommitId")
  171. {
  172. return "Commit";
  173. }
  174. if (name == "scmBranch")
  175. {
  176. return "Branch";
  177. }
  178. if (name == "cloudBuildTargetName")
  179. {
  180. return "Build Target";
  181. }
  182. if (name == "buildStartTime")
  183. {
  184. return "Build Date";
  185. }
  186. }
  187. return name.Substring(0, 1).ToUpper() + name.Substring(1);
  188. }
  189. private readonly Dictionary<string, IList<InfoEntry>> _info = new Dictionary<string, IList<InfoEntry>>();
  190. [CompilerGenerated]
  191. private static Func<object> _003C_003Ef__mg_0024cache0;
  192. [CompilerGenerated]
  193. private static Func<object> _003C_003Ef__mg_0024cache1;
  194. [CompilerGenerated]
  195. private static Func<object> _003C_003Ef__mg_0024cache2;
  196. [CompilerGenerated]
  197. private static Func<object> _003C_003Ef__mg_0024cache3;
  198. [CompilerGenerated]
  199. private static Func<object> _003C_003Ef__mg_0024cache4;
  200. }
  201. }