@@ -14,11 +14,11 @@ namespace Backtrace.Unity.Runtime.Native.Android
1414 /// </summary>
1515 internal class NativeClient : INativeClient
1616 {
17- [ DllImport ( "backtrace-crashpad " ) ]
18- private static extern bool InitializeCrashpad ( IntPtr submissionUrl , IntPtr databasePath , IntPtr handlerPath , IntPtr keys , IntPtr values ) ;
17+ [ DllImport ( "backtrace-native " ) ]
18+ private static extern bool Initialize ( IntPtr submissionUrl , IntPtr databasePath , IntPtr handlerPath , IntPtr keys , IntPtr values ) ;
1919
20- [ DllImport ( "backtrace-crashpad " ) ]
21- private static extern bool AddCrashpadAttribute ( IntPtr key , IntPtr value ) ;
20+ [ DllImport ( "backtrace-native " ) ]
21+ private static extern bool AddAttribute ( IntPtr key , IntPtr value ) ;
2222
2323 private readonly BacktraceConfiguration _configuration ;
2424 // Android native interface paths
@@ -29,15 +29,20 @@ internal class NativeClient : INativeClient
2929 /// <summary>
3030 /// Determine if android integration should be enabled
3131 /// </summary>
32- private bool _enabled = Application . platform == RuntimePlatform . Android ;
32+ private bool _enabled =
33+ #if UNITY_ANDROID && ! UNITY_EDITOR
34+ true ;
35+ #else
36+ false ;
37+ #endif
3338
3439 /// <summary>
3540 /// Anr watcher object
3641 /// </summary>
3742 private AndroidJavaObject _anrWatcher;
3843
3944 private bool _captureNativeCrashes = false ;
40- private bool _handlerANR = false ;
45+ private readonly bool _handlerANR = false ;
4146 public NativeClient ( string gameObjectName , BacktraceConfiguration configuration )
4247 {
4348 _configuration = configuration ;
@@ -48,10 +53,9 @@ public NativeClient(string gameObjectName, BacktraceConfiguration configuration)
4853#if UNITY_ANDROID
4954 _captureNativeCrashes = _configuration . CaptureNativeCrashes ;
5055 _handlerANR = _configuration . HandleANR ;
51- #endif
5256 HandleAnr ( gameObjectName , "OnAnrDetected" ) ;
5357 HandleNativeCrashes ( ) ;
54-
58+ #endif
5559
5660 }
5761 /// <summary>
@@ -87,12 +91,15 @@ private void HandleNativeCrashes()
8791 }
8892 // get default built-in Backtrace-Unity attributes
8993 var backtraceAttributes = new BacktraceAttributes ( null , null , true ) ;
94+ // add exception type to crashes handled by crashpad - all exception handled by crashpad
95+ // will be game crashes
96+ backtraceAttributes . Attributes [ "exception.type" ] = "Crash" ;
9097 var minidumpUrl = new BacktraceCredentials ( _configuration . GetValidServerUrl ( ) ) . GetMinidumpSubmissionUrl ( ) . ToString ( ) ;
9198
9299 // reassign to captureNativeCrashes
93100 // to avoid doing anything on crashpad binary, when crashpad
94101 // isn't available
95- _captureNativeCrashes = InitializeCrashpad (
102+ _captureNativeCrashes = Initialize (
96103 AndroidJNI . NewStringUTF ( minidumpUrl ) ,
97104 AndroidJNI . NewStringUTF ( _configuration . CrashpadDatabasePath ) ,
98105 AndroidJNI . NewStringUTF ( crashpadHandlerPath ) ,
@@ -179,7 +186,7 @@ public void SetAttribute(string key, string value)
179186 value = string . Empty ;
180187 }
181188
182- AddCrashpadAttribute (
189+ AddAttribute (
183190 AndroidJNI . NewStringUTF ( key ) ,
184191 AndroidJNI . NewStringUTF ( value ) ) ;
185192 }
0 commit comments