浏览代码

android: disable ConnectionService if permissions are not granted

Some devices seem to have a bug in their Android versions and startCall fails
with SecurityError because the CALL_PHONE permissions is not granted. This is
not a requirement for self-managed connection services as per the official
documentation though:
https://developer.android.com/guide/topics/connectivity/telecom/selfManaged

Alas, connection services takes over audio device management too, so let's
handle the error and disable CS if we get SecurityError.
j8
Saúl Ibarra Corretgé 5 年前
父节点
当前提交
58bd48c1ae

+ 5
- 1
android/sdk/src/main/java/org/jitsi/meet/sdk/RNConnectionService.java 查看文件

@@ -116,7 +116,11 @@ class RNConnectionService extends ReactContextBaseJavaModule {
116 116
                 tm.unregisterPhoneAccount(accountHandle);
117 117
             }
118 118
             ConnectionService.unregisterStartCallPromise(callUUID);
119
-            promise.reject(e);
119
+            if (e instanceof SecurityException) {
120
+                promise.reject("SECURITY_ERROR", "Required permissions not granted.");
121
+            } else {
122
+                promise.reject(e);
123
+            }
120 124
         }
121 125
     }
122 126
 

+ 16
- 2
react/features/mobile/call-integration/middleware.js 查看文件

@@ -1,6 +1,6 @@
1 1
 // @flow
2 2
 
3
-import { Alert, Platform } from 'react-native';
3
+import { Alert, NativeModules, Platform } from 'react-native';
4 4
 import uuid from 'uuid';
5 5
 
6 6
 import { createTrackMutedEvent, sendAnalytics } from '../../analytics';
@@ -36,6 +36,7 @@ import CallKit from './CallKit';
36 36
 import ConnectionService from './ConnectionService';
37 37
 import { isCallIntegrationEnabled } from './functions';
38 38
 
39
+const { AudioMode } = NativeModules;
39 40
 const CallIntegration = CallKit || ConnectionService;
40 41
 
41 42
 /**
@@ -276,7 +277,8 @@ function _conferenceWillJoin({ dispatch, getState }, next, action) {
276 277
             }
277 278
         })
278 279
         .catch(error => {
279
-            // Currently this error code is emitted only by Android.
280
+            // Currently this error codes are emitted only by Android.
281
+            //
280 282
             if (error.code === 'CREATE_OUTGOING_CALL_FAILED') {
281 283
                 // We're not tracking the call anymore - it doesn't exist on
282 284
                 // the native side.
@@ -290,6 +292,18 @@ function _conferenceWillJoin({ dispatch, getState }, next, action) {
290 292
                         { text: 'OK' }
291 293
                     ],
292 294
                     { cancelable: false });
295
+            } else if (error.code === 'SECURITY_ERROR') {
296
+                // Some devices fail because the CALL_PHONE permission is not granted, which is
297
+                // nonsense, because it's not needed for self-managed connections. Alas, this also
298
+                // means audio device management would be broken, so fallback to not using ConnectionService.
299
+                // NOTE: We are not storing this in Settings, in case it's a transient issue, as far fetched as
300
+                // that may be.
301
+                if (AudioMode.setUseConnectionService) {
302
+                    AudioMode.setUseConnectionService(false);
303
+
304
+                    // Set the desired audio mode, since we just reset the whole thing.
305
+                    AudioMode.setMode(hasVideo ? AudioMode.VIDEO_CALL : AudioMode.AUDIO_CALL);
306
+                }
293 307
             }
294 308
         });
295 309
 

正在加载...
取消
保存