Closed Vivektilva closed 2 years ago
@Vivektilva
Can you provide device logs?
2022-03-24 15:21:31.706 11170-11170/com.callhippo.bueno.callhippo E/Dialer_Fragment: auto_switched_countryname:United States:+18474162145:tech twilio 2022-03-24 15:21:32.861 11170-11170/com.callhippo.bueno.callhippo D/twilio_login: Successfully registered FCM
2022-03-24 15:21:51.421 11170-11170/com.callhippo.bueno.callhippo E/incom_IncomingActivity: Call going to Receive_twilio: 2022-03-24 15:21:51.459 11170-11170/com.callhippo.bueno.callhippo E/twilio_incom_incomingcall: onConnectFailure Unable to answer because the call has ended. 2022-03-24 15:21:51.459 11170-11170/com.callhippo.bueno.callhippo E/twilio_incom_incomingcall: onConnectFailure_code Call Cancelled 2022-03-24 15:21:51.459 11170-11170/com.callhippo.bueno.callhippo E/twilio_incom_incomingcall: onConnectFailure_code1 null
@kbagchiGWC
Description In android OS version 12 , when incoming call notification comes and we receive calls from "ACCEPT" button from the notification , it gets disconnected in a second ,
It happens when we receive calls after 1st attempt , in first attempt , call is being received successfully but once app is closed and we reopen the app and try to get incoming call and click on "accept " , call don't get connected and in listener onConnectFailure event is being called instead of onConnected.
Steps to Reproduce Start the app and register for incoming calls keep app open in foreground or background Receive an incoming call Click on "Accept " button in notification .
Code I don't know which code is relevant to this issue, we got a lot of code that may be related, if you'll ask for specific snippet - I'll be happy to provide 🙏
Expected Behavior Call should get connected and onConnected listener should be called.
Actual Behavior
Listener onConnectFailure is being called and callException.getExplanation() = "Unable to answer because the call has ended."
Reproduces How Often Always
Voice Android SDK 6.0.2
OS Version Android 12 - so far, this only happened with Android 12
Device Model Google Pixel 6 (reproduced with other devices with Android 12 as well)
Attaching twilio debug log .
2022-03-24 18:05:18.010 21169-21169/com.callhippo.bueno.callhippo E/twilio_login: provider_twilio::
2022-03-24 18:05:29.140 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call create
2022-03-24 18:05:29.140 21169-21169/com.callhippo.bueno.callhippo I/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Creating peer connection signaling thread ...
2022-03-24 18:05:29.140 21169-21169/com.callhippo.bueno.callhippo I/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Creating peer connection worker thread ...
2022-03-24 18:05:29.140 21169-21169/com.callhippo.bueno.callhippo I/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Creating peer connection networking thread ...
2022-03-24 18:05:29.140 21169-21169/com.callhippo.bueno.callhippo I/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Creating media engine ...
2022-03-24 18:05:29.141 21169-21169/com.callhippo.bueno.callhippo I/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Done creating media engine.
2022-03-24 18:05:29.141 21169-21169/com.callhippo.bueno.callhippo I/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Creating peer connection factory ...
2022-03-24 18:05:29.142 21169-21169/com.callhippo.bueno.callhippo I/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Done creating peer connection factory.
2022-03-24 18:05:29.143 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call handleMessage
2022-03-24 18:05:29.144 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Selected edge - roaming Selected region - gll
2022-03-24 18:05:29.144 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Initializing SIP stack ...
2022-03-24 18:05:29.148 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Adding IPv4/IPv6 TLS transports ...
2022-03-24 18:05:29.148 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Selected edge - roaming Selected region - gll
2022-03-24 18:05:29.148 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Selected edge - roaming Selected region - gll
2022-03-24 18:05:29.149 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Initializing DUM ...
2022-03-24 18:05:29.149 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Starting SIP stack thread ...
2022-03-24 18:05:29.149 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Starting DUM thread ...
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call getSignalingThread
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call getNetworkingThread
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): <0xb40000782bdf3190> initializeThreadCheckers
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): <0xb40000782bdf3190> initialize
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): <0xb4000077dbcee390> Starting the Network Manager
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): <0xb4000077bbd115d0> RtcMonitor
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call getFrom
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): listen
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call getFrom
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call getTo
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call getCallSid
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call getFrom
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call getTo
2022-03-24 18:05:29.150 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): API Call getCallSid
2022-03-24 18:05:29.151 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): ListenerImpl
2022-03-24 18:05:29.151 21169-21169/com.callhippo.bueno.callhippo D/Twilio: [Core](Thread 0x0xb4000077ebcdb4f0): Started listen no-op timer for 40000 ms
2022-03-24 18:05:29.151 21169-21777/com.callhippo.bueno.callhippo D/Twilio: [Core](MediaFactoryImpl::signaling 0x0xb40000779bd2b6c0): twilio::voice::AsyncDnsResolver::AsyncDnsResolver(std::weak_ptr
when i try to accept the call using callInvite1.accept(IncomingActivity.this,callListener); I am getting following in twilio debug logs :
com.callhippo.bueno.callhippo D/InternalCall: Attempted to accept CallInvite that was previously accepted,rejected, or cancelled.
This is the event we see at the Voice Insights for the call sid CA14e2787b727948768842533bfcb37e33
Call was received on two devices and then got cancelled (timeout)after ~25 seconds. If attempt to accept was after the call got cancelled - onConnectFailure() is expected.
We looked at the TwiML used for this call:
<Response><Dial callerId="+1xxxxxxxxxx" answerOnBridge="true" action="https://call.callhippo.com/api/v2/smartaction/twilio" timeLimit="5400" timeout="20" record="do-not-record" recordingTrack="both" recordingStatusCallback="https://call.callhippo.com/......">
........
Can you increase the timeout value to a higher value, i.e. 40 and retry?
we fixed above issue , now our endpoint is logged into one device only . While debugging more on this I found that call sid which i am getting in firebase notification for incoming call and call sid on which i try to accept call is different , while i call callinvite.accept() function , previous call's callinvite is going and that is the reason for that error of com.callhippo.bueno.callhippo D/InternalCall: Attempted to accept CallInvite that was previously accepted,rejected, or cancelled.
I am passing call invite from firebase service to incoming call activity via intent , can you please check that code and let me know if i am missing something .
Firebase code
if(remoteMessage.getData().containsKey("twi_account_sid"))
{
Voice.handleMessage(context,data,new MessageListener() {
@Override
public void onCallInvite(@NonNull CallInvite callInvite) {
Log.e(TAG,"onCallInvite:"+callInvite.getCallSid());
String from=callInvite.getFrom();
Log.e(TAG,"tw_from:"+from);
sendNotification_ongoing_call_twilio(displayNum,"Incoming call",callInvite);
}
@Override
public void onCancelledCallInvite(@NonNull CancelledCallInvite cancelledCallInvite, @Nullable CallException callException) {
Log.e(TAG,"onCancelledCallInvite"+cancelledCallInvite.getCallSid());
try
{
String ac_sid=sharedPreferences.getString("tw_activecall_sid","");
Log.e(TAG,"onCancelledCallInvite_activecall"+ac_sid);
Log.e(TAG,"call_cancelled_notify");
if(ac_sid.equalsIgnoreCase(""))
{
Intent intent = new Intent(tw_NOTIFICATION);
intent.putExtra("tw_actionname", "tw_call_cancelled");
sendBroadcast(intent);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if(notificationManager!=null){notificationManager.cancel(410);}
try{mRingTone_10.stop();}catch(Exception e){}
}
}
catch (Exception e){}
}
});
}
}
catch (Exception e){}
}
void sendNotification_ongoing_call_twilio(String messageBody,String title,CallInvite callInvite)
{
Intent intent2 = new Intent(getApplicationContext(),IncomingActivity.class);
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent2.putExtra("tw_actionname", "tw_call_incoming_accept");
intent2.putExtra("tw_callInvite", callInvite);
intent2.putExtra("Incomingnumber", callNumber);
intent2.putExtra("Incoming_uid", "");
intent2.putExtra("is_accept","true");
Log.e(TAG,"call_accepted_button_clicked0");
PendingIntent pIntent2 = PendingIntent.getActivity(this, 201, intent2, PendingIntent.FLAG_IMMUTABLE);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID2, "My Notifications2", NotificationManager.IMPORTANCE_HIGH);
AudioAttributes attributes = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.build();
// Configure the notification channel.
notificationChannel.setDescription("Call notification");
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.RED);
notificationChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
notificationChannel.enableVibration(true);
notificationManager.createNotificationChannel(notificationChannel);
}
Bitmap icon = BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_launcher_v2);
androidx.core.app.NotificationCompat.Builder builder = new androidx.core.app.NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID2)
// .setVibrate(new long[]{0, 100, 100, 100, 100, 100})
// .setSound(uri)
// .setSound(null)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE))
.setSmallIcon(R.drawable.usernumber_logo_v2)
.setContentTitle(title)
.setContentText(messageBody)
// .setContentIntent(pIntent)
.setLargeIcon(icon)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_CALL)
// .addAction(R.drawable.icon_call_frwd1, "pick up",
// pIntent)
.addAction(R.color.colorPrimary, "DISMISS", pIntent3)
.addAction(R.color.colorPrimary, "ACCEPT", pIntent2)
.setAutoCancel(true)
.setFullScreenIntent(pIntent,true);
notificationManager.notify(notification_id, builder.build());
}
}
On incomingActivity.java i am doing following callInvite1=intentcall.getParcelableExtra("tw_callInvite"); callInvite1.accept(IncomingActivity.this,callListener);
Note : it was working until i set PendingIntent.FLAG_IMMUTABLE , previously it was PendingIntent.FLAG_UPDATE_CURRENT
we fixed above issue , now our endpoint is logged into one device only . While debugging more on this I found that call sid which i am getting in firebase notification for incoming call and call sid on which i try to accept call is different , while i call callinvite.accept() function , previous call's callinvite is going and that is the reason for that error of com.callhippo.bueno.callhippo D/InternalCall: Attempted to accept CallInvite that was previously accepted,rejected, or cancelled.
I am passing call invite from firebase service to incoming call activity via intent , can you please check that code and let me know if i am missing something .
Firebase code
if(remoteMessage.getData().containsKey("twi_account_sid")) { Voice.handleMessage(context,data,new MessageListener() { @Override public void onCallInvite(@NonNull CallInvite callInvite) { Log.e(TAG,"onCallInvite:"+callInvite.getCallSid()); String from=callInvite.getFrom(); Log.e(TAG,"tw_from:"+from);
sendNotification_ongoing_call_twilio(displayNum,"Incoming call",callInvite);
}
@Override
public void onCancelledCallInvite(@NonNull CancelledCallInvite cancelledCallInvite, @Nullable CallException callException) {
Log.e(TAG,"onCancelledCallInvite"+cancelledCallInvite.getCallSid());
try
{
String ac_sid=sharedPreferences.getString("tw_activecall_sid","");
Log.e(TAG,"onCancelledCallInvite_activecall"+ac_sid);
Log.e(TAG,"call_cancelled_notify");
if(ac_sid.equalsIgnoreCase(""))
{
Intent intent = new Intent(tw_NOTIFICATION);
intent.putExtra("tw_actionname", "tw_call_cancelled");
sendBroadcast(intent);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if(notificationManager!=null){notificationManager.cancel(410);}
try{mRingTone_10.stop();}catch(Exception e){}
}
}
catch (Exception e){}
}
});
}
}
catch (Exception e){}
}
void sendNotification_ongoing_call_twilio(String messageBody,String title,CallInvite callInvite)
{
Intent intent2 = new Intent(getApplicationContext(),IncomingActivity.class);
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent2.putExtra("tw_actionname", "tw_call_incoming_accept");
intent2.putExtra("tw_callInvite", callInvite);
intent2.putExtra("Incomingnumber", callNumber);
intent2.putExtra("Incoming_uid", "");
intent2.putExtra("is_accept","true");
Log.e(TAG,"call_accepted_button_clicked0");
PendingIntent pIntent2 = PendingIntent.getActivity(this, 201, intent2, PendingIntent.FLAG_IMMUTABLE);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID2, "My Notifications2", NotificationManager.IMPORTANCE_HIGH);
AudioAttributes attributes = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.build();
// Configure the notification channel.
notificationChannel.setDescription("Call notification");
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.RED);
notificationChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
notificationChannel.enableVibration(true);
notificationManager.createNotificationChannel(notificationChannel);
}
Bitmap icon = BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_launcher_v2);
androidx.core.app.NotificationCompat.Builder builder = new androidx.core.app.NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID2)
// .setVibrate(new long[]{0, 100, 100, 100, 100, 100}) // .setSound(uri) // .setSound(null) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE)) .setSmallIcon(R.drawable.usernumber_logo_v2) .setContentTitle(title) .setContentText(messageBody) // .setContentIntent(pIntent) .setLargeIcon(icon) .setPriority(NotificationCompat.PRIORITY_HIGH) .setCategory(NotificationCompat.CATEGORY_CALL) // .addAction(R.drawable.icon_call_frwd1, "pick up", // pIntent) .addAction(R.color.colorPrimary, "DISMISS", pIntent3) .addAction(R.color.colorPrimary, "ACCEPT", pIntent2) .setAutoCancel(true) .setFullScreenIntent(pIntent,true); notificationManager.notify(notification_id, builder.build());
}
}
On incomingActivity.java i am doing following callInvite1=intentcall.getParcelableExtra("tw_callInvite"); callInvite1.accept(IncomingActivity.this,callListener);
Note : it was working until i set PendingIntent.FLAG_IMMUTABLE , previously it was PendingIntent.FLAG_UPDATE_CURRENT
https://www.flybuy.com/android-12-pendingintent-mutability-and-geofences refer this, and make FLAG_MUTABLE
Closing the issue as it was answered by @sonubabu7373. Thanks.
When we receive call with callInvite.accept(IncomingActivity.this,callListener);
and in listener onConnectFailure is being called when i call above function and callException.getExplanation() = Unable to answer because the call has ended. callException.getMessage() = Call Cancelled.
Note : when I run the same code with OS 11 (targetSdkVersion 30) it is working properly but when I run this code with (targetSdkVersion 31) above erroe comes
I am using 'com.twilio:voice-android:5.6.3'