Search in sources :

Example 21 with TelecomManager

use of android.telecom.TelecomManager in project android_packages_apps_Settings by LineageOS.

the class SimSettings method updateCallValues.

private void updateCallValues() {
    final Preference simPref = findPreference(KEY_CALLS);
    final TelecomManager telecomManager = TelecomManager.from(mContext);
    final PhoneAccountHandle phoneAccount = telecomManager.getUserSelectedOutgoingPhoneAccount();
    final List<PhoneAccountHandle> allPhoneAccounts = telecomManager.getCallCapablePhoneAccounts();
    simPref.setTitle(R.string.calls_title);
    simPref.setSummary(phoneAccount == null ? mContext.getResources().getString(R.string.sim_calls_ask_first_prefs_title) : (String) telecomManager.getPhoneAccount(phoneAccount).getLabel());
    simPref.setEnabled(allPhoneAccounts.size() > 1);
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) Preference(android.support.v7.preference.Preference) TelecomManager(android.telecom.TelecomManager)

Example 22 with TelecomManager

use of android.telecom.TelecomManager in project android_packages_apps_Dialer by LineageOS.

the class VoicemailChannelUtils method getAllEligableAccounts.

private static List<PhoneAccountHandle> getAllEligableAccounts(@NonNull Context context) {
    List<PhoneAccountHandle> handles = new ArrayList<>();
    TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
    for (PhoneAccountHandle handle : telecomManager.getCallCapablePhoneAccounts()) {
        if (isChannelAllowedForAccount(context, handle)) {
            handles.add(handle);
        }
    }
    return handles;
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) ArrayList(java.util.ArrayList) TelecomManager(android.telecom.TelecomManager)

Example 23 with TelecomManager

use of android.telecom.TelecomManager in project android_packages_apps_Dialer by LineageOS.

the class VoicemailChannelUtils method createGlobalVoicemailChannel.

/**
 * Creates a voicemail channel but doesn't associate it with a SIM. For devices with only one SIM
 * slot this is ideal because there won't be duplication in the settings UI.
 */
private static void createGlobalVoicemailChannel(@NonNull Context context) {
    NotificationChannel channel = newChannel(context, GLOBAL_VOICEMAIL_CHANNEL_ID, null);
    TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
    PhoneAccountHandle handle = telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL);
    if (handle == null) {
        LogUtil.i("VoicemailChannelUtils.createGlobalVoicemailChannel", "phone account is null, not migrating sound settings");
    } else if (!isChannelAllowedForAccount(context, handle)) {
        LogUtil.i("VoicemailChannelUtils.createGlobalVoicemailChannel", "phone account is not eligable, not migrating sound settings");
    } else {
        migrateVoicemailSoundSettings(context, channel, handle);
    }
    context.getSystemService(NotificationManager.class).createNotificationChannel(channel);
}
Also used : NotificationChannel(android.app.NotificationChannel) PhoneAccountHandle(android.telecom.PhoneAccountHandle) NotificationManager(android.app.NotificationManager) TelecomManager(android.telecom.TelecomManager)

Example 24 with TelecomManager

use of android.telecom.TelecomManager in project android_packages_apps_Dialer by LineageOS.

the class LegacyVoicemailNotifier method getNotificationText.

@NonNull
private static String getNotificationText(@NonNull Context context, PhoneAccountHandle handle, String voicemailNumber) {
    if (PhoneAccountUtils.getSubscriptionPhoneAccounts(context).size() > 1) {
        TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
        PhoneAccount phoneAccount = telecomManager.getPhoneAccount(handle);
        return phoneAccount.getShortDescription().toString();
    } else {
        return String.format(context.getString(R.string.notification_voicemail_text_format), PhoneNumberUtils.formatNumber(voicemailNumber));
    }
}
Also used : PhoneAccount(android.telecom.PhoneAccount) TelecomManager(android.telecom.TelecomManager) NonNull(android.support.annotation.NonNull)

Example 25 with TelecomManager

use of android.telecom.TelecomManager in project android_packages_apps_Dialer by LineageOS.

the class PhoneAccountSelectionFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    setPreferenceScreen(getPreferenceManager().createPreferenceScreen(getContext()));
    PreferenceScreen screen = getPreferenceScreen();
    TelecomManager telecomManager = getContext().getSystemService(TelecomManager.class);
    List<PhoneAccountHandle> accountHandles = telecomManager.getCallCapablePhoneAccounts();
    Context context = getActivity();
    for (PhoneAccountHandle handle : accountHandles) {
        PhoneAccount account = telecomManager.getPhoneAccount(handle);
        if (account != null) {
            final boolean isSimAccount = 0 != (account.getCapabilities() & PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION);
            if (isSimAccount) {
                screen.addPreference(new AccountPreference(context, handle, account));
            }
        }
    }
}
Also used : Context(android.content.Context) PhoneAccount(android.telecom.PhoneAccount) PreferenceScreen(android.preference.PreferenceScreen) PhoneAccountHandle(android.telecom.PhoneAccountHandle) 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