System managed connection - place inbound call process
first i initialzed the telecom manager
private void initializeTelecomManager(){
Context context=this.getAppContext();
ComponentName cName = new ComponentName(context, VoiceConnectionService.class);
String appName=this.getApplicationName(context);
handle = new PhoneAccountHandle(cName, appName);
telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
}
then register the phone account handler
this.initializeTelecomManager();
String appName = this.getApplicationName(this.getAppContext());
PhoneAccount.Builder builder = new PhoneAccount.Builder(handle, appName)
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER);
PhoneAccount account = builder.build();
telephonyManager = (TelephonyManager) this.getAppContext().getSystemService(Context.TELEPHONY_SERVICE);
telecomManager.registerPhoneAccount(account);
but whenever i tried to mock add incoming call it says -:
Phone Account Handle is not enabled for this user
Bundle extras = new Bundle();
Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, "1234567890", null);
extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, uri);
extras.putString("EXTRA_CALLER_NAME", callerName);
extras.putString("EXTRA_CALL_UUID", uuid);
telecomManager.addNewIncomingCall(handle, extras);