|
@@ -17,6 +17,7 @@
|
17
|
17
|
package org.jitsi.meet.sdk;
|
18
|
18
|
|
19
|
19
|
import android.content.Context;
|
|
20
|
+import android.media.AudioManager;
|
20
|
21
|
import android.os.Build;
|
21
|
22
|
|
22
|
23
|
import com.facebook.react.bridge.Arguments;
|
|
@@ -85,6 +86,12 @@ class AudioModeModule extends ReactContextBaseJavaModule {
|
85
|
86
|
return supportsConnectionService && useConnectionService_;
|
86
|
87
|
}
|
87
|
88
|
|
|
89
|
+ /**
|
|
90
|
+ * {@link AudioManager} instance used to interact with the Android audio
|
|
91
|
+ * subsystem.
|
|
92
|
+ */
|
|
93
|
+ private AudioManager audioManager;
|
|
94
|
+
|
88
|
95
|
private AudioDeviceHandlerInterface audioDeviceHandler;
|
89
|
96
|
|
90
|
97
|
/**
|
|
@@ -136,6 +143,8 @@ class AudioModeModule extends ReactContextBaseJavaModule {
|
136
|
143
|
*/
|
137
|
144
|
public AudioModeModule(ReactApplicationContext reactContext) {
|
138
|
145
|
super(reactContext);
|
|
146
|
+
|
|
147
|
+ audioManager = (AudioManager)reactContext.getSystemService(Context.AUDIO_SERVICE);
|
139
|
148
|
}
|
140
|
149
|
|
141
|
150
|
/**
|
|
@@ -212,14 +221,14 @@ class AudioModeModule extends ReactContextBaseJavaModule {
|
212
|
221
|
}
|
213
|
222
|
|
214
|
223
|
if (useConnectionService()) {
|
215
|
|
- audioDeviceHandler = new AudioDeviceHandlerConnectionService();
|
|
224
|
+ audioDeviceHandler = new AudioDeviceHandlerConnectionService(audioManager);
|
216
|
225
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
217
|
|
- audioDeviceHandler = new AudioDeviceHandlerGeneric();
|
|
226
|
+ audioDeviceHandler = new AudioDeviceHandlerGeneric(audioManager);
|
218
|
227
|
} else {
|
219
|
|
- audioDeviceHandler = new AudioDeviceHandlerLegacy();
|
|
228
|
+ audioDeviceHandler = new AudioDeviceHandlerLegacy(audioManager);
|
220
|
229
|
}
|
221
|
230
|
|
222
|
|
- audioDeviceHandler.start(getReactApplicationContext(), this);
|
|
231
|
+ audioDeviceHandler.start(this);
|
223
|
232
|
}
|
224
|
233
|
|
225
|
234
|
/**
|
|
@@ -418,16 +427,24 @@ class AudioModeModule extends ReactContextBaseJavaModule {
|
418
|
427
|
}
|
419
|
428
|
}
|
420
|
429
|
|
|
430
|
+ /**
|
|
431
|
+ * Needed on the legacy handler...
|
|
432
|
+ *
|
|
433
|
+ * @return Context for the application.
|
|
434
|
+ */
|
|
435
|
+ Context getContext() {
|
|
436
|
+ return getReactApplicationContext();
|
|
437
|
+ }
|
|
438
|
+
|
421
|
439
|
/**
|
422
|
440
|
* Interface for the modules implementing the actual audio device management.
|
423
|
441
|
*/
|
424
|
442
|
interface AudioDeviceHandlerInterface {
|
425
|
443
|
/**
|
426
|
444
|
* Start detecting audio device changes.
|
427
|
|
- * @param context Android {@link Context} where detection should take place.
|
428
|
445
|
* @param audioModeModule Reference to the main {@link AudioModeModule}.
|
429
|
446
|
*/
|
430
|
|
- void start(Context context, AudioModeModule audioModeModule);
|
|
447
|
+ void start(AudioModeModule audioModeModule);
|
431
|
448
|
|
432
|
449
|
/**
|
433
|
450
|
* Stop audio device detection.
|