@cometchat/calls-sdk-react-native 4.4.2-beta.1 → 5.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +85 -19
  2. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  3. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  4. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  5. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/8.9/gc.properties +0 -0
  7. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  8. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  9. package/android/.gradle/vcs-1/gc.properties +0 -0
  10. package/android/build.gradle +13 -12
  11. package/android/src/main/AndroidManifest.xml +15 -6
  12. package/android/src/main/java/com/callingv5/AudioDeviceHandlerConnectionService.java +185 -0
  13. package/android/src/main/java/com/callingv5/AudioDeviceHandlerGeneric.java +254 -0
  14. package/android/src/main/java/com/{CometChatCalls → callingv5}/AudioModeModule.java +93 -56
  15. package/android/src/main/java/com/callingv5/ConnectionService.java +451 -0
  16. package/android/src/main/java/com/callingv5/KeepAwakeModule.java +53 -0
  17. package/android/src/main/java/com/callingv5/MyAppPackage.java +35 -0
  18. package/android/src/main/java/com/callingv5/RNConnectionService.java +244 -0
  19. package/android/src/main/java/com/callingv5/ToastModule.java +29 -0
  20. package/android/src/main/java/com/callingv5/utils/CometChatLogger.java +88 -0
  21. package/dist/index.d.mts +3940 -0
  22. package/dist/index.d.ts +3940 -9
  23. package/dist/index.js +10990 -132
  24. package/dist/index.js.map +1 -0
  25. package/dist/index.mjs +10959 -0
  26. package/dist/index.mjs.map +1 -0
  27. package/dist/polyfills/RTCPeerConnection.js +19 -0
  28. package/dist/polyfills/Storage.js +192 -0
  29. package/dist/polyfills/browser.js +337 -0
  30. package/dist/polyfills/index.js +1 -0
  31. package/dist/polyfills/ipv6utils.js +197 -0
  32. package/dist/polyfills/webrtc.js +11 -0
  33. package/package.json +18 -111
  34. package/LICENSE.md +0 -3
  35. package/android/src/main/java/com/CometChatCalls/AudioDeviceHandlerGeneric.java +0 -213
  36. package/android/src/main/java/com/CometChatCalls/AudioDeviceHandlerLegacy.java +0 -213
  37. package/android/src/main/java/com/CometChatCalls/BluetoothHeadsetMonitor.java +0 -187
  38. package/android/src/main/java/com/CometChatCalls/CallNotificationService.java +0 -93
  39. package/android/src/main/java/com/CometChatCalls/CallNotificationServiceModule.java +0 -48
  40. package/android/src/main/java/com/CometChatCalls/CometChatCallsPackage.java +0 -56
  41. package/android/src/main/java/com/CometChatCalls/CometChatCommonModule.java +0 -48
  42. package/android/src/main/java/com/CometChatCalls/PictureInPictureModule.java +0 -133
  43. package/android/src/main/res/drawable-mdpi/callingcomponent_icons_headphones_pluged.png +0 -0
  44. package/cometchat-calls-sdk-react-native.podspec +0 -21
  45. package/dist/CometChatErrorConstants.d.ts +0 -124
  46. package/dist/Constants.d.ts +0 -724
  47. package/dist/Helper copy.d.ts +0 -1
  48. package/dist/Helper.d.ts +0 -7
  49. package/dist/api/APIHandler.d.ts +0 -42
  50. package/dist/api/endpoints.d.ts +0 -7
  51. package/dist/api/helper.d.ts +0 -69
  52. package/dist/api/index.d.ts +0 -2
  53. package/dist/constants/CallConstants.d.ts +0 -136
  54. package/dist/constants/index.d.ts +0 -1
  55. package/dist/defaultCallsettings.d.ts +0 -2
  56. package/dist/models/CallAppSettings.d.ts +0 -42
  57. package/dist/models/CallGroup.d.ts +0 -14
  58. package/dist/models/CallLog.d.ts +0 -276
  59. package/dist/models/CallLogFilterParams.d.ts +0 -97
  60. package/dist/models/CallSettings.d.ts +0 -330
  61. package/dist/models/CallUser.d.ts +0 -14
  62. package/dist/models/CometChatCallLogs.d.ts +0 -193
  63. package/dist/models/CometChatCalls.d.ts +0 -110
  64. package/dist/models/CometChatCallsComponent.d.ts +0 -13
  65. package/dist/models/CometChatCallsComponentCore.d.ts +0 -18
  66. package/dist/models/CometChatCallsException.d.ts +0 -7
  67. package/dist/models/CometChatPresenterComponent.d.ts +0 -13
  68. package/dist/models/ErrorModel.d.ts +0 -11
  69. package/dist/models/Listner.d.ts +0 -69
  70. package/dist/models/ListnerHandler.d.ts +0 -10
  71. package/dist/models/MessageComponent.d.ts +0 -7
  72. package/dist/models/Participant.d.ts +0 -184
  73. package/dist/models/PresenterSettings.d.ts +0 -208
  74. package/dist/models/RTCUser.d.ts +0 -18
  75. package/dist/models/Recording.d.ts +0 -86
  76. package/dist/models/index.d.ts +0 -9
  77. package/dist/types/ICallAppSettings.d.ts +0 -6
  78. package/dist/types/ICallSettings.d.ts +0 -61
  79. package/dist/types/RTCUser.d.ts +0 -6
  80. package/dist/types/callEvents.d.ts +0 -54
  81. package/dist/types/common.d.ts +0 -18
  82. package/dist/types/index.d.ts +0 -2
  83. package/ios/AudioMode.h +0 -11
  84. package/ios/AudioMode.m +0 -418
  85. package/ios/CometChatCommonModule.h +0 -6
  86. package/ios/CometChatCommonModule.m +0 -29
  87. package/ios/JitsiAudioSession+Private.h +0 -25
  88. package/ios/JitsiAudioSession.h +0 -17
  89. package/ios/JitsiAudioSession.m +0 -34
  90. package/ios/LogUtils.h +0 -23
  91. package/ios/react-native-calls2.xcodeproj/project.pbxproj +0 -269
