android.telecom.TelecomManager Java Examples
The following examples show how to use
android.telecom.TelecomManager.
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: 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 #4
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 #5
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 #6
Source File: Utilities.java From call_manage with MIT License | 6 votes |
/** * Check if koler is set as the default dialer app * * @param activity * @return boolean */ public static boolean checkDefaultDialer(FragmentActivity activity) { String packageName = activity.getApplication().getPackageName(); try { if (!activity.getSystemService(TelecomManager.class).getDefaultDialerPackage().equals(packageName)) { // Prompt the user with a dialog to select this app to be the default phone app Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER) .putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, packageName); activity.startActivityForResult(intent, DEFAULT_DIALER_RC); return false; } return true; } catch (Exception e) { return false; } }
Example #7
Source File: DialerActivity.java From BaldPhone with Apache License 2.0 | 6 votes |
@SuppressLint("NewApi") public static void call(final CharSequence number, final Context context, SubscriptionInfo subscriptionInfo) { try { if (subscriptionInfo == null) { context.startActivity(new Intent(Intent.ACTION_CALL).setData(Uri.parse(("tel:" + number).replace("#", Uri.encode("#"))))); } else { final TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); final List<PhoneAccountHandle> list = telecomManager.getCallCapablePhoneAccounts(); for (final PhoneAccountHandle phoneAccountHandle : list) { if (phoneAccountHandle.getId().contains(subscriptionInfo.getIccId())) { context.startActivity(new Intent(Intent.ACTION_CALL).setData(Uri.parse(("tel:" + number).replace("#", Uri.encode("#")))) .putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", (Parcelable) phoneAccountHandle)); return; } } BaldToast.error(context); } } catch (SecurityException e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); throw new RuntimeException(e); } }
Example #8
Source File: VoIPService.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.O) @Override public CallConnection getConnectionAndStartCall(){ if(systemCallConnection==null){ if(BuildVars.LOGS_ENABLED) FileLog.d("creating call connection"); systemCallConnection=new CallConnection(); systemCallConnection.setInitializing(); if(isOutgoing){ delayedStartOutgoingCall=new Runnable(){ @Override public void run(){ delayedStartOutgoingCall=null; startOutgoingCall(); } }; AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000); } systemCallConnection.setCallerDisplayName(ContactsController.formatName(user.first_name, user.last_name), TelecomManager.PRESENTATION_ALLOWED); } return systemCallConnection; }
Example #9
Source File: VoIPService.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.O) @Override public CallConnection getConnectionAndStartCall(){ if(systemCallConnection==null){ if(BuildVars.LOGS_ENABLED) FileLog.d("creating call connection"); systemCallConnection=new CallConnection(); systemCallConnection.setInitializing(); if(isOutgoing){ delayedStartOutgoingCall=new Runnable(){ @Override public void run(){ delayedStartOutgoingCall=null; startOutgoingCall(); } }; AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000); } systemCallConnection.setCallerDisplayName(ContactsController.formatName(user.first_name, user.last_name), TelecomManager.PRESENTATION_ALLOWED); } return systemCallConnection; }
Example #10
Source File: LockTaskController.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private boolean isEmergencyCallTask(TaskRecord task) { final Intent intent = task.intent; if (intent == null) { return false; } // 1. The emergency keypad activity launched on top of the keyguard if (EMERGENCY_DIALER_COMPONENT.equals(intent.getComponent())) { return true; } // 2. The intent sent by the keypad, which is handled by Telephony if (ACTION_CALL_EMERGENCY.equals(intent.getAction())) { return true; } // 3. Telephony then starts the default package for making the call final TelecomManager tm = getTelecomManager(); final String dialerPackage = tm != null ? tm.getSystemDialerPackage() : null; if (dialerPackage != null && dialerPackage.equals(intent.getComponent().getPackageName())) { return true; } return false; }
Example #11
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 #12
Source File: VoIPService.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.O) @Override public CallConnection getConnectionAndStartCall(){ if(systemCallConnection==null){ if(BuildVars.LOGS_ENABLED) FileLog.d("creating call connection"); systemCallConnection=new CallConnection(); systemCallConnection.setInitializing(); if(isOutgoing){ delayedStartOutgoingCall=new Runnable(){ @Override public void run(){ delayedStartOutgoingCall=null; startOutgoingCall(); } }; AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000); } systemCallConnection.setAddress(Uri.fromParts("tel", "+99084"+user.id, null), TelecomManager.PRESENTATION_ALLOWED); systemCallConnection.setCallerDisplayName(ContactsController.formatName(user.first_name, user.last_name), TelecomManager.PRESENTATION_ALLOWED); } return systemCallConnection; }
Example #13
Source File: VoIPService.java From Telegram with GNU General Public License v2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.O) @Override public CallConnection getConnectionAndStartCall(){ if(systemCallConnection==null){ if(BuildVars.LOGS_ENABLED) FileLog.d("creating call connection"); systemCallConnection=new CallConnection(); systemCallConnection.setInitializing(); if(isOutgoing){ delayedStartOutgoingCall=new Runnable(){ @Override public void run(){ delayedStartOutgoingCall=null; startOutgoingCall(); } }; AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000); } systemCallConnection.setAddress(Uri.fromParts("tel", "+99084"+user.id, null), TelecomManager.PRESENTATION_ALLOWED); systemCallConnection.setCallerDisplayName(ContactsController.formatName(user.first_name, user.last_name), TelecomManager.PRESENTATION_ALLOWED); } return systemCallConnection; }
Example #14
Source File: SubscriptionManager.java From GravityBox with Apache License 2.0 | 5 votes |
private boolean setDefaultVoiceSubscription(final SubscriptionInfo subInfo) { try { final TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); XposedHelpers.callMethod(telecomManager, "setUserSelectedOutgoingPhoneAccount", subscriptionToPhoneAccountHandle(subInfo)); return true; } catch (Throwable t) { XposedBridge.log(t); return false; } }
Example #15
Source File: RNCallKeepModule.java From react-native-callkeep with ISC License | 5 votes |
@ReactMethod public void openPhoneAccountSettings() { if (!isConnectionServiceAvailable()) { return; } Intent intent = new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); this.getAppContext().startActivity(intent); }
Example #16
Source File: CallFeatures.java From GravityBox with Apache License 2.0 | 5 votes |
private void silenceRinger() { try { TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); tm.silenceRinger(); } catch(Throwable t) { XposedBridge.log(t); } }
Example #17
Source File: CallBroadcastReceiver.java From BlackList with Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") private void breakCallPieAndHigher(Context context) { Log.d(TAG, "Trying to break call for Pie and higher with TelecomManager."); TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); try { telecomManager.getClass().getMethod("endCall").invoke(telecomManager); Log.d(TAG, "Invoked 'endCall' on TelecomManager."); } catch (Exception e) { Log.e(TAG, "Could not end call. Check stdout for more info."); e.printStackTrace(); } }
Example #18
Source File: Utils.java From GravityBox with Apache License 2.0 | 5 votes |
public static String getDefaultDialerPackageName(Context ctx) { if (mDefaultDialerPkgName == null) { try { TelecomManager tm = (TelecomManager) ctx.getSystemService(Context.TELECOM_SERVICE); mDefaultDialerPkgName = tm.getDefaultDialerPackage(); } catch (Throwable t) { t.printStackTrace(); } } return mDefaultDialerPkgName; }
Example #19
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 #20
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 #21
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; }
Example #22
Source File: VoiceConnection.java From react-native-callkeep with ISC License | 5 votes |
VoiceConnection(Context context, HashMap<String, String> handle) { super(); this.handle = handle; this.context = context; String number = handle.get(EXTRA_CALL_NUMBER); String name = handle.get(EXTRA_CALLER_NAME); if (number != null) { setAddress(Uri.parse(number), TelecomManager.PRESENTATION_ALLOWED); } if (name != null && !name.equals("")) { setCallerDisplayName(name, TelecomManager.PRESENTATION_ALLOWED); } }
Example #23
Source File: USSDController.java From VoIpUSSD with Apache License 2.0 | 5 votes |
/** * get action call Intent * * @param uri parsed uri to call * @param simSlot simSlot number to use */ @SuppressLint("MissingPermission") private Intent getActionCallIntent(Uri uri, int simSlot) { // https://stackoverflow.com/questions/25524476/make-call-using-a-specified-sim-in-a-dual-sim-device final String simSlotName[] = { "extra_asus_dial_use_dualsim", "com.android.phone.extra.slot", "slot", "simslot", "sim_slot", "subscription", "Subscription", "phone", "com.android.phone.DialingMode", "simSlot", "slot_id", "simId", "simnum", "phone_type", "slotId", "slotIdx" }; Intent intent = new Intent(Intent.ACTION_CALL, uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("com.android.phone.force.slot", true); intent.putExtra("Cdma_Supp", true); for (String s : simSlotName) intent.putExtra(s, simSlot); TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); if (telecomManager != null) { List<PhoneAccountHandle> phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts(); if (phoneAccountHandleList != null && phoneAccountHandleList.size() > simSlot) intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", phoneAccountHandleList.get(simSlot)); } return intent; }
Example #24
Source File: TelecomLoaderService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void updateSimCallManagerPermissions(PackageManagerInternal packageManagerInternal, int userId) { TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); PhoneAccountHandle phoneAccount = telecomManager.getSimCallManager(userId); if (phoneAccount != null) { Slog.i(TAG, "updating sim call manager permissions for userId:" + userId); String packageName = phoneAccount.getComponentName().getPackageName(); packageManagerInternal.grantDefaultPermissionsToDefaultSimCallManager( packageName, userId); } }
Example #25
Source File: NotificationComparator.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private boolean isDefaultPhoneApp(String pkg) { if (mDefaultPhoneApp == null) { final TelecomManager telecomm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); mDefaultPhoneApp = telecomm != null ? telecomm.getDefaultDialerPackage() : null; } return Objects.equals(pkg, mDefaultPhoneApp); }
Example #26
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 #27
Source File: RNCallKeepModule.java From react-native-callkeep with ISC License | 5 votes |
@ReactMethod public void updateDisplay(String uuid, String displayName, String uri) { Connection conn = VoiceConnectionService.getConnection(uuid); if (conn == null) { return; } conn.setAddress(Uri.parse(uri), TelecomManager.PRESENTATION_ALLOWED); conn.setCallerDisplayName(displayName, TelecomManager.PRESENTATION_ALLOWED); }
Example #28
Source File: LockTaskController.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Nullable private TelecomManager getTelecomManager() { if (mTelecomManager == null) { // We don't preserve the TelecomManager object to save memory return mContext.getSystemService(TelecomManager.class); } return mTelecomManager; }
Example #29
Source File: ZenModeFiltering.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private boolean isDefaultPhoneApp(String pkg) { if (mDefaultPhoneApp == null) { final TelecomManager telecomm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); mDefaultPhoneApp = telecomm != null ? telecomm.getDefaultPhoneApp() : null; if (DEBUG) Slog.d(TAG, "Default phone app: " + mDefaultPhoneApp); } return pkg != null && mDefaultPhoneApp != null && pkg.equals(mDefaultPhoneApp.getPackageName()); }
Example #30
Source File: SystemServiceRegistry.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public TelecomManager createService(ContextImpl ctx) { return new TelecomManager(ctx.getOuterContext()); }