cordova-plugin-salus-call 0.2.2 → 0.2.3

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 CHANGED
@@ -7,7 +7,7 @@ Plugin proprietário do Salus para integrar a interface Cordova ao ciclo de vida
7
7
  ## Instalação
8
8
 
9
9
  ```xml
10
- <plugin name="cordova-plugin-salus-call" spec="0.2.2" />
10
+ <plugin name="cordova-plugin-salus-call" spec="0.2.3" />
11
11
  ```
12
12
 
13
13
  ## API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-salus-call",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Integração nativa de chamadas VoIP para o aplicativo Salus.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "engines": {
31
31
  "cordovaDependencies": {
32
- "0.2.2": {
32
+ "0.2.3": {
33
33
  "cordova": ">=12.0.0",
34
34
  "cordova-android": ">=14.0.0"
35
35
  }
package/plugin.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
3
3
  xmlns:android="http://schemas.android.com/apk/res/android"
4
4
  id="cordova-plugin-salus-call"
5
- version="0.2.2">
5
+ version="0.2.3">
6
6
  <name>Salus Call</name>
7
7
  <description>Ponte nativa para chamadas de interfone do Salus.</description>
8
8
  <license>UNLICENSED</license>
@@ -4,6 +4,7 @@ import android.content.Context;
4
4
  import android.content.Intent;
5
5
  import android.media.AudioAttributes;
6
6
  import android.media.AudioFocusRequest;
7
+ import android.media.AudioDeviceInfo;
7
8
  import android.media.AudioManager;
8
9
  import android.os.Build;
9
10
 
@@ -186,6 +187,7 @@ public class SalusCallPlugin extends CordovaPlugin {
186
187
  if (audioManager == null) return;
187
188
 
188
189
  audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
190
+ routeToEarpiece();
189
191
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
190
192
  AudioAttributes attributes = new AudioAttributes.Builder()
191
193
  .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
@@ -209,8 +211,26 @@ public class SalusCallPlugin extends CordovaPlugin {
209
211
  } else {
210
212
  audioManager.abandonAudioFocus(null);
211
213
  }
214
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
215
+ audioManager.clearCommunicationDevice();
216
+ } else {
217
+ audioManager.setSpeakerphoneOn(false);
218
+ }
212
219
  audioManager.setMode(AudioManager.MODE_NORMAL);
213
220
  audioFocusRequest = null;
214
221
  audioManager = null;
215
222
  }
223
+
224
+ private void routeToEarpiece() {
225
+ if (audioManager == null) return;
226
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
227
+ for (AudioDeviceInfo device : audioManager.getAvailableCommunicationDevices()) {
228
+ if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_EARPIECE) {
229
+ audioManager.setCommunicationDevice(device);
230
+ return;
231
+ }
232
+ }
233
+ }
234
+ audioManager.setSpeakerphoneOn(false);
235
+ }
216
236
  }