@@ -1,17 +1,37 @@
1
- package com.CometChatCalls;
1
+ /*
2
+ * Copyright @ 2017-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
2
16
 
17
+ package com.cometchat.calls;
18
+
19
+ import android.annotation.SuppressLint;
20
+ import android.app.Activity;
3
21
  import android.content.Context;
4
22
  import android.media.AudioManager;
5
23
  import android.os.Build;
6
- import android.util.Log;
7
24
 
25
+ import com.cometchat.calls.utils.CometChatLogger;
8
26
  import com.facebook.react.bridge.Arguments;
9
27
  import com.facebook.react.bridge.Promise;
10
28
  import com.facebook.react.bridge.ReactApplicationContext;
29
+ import com.facebook.react.bridge.ReactContext;
11
30
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
12
31
  import com.facebook.react.bridge.ReactMethod;
13
32
  import com.facebook.react.bridge.WritableArray;
14
33
  import com.facebook.react.bridge.WritableMap;
34
+ import com.facebook.react.module.annotations.ReactModule;
15
35
  import com.facebook.react.modules.core.DeviceEventManagerModule;
16
36
 
17
37
  import java.util.HashMap;
@@ -36,19 +56,21 @@ import java.util.concurrent.Executors;
36
56
  * Before a call has started and after it has ended the
37
57
  * {@code AudioModeModule.DEFAULT} mode should be used.
38
58
  */
