Search in sources :

Example 36 with PhoneAccount

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

the class Telecom method runRegisterPhoneAccount.

private void runRegisterPhoneAccount() throws RemoteException {
    final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs();
    final String label = nextArgRequired();
    PhoneAccount account = PhoneAccount.builder(handle, label).setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER).build();
    mTelecomService.registerPhoneAccount(account);
    System.out.println("Success - " + handle + " registered.");
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle)

Example 37 with PhoneAccount

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

the class CallSubjectDialog method loadConfiguration.

/**
 * Loads the message encoding and maximum message length from the phone account extras for the
 * current phone account.
 */
private void loadConfiguration() {
    // later.  If we've got a prior SDK the default encoding and message length will suffice.
    if (VERSION.SDK_INT < VERSION_CODES.N) {
        return;
    }
    if (mPhoneAccountHandle == null) {
        return;
    }
    TelecomManager telecomManager = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
    final PhoneAccount account = telecomManager.getPhoneAccount(mPhoneAccountHandle);
    Bundle phoneAccountExtras = account.getExtras();
    if (phoneAccountExtras == null) {
        return;
    }
    // Get limit, if provided; otherwise default to existing value.
    mLimit = phoneAccountExtras.getInt(PhoneAccount.EXTRA_CALL_SUBJECT_MAX_LENGTH, mLimit);
    // Get charset; default to none (e.g. count characters 1:1).
    String charsetName = phoneAccountExtras.getString(PhoneAccount.EXTRA_CALL_SUBJECT_CHARACTER_ENCODING);
    if (!TextUtils.isEmpty(charsetName)) {
        try {
            mMessageEncoding = Charset.forName(charsetName);
        } catch (java.nio.charset.UnsupportedCharsetException uce) {
            // Character set was invalid; log warning and fallback to none.
            LogUtil.e("CallSubjectDialog.loadConfiguration", "invalid charset: " + charsetName);
            mMessageEncoding = null;
        }
    } else {
        // No character set specified, so count characters 1:1.
        mMessageEncoding = null;
    }
}
Also used : PhoneAccount(android.telecom.PhoneAccount) Bundle(android.os.Bundle) TelecomManager(android.telecom.TelecomManager)

Example 38 with PhoneAccount

use of android.telecom.PhoneAccount 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 39 with PhoneAccount

use of android.telecom.PhoneAccount 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 40 with PhoneAccount

use of android.telecom.PhoneAccount 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)

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