|
@@ -0,0 +1,58 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright @ 2018-present 8x8, Inc.
|
|
3
|
+ * Copyright @ 2017-2018 Atlassian Pty Ltd
|
|
4
|
+ *
|
|
5
|
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+ * you may not use this file except in compliance with the License.
|
|
7
|
+ * You may obtain a copy of the License at
|
|
8
|
+ *
|
|
9
|
+ * http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+ *
|
|
11
|
+ * Unless required by applicable law or agreed to in writing, software
|
|
12
|
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+ * See the License for the specific language governing permissions and
|
|
15
|
+ * limitations under the License.
|
|
16
|
+ */
|
|
17
|
+
|
|
18
|
+package org.jitsi.meet.sdk;
|
|
19
|
+
|
|
20
|
+import android.util.Log;
|
|
21
|
+
|
|
22
|
+class JitsiMeetUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
|
|
23
|
+ private final Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler;
|
|
24
|
+
|
|
25
|
+ public static void register() {
|
|
26
|
+ Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
|
27
|
+
|
|
28
|
+ JitsiMeetUncaughtExceptionHandler uncaughtExceptionHandler
|
|
29
|
+ = new JitsiMeetUncaughtExceptionHandler(defaultUncaughtExceptionHandler);
|
|
30
|
+
|
|
31
|
+ Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler);
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ private JitsiMeetUncaughtExceptionHandler(Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler) {
|
|
35
|
+ this.defaultUncaughtExceptionHandler = defaultUncaughtExceptionHandler;
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ @Override
|
|
39
|
+ public void uncaughtException(Thread t, Throwable e) {
|
|
40
|
+ Log.e(this.getClass().getSimpleName(), "FATAL ERROR", e);
|
|
41
|
+
|
|
42
|
+ // Terminate all conferences
|
|
43
|
+ for (BaseReactView view: BaseReactView.getViews()) {
|
|
44
|
+ if (view instanceof JitsiMeetView) {
|
|
45
|
+ ((JitsiMeetView) view).leave();
|
|
46
|
+ }
|
|
47
|
+ }
|
|
48
|
+
|
|
49
|
+ // Abort all ConnectionService ongoing calls
|
|
50
|
+ if (AudioModeModule.useConnectionService()) {
|
|
51
|
+ ConnectionService.abortConnections();
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ if (defaultUncaughtExceptionHandler != null) {
|
|
55
|
+ defaultUncaughtExceptionHandler.uncaughtException(t, e);
|
|
56
|
+ }
|
|
57
|
+ }
|
|
58
|
+}
|