Search in sources :

Example 86 with TelecomManager

use of android.telecom.TelecomManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CallsSimListDialogFragment method getCurrentSubscriptions.

@Override
protected List<SubscriptionInfo> getCurrentSubscriptions() {
    final Context context = getContext();
    final SubscriptionManager subscriptionManager = context.getSystemService(SubscriptionManager.class);
    final TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
    final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
    final List<PhoneAccountHandle> phoneAccounts = telecomManager.getCallCapablePhoneAccounts();
    final List<SubscriptionInfo> result = new ArrayList<>();
    if (phoneAccounts == null) {
        return result;
    }
    for (PhoneAccountHandle handle : phoneAccounts) {
        final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(handle);
        final int subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount);
        if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            continue;
        }
        result.add(subscriptionManager.getActiveSubscriptionInfo(subId));
    }
    return result;
}
Also used : Context(android.content.Context) PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelephonyManager(android.telephony.TelephonyManager) ArrayList(java.util.ArrayList) SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager) 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