@@ -14,10 +14,6 @@ namespace MADE.Diagnostics
1414 /// </summary>
1515 public class AppDiagnostics : IAppDiagnostics
1616 {
17- #if __ANDROID__
18- private UncaughtExceptionHandler javaExceptionHandler ;
19- #endif
20-
2117 /// <summary>
2218 /// Initializes a new instance of the <see cref="AppDiagnostics"/> class.
2319 /// </summary>
@@ -63,17 +59,9 @@ public async Task StartRecordingDiagnosticsAsync()
6359
6460#if WINDOWS_UWP
6561 Windows . UI . Xaml . Application . Current . UnhandledException += this . OnAppUnhandledException ;
66- #elif NETSTANDARD2_0 || __ANDROID__ || __IOS__
62+ #elif NETSTANDARD2_0
6763 AppDomain . CurrentDomain . UnhandledException += this . OnAppUnhandledException ;
6864#endif
69-
70- #if __ANDROID__
71- Android . Runtime . AndroidEnvironment . UnhandledExceptionRaiser += this . OnAndroidAppUnhandledException ;
72-
73- this . javaExceptionHandler = new UncaughtExceptionHandler ( this . OnJavaUncaughtException ) ;
74- Java . Lang . Thread . DefaultUncaughtExceptionHandler = this . javaExceptionHandler ;
75- #endif
76-
7765 TaskScheduler . UnobservedTaskException += this . OnTaskUnobservedException ;
7866
7967 await Task . CompletedTask ;
@@ -91,14 +79,9 @@ public void StopRecordingDiagnostics()
9179
9280#if WINDOWS_UWP
9381 Windows . UI . Xaml . Application . Current . UnhandledException -= this . OnAppUnhandledException ;
94- #elif NETSTANDARD2_0 || __ANDROID__ || __IOS__
82+ #elif NETSTANDARD2_0
9583 AppDomain . CurrentDomain . UnhandledException -= this . OnAppUnhandledException ;
9684#endif
97-
98- #if __ANDROID__
99- Android . Runtime . AndroidEnvironment . UnhandledExceptionRaiser -= this . OnAndroidAppUnhandledException ;
100- #endif
101-
10285 TaskScheduler . UnobservedTaskException -= this . OnTaskUnobservedException ;
10386
10487 this . IsRecordingDiagnostics = false ;
@@ -128,7 +111,7 @@ private void OnAppUnhandledException(object sender, Windows.UI.Xaml.UnhandledExc
128111 ? $ "An unhandled exception was thrown. Error: { args . Exception } "
129112 : "An unhandled exception was thrown. Error: No exception information was available." ) ;
130113 }
131- #elif NETSTANDARD2_0 || __ANDROID__ || __IOS__
114+ #elif NETSTANDARD2_0
132115 private void OnAppUnhandledException ( object sender , UnhandledExceptionEventArgs args )
133116 {
134117 if ( args . IsTerminating )
@@ -149,29 +132,5 @@ private void OnAppUnhandledException(object sender, UnhandledExceptionEventArgs
149132 this . ExceptionObserved ? . Invoke ( this , new ExceptionObservedEventArgs ( correlationId , ex ) ) ;
150133 }
151134#endif
152-
153- #if __ANDROID__
154- private void OnAndroidAppUnhandledException ( object sender , Android . Runtime . RaiseThrowableEventArgs args )
155- {
156- args . Handled = true ;
157-
158- var correlationId = Guid . NewGuid ( ) ;
159-
160- this . EventLogger . WriteCritical ( $ "An unhandled exception was thrown. Correlation ID: { correlationId } . Error: { args . Exception } .") ;
161- this . ExceptionObserved ? . Invoke ( this , new ExceptionObservedEventArgs ( correlationId , args . Exception ) ) ;
162- }
163-
164- private void OnJavaUncaughtException ( Exception ex )
165- {
166- var correlationId = Guid . NewGuid ( ) ;
167-
168- this . EventLogger . WriteCritical (
169- ex != null
170- ? $ "An unhandled exception was thrown. Correlation ID: { correlationId } . Error: { ex } ."
171- : $ "An unhandled exception was thrown. Correlation ID: { correlationId } . Error: No exception information was available.") ;
172-
173- this . ExceptionObserved ? . Invoke ( this , new ExceptionObservedEventArgs ( correlationId , ex ) ) ;
174- }
175- #endif
176135 }
177136}
0 commit comments