Example usage for android.telecom PhoneAccount CAPABILITY_CALL_SUBJECT

List of usage examples for android.telecom PhoneAccount CAPABILITY_CALL_SUBJECT

Introduction

In this page you can find the example usage for android.telecom PhoneAccount CAPABILITY_CALL_SUBJECT.

Prototype

int CAPABILITY_CALL_SUBJECT

To view the source code for android.telecom PhoneAccount CAPABILITY_CALL_SUBJECT.

Click Source Link

Document

Flag indicating that this PhoneAccount supports a subject for Calls.

Usage

From source file:com.mobileglobe.android.simpledialer.common.CallUtil.java

/**
 * Determines if one of the call capable phone accounts defined supports calling with a subject
 * specified.//from ww  w .  java  2s.  c o  m
 *
 * @param context The context.
 * @return {@code true} if one of the call capable phone accounts supports calling with a
 *      subject specified, {@code false} otherwise.
 */
@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean isCallWithSubjectSupported(Context context) {
    if (!PermissionsUtil.hasPermission(context, Manifest.permission.READ_PHONE_STATE)
            || !CompatUtils.isCallSubjectCompatible()) {
        return false;
    }
    TelecomManager telecommMgr = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
    if (telecommMgr == null) {
        return false;
    }

    if (ActivityCompat.checkSelfPermission(context,
            Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        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;
}

From source file:com.mobileglobe.android.customdialer.common.CallUtil.java

/**
 * Determines if one of the call capable phone accounts defined supports calling with a subject
 * specified./*from   w w w.  j  a v  a  2s  . com*/
 *
 * @param context The context.
 * @return {@code true} if one of the call capable phone accounts supports calling with a
 *      subject specified, {@code false} otherwise.
 */
@RequiresApi(api = Build.VERSION_CODES.M)
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;
    }

    if (ActivityCompat.checkSelfPermission(context,
            Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        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;
}