/** * Builds and returns an icon {@code Drawable} to represent this {@code PhoneAccount} in a user * interface. * * @param phoneAccount the PhoneAccount from which to build the icon. * @param context A {@code Context} to use for loading Drawables. * * @return An icon for this PhoneAccount, or null */ @Nullable public static Drawable createIconDrawable(@Nullable PhoneAccount phoneAccount, @Nullable Context context) { if (phoneAccount == null || context == null) { return null; } if (CompatUtils.isMarshmallowCompatible()) { return createIconDrawableMarshmallow(phoneAccount, context); } if (CompatUtils.isLollipopMr1Compatible()) { return createIconDrawableLollipopMr1(phoneAccount, context); } return null; }
/** * @param telephonyManager The telephony manager instance to use for method calls. * @return true if the current device is "voice capable". * <p> * "Voice capable" means that this device supports circuit-switched * (i.e. voice) phone calls over the telephony network, and is allowed * to display the in-call UI while a cellular voice call is active. * This will be false on "data only" devices which can't make voice * calls and don't support any in-call UI. * <p> * Note: the meaning of this flag is subtly different from the * PackageManager.FEATURE_TELEPHONY system feature, which is available * on any device with a telephony radio, even if the device is * data-only. */ public static boolean isVoiceCapable(@Nullable TelephonyManager telephonyManager) { if (telephonyManager == null) { return false; } if (CompatUtils.isLollipopMr1Compatible() || CompatUtils.isMethodAvailable(TELEPHONY_MANAGER_CLASS, "isVoiceCapable")) { // isVoiceCapable was unhidden in L-MR1 return telephonyManager.isVoiceCapable(); } final int phoneType = telephonyManager.getPhoneType(); return phoneType == TelephonyManager.PHONE_TYPE_CDMA || phoneType == TelephonyManager.PHONE_TYPE_GSM; }