Преглед на файлове

android: handle ConnectionService failures more resiliently

Fallback to the non-ConnectionService case for any error. Also, handle errors
when registering the phone account; Pixel C devices throw UnsupportedException.
master
Saúl Ibarra Corretgé преди 5 години
родител
ревизия
fddaf7c8a8
променени са 2 файла, в които са добавени 25 реда и са изтрити 21 реда
  1. 15
    11
      android/sdk/src/main/java/org/jitsi/meet/sdk/RNConnectionService.java
  2. 10
    10
      react/features/mobile/call-integration/middleware.js

+ 15
- 11
android/sdk/src/main/java/org/jitsi/meet/sdk/RNConnectionService.java Целия файл

@@ -89,9 +89,17 @@ class RNConnectionService extends ReactContextBaseJavaModule {
89 89
         ReactApplicationContext ctx = getReactApplicationContext();
90 90
 
91 91
         Uri address = Uri.fromParts(PhoneAccount.SCHEME_SIP, handle, null);
92
-        PhoneAccountHandle accountHandle
93
-            = ConnectionService.registerPhoneAccount(
94
-                    getReactApplicationContext(), address, callUUID);
92
+        PhoneAccountHandle accountHandle;
93
+
94
+        try {
95
+            accountHandle
96
+                = ConnectionService.registerPhoneAccount(getReactApplicationContext(), address, callUUID);
97
+        } catch (Throwable tr) {
98
+            JitsiMeetLogger.e(tr, TAG + " error in startCall");
99
+
100
+            promise.reject(tr);
101
+            return;
102
+        }
95 103
 
96 104
         Bundle extras = new Bundle();
97 105
         extras.putParcelable(
@@ -110,22 +118,18 @@ class RNConnectionService extends ReactContextBaseJavaModule {
110 118
         try {
111 119
             tm = (TelecomManager) ctx.getSystemService(Context.TELECOM_SERVICE);
112 120
             tm.placeCall(address, extras);
113
-        } catch (Exception e) {
114
-            JitsiMeetLogger.e(e, TAG + " error in startCall");
121
+        } catch (Throwable tr) {
122
+            JitsiMeetLogger.e(tr, TAG + " error in startCall");
115 123
             if (tm != null) {
116 124
                 try {
117 125
                     tm.unregisterPhoneAccount(accountHandle);
118
-                } catch (Throwable tr) {
126
+                } catch (Throwable tr1) {
119 127
                     // UnsupportedOperationException: System does not support feature android.software.connectionservice
120 128
                     // was observed here. Ignore.
121 129
                 }
122 130
             }
123 131
             ConnectionService.unregisterStartCallPromise(callUUID);
124
-            if (e instanceof SecurityException) {
125
-                promise.reject("SECURITY_ERROR", "Required permissions not granted.");
126
-            } else {
127
-                promise.reject(e);
128
-            }
132
+            promise.reject(tr);
129 133
         }
130 134
     }
131 135
 

+ 10
- 10
react/features/mobile/call-integration/middleware.js Целия файл

@@ -194,16 +194,14 @@ function _conferenceJoined({ getState }, next, action) {
194 194
                     _updateCallIntegrationMuted(action.conference, getState());
195 195
                 }
196 196
             })
197
-            .catch(error => {
198
-                // Currently this error code is emitted only by Android.
197
+            .catch(() => {
198
+                // Currently errors here are only emitted by Android.
199 199
                 //
200
-                if (error.code === 'CONNECTION_NOT_FOUND_ERROR') {
201
-                    // Some Samsung devices will fail to fully engage ConnectionService if no SIM card
202
-                    // was ever installed on the device. We could check for it, but it would require
203
-                    // the CALL_PHONE permission, which is not something we want to do, so fallback to
204
-                    // not using ConnectionService.
205
-                    _handleConnectionServiceFailure(getState());
206
-                }
200
+                // Some Samsung devices will fail to fully engage ConnectionService if no SIM card
201
+                // was ever installed on the device. We could check for it, but it would require
202
+                // the CALL_PHONE permission, which is not something we want to do, so fallback to
203
+                // not using ConnectionService.
204
+                _handleConnectionServiceFailure(getState());
207 205
             });
208 206
     }
209 207
 
@@ -304,9 +302,11 @@ function _conferenceWillJoin({ dispatch, getState }, next, action) {
304 302
                         { text: 'OK' }
305 303
                     ],
306 304
                     { cancelable: false });
307
-            } else if (error.code === 'SECURITY_ERROR') {
305
+            } else {
308 306
                 // Some devices fail because the CALL_PHONE permission is not granted, which is
309 307
                 // nonsense, because it's not needed for self-managed connections.
308
+                // Some other devices fail because ConnectionService is not supported.
309
+                // Be that as it may, fallback to non-ConnectionService audio device handling.
310 310
 
311 311
                 _handleConnectionServiceFailure(state);
312 312
             }

Loading…
Отказ
Запис