59
+ @SuppressLint("AnnotateVersionCheck")
60
+ @ReactModule(name = AudioModeModule.NAME)
39
61
  class AudioModeModule extends ReactContextBaseJavaModule {
40
62
  public static final String NAME = "AudioMode";
41
63
 
42
64
  /**
43
65
  * Constants representing the audio mode.
44
66
  * - DEFAULT: Used before and after every call. It represents the default
45
- * audio routing scheme.
67
+ * audio routing scheme.
46
68
  * - AUDIO_CALL: Used for audio only calls. It will use the earpiece by
47
- * default, unless a wired or Bluetooth headset is connected.
69
+ * default, unless a wired or Bluetooth headset is connected.
48
70
  * - VIDEO_CALL: Used for video calls. It will use the speaker by default,
49
- * unless a wired or Bluetooth headset is connected.
71
+ * unless a wired or Bluetooth headset is connected.
50
72
  */
51
- static final int DEFAULT = 0;
73
+ static final int DEFAULT = 0;
52
74
  static final int AUDIO_CALL = 1;
53
75
  static final int VIDEO_CALL = 2;
54
76
 
@@ -60,9 +82,9 @@ class AudioModeModule extends ReactContextBaseJavaModule {
60
82
  /**
61
83
  * Whether or not the ConnectionService is used for selecting audio devices.
62
84
  */
63
-
64
85
  private static final boolean supportsConnectionService = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
65
- private static boolean useConnectionService_ = false;
86
+ // TODO: implement connection service fully and update the below line
87
+ private static boolean useConnectionService_ = supportsConnectionService && false;
66
88
 
67
89
  static boolean useConnectionService() {
68
90
  return supportsConnectionService && useConnectionService_;
@@ -90,10 +112,10 @@ class AudioModeModule extends ReactContextBaseJavaModule {
90
112
  /**
91
113
  * Audio device types.
92
114
  */
93
- static final String DEVICE_BLUETOOTH = "BLUETOOTH";
94
- static final String DEVICE_EARPIECE = "EARPIECE";
115
+ static final String DEVICE_BLUETOOTH = "BLUETOOTH";
116
+ static final String DEVICE_EARPIECE = "EARPIECE";
95
117
  static final String DEVICE_HEADPHONES = "HEADPHONES";
96
- static final String DEVICE_SPEAKER = "SPEAKER";
118
+ static final String DEVICE_SPEAKER = "SPEAKER";
97
119
 
98
120
  /**
99
121
  * Device change event.
@@ -116,27 +138,34 @@ class AudioModeModule extends ReactContextBaseJavaModule {
116
138
  */
117
139
  private String userSelectedDevice;
118
140
 
119
- private ReactApplicationContext reactContext;
120
141
  /**
121
142
  * Initializes a new module instance. There shall be a single instance of
122
143
  * this module throughout the lifetime of the application.
123
144
  *
124
145
  * @param reactContext the {@link ReactApplicationContext} where this module
125
- * is created.
146
+ * is created.
126
147
  */
127
148
  public AudioModeModule(ReactApplicationContext reactContext) {
128
149
  super(reactContext);
129
150
 
130
- this.reactContext = reactContext;
131
- audioManager = (AudioManager) reactContext.getSystemService(Context.AUDIO_SERVICE);
132
- // audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
151
+ audioManager = (AudioManager)reactContext.getSystemService(Context.AUDIO_SERVICE);
152
+ }
153
+
154
+ @ReactMethod
155
+ public void addListener(String eventName) {
156
+ // Keep: Required for RN built in Event Emitter Calls.
157
+ }
158
+
159
+ @ReactMethod
160
+ public void removeListeners(Integer count) {
161
+ // Keep: Required for RN built in Event Emitter Calls.
133
162
  }
134
163
 
135
164
  /**
136
165
  * Gets a mapping with the constants this module is exporting.
137
166
  *
138
167
  * @return a {@link Map} mapping the constants to be exported with their
139
- * values.
168
+ * values.
140
169
  */
141
170
  @Override
142
171
  public Map<String, Object> getConstants() {
@@ -159,7 +188,6 @@ class AudioModeModule extends ReactContextBaseJavaModule {
159
188
  public void run() {
160
189
  WritableArray data = Arguments.createArray();
161
190
  final boolean hasHeadphones = availableDevices.contains(DEVICE_HEADPHONES);
162
- Log.e(TAG, "hasHeadphones ? " + hasHeadphones);
163
191
  for (String device : availableDevices) {
164
192
  if (hasHeadphones && device.equals(DEVICE_EARPIECE)) {
165
193
  // Skip earpiece when headphones are plugged in.
@@ -170,8 +198,7 @@ class AudioModeModule extends ReactContextBaseJavaModule {
170
198
  deviceInfo.putBoolean("selected", device.equals(selectedDevice));
171
199
  data.pushMap(deviceInfo);
172
200
  }
173
- reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
174
- .emit(DEVICE_CHANGE_EVENT, data);
201
+ getContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(DEVICE_CHANGE_EVENT, data);
175
202
  }
176
203
  });
177
204
  }
@@ -186,6 +213,15 @@ class AudioModeModule extends ReactContextBaseJavaModule {
186
213
  return NAME;
187
214
  }
188
215
 
216
+ public ReactContext getContext(){
217
+ return this.getReactApplicationContext();
218
+ }
219
+
220
+ /**
221
+ * Initializes the audio device handler module. This function is called *after* all Catalyst
222
+ * modules have been created, and that's why we use it, because {@link AudioDeviceHandlerConnectionService}
223
+ * needs access to another Catalyst module, so doing this in the constructor would be too early.
224
+ */
189
225
  @Override
190
226
  public void initialize() {
191
227
  runInAudioThread(new Runnable() {
@@ -201,10 +237,10 @@ class AudioModeModule extends ReactContextBaseJavaModule {
201
237
  audioDeviceHandler.stop();
202
238
  }
203
239
 
204
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
205
- audioDeviceHandler = new AudioDeviceHandlerGeneric(audioManager);
240
+ if (useConnectionService()) {
241
+ audioDeviceHandler = new AudioDeviceHandlerConnectionService(audioManager);
206
242
  } else {
207
- audioDeviceHandler = new AudioDeviceHandlerLegacy(audioManager);
243
+ audioDeviceHandler = new AudioDeviceHandlerGeneric(audioManager);
208
244
  }
209
245
 
210
246
  audioDeviceHandler.start(this);
@@ -212,7 +248,6 @@ class AudioModeModule extends ReactContextBaseJavaModule {
212
248
 
213
249
  /**
214
250
  * Helper function to run operations on a dedicated thread.
215
- *
216
251
  * @param runnable
217
252
  */
218
253
  void runInAudioThread(Runnable runnable) {
@@ -229,35 +264,27 @@ class AudioModeModule extends ReactContextBaseJavaModule {
229
264
  runInAudioThread(new Runnable() {
230
265
  @Override
231
266
  public void run() {
232
- Log.e(TAG, "Selected Devices = " + device);
233
- Log.e(TAG, "Available Devices = " + availableDevices);
234
- if (availableDevices != null && device != null) {
235
- if (!availableDevices.contains(device)) {
236
- userSelectedDevice = null;
237
- return;
238
- }
267
+ if (!availableDevices.contains(device)) {
268
+ CometChatLogger.w(TAG , " Audio device not available: " + device);
269
+ userSelectedDevice = null;
270
+ return;
271
+ }
239
272
 
240
- if (mode != -1) {
241
- userSelectedDevice = device;
242
- updateAudioRoute(mode);
243
- }
273
+ if (mode != -1) {
274
+ CometChatLogger.i(TAG , " User selected device set to: " + device);
275
+ userSelectedDevice = device;
276
+ updateAudioRoute(mode, false);
244
277
  }
245
278
  }
246
279
  });
247
280
  }
248
281
 
249
- @ReactMethod
250
- public void getAllDevices() {
251
- Log.e("getAllDevices","getAllDevices");
252
- notifyDevicesChanged();
253
- }
254
282
  /**
255
283
  * Public method to set the current audio mode.
256
284
  *
257
- * @param mode the desired audio mode.
285
+ * @param mode the desired audio mode.
258
286
  * @param promise a {@link Promise} which will be resolved if the audio mode
259
- * could be updated successfully, and it will be rejected
260
- * otherwise.
287
+ * could be updated successfully, and it will be rejected otherwise.
261
288
  */
262
289
  @ReactMethod
263
290
  public void setMode(final int mode, final Promise promise) {
@@ -266,15 +293,25 @@ class AudioModeModule extends ReactContextBaseJavaModule {
266
293
  return;
267
294
  }
268
295
 
296
+ Activity currentActivity = getCurrentActivity();
297
+ if (currentActivity != null) {
298
+ if (mode == DEFAULT) {
299
+ currentActivity.setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
300
+ } else {
301
+ currentActivity.setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
302
+ }
303
+ }
304
+
269
305
  runInAudioThread(new Runnable() {
270
306
  @Override
271
307
  public void run() {
272
308
  boolean success;
273
309
 
274
310
  try {
275
- success = updateAudioRoute(mode);
311
+ success = updateAudioRoute(mode, false);
276
312
  } catch (Throwable e) {
277
313
  success = false;
314
+ CometChatLogger.e( TAG , " Failed to update audio route for mode: " + mode);
278
315
  }
279
316
  if (success) {
280
317
  AudioModeModule.this.mode = mode;
@@ -287,8 +324,7 @@ class AudioModeModule extends ReactContextBaseJavaModule {
287
324
  }
288
325
 
289
326
  /**
290
- * Sets whether ConnectionService should be used (if available) for setting the
291
- * audio mode
327
+ * Sets whether ConnectionService should be used (if available) for setting the audio mode
292
328
  * or not.
293
329
  *
294
330
  * @param use Boolean indicator of where it should be used or not.
@@ -309,9 +345,10 @@ class AudioModeModule extends ReactContextBaseJavaModule {
309
345
  *
310
346
  * @param mode the audio mode to be used when computing the audio route.
311
347
  * @return {@code true} if the audio route was updated successfully;
312
- * {@code false}, otherwise.
348
+ * {@code false}, otherwise.
313
349
  */
314
- private boolean updateAudioRoute(int mode) {
350
+ private boolean updateAudioRoute(int mode, boolean force) {
351
+ CometChatLogger.i(TAG , " Update audio route for mode: " + mode);
315
352
 
316
353
  if (!audioDeviceHandler.setMode(mode)) {
317
354
  return false;
@@ -345,11 +382,12 @@ class AudioModeModule extends ReactContextBaseJavaModule {
345
382
 
346
383
  // If the previously selected device and the current default one
347
384
  // match, do nothing.
348
- if (selectedDevice != null && selectedDevice.equals(audioDevice)) {
385
+ if (!force && selectedDevice != null && selectedDevice.equals(audioDevice)) {
349
386
  return true;
350
387
  }
351
388
 
352
389
  selectedDevice = audioDevice;
390
+ CometChatLogger.i(TAG , " Selected audio device: " + audioDevice);
353
391
 
354
392
  audioDeviceHandler.setAudioRoute(audioDevice);
355
393
 
@@ -409,17 +447,17 @@ class AudioModeModule extends ReactContextBaseJavaModule {
409
447
  */
410
448
  void updateAudioRoute() {
411
449
  if (mode != -1) {
412
- updateAudioRoute(mode);
450
+ updateAudioRoute(mode, false);
413
451
  }
414
452
  }
415
453
 
416
454
  /**
417
- * Needed on the legacy handler...
418
- *
419
- * @return Context for the application.
455
+ * Re-sets the current audio route. Needed when focus is lost and regained.
420
456
  */
421
- Context getContext() {
422
- return getReactApplicationContext();
457
+ void resetAudioRoute() {
458
+ if (mode != -1) {
459
+ updateAudioRoute(mode, true);
460
+ }
423
461
  }
424
462
 
425
463
  /**
@@ -428,7 +466,6 @@ class AudioModeModule extends ReactContextBaseJavaModule {
428
466
  interface AudioDeviceHandlerInterface {
429
467
  /**
430
468
  * Start detecting audio device changes.
431
- *
432
469
  * @param audioModeModule Reference to the main {@link AudioModeModule}.
433
470
  */
434
471
  void start(AudioModeModule audioModeModule);