use of android.telecom.TelecomManager in project android_packages_apps_Dialer by LineageOS.
the class CallUtil method isCallWithSubjectSupported.
/**
* Determines if one of the call capable phone accounts defined supports calling with a subject
* specified.
*
* @param context The context.
* @return {@code true} if one of the call capable phone accounts supports calling with a subject
* specified, {@code false} otherwise.
*/
public static boolean isCallWithSubjectSupported(Context context) {
if (!PermissionsUtil.hasPermission(context, android.Manifest.permission.READ_PHONE_STATE) || !CompatUtils.isCallSubjectCompatible()) {
return false;
}
TelecomManager telecommMgr = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
if (telecommMgr == null) {
return false;
}
List<PhoneAccountHandle> accountHandles = telecommMgr.getCallCapablePhoneAccounts();
for (PhoneAccountHandle accountHandle : accountHandles) {
PhoneAccount account = telecommMgr.getPhoneAccount(accountHandle);
if (account != null && account.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT)) {
return true;
}
}
return false;
}
use of android.telecom.TelecomManager in project android_packages_apps_Dialer by LineageOS.
the class DialerSettingsActivity method getSoleSimAccount.
/**
* @return the only SIM phone account, or {@code null} if there are none or more than one. Note:
* having a empty SIM slot still count as a PhoneAccountHandle that is "invalid", and
* voicemail settings should still be available for it.
*/
@Nullable
private PhoneAccountHandle getSoleSimAccount() {
TelecomManager telecomManager = getSystemService(TelecomManager.class);
PhoneAccountHandle result = null;
for (PhoneAccountHandle phoneAccountHandle : telecomManager.getCallCapablePhoneAccounts()) {
PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
LogUtil.i("DialerSettingsActivity.getSoleSimAccount", phoneAccountHandle + " is a SIM account");
if (result != null) {
return null;
}
result = phoneAccountHandle;
}
}
return result;
}
use of android.telecom.TelecomManager in project android_packages_apps_Dialer by LineageOS.
the class StatusBarNotifier method getAnyPhoneAccount.
@Nullable
@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
private PhoneAccountHandle getAnyPhoneAccount() {
PhoneAccountHandle accountHandle;
TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
accountHandle = telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL);
if (accountHandle == null) {
List<PhoneAccountHandle> accountHandles = telecomManager.getCallCapablePhoneAccounts();
if (!accountHandles.isEmpty()) {
accountHandle = accountHandles.get(0);
}
}
return accountHandle;
}
use of android.telecom.TelecomManager in project android_packages_apps_Settings by DirtyUnicorns.
the class SimDialogActivity method subscriptionIdToPhoneAccountHandle.
private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) {
final TelecomManager telecomManager = TelecomManager.from(this);
final TelephonyManager telephonyManager = TelephonyManager.from(this);
final Iterator<PhoneAccountHandle> phoneAccounts = telecomManager.getCallCapablePhoneAccounts().listIterator();
while (phoneAccounts.hasNext()) {
final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();
final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
if (subId == telephonyManager.getSubIdForPhoneAccount(phoneAccount)) {
return phoneAccountHandle;
}
}
return null;
}
use of android.telecom.TelecomManager in project android_packages_apps_Settings by DirtyUnicorns.
the class SimDialogActivity method setUserSelectedOutgoingPhoneAccount.
private void setUserSelectedOutgoingPhoneAccount(PhoneAccountHandle phoneAccount) {
final TelecomManager telecomManager = TelecomManager.from(this);
telecomManager.setUserSelectedOutgoingPhoneAccount(phoneAccount);
}
Aggregations