Search in sources :

Example 71 with TelecomManager

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;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelecomManager(android.telecom.TelecomManager)

Example 72 with TelecomManager

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;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelecomManager(android.telecom.TelecomManager) Nullable(android.support.annotation.Nullable)

Example 73 with TelecomManager

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;
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelecomManager(android.telecom.TelecomManager) RequiresPermission(android.support.annotation.RequiresPermission) Nullable(android.support.annotation.Nullable)

Example 74 with TelecomManager

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;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelephonyManager(android.telephony.TelephonyManager) TelecomManager(android.telecom.TelecomManager)

Example 75 with TelecomManager

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);
}
Also used : TelecomManager(android.telecom.TelecomManager)

Aggregations

TelecomManager (android.telecom.TelecomManager)86 PhoneAccountHandle (android.telecom.PhoneAccountHandle)45 PhoneAccount (android.telecom.PhoneAccount)30 TelephonyManager (android.telephony.TelephonyManager)17 SubscriptionInfo (android.telephony.SubscriptionInfo)11 KeyEvent (android.view.KeyEvent)9 ArrayList (java.util.ArrayList)9 AlertDialog (android.app.AlertDialog)8 ActivityNotFoundException (android.content.ActivityNotFoundException)8 DialogInterface (android.content.DialogInterface)8 Message (android.os.Message)8 SubscriptionManager (android.telephony.SubscriptionManager)8 Dialog (android.app.Dialog)7 ListAdapter (android.widget.ListAdapter)7 Intent (android.content.Intent)6 Preference (android.support.v7.preference.Preference)6 ComponentName (android.content.ComponentName)4 PackageManagerInternal (android.content.pm.PackageManagerInternal)4 RemoteException (android.os.RemoteException)4 IntArray (android.util.IntArray)4