|
52 | 52 | import com.twilio.voice.RegistrationListener; |
53 | 53 | import com.twilio.voice.Voice; |
54 | 54 |
|
| 55 | +import java.util.HashSet; |
| 56 | +import java.util.Locale; |
| 57 | +import java.util.Set; |
55 | 58 | import java.util.HashMap; |
56 | 59 | import java.util.Map; |
57 | 60 | import java.util.List; |
@@ -379,6 +382,34 @@ public void onConnectFailure(@NonNull Call call, CallException error) { |
379 | 382 | toName = ""; |
380 | 383 | activeCallInvite = null; |
381 | 384 | } |
| 385 | + |
| 386 | + /* |
| 387 | + * currentWarnings: existing quality warnings that have not been cleared yet |
| 388 | + * previousWarnings: last set of warnings prior to receiving this callback |
| 389 | + * |
| 390 | + * Example: |
| 391 | + * - currentWarnings: { A, B } |
| 392 | + * - previousWarnings: { B, C } |
| 393 | + * |
| 394 | + * Newly raised warnings = currentWarnings - intersection = { A } |
| 395 | + * Newly cleared warnings = previousWarnings - intersection = { C } |
| 396 | + */ |
| 397 | + public void onCallQualityWarningsChanged(@NonNull Call call, |
| 398 | + @NonNull Set<Call.CallQualityWarning> currentWarnings, |
| 399 | + @NonNull Set<Call.CallQualityWarning> previousWarnings) { |
| 400 | + if (previousWarnings.size() > 1) { |
| 401 | + Set<Call.CallQualityWarning> intersection = new HashSet<>(currentWarnings); |
| 402 | + currentWarnings.removeAll(previousWarnings); |
| 403 | + intersection.retainAll(previousWarnings); |
| 404 | + previousWarnings.removeAll(intersection); |
| 405 | + } |
| 406 | + String message = String.format( |
| 407 | + Locale.US, |
| 408 | + "Newly raised warnings: " + currentWarnings + " Clear warnings " + previousWarnings); |
| 409 | + Log.e(TAG, message); |
| 410 | + |
| 411 | + // TODO send event to JS |
| 412 | + } |
382 | 413 | }; |
383 | 414 | } |
384 | 415 |
|
@@ -522,6 +553,9 @@ private void handleStartActivityIntent(Intent intent) { |
522 | 553 |
|
523 | 554 | case Constants.ACTION_OPEN_CALL_IN_PROGRESS: |
524 | 555 | // the notification already brings the activity to the top |
| 556 | + if (activeCall == null) { |
| 557 | + callNotificationManager.removeHangupNotification(getReactApplicationContext()); |
| 558 | + } |
525 | 559 | break; |
526 | 560 |
|
527 | 561 | default: |
|
0 commit comments