1- using System . Collections . Generic ;
1+ using OpenCVForUnity . CoreModule ;
2+ using OpenCVForUnity . UnityUtils ;
3+ using System ;
4+ using System . Collections . Generic ;
5+ using System . Reflection ;
6+ using System . Text ;
27using UnityEngine ;
38using UnityEngine . SceneManagement ;
49using UnityEngine . UI ;
@@ -9,24 +14,42 @@ public class ShowSystemInfo : MonoBehaviour
914 {
1015 public Text systemInfoText ;
1116 public InputField systemInfoInputField ;
12- Dictionary < string , string > dicSystemInfo ;
17+
18+ private const string ASSET_NAME = "OpenCVForUnity" ;
1319
1420 // Use this for initialization
1521 void Start ( )
1622 {
17- dicSystemInfo = GetSystemInfo ( ) ;
1823
19- systemInfoText . text = systemInfoInputField . text = "### System Info ###" + "\n " ;
20- Debug . Log ( "### System Info ###" ) ;
24+ StringBuilder sb = new StringBuilder ( ) ;
25+ sb . Append ( "###### Build Info ######\n " ) ;
26+ IDictionary < string , string > buildInfo = GetBuildInfo ( ) ;
27+ foreach ( string key in buildInfo . Keys )
28+ {
29+ sb . Append ( key ) . Append ( " = " ) . Append ( buildInfo [ key ] ) . Append ( "\n " ) ;
30+ }
31+ sb . Append ( "\n " ) ;
32+
33+ #if UNITY_IOS || ( UNITY_ANDROID && UNITY_2018_3_OR_NEWER )
34+ sb . Append ( "###### Device Info ######\n " ) ;
35+ IDictionary < string , string > deviceInfo = GetDeviceInfo ( ) ;
36+ foreach ( string key in deviceInfo . Keys )
37+ {
38+ sb . Append ( key ) . Append ( " = " ) . Append ( deviceInfo [ key ] ) . Append ( "\n " ) ;
39+ }
40+ sb . Append ( "\n " ) ;
41+ #endif
2142
22- foreach ( string key in dicSystemInfo . Keys )
43+ sb . Append ( "###### System Info ######\n " ) ;
44+ IDictionary < string , string > systemInfo = GetSystemInfo ( ) ;
45+ foreach ( string key in systemInfo . Keys )
2346 {
24- systemInfoText . text = systemInfoInputField . text += key + " = " + dicSystemInfo [ key ] + "\n " ;
25- Debug . Log ( key + "=" + dicSystemInfo [ key ] ) ;
47+ sb . Append ( key ) . Append ( " = " ) . Append ( systemInfo [ key ] ) . Append ( "\n " ) ;
2648 }
49+ sb . Append ( "#########################\n " ) ;
2750
28- systemInfoText . text = systemInfoInputField . text += "###################" + " \n " ;
29- Debug . Log ( "###################" ) ;
51+ systemInfoText . text = systemInfoInputField . text = sb . ToString ( ) ;
52+ Debug . Log ( sb . ToString ( ) ) ;
3053 }
3154
3255 // Update is called once per frame
@@ -35,84 +58,119 @@ void Update()
3558
3659 }
3760
38- public Dictionary < string , string > GetSystemInfo ( )
61+ public Dictionary < string , string > GetBuildInfo ( )
3962 {
40- Dictionary < string , string > dicSystemInfo = new Dictionary < string , string > ( ) ;
63+ Dictionary < string , string > dict = new Dictionary < string , string > ( ) ;
4164
42- dicSystemInfo . Add ( "OpenCVForUnity version", OpenCVForUnity . CoreModule . Core . NATIVE_LIBRARY_NAME + " " + OpenCVForUnity . UnityUtils . Utils . getVersion ( ) + " (" + OpenCVForUnity . CoreModule . Core . VERSION + ")" ) ;
43- dicSystemInfo . Add ( "Build Unity version" , Application . unityVersion ) ;
65+ dict . Add ( ASSET_NAME + " version", Core . NATIVE_LIBRARY_NAME + " " + Utils . getVersion ( ) + " (" + Core . VERSION + ")" ) ;
66+ dict . Add ( "Build Unity version" , Application . unityVersion ) ;
4467
4568#if UNITY_EDITOR
46- dicSystemInfo . Add ( "Build target" , "Editor" ) ;
69+ dict . Add ( "Build target" , "Editor" ) ;
4770#elif UNITY_STANDALONE_WIN
48- dicSystemInfo . Add ( "Build target" , "Windows" ) ;
71+ dict . Add ( "Build target" , "Windows" ) ;
4972#elif UNITY_STANDALONE_OSX
50- dicSystemInfo . Add ( "Build target" , "Mac OSX" ) ;
73+ dict . Add ( "Build target" , "Mac OSX" ) ;
5174#elif UNITY_STANDALONE_LINUX
52- dicSystemInfo . Add ( "Build target" , "Linux" ) ;
75+ dict . Add ( "Build target" , "Linux" ) ;
5376#elif UNITY_ANDROID
54- dicSystemInfo . Add ( "Build target" , "Android" ) ;
77+ dict . Add ( "Build target" , "Android" ) ;
5578#elif UNITY_IOS
56- dicSystemInfo . Add ( "Build target" , "iOS" ) ;
79+ dict . Add ( "Build target" , "iOS" ) ;
5780#elif UNITY_WSA
58- dicSystemInfo . Add ( "Build target" , "WSA" ) ;
81+ dict . Add ( "Build target" , "WSA" ) ;
5982#elif UNITY_WEBGL
60- dicSystemInfo . Add ( "Build target" , "WebGL" ) ;
83+ dict . Add ( "Build target" , "WebGL" ) ;
84+ #elif PLATFORM_LUMIN
85+ dict . Add ( "Build target" , "LUMIN" ) ;
6186#else
62- dicSystemInfo . Add ( "Build target" , "" ) ;
87+ dict . Add ( "Build target" , "" ) ;
6388#endif
6489
6590#if ENABLE_MONO
66- dicSystemInfo . Add ( "Scripting backend" , "Mono" ) ;
91+ dict . Add ( "Scripting backend" , "Mono" ) ;
6792#elif ENABLE_IL2CPP
68- dicSystemInfo . Add ( "Scripting backend" , "IL2CPP" ) ;
93+ dict . Add ( "Scripting backend" , "IL2CPP" ) ;
6994#elif ENABLE_DOTNET
70- dicSystemInfo . Add ( "Scripting backend" , ".NET" ) ;
95+ dict . Add ( "Scripting backend" , ".NET" ) ;
96+ #else
97+ dict . Add ( "Scripting backend" , "" ) ;
98+ #endif
99+
100+ #if OPENCV_USE_UNSAFE_CODE
101+ dict . Add ( "Allow 'unsafe' Code" , "Enabled" ) ;
71102#else
72- dicSystemInfo . Add ( "Scripting backend " , "" ) ;
103+ dict . Add ( "Allow 'unsafe' Code " , "Disabled " ) ;
73104#endif
74105
75- dicSystemInfo . Add ( "operatingSystem" , SystemInfo . operatingSystem ) ;
106+ return dict ;
107+ }
108+
109+ public Dictionary < string , string > GetDeviceInfo ( )
110+ {
111+ Dictionary < string , string > dict = new Dictionary < string , string > ( ) ;
76112
77113#if UNITY_IOS
78- #if UNITY_5_4_OR_NEWER
79- dicSystemInfo . Add ( "iPhone.generation" , UnityEngine . iOS . Device . generation . ToString ( ) ) ;
80- #else
81- dicSystemInfo . Add ( "iPhone.generation" , UnityEngine . iPhone . generation . ToString ( ) ) ;
114+ dict . Add ( "iOS.Device.generation" , UnityEngine . iOS . Device . generation . ToString ( ) ) ;
115+ dict . Add ( "iOS.Device.systemVersion" , UnityEngine . iOS . Device . systemVersion . ToString ( ) ) ;
82116#endif
83- #else
84- dicSystemInfo . Add ( "iPhone.generation" , "" ) ;
117+ #if UNITY_IOS && UNITY_2018_1_OR_NEWER
118+ dict . Add ( "UserAuthorization.WebCam" , Application . HasUserAuthorization ( UserAuthorization . WebCam ) . ToString ( ) ) ;
119+ dict . Add ( "UserAuthorization.Microphone" , Application . HasUserAuthorization ( UserAuthorization . Microphone ) . ToString ( ) ) ;
85120#endif
86-
87- //dicSystemInfo.Add("deviceUniqueIdentifier", SystemInfo.deviceUniqueIdentifier);
88- dicSystemInfo . Add ( "deviceModel" , SystemInfo . deviceModel ) ;
89- dicSystemInfo . Add ( "deviceName" , SystemInfo . deviceName ) ;
90- dicSystemInfo . Add ( "deviceType" , SystemInfo . deviceType . ToString ( ) ) ;
91- dicSystemInfo . Add ( "graphicsDeviceName" , SystemInfo . graphicsDeviceName ) ;
92- dicSystemInfo . Add ( "graphicsDeviceVendor" , SystemInfo . graphicsDeviceVendor ) ;
93- dicSystemInfo . Add ( "processorType" , SystemInfo . processorType ) ;
94- dicSystemInfo . Add ( "graphicsMemorySize" , SystemInfo . graphicsMemorySize . ToString ( ) ) ;
95- dicSystemInfo . Add ( "systemMemorySize" , SystemInfo . systemMemorySize . ToString ( ) ) ;
96-
97- dicSystemInfo . Add ( "graphicsDeviceID" , SystemInfo . graphicsDeviceID . ToString ( ) ) ;
98- dicSystemInfo . Add ( "graphicsDeviceType" , SystemInfo . graphicsDeviceType . ToString ( ) ) ;
99- dicSystemInfo . Add ( "graphicsDeviceVendorID" , SystemInfo . graphicsDeviceVendorID . ToString ( ) ) ;
100- dicSystemInfo . Add ( "graphicsDeviceVersion" , SystemInfo . graphicsDeviceVersion ) ;
101- dicSystemInfo . Add ( "graphicsMultiThreaded" , SystemInfo . graphicsMultiThreaded . ToString ( ) ) ;
102- dicSystemInfo . Add ( "graphicsShaderLevel" , SystemInfo . graphicsShaderLevel . ToString ( ) ) ;
103-
104- #if UNITY_5_4_OR_NEWER
105- dicSystemInfo . Add ( "copyTextureSupport" , SystemInfo . copyTextureSupport . ToString ( ) ) ;
106- #else
107- dicSystemInfo . Add ( "copyTextureSupport" , "" ) ;
121+ #if UNITY_ANDROID && UNITY_2018_3_OR_NEWER
122+ dict . Add ( "Android.Permission.Camera" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . Camera ) . ToString ( ) ) ;
123+ dict . Add ( "Android.Permission.CoarseLocation" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . CoarseLocation ) . ToString ( ) ) ;
124+ dict . Add ( "Android.Permission.ExternalStorageRead" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . ExternalStorageRead ) . ToString ( ) ) ;
125+ dict . Add ( "Android.Permission.ExternalStorageWrite" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . ExternalStorageWrite ) . ToString ( ) ) ;
126+ dict . Add ( "Android.Permission.FineLocation" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . FineLocation ) . ToString ( ) ) ;
127+ dict . Add ( "Android.Permission.Microphone" , UnityEngine . Android . Permission . HasUserAuthorizedPermission ( UnityEngine . Android . Permission . Microphone ) . ToString ( ) ) ;
108128#endif
109129
110- dicSystemInfo . Add ( "supportsAccelerometer" , SystemInfo . supportsAccelerometer . ToString ( ) ) ;
111- dicSystemInfo . Add ( "supportsGyroscope" , SystemInfo . supportsGyroscope . ToString ( ) ) ;
112- dicSystemInfo . Add ( "supportsVibration" , SystemInfo . supportsVibration . ToString ( ) ) ;
113- dicSystemInfo . Add ( "supportsLocationService" , SystemInfo . supportsLocationService . ToString ( ) ) ;
130+ return dict ;
131+ }
132+
133+ /// SystemInfo Class Propertys
134+ public SortedDictionary < string , string > GetSystemInfo ( )
135+ {
136+ SortedDictionary < string , string > dict = new SortedDictionary < string , string > ( ) ;
137+
138+ Type type = typeof ( SystemInfo ) ;
139+ MemberInfo [ ] members = type . GetMembers (
140+ BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
141+
142+ foreach ( MemberInfo mb in members )
143+ {
144+ try
145+ {
146+ if ( mb . MemberType == MemberTypes . Property )
147+ {
148+ if ( mb . Name == "deviceUniqueIdentifier" )
149+ {
150+ dict . Add ( mb . Name , "xxxxxxxxxxxxxxxxxxxxxxxx" ) ;
151+ continue ;
152+ }
153+
154+ PropertyInfo pr = type . GetProperty ( mb . Name ) ;
155+
156+ if ( pr != null )
157+ {
158+ object resobj = pr . GetValue ( type , null ) ;
159+ dict . Add ( mb . Name , resobj . ToString ( ) ) ;
160+ }
161+ else
162+ {
163+ dict . Add ( mb . Name , "" ) ;
164+ }
165+ }
166+ }
167+ catch ( Exception e )
168+ {
169+ Debug . Log ( "Exception: " + e ) ;
170+ }
171+ }
114172
115- return dicSystemInfo ;
173+ return dict ;
116174 }
117175
118176 public void OnBackButtonClick ( )
0 commit comments