Search in sources :

Example 26 with PhoneAccount

use of android.telecom.PhoneAccount in project android_packages_apps_Dialer by MoKee.

the class Call method getSubId.

public int getSubId(PhoneAccountHandle ph) {
    if (ph == null) {
        return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    }
    TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager();
    PhoneAccount account = mgr.getPhoneAccount(ph);
    if (account != null) {
        return TelephonyManager.getDefault().getSubIdForPhoneAccount(account);
    } else {
        return SubscriptionManager.getDefaultVoiceSubscriptionId();
    }
}
Also used : PhoneAccount(android.telecom.PhoneAccount) TelecomManager(android.telecom.TelecomManager)

Example 27 with PhoneAccount

use of android.telecom.PhoneAccount in project platform_packages_apps_Settings by BlissRoms.

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 28 with PhoneAccount

use of android.telecom.PhoneAccount in project packages_apps_Contacts by AOKP.

the class DelCallLogAdapter method getAccountIcon.

private Drawable getAccountIcon(Context context, PhoneAccountHandle accountHandle) {
    TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
    final PhoneAccount account;
    if (telecomManager.getCallCapablePhoneAccounts().size() <= 1) {
        account = null;
    } else {
        account = telecomManager.getPhoneAccount(accountHandle);
    }
    if (account == null) {
        return null;
    } else {
        return account.getIcon().loadDrawable(context);
    }
}
Also used : PhoneAccount(android.telecom.PhoneAccount) TelecomManager(android.telecom.TelecomManager)

Example 29 with PhoneAccount

use of android.telecom.PhoneAccount in project robolectric by robolectric.

the class ShadowTelecomManagerTest method registerAndUnRegister.

@Test
public void registerAndUnRegister() {
    assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(0);
    assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(0);
    PhoneAccountHandle handler = createHandle("id");
    PhoneAccount phoneAccount = PhoneAccount.builder(handler, "main_account").build();
    telecomService.registerPhoneAccount(phoneAccount);
    assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(1);
    assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(1);
    assertThat(telecomService.getAllPhoneAccountHandles()).hasSize(1);
    assertThat(telecomService.getAllPhoneAccountHandles()).contains(handler);
    assertThat(telecomService.getPhoneAccount(handler).getLabel().toString()).isEqualTo(phoneAccount.getLabel().toString());
    telecomService.unregisterPhoneAccount(handler);
    assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(0);
    assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(0);
    assertThat(telecomService.getAllPhoneAccountHandles()).hasSize(0);
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) Test(org.junit.Test)

Example 30 with PhoneAccount

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

the class SimDialogActivity method subscriptionIdToPhoneAccountHandle.

private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) {
    final TelecomManager telecomManager = getSystemService(TelecomManager.class);
    final TelephonyManager telephonyManager = getSystemService(TelephonyManager.class);
    for (PhoneAccountHandle handle : telecomManager.getCallCapablePhoneAccounts()) {
        final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(handle);
        if (subId == telephonyManager.getSubIdForPhoneAccount(phoneAccount)) {
            return handle;
        }
    }
    return null;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelephonyManager(android.telephony.TelephonyManager) TelecomManager(android.telecom.TelecomManager)

Aggregations

PhoneAccount (android.telecom.PhoneAccount)53 PhoneAccountHandle (android.telecom.PhoneAccountHandle)41 TelecomManager (android.telecom.TelecomManager)32 TelephonyManager (android.telephony.TelephonyManager)19 ArrayList (java.util.ArrayList)13 SubscriptionInfo (android.telephony.SubscriptionInfo)11 SubscriptionManager (android.telephony.SubscriptionManager)10 AlertDialog (android.app.AlertDialog)7 Dialog (android.app.Dialog)7 DialogInterface (android.content.DialogInterface)7 KeyEvent (android.view.KeyEvent)7 ListAdapter (android.widget.ListAdapter)7 Uri (android.net.Uri)3 Context (android.content.Context)2 NotificationChannel (android.app.NotificationChannel)1 NotificationManager (android.app.NotificationManager)1 ContentResolver (android.content.ContentResolver)1 ContentValues (android.content.ContentValues)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1