Subscription preference

Notification emails are sent to your Samsung account email address.

* Email : anonymous@samsung.com

  

Close

I'm trying to implement android class ConnectionService for voip calls.

Forums View
Started by Newbie xxxak**** , 120 Seed Jul 06, 2017 06:35 Replies : 1 View : 2557 Likes : 0
I'm trying to implement android class ConnectionService for voip calls.
Registering the phone account:


Code

 TelecomManager tm = (TelecomManager) 
getSystemService(Context.TELECOM_SERVICE);
                PhoneAccountHandle phoneAccountHandle = new 
PhoneAccountHandle(
                        new ComponentName(getApplicationContext(), 
ConnectionService33.class), "sample");
                PhoneAccount phoneAccount = 
PhoneAccount.builder(phoneAccountHandle, "sample")
                        .setShortDescription("sample")
                        .addSupportedUriScheme(PhoneAccount.SCHEME_TEL)
                        .setSupportedUriSchemes(Arrays.asList("tel"))

.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
                        .setIcon(Icon.createWithResource(MainActivity.this, 
R.drawable.ic_action_name))
                        .build();
tm.registerPhoneAccount(phoneAccount);
                    if (Build.MANUFACTURER.equalsIgnoreCase("Samsung")) {
                        Intent intent = new Intent();
                        intent.setComponent(new 
   ComponentName("com.android.server.telecom",

 "com.android.server.telecom.settings.EnableAccountPreferenceActivity"));
                        startActivity(intent);
                    } else {
                        startActivity(new 
Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS));
                    }

Placing the call:

Code

 TelecomManager tm = (TelecomManager) 
getSystemService(Context.TELECOM_SERVICE);
                PhoneAccountHandle phoneAccountHandle = new 
PhoneAccountHandle(
                        new ComponentName(getApplicationContext(), 
ConnectionService33.class), "sample");
                Bundle extras = new Bundle();
                Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, 
 "999999999", null);

extras.putParcelable(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, uri);

extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, uri);

extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, 
phoneAccountHandle);
//tm.addNewIncomingCall(phoneAccountHandle, extras);
tm.placeCall(uri, extras);


 My ConnectionService

Code

  @Override
 public Connection onCreateIncomingConnection(PhoneAccountHandle 
  connectionManagerPhoneAccount, ConnectionRequest request) {
    Log.d(TAG,"onCreateIncomingConnection");
    Log.d(TAG,"incomong call = " + request.getAddress().toString());
    TConnection tConnection = new TConnection(this);
    tConnection.setAddress(request. getAddress(),TelecomManager. 
     PRESENTATION_ALLOWED);
    tConnection.setAudioModeIsVoip(true);
    tConnection.setConnectionCapabilities(Connection.CAPABILITY_MUTE);
    tConnection.setInitializing();
    return tConnection;
}

@Override
public Connection onCreateOutgoingConnection(PhoneAccountHandle 
 connectionManagerPhoneAccount, ConnectionRequest request) {
    Log.d(TAG,"onCreateOutgoingConnection");
    Log.d(TAG,"outgoing call = " + request.getAddress().toString());
    TConnection tConnection = new TConnection(this);
    tConnection.setAddress(request.getAddress(),TelecomManager. 
   PRESENTATION_ALLOWED);
    tConnection.setAudioModeIsVoip(true);
    tConnection.setConnectionCapabilities(Connection.CAPABILITY_MUTE);
    tConnection.setInitializing();
    return tConnection;
}


 
 placing incoming and outgouing from app works correctly

when click dial button in device dialpad (Nexus)


when click dial button in samsung devices Error in samsung phone app : Unfortunately, Phone has stopped

Code

 D/InCallUtilsMultiSIM: getSimIconIndex: simidx =-1 returnValue-1
05-29 12:43:49.595 31474-31474/? D/AndroidRuntime: Shutting down VM
05-29 12:43:49.605 31474-31474/? E/AndroidRuntime: FATAL EXCEPTION: main
                                               Process: 
com.android.incallui, 
PID: 31474

java.lang.ArrayIndexOutOfBoundsException: length=9; index=-1
                                                   at 
com.android.incallui.InCallUtilsMultiSIM. 
getSimImage(InCallUtilsMultiSIM.java:391)at
com.android.incallui.SelectPhoneSimAccountDialogFragment 
$SelectAccountListAdapter.getView 
(SelectPhoneSimAccountDialogFragment.java:154)
                                                   at 
android.widget.AbsListView.obtainView(AbsListView.java:2929)
                                                   at 
android.widget.ListView.measureHeightOfChildren(ListView.java:1305)
                                                   at 
android.widget.ListView.onMeasure(ListView.java:1212)
                                                   at 
android.view.View.measure(View.java:20151)


 


Tags

android

Post Reply
Board View
Newbie mo**** , 220 Seed Sep 05, 2017 08:28 Post #1 0
Hi there, have you had any luck getting this working?

I'm encountering similar behaviour for Samsung phones but not for phones running Vanilla Android.
Post Reply