/** * @return the column name that stores contact id for phone lookup query. */ public static String getContactIdColumnNameForUri(Uri phoneLookupUri) { if (CompatUtils.isNCompatible()) { return PhoneLookupSdkCompat.CONTACT_ID; } // In pre-N, contact id is stored in {@link PhoneLookup#_ID} in non-sip query. boolean isSip = phoneLookupUri.getBooleanQueryParameter( ContactsContract.PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, false); return (isSip) ? PhoneLookupSdkCompat.CONTACT_ID : ContactsContract.PhoneLookup._ID; }
public static String[] getPhoneLookupProjection(Uri phoneLookupUri) { if (CompatUtils.isNCompatible()) { return PHONE_LOOKUP_PROJECTION; } // Pre-N boolean isSip = phoneLookupUri.getBooleanQueryParameter( ContactsContract.PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, false); return (isSip) ? PHONE_LOOKUP_PROJECTION : BACKWARD_COMPATIBLE_NON_SIP_PHONE_LOOKUP_PROJECTION; }
/** * @return {@code true} if the current SDK version supports using new filtering, {@code false} * otherwise. */ public static boolean canUseNewFiltering() { if (isEnabledForTest != null) { return CompatUtils.isNCompatible() && isEnabledForTest; } return CompatUtils.isNCompatible() && ObjectFactory .isNewBlockingEnabled(DialerApplication.getContext()); }
/** * Returns whether vibration is set for voicemail notification in Phone settings. * * @param telephonyManager The telephony manager instance to use for method calls. * @param accountHandle The handle for the {@link android.telecom.PhoneAccount} for which to * retrieve the voicemail vibration setting. * @return {@code true} if the vibration is set for this PhoneAccount, {@code false} otherwise. */ public static boolean isVoicemailVibrationEnabled(TelephonyManager telephonyManager, PhoneAccountHandle accountHandle) { if (!CompatUtils.isNCompatible()) { return true; } return TelephonyManagerSdkCompat .isVoicemailVibrationEnabled(telephonyManager, accountHandle); } }
/** * Returns the URI for the per-account voicemail ringtone set in Phone settings. * * @param telephonyManager The telephony manager instance to use for method calls. * @param accountHandle The handle for the {@link android.telecom.PhoneAccount} for which to * retrieve the voicemail ringtone. * @return The URI for the ringtone to play when receiving a voicemail from a specific * PhoneAccount. */ @Nullable public static Uri getVoicemailRingtoneUri(TelephonyManager telephonyManager, PhoneAccountHandle accountHandle) { if (!CompatUtils.isNCompatible()) { return null; } return TelephonyManagerSdkCompat .getVoicemailRingtoneUri(telephonyManager, accountHandle); }
/** * Return whether the calling user is running in an "unlocked" state. A user * is unlocked only after they've entered their credentials (such as a lock * pattern or PIN), and credential-encrypted private app data storage is * available. * * TODO b/26688153 * * @param context the current context * @return {@code true} if the user is unlocked, {@code false} otherwise * @throws NullPointerException if context is null */ public static boolean isUserUnlocked(Context context) { if (CompatUtils.isNCompatible()) { return UserManagerSdkCompat.isUserUnlocked(context); } return true; } }
/** * @return True if the drag is started, false if the drag is cancelled for some reason. */ boolean handleDragStarted(View v, int x, int y) { int screenX = x; int screenY = y; // The coordinates in dragEvent of DragEvent.ACTION_DRAG_STARTED before NYC is window-related. // This is fixed in NYC. if (CompatUtils.isNCompatible()) { v.getLocationOnScreen(mLocationOnScreen); screenX = x + mLocationOnScreen[0]; screenY = y + mLocationOnScreen[1]; } final PhoneFavoriteSquareTileView tileView = mDragItemContainer.getViewForLocation( screenX, screenY); if (tileView == null) { return false; } for (int i = 0; i < mOnDragDropListeners.size(); i++) { mOnDragDropListeners.get(i).onDragStarted(screenX, screenY, tileView); } return true; }
/** * Method used to determine if block operations are possible. * * @param context The {@link Context}. * @return {@code true} if the app and user can block numbers, {@code false} otherwise. */ public static boolean canAttemptBlockOperations(Context context) { if (!CompatUtils.isNCompatible()) { // Dialer blocking, must be primary user return UserManagerCompat.isSystemUser( (UserManager) context.getSystemService(Context.USER_SERVICE)); } // Great Wall blocking, must be primary user and the default or system dialer // TODO(maxwelb): check that we're the default or system Dialer return BlockedNumbersSdkCompat.canCurrentUserBlockNumbers(context); }
/** * Used to determine if the call blocking settings can be opened. * * @param context The {@link Context}. * @return {@code true} if the current user can open the call blocking settings, {@code false} * otherwise. */ public static boolean canCurrentUserOpenBlockSettings(Context context) { if (!CompatUtils.isNCompatible()) { // Dialer blocking, must be primary user return UserManagerCompat.isSystemUser( (UserManager) context.getSystemService(Context.USER_SERVICE)); } // BlockedNumberContract blocking, verify through Contract API return BlockedNumbersSdkCompat.canCurrentUserBlockNumbers(context); } }
/** * Returns the contact information stored in an entry of the call log. * * @param c A cursor pointing to an entry in the call log. */ public static ContactInfo getContactInfo(Cursor c) { ContactInfo info = new ContactInfo(); info.lookupUri = UriUtils.parseUriOrNull(c.getString(CallLogQuery.CACHED_LOOKUP_URI)); info.name = c.getString(CallLogQuery.CACHED_NAME); info.type = c.getInt(CallLogQuery.CACHED_NUMBER_TYPE); info.label = c.getString(CallLogQuery.CACHED_NUMBER_LABEL); String matchedNumber = c.getString(CallLogQuery.CACHED_MATCHED_NUMBER); String postDialDigits = CompatUtils.isNCompatible() ? c.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; info.number = (matchedNumber == null) ? c.getString(CallLogQuery.NUMBER) + postDialDigits : matchedNumber; info.normalizedNumber = c.getString(CallLogQuery.CACHED_NORMALIZED_NUMBER); info.photoId = c.getLong(CallLogQuery.CACHED_PHOTO_ID); info.photoUri = DialerCompatUtils.isCallsCachedPhotoUriCompatible() ? UriUtils.nullForNonContactsUri( UriUtils.parseUriOrNull(c.getString(CallLogQuery.CACHED_PHOTO_URI))) : null; info.formattedNumber = c.getString(CallLogQuery.CACHED_FORMATTED_NUMBER); return info; }
final String postDialDigits = CompatUtils.isNCompatible() ? cursor.getString(CallDetailQuery.POST_DIAL_DIGITS) : ""; final String viaNumber = CompatUtils.isNCompatible() ? cursor.getString(CallDetailQuery.VIA_NUMBER) : ""; final int numberPresentation =
String groupPostDialDigits = CompatUtils.isNCompatible() ? cursor.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; String groupViaNumbers = CompatUtils.isNCompatible() ? cursor.getString(CallLogQuery.VIA_NUMBER) : ""; int groupCallType = cursor.getInt(CallLogQuery.CALL_TYPE); numberPostDialDigits = CompatUtils.isNCompatible() ? cursor.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; numberViaNumbers = CompatUtils.isNCompatible() ? cursor.getString(CallLogQuery.VIA_NUMBER) : ""; callType = cursor.getInt(CallLogQuery.CALL_TYPE);
final String postDialDigits = CompatUtils.isNCompatible() && mActivityType != ACTIVITY_TYPE_ARCHIVE ? c.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; final String viaNumber = CompatUtils.isNCompatible() && mActivityType != ACTIVITY_TYPE_ARCHIVE ? c.getString(CallLogQuery.VIA_NUMBER) : "";