android.telecom.PhoneAccount Java Examples
The following examples show how to use
android.telecom.PhoneAccount.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RNCallKeepModule.java From react-native-callkeep with ISC License | 7 votes |
@ReactMethod public void startCall(String uuid, String number, String callerName) { if (!isConnectionServiceAvailable() || !hasPhoneAccount() || !hasPermissions() || number == null) { return; } Log.d(TAG, "startCall number: " + number + ", callerName: " + callerName); Bundle extras = new Bundle(); Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null); Bundle callExtras = new Bundle(); callExtras.putString(EXTRA_CALLER_NAME, callerName); callExtras.putString(EXTRA_CALL_UUID, uuid); callExtras.putString(EXTRA_CALL_NUMBER, number); extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle); extras.putParcelable(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, callExtras); telecomManager.placeCall(uri, extras); }
Example #2
Source File: SubscriptionManager.java From GravityBox with Apache License 2.0 | 7 votes |
private PhoneAccountHandle subscriptionToPhoneAccountHandle(final SubscriptionInfo subInfo) { if (subInfo == null) return null; final TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); final Iterator<PhoneAccountHandle> phoneAccounts = telecomManager.getCallCapablePhoneAccounts().listIterator(); while (phoneAccounts.hasNext()) { final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next(); final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle); if (subInfo.getSubscriptionId() == getSubIdForPhoneAccount(telephonyManager, phoneAccount)) { return phoneAccountHandle; } } return null; }
Example #3
Source File: RNCallKeepModule.java From react-native-callkeep with ISC License | 6 votes |
@ReactMethod public void displayIncomingCall(String uuid, String number, String callerName) { if (!isConnectionServiceAvailable() || !hasPhoneAccount()) { return; } Log.d(TAG, "displayIncomingCall number: " + number + ", callerName: " + callerName); Bundle extras = new Bundle(); Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, 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); }
Example #4
Source File: RNCallKeepModule.java From react-native-callkeep with ISC License | 6 votes |
private void registerPhoneAccount(Context appContext) { if (!isConnectionServiceAvailable()) { return; } ComponentName cName = new ComponentName(this.getAppContext(), VoiceConnectionService.class); String appName = this.getApplicationName(appContext); handle = new PhoneAccountHandle(cName, appName); PhoneAccount.Builder builder = new PhoneAccount.Builder(handle, appName) .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER); if (_settings != null && _settings.hasKey("imageName")) { int identifier = appContext.getResources().getIdentifier(_settings.getString("imageName"), "drawable", appContext.getPackageName()); Icon icon = Icon.createWithResource(appContext, identifier); builder.setIcon(icon); } PhoneAccount account = builder.build(); telephonyManager = (TelephonyManager) this.getAppContext().getSystemService(Context.TELEPHONY_SERVICE); telecomManager = (TelecomManager) this.getAppContext().getSystemService(Context.TELECOM_SERVICE); telecomManager.registerPhoneAccount(account); }
Example #5
Source File: SubscriptionManager.java From GravityBox with Apache License 2.0 | 6 votes |
private List<IIconListAdapterItem> getSubItemList(final SubType subType) { List<IIconListAdapterItem> list = new ArrayList<>(); if (subType == SubType.VOICE) { list.add(new SubListItem(null)); final TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); final Iterator<PhoneAccountHandle> phoneAccounts = telecomManager.getCallCapablePhoneAccounts().listIterator(); while (phoneAccounts.hasNext()) { final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccounts.next()); int subId = getSubIdForPhoneAccount(telephonyManager, phoneAccount); if (subId != -1) { list.add(new SubListItem(mSubMgr.getActiveSubscriptionInfo(subId))); } } } else { for (SubscriptionInfo si : mSubMgr.getActiveSubscriptionInfoList()) if (si != null) list.add(new SubListItem(si)); } return list; }
Example #6
Source File: SubscriptionManager.java From GravityBox with Apache License 2.0 | 6 votes |
private int getDefaultVoiceSubscriptionSimSlot() { try { final TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); PhoneAccountHandle pah = (PhoneAccountHandle) XposedHelpers.callMethod(telecomManager, "getUserSelectedOutgoingPhoneAccount"); if (pah != null) { PhoneAccount pa = telecomManager.getPhoneAccount(pah); int subId = getSubIdForPhoneAccount(telephonyManager, pa); SubscriptionInfo si = mSubMgr.getActiveSubscriptionInfo(subId); if (si != null) { return si.getSimSlotIndex(); } } return -1; } catch (Throwable t) { XposedBridge.log(t); return -1; } }
Example #7
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.O) protected PhoneAccountHandle addAccountToTelecomManager(){ TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE); TLRPC.User self=UserConfig.getInstance(currentAccount).getCurrentUser(); PhoneAccountHandle handle=new PhoneAccountHandle(new ComponentName(this, TelegramConnectionService.class), ""+self.id); PhoneAccount account=new PhoneAccount.Builder(handle, ContactsController.formatName(self.first_name, self.last_name)) .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED) .setIcon(Icon.createWithResource(this, R.drawable.ic_launcher)) .setHighlightColor(0xff2ca5e0) .addSupportedUriScheme("sip") .build(); tm.registerPhoneAccount(account); return handle; }
Example #8
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.O) protected PhoneAccountHandle addAccountToTelecomManager(){ TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE); TLRPC.User self=UserConfig.getInstance(currentAccount).getCurrentUser(); PhoneAccountHandle handle=new PhoneAccountHandle(new ComponentName(this, TelegramConnectionService.class), ""+self.id); PhoneAccount account=new PhoneAccount.Builder(handle, ContactsController.formatName(self.first_name, self.last_name)) .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED) .setIcon(Icon.createWithResource(this, R.drawable.ic_launcher)) .setHighlightColor(0xff2ca5e0) .addSupportedUriScheme("sip") .build(); tm.registerPhoneAccount(account); return handle; }
Example #9
Source File: SubscriptionManager.java From GravityBox with Apache License 2.0 | 5 votes |
private int getSubIdForPhoneAccount(final TelephonyManager tm, final PhoneAccount account) { try { return (int) XposedHelpers.callMethod(tm, "getSubIdForPhoneAccount", account); } catch (Throwable t) { XposedBridge.log(t); return -1; } }
Example #10
Source File: VoIPBaseService.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.O) protected PhoneAccountHandle addAccountToTelecomManager(){ TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE); TLRPC.User self=UserConfig.getInstance(currentAccount).getCurrentUser(); PhoneAccountHandle handle=new PhoneAccountHandle(new ComponentName(this, TelegramConnectionService.class), ""+self.id); PhoneAccount account=new PhoneAccount.Builder(handle, ContactsController.formatName(self.first_name, self.last_name)) .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED) .setIcon(Icon.createWithResource(this, R.drawable.ic_launcher_dr)) .setHighlightColor(0xff2ca5e0) .addSupportedUriScheme("sip") .build(); tm.registerPhoneAccount(account); return handle; }
Example #11
Source File: VoIPBaseService.java From Telegram with GNU General Public License v2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.O) protected PhoneAccountHandle addAccountToTelecomManager(){ TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE); TLRPC.User self=UserConfig.getInstance(currentAccount).getCurrentUser(); PhoneAccountHandle handle=new PhoneAccountHandle(new ComponentName(this, TelegramConnectionService.class), ""+self.id); PhoneAccount account=new PhoneAccount.Builder(handle, ContactsController.formatName(self.first_name, self.last_name)) .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED) .setIcon(Icon.createWithResource(this, R.drawable.ic_launcher_dr)) .setHighlightColor(0xff2ca5e0) .addSupportedUriScheme("sip") .build(); tm.registerPhoneAccount(account); return handle; }