@cometchat/calls-sdk-react-native 4.4.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.
- package/README.md +85 -19
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +13 -12
- package/android/src/main/AndroidManifest.xml +15 -6
- package/android/src/main/java/com/callingv5/AudioDeviceHandlerConnectionService.java +185 -0
- package/android/src/main/java/com/callingv5/AudioDeviceHandlerGeneric.java +254 -0
- package/android/src/main/java/com/{CometChatCalls → callingv5}/AudioModeModule.java +93 -56
- package/android/src/main/java/com/callingv5/ConnectionService.java +451 -0
- package/android/src/main/java/com/callingv5/KeepAwakeModule.java +53 -0
- package/android/src/main/java/com/callingv5/MyAppPackage.java +35 -0
- package/android/src/main/java/com/callingv5/RNConnectionService.java +244 -0
- package/android/src/main/java/com/callingv5/ToastModule.java +29 -0
- package/android/src/main/java/com/callingv5/utils/CometChatLogger.java +88 -0
- package/dist/index.d.mts +3940 -0
- package/dist/index.d.ts +3940 -9
- package/dist/index.js +10990 -127
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +10959 -0
- package/dist/index.mjs.map +1 -0
- package/dist/polyfills/RTCPeerConnection.js +19 -0
- package/dist/polyfills/Storage.js +192 -0
- package/dist/polyfills/browser.js +337 -0
- package/dist/polyfills/index.js +1 -0
- package/dist/polyfills/ipv6utils.js +197 -0
- package/dist/polyfills/webrtc.js +11 -0
- package/package.json +18 -110
- package/LICENSE.md +0 -3
- package/android/src/main/java/com/CometChatCalls/AudioDeviceHandlerGeneric.java +0 -213
- package/android/src/main/java/com/CometChatCalls/AudioDeviceHandlerLegacy.java +0 -213
- package/android/src/main/java/com/CometChatCalls/BluetoothHeadsetMonitor.java +0 -187
- package/android/src/main/java/com/CometChatCalls/CallNotificationService.java +0 -93
- package/android/src/main/java/com/CometChatCalls/CallNotificationServiceModule.java +0 -48
- package/android/src/main/java/com/CometChatCalls/CometChatCallsPackage.java +0 -56
- package/android/src/main/java/com/CometChatCalls/CometChatCommonModule.java +0 -48
- package/android/src/main/java/com/CometChatCalls/PictureInPictureModule.java +0 -133
- package/android/src/main/res/drawable-mdpi/callingcomponent_icons_headphones_pluged.png +0 -0
- package/cometchat-calls-sdk-react-native.podspec +0 -21
- package/dist/CometChatErrorConstants.d.ts +0 -124
- package/dist/Constants.d.ts +0 -724
- package/dist/Helper copy.d.ts +0 -1
- package/dist/Helper.d.ts +0 -7
- package/dist/api/APIHandler.d.ts +0 -42
- package/dist/api/endpoints.d.ts +0 -7
- package/dist/api/helper.d.ts +0 -69
- package/dist/api/index.d.ts +0 -2
- package/dist/constants/CallConstants.d.ts +0 -136
- package/dist/constants/index.d.ts +0 -1
- package/dist/defaultCallsettings.d.ts +0 -2
- package/dist/models/CallAppSettings.d.ts +0 -42
- package/dist/models/CallGroup.d.ts +0 -14
- package/dist/models/CallLog.d.ts +0 -276
- package/dist/models/CallLogFilterParams.d.ts +0 -97
- package/dist/models/CallSettings.d.ts +0 -330
- package/dist/models/CallUser.d.ts +0 -14
- package/dist/models/CometChatCallLogs.d.ts +0 -193
- package/dist/models/CometChatCalls.d.ts +0 -110
- package/dist/models/CometChatCallsComponent.d.ts +0 -13
- package/dist/models/CometChatCallsComponentCore.d.ts +0 -18
- package/dist/models/CometChatCallsException.d.ts +0 -7
- package/dist/models/CometChatPresenterComponent.d.ts +0 -13
- package/dist/models/ErrorModel.d.ts +0 -11
- package/dist/models/Listner.d.ts +0 -69
- package/dist/models/ListnerHandler.d.ts +0 -10
- package/dist/models/MessageComponent.d.ts +0 -7
- package/dist/models/Participant.d.ts +0 -184
- package/dist/models/PresenterSettings.d.ts +0 -208
- package/dist/models/RTCUser.d.ts +0 -18
- package/dist/models/Recording.d.ts +0 -86
- package/dist/models/index.d.ts +0 -9
- package/dist/types/ICallAppSettings.d.ts +0 -6
- package/dist/types/ICallSettings.d.ts +0 -61
- package/dist/types/RTCUser.d.ts +0 -6
- package/dist/types/callEvents.d.ts +0 -54
- package/dist/types/common.d.ts +0 -18
- package/dist/types/index.d.ts +0 -2
- package/ios/AudioMode.h +0 -11
- package/ios/AudioMode.m +0 -418
- package/ios/CometChatCommonModule.h +0 -6
- package/ios/CometChatCommonModule.m +0 -29
- package/ios/JitsiAudioSession+Private.h +0 -25
- package/ios/JitsiAudioSession.h +0 -17
- package/ios/JitsiAudioSession.m +0 -34
- package/ios/LogUtils.h +0 -23
- package/ios/react-native-calls2.xcodeproj/project.pbxproj +0 -269
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
package com.CometChatCalls;
|
|
2
|
-
|
|
3
|
-
import android.content.BroadcastReceiver;
|
|
4
|
-
import android.content.Context;
|
|
5
|
-
import android.content.Intent;
|
|
6
|
-
import android.content.IntentFilter;
|
|
7
|
-
import android.content.pm.PackageManager;
|
|
8
|
-
import android.media.AudioManager;
|
|
9
|
-
import android.util.Log;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* {@link AudioModeModule.AudioDeviceHandlerInterface} module implementing device handling for
|
|
14
|
-
* legacy (pre-M) Android versions.
|
|
15
|
-
*/
|
|
16
|
-
class AudioDeviceHandlerLegacy implements
|
|
17
|
-
AudioModeModule.AudioDeviceHandlerInterface,
|
|
18
|
-
AudioManager.OnAudioFocusChangeListener,
|
|
19
|
-
BluetoothHeadsetMonitor.Listener {
|
|
20
|
-
|
|
21
|
-
private final static String TAG = AudioDeviceHandlerLegacy.class.getSimpleName();
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Reference to the main {@code AudioModeModule}.
|
|
25
|
-
*/
|
|
26
|
-
private AudioModeModule module;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Indicator that we have lost audio focus.
|
|
30
|
-
*/
|
|
31
|
-
private boolean audioFocusLost = false;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* {@link AudioManager} instance used to interact with the Android audio
|
|
35
|
-
* subsystem.
|
|
36
|
-
*/
|
|
37
|
-
private AudioManager audioManager;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* {@link BluetoothHeadsetMonitor} for detecting Bluetooth device changes in
|
|
41
|
-
* old (< M) Android versions.
|
|
42
|
-
*/
|
|
43
|
-
private BluetoothHeadsetMonitor bluetoothHeadsetMonitor;
|
|
44
|
-
|
|
45
|
-
public AudioDeviceHandlerLegacy(AudioManager audioManager) {
|
|
46
|
-
this.audioManager = audioManager;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Helper method to trigger an audio route update when Bluetooth devices are
|
|
51
|
-
* connected / disconnected.
|
|
52
|
-
*/
|
|
53
|
-
@Override
|
|
54
|
-
public void onBluetoothDeviceChange(final boolean deviceAvailable) {
|
|
55
|
-
module.runInAudioThread(new Runnable() {
|
|
56
|
-
@Override
|
|
57
|
-
public void run() {
|
|
58
|
-
if (deviceAvailable) {
|
|
59
|
-
module.addDevice(AudioModeModule.DEVICE_BLUETOOTH);
|
|
60
|
-
} else {
|
|
61
|
-
module.removeDevice(AudioModeModule.DEVICE_BLUETOOTH);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
module.updateAudioRoute();
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Helper method to trigger an audio route update when a headset is plugged
|
|
71
|
-
* or unplugged.
|
|
72
|
-
*/
|
|
73
|
-
private void onHeadsetDeviceChange() {
|
|
74
|
-
module.runInAudioThread(new Runnable() {
|
|
75
|
-
@Override
|
|
76
|
-
public void run() {
|
|
77
|
-
// XXX: isWiredHeadsetOn is not deprecated when used just for
|
|
78
|
-
// knowing if there is a wired headset connected, regardless of
|
|
79
|
-
// audio being routed to it.
|
|
80
|
-
//noinspection deprecation
|
|
81
|
-
if (audioManager.isWiredHeadsetOn()) {
|
|
82
|
-
module.addDevice(AudioModeModule.DEVICE_HEADPHONES);
|
|
83
|
-
} else {
|
|
84
|
-
module.removeDevice(AudioModeModule.DEVICE_HEADPHONES);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
module.updateAudioRoute();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* {@link AudioManager.OnAudioFocusChangeListener} interface method. Called
|
|
94
|
-
* when the audio focus of the system is updated.
|
|
95
|
-
*
|
|
96
|
-
* @param focusChange - The type of focus change.
|
|
97
|
-
*/
|
|
98
|
-
@Override
|
|
99
|
-
public void onAudioFocusChange(final int focusChange) {
|
|
100
|
-
module.runInAudioThread(new Runnable() {
|
|
101
|
-
@Override
|
|
102
|
-
public void run() {
|
|
103
|
-
switch (focusChange) {
|
|
104
|
-
case AudioManager.AUDIOFOCUS_GAIN: {
|
|
105
|
-
Log.d(TAG , " Audio focus gained");
|
|
106
|
-
// Some other application potentially stole our audio focus
|
|
107
|
-
// temporarily. Restore our mode.
|
|
108
|
-
if (audioFocusLost) {
|
|
109
|
-
module.updateAudioRoute();
|
|
110
|
-
}
|
|
111
|
-
audioFocusLost = false;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
case AudioManager.AUDIOFOCUS_LOSS:
|
|
115
|
-
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
|
116
|
-
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: {
|
|
117
|
-
Log.d(TAG , " Audio focus lost");
|
|
118
|
-
audioFocusLost = true;
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Helper method to set the output route to a Bluetooth device.
|
|
128
|
-
*
|
|
129
|
-
* @param enabled true if Bluetooth should use used, false otherwise.
|
|
130
|
-
*/
|
|
131
|
-
private void setBluetoothAudioRoute(boolean enabled) {
|
|
132
|
-
if (enabled) {
|
|
133
|
-
audioManager.startBluetoothSco();
|
|
134
|
-
audioManager.setBluetoothScoOn(true);
|
|
135
|
-
} else {
|
|
136
|
-
audioManager.setBluetoothScoOn(false);
|
|
137
|
-
audioManager.stopBluetoothSco();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
@Override
|
|
142
|
-
public void start(AudioModeModule audioModeModule) {
|
|
143
|
-
Log.i( TAG , " as the audio device handler");
|
|
144
|
-
|
|
145
|
-
module = audioModeModule;
|
|
146
|
-
Context context = module.getContext();
|
|
147
|
-
|
|
148
|
-
// Setup runtime device change detection.
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
// Detect changes in wired headset connections.
|
|
152
|
-
IntentFilter wiredHeadSetFilter = new IntentFilter(AudioManager.ACTION_HEADSET_PLUG);
|
|
153
|
-
BroadcastReceiver wiredHeadsetReceiver = new BroadcastReceiver() {
|
|
154
|
-
@Override
|
|
155
|
-
public void onReceive(Context context, Intent intent) {
|
|
156
|
-
Log.d(TAG , " Wired headset added / removed");
|
|
157
|
-
onHeadsetDeviceChange();
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
context.registerReceiver(wiredHeadsetReceiver, wiredHeadSetFilter);
|
|
161
|
-
|
|
162
|
-
// Detect Bluetooth device changes.
|
|
163
|
-
bluetoothHeadsetMonitor = new BluetoothHeadsetMonitor(context, this);
|
|
164
|
-
|
|
165
|
-
// On Android < M, detect if we have an earpiece.
|
|
166
|
-
PackageManager pm = context.getPackageManager();
|
|
167
|
-
if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
|
|
168
|
-
module.addDevice(AudioModeModule.DEVICE_EARPIECE);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Always assume there is a speaker.
|
|
172
|
-
module.addDevice(AudioModeModule.DEVICE_SPEAKER);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
@Override
|
|
176
|
-
public void stop() {
|
|
177
|
-
bluetoothHeadsetMonitor.stop();
|
|
178
|
-
bluetoothHeadsetMonitor = null;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
@Override
|
|
182
|
-
public void setAudioRoute(String device) {
|
|
183
|
-
// Turn speaker on / off
|
|
184
|
-
audioManager.setSpeakerphoneOn(device.equals(AudioModeModule.DEVICE_SPEAKER));
|
|
185
|
-
|
|
186
|
-
// Turn bluetooth on / off
|
|
187
|
-
setBluetoothAudioRoute(device.equals(AudioModeModule.DEVICE_BLUETOOTH));
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
@Override
|
|
191
|
-
public boolean setMode(int mode) {
|
|
192
|
-
if (mode == AudioModeModule.DEFAULT) {
|
|
193
|
-
audioFocusLost = false;
|
|
194
|
-
audioManager.setMode(AudioManager.MODE_NORMAL);
|
|
195
|
-
audioManager.abandonAudioFocus(this);
|
|
196
|
-
audioManager.setSpeakerphoneOn(false);
|
|
197
|
-
setBluetoothAudioRoute(false);
|
|
198
|
-
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
|
|
203
|
-
audioManager.setMicrophoneMute(false);
|
|
204
|
-
|
|
205
|
-
if (audioManager.requestAudioFocus(this, AudioManager.STREAM_VOICE_CALL, AudioManager.AUDIOFOCUS_GAIN)
|
|
206
|
-
== AudioManager.AUDIOFOCUS_REQUEST_FAILED) {
|
|
207
|
-
Log.w(TAG , " Audio focus request failed");
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return true;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
package com.CometChatCalls;
|
|
3
|
-
|
|
4
|
-
import android.Manifest;
|
|
5
|
-
import android.bluetooth.BluetoothAdapter;
|
|
6
|
-
import android.bluetooth.BluetoothHeadset;
|
|
7
|
-
import android.bluetooth.BluetoothProfile;
|
|
8
|
-
import android.content.BroadcastReceiver;
|
|
9
|
-
import android.content.Context;
|
|
10
|
-
import android.content.Intent;
|
|
11
|
-
import android.content.IntentFilter;
|
|
12
|
-
import android.content.pm.PackageManager;
|
|
13
|
-
import android.media.AudioManager;
|
|
14
|
-
import android.os.Build;
|
|
15
|
-
import android.util.Log;
|
|
16
|
-
|
|
17
|
-
import androidx.core.app.ActivityCompat;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Helper class to detect and handle Bluetooth device changes. It monitors
|
|
21
|
-
* Bluetooth headsets being connected / disconnected and notifies the module
|
|
22
|
-
* about device changes when this occurs.
|
|
23
|
-
*/
|
|
24
|
-
class BluetoothHeadsetMonitor {
|
|
25
|
-
private final static String TAG = BluetoothHeadsetMonitor.class.getSimpleName();
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The {@link Context} in which this module executes.
|
|
29
|
-
*/
|
|
30
|
-
private final Context context;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Reference to the {@link BluetoothAdapter} object, used to access Bluetooth functionality.
|
|
34
|
-
*/
|
|
35
|
-
private BluetoothAdapter adapter;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Reference to a proxy object which allows us to query connected devices.
|
|
39
|
-
*/
|
|
40
|
-
private BluetoothHeadset headset;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* receiver registered for receiving Bluetooth connection state changes.
|
|
44
|
-
*/
|
|
45
|
-
private BroadcastReceiver receiver;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Listener for receiving Bluetooth device change events.
|
|
49
|
-
*/
|
|
50
|
-
private Listener listener;
|
|
51
|
-
|
|
52
|
-
public BluetoothHeadsetMonitor(Context context, Listener listener) {
|
|
53
|
-
this.context = context;
|
|
54
|
-
this.listener = listener;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private boolean getBluetoothHeadsetProfileProxy() {
|
|
58
|
-
adapter = BluetoothAdapter.getDefaultAdapter();
|
|
59
|
-
|
|
60
|
-
if (adapter == null) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// XXX: The profile listener listens for system services of the given
|
|
65
|
-
// type being available to the application. That is, if our Bluetooth
|
|
66
|
-
// adapter has the "headset" profile.
|
|
67
|
-
BluetoothProfile.ServiceListener listener
|
|
68
|
-
= new BluetoothProfile.ServiceListener() {
|
|
69
|
-
@Override
|
|
70
|
-
public void onServiceConnected(int profile, BluetoothProfile proxy) {
|
|
71
|
-
if (profile == BluetoothProfile.HEADSET) {
|
|
72
|
-
headset = (BluetoothHeadset) proxy;
|
|
73
|
-
updateDevices();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@Override
|
|
78
|
-
public void onServiceDisconnected(int profile) {
|
|
79
|
-
// The logic is the same as the logic of onServiceConnected.
|
|
80
|
-
onServiceConnected(profile, /* proxy */ null);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
return adapter.getProfileProxy(context, listener, BluetoothProfile.HEADSET);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private void onBluetoothReceiverReceive(Context context, Intent intent) {
|
|
88
|
-
final String action = intent.getAction();
|
|
89
|
-
|
|
90
|
-
if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) {
|
|
91
|
-
// XXX: This action will be fired when a Bluetooth headset is
|
|
92
|
-
// connected or disconnected to the system. This is not related to
|
|
93
|
-
// audio routing.
|
|
94
|
-
int state = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, -99);
|
|
95
|
-
|
|
96
|
-
switch (state) {
|
|
97
|
-
case BluetoothHeadset.STATE_CONNECTED:
|
|
98
|
-
case BluetoothHeadset.STATE_DISCONNECTED:
|
|
99
|
-
Log.d(TAG , " BT headset connection state changed: " + state);
|
|
100
|
-
updateDevices();
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
} else if (action.equals(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED)) {
|
|
104
|
-
// XXX: This action will be fired when the connection established
|
|
105
|
-
// with a Bluetooth headset (called a SCO connection) changes state.
|
|
106
|
-
// When the SCO connection is active we route audio to it.
|
|
107
|
-
int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -99);
|
|
108
|
-
|
|
109
|
-
switch (state) {
|
|
110
|
-
case AudioManager.SCO_AUDIO_STATE_CONNECTED:
|
|
111
|
-
case AudioManager.SCO_AUDIO_STATE_DISCONNECTED:
|
|
112
|
-
Log.d(TAG , " BT SCO connection state changed: " + state);
|
|
113
|
-
updateDevices();
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
private void registerBluetoothReceiver() {
|
|
120
|
-
receiver = new BroadcastReceiver() {
|
|
121
|
-
@Override
|
|
122
|
-
public void onReceive(Context context, Intent intent) {
|
|
123
|
-
onBluetoothReceiverReceive(context, intent);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
IntentFilter filter = new IntentFilter();
|
|
128
|
-
filter.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED);
|
|
129
|
-
filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
|
|
130
|
-
|
|
131
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
132
|
-
context.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED);
|
|
133
|
-
} else {
|
|
134
|
-
context.registerReceiver(receiver, filter);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Detects if there are new devices connected / disconnected and fires the
|
|
140
|
-
* {@link Listener} registered event.
|
|
141
|
-
*/
|
|
142
|
-
private void updateDevices() {
|
|
143
|
-
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
|
|
144
|
-
Log.w(TAG, "BLUETOOTH_CONNECT permission not granted. Unable to update Bluetooth devices.");
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
boolean headsetAvailable = (headset != null) && !headset.getConnectedDevices().isEmpty();
|
|
148
|
-
listener.onBluetoothDeviceChange(headsetAvailable);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
public void start() {
|
|
152
|
-
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
|
153
|
-
|
|
154
|
-
if (!audioManager.isBluetoothScoAvailableOffCall()) {
|
|
155
|
-
Log.w(TAG , " Bluetooth SCO is not available");
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (!getBluetoothHeadsetProfileProxy()) {
|
|
160
|
-
Log.w(TAG , " Couldn't get BT profile proxy");
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
registerBluetoothReceiver();
|
|
165
|
-
|
|
166
|
-
// Initial detection.
|
|
167
|
-
updateDevices();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
public void stop() {
|
|
171
|
-
if (receiver != null) {
|
|
172
|
-
context.unregisterReceiver(receiver);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (adapter != null && headset != null) {
|
|
176
|
-
adapter.closeProfileProxy(BluetoothProfile.HEADSET, headset);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
receiver = null;
|
|
180
|
-
headset = null;
|
|
181
|
-
adapter = null;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
interface Listener {
|
|
185
|
-
void onBluetoothDeviceChange(boolean deviceAvailable);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
package com.CometChatCalls;
|
|
2
|
-
|
|
3
|
-
import android.app.Notification;
|
|
4
|
-
import android.app.NotificationChannel;
|
|
5
|
-
import android.app.NotificationManager;
|
|
6
|
-
import android.app.PendingIntent;
|
|
7
|
-
import android.app.Service;
|
|
8
|
-
import android.content.Intent;
|
|
9
|
-
import android.content.pm.ServiceInfo;
|
|
10
|
-
import android.os.Build;
|
|
11
|
-
import android.os.IBinder;
|
|
12
|
-
import android.util.Log;
|
|
13
|
-
|
|
14
|
-
import androidx.annotation.Nullable;
|
|
15
|
-
import androidx.annotation.RequiresApi;
|
|
16
|
-
import androidx.core.app.NotificationCompat;
|
|
17
|
-
|
|
18
|
-
public class CallNotificationService extends Service {
|
|
19
|
-
|
|
20
|
-
private static final String CHANNEL_ID = "CALL_NOTIFICATION_CHANNEL";
|
|
21
|
-
private static final int NOTIFICATION_ID = 1;
|
|
22
|
-
private static long startingTime = 0;
|
|
23
|
-
|
|
24
|
-
@Override
|
|
25
|
-
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
26
|
-
createNotificationChannel();
|
|
27
|
-
Intent notificationIntent = new Intent(this, CallNotificationService.class);
|
|
28
|
-
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
|
|
29
|
-
if (startingTime == 0) {
|
|
30
|
-
startingTime = System.currentTimeMillis();
|
|
31
|
-
}
|
|
32
|
-
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
|
|
33
|
-
.setCategory(NotificationCompat.CATEGORY_CALL)
|
|
34
|
-
.setContentTitle("Ongoing Call")
|
|
35
|
-
.setContentText("Tap to return to the call")
|
|
36
|
-
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
|
37
|
-
.setSmallIcon(R.drawable.callingcomponent_icons_headphones_pluged)
|
|
38
|
-
.setContentIntent(pendingIntent)
|
|
39
|
-
.setOngoing(true)
|
|
40
|
-
.setWhen(startingTime)
|
|
41
|
-
.setUsesChronometer(true)
|
|
42
|
-
.setAutoCancel(false)
|
|
43
|
-
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
|
44
|
-
.setOnlyAlertOnce(true)
|
|
45
|
-
.build();
|
|
46
|
-
|
|
47
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
48
|
-
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK | ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE);
|
|
49
|
-
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
|
|
50
|
-
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
|
|
51
|
-
} else {
|
|
52
|
-
startForeground(NOTIFICATION_ID, notification);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return START_NOT_STICKY;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@Override
|
|
59
|
-
public void onDestroy() {
|
|
60
|
-
super.onDestroy();
|
|
61
|
-
stopSelf();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
static void resetStartingTime() {
|
|
66
|
-
startingTime = 0;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@Override
|
|
70
|
-
public void onTaskRemoved(Intent rootIntent) {
|
|
71
|
-
super.onTaskRemoved(rootIntent);
|
|
72
|
-
stopSelf();
|
|
73
|
-
CallNotificationServiceModule.sendEvent("onTaskRemoved", "onTaskRemoved");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@Nullable
|
|
77
|
-
@Override
|
|
78
|
-
public IBinder onBind(Intent intent) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private void createNotificationChannel() {
|
|
83
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
84
|
-
NotificationChannel serviceChannel = new NotificationChannel(
|
|
85
|
-
CHANNEL_ID,
|
|
86
|
-
"Call Notification Service",
|
|
87
|
-
NotificationManager.IMPORTANCE_DEFAULT
|
|
88
|
-
);
|
|
89
|
-
NotificationManager manager = getSystemService(NotificationManager.class);
|
|
90
|
-
manager.createNotificationChannel(serviceChannel);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
package com.CometChatCalls;
|
|
2
|
-
|
|
3
|
-
import android.content.Intent;
|
|
4
|
-
|
|
5
|
-
import androidx.annotation.NonNull;
|
|
6
|
-
|
|
7
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
9
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
10
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
11
|
-
|
|
12
|
-
public class CallNotificationServiceModule extends ReactContextBaseJavaModule {
|
|
13
|
-
|
|
14
|
-
public static ReactApplicationContext reactContext;
|
|
15
|
-
|
|
16
|
-
public CallNotificationServiceModule(ReactApplicationContext reactContext) {
|
|
17
|
-
super(reactContext);
|
|
18
|
-
CallNotificationServiceModule.reactContext = reactContext;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public static void sendEvent(String eventName, String message) {
|
|
22
|
-
if (reactContext != null) {
|
|
23
|
-
reactContext
|
|
24
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
25
|
-
.emit(eventName, message);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@NonNull
|
|
30
|
-
@Override
|
|
31
|
-
public String getName() {
|
|
32
|
-
return "CallNotificationService";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@ReactMethod
|
|
36
|
-
public void startService() {
|
|
37
|
-
Intent serviceIntent = new Intent(reactContext, CallNotificationService.class);
|
|
38
|
-
reactContext.startService(serviceIntent);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@ReactMethod
|
|
42
|
-
public void stopService() {
|
|
43
|
-
Intent serviceIntent = new Intent(reactContext, CallNotificationService.class);
|
|
44
|
-
reactContext.stopService(serviceIntent);
|
|
45
|
-
CallNotificationService.resetStartingTime();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2017 Henry Lin @zxcpoiu
|
|
3
|
-
*
|
|
4
|
-
* Permission to use, copy, modify, and distribute this software for any
|
|
5
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
-
* copyright notice and this permission notice appear in all copies.
|
|
7
|
-
*
|
|
8
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
-
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
-
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
-
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
package com.CometChatCalls;
|
|
18
|
-
|
|
19
|
-
import androidx.annotation.NonNull;
|
|
20
|
-
import androidx.annotation.NonNull;
|
|
21
|
-
import com.facebook.react.ReactPackage;
|
|
22
|
-
import com.facebook.react.bridge.JavaScriptModule;
|
|
23
|
-
import com.facebook.react.bridge.NativeModule;
|
|
24
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
25
|
-
import com.facebook.react.uimanager.ViewManager;
|
|
26
|
-
|
|
27
|
-
import java.util.ArrayList;
|
|
28
|
-
import java.util.ArrayList;
|
|
29
|
-
import java.util.Collections;
|
|
30
|
-
import java.util.List;
|
|
31
|
-
|
|
32
|
-
public class CometChatCallsPackage implements ReactPackage {
|
|
33
|
-
|
|
34
|
-
@NonNull
|
|
35
|
-
@Override
|
|
36
|
-
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
37
|
-
List<NativeModule> modules = new ArrayList<>();
|
|
38
|
-
modules.add(new AudioModeModule(reactContext));
|
|
39
|
-
modules.add(new CallNotificationServiceModule(reactContext));
|
|
40
|
-
modules.add(new PictureInPictureModule(reactContext));
|
|
41
|
-
modules.add(new CometChatCommonModule(reactContext));
|
|
42
|
-
return modules;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Deprecated RN 0.47
|
|
46
|
-
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
47
|
-
return Collections.emptyList();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@NonNull
|
|
51
|
-
@Override
|
|
52
|
-
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
53
|
-
return Collections.emptyList();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
package com.CometChatCalls;
|
|
2
|
-
|
|
3
|
-
import android.annotation.SuppressLint;
|
|
4
|
-
import android.app.Activity;
|
|
5
|
-
import android.content.Context;
|
|
6
|
-
import android.content.pm.ActivityInfo;
|
|
7
|
-
|
|
8
|
-
import androidx.annotation.NonNull;
|
|
9
|
-
|
|
10
|
-
import com.facebook.react.bridge.Promise;
|
|
11
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
13
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
14
|
-
|
|
15
|
-
public class CometChatCommonModule extends ReactContextBaseJavaModule {
|
|
16
|
-
public static final String NAME = "CometChatCommonModule";
|
|
17
|
-
public static final String TAG = NAME;
|
|
18
|
-
private final ReactApplicationContext mReactContext;
|
|
19
|
-
|
|
20
|
-
public int appOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
|
21
|
-
|
|
22
|
-
public CometChatCommonModule(@NonNull ReactApplicationContext reactContext) {
|
|
23
|
-
super(reactContext);
|
|
24
|
-
mReactContext = reactContext;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@NonNull
|
|
28
|
-
@Override
|
|
29
|
-
public String getName() {
|
|
30
|
-
return NAME;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@SuppressLint("SourceLockedOrientationActivity")
|
|
34
|
-
@ReactMethod
|
|
35
|
-
public void lockToPortrait() {
|
|
36
|
-
Activity currentActivity = getCurrentActivity();
|
|
37
|
-
if (currentActivity == null) return;
|
|
38
|
-
this.appOrientation = currentActivity.getRequestedOrientation();
|
|
39
|
-
currentActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@ReactMethod
|
|
43
|
-
public void unlockAllOrientations() {
|
|
44
|
-
Activity currentActivity = getCurrentActivity();
|
|
45
|
-
if (currentActivity == null) return;
|
|
46
|
-
currentActivity.setRequestedOrientation(this.appOrientation);
|
|
47
|
-
}
|
|
48
|
-
}
|