use of com.android.dialer.phonelookup.PhoneLookupInfo.SystemBlockedNumberInfo in project android_packages_apps_Dialer by LineageOS.
the class SystemBlockedNumberPhoneLookup method queryNumbers.
@WorkerThread
private ImmutableMap<DialerPhoneNumber, SystemBlockedNumberInfo> queryNumbers(ImmutableSet<DialerPhoneNumber> numbers) {
Assert.isWorkerThread();
PartitionedNumbers partitionedNumbers = new PartitionedNumbers(numbers);
Set<DialerPhoneNumber> blockedNumbers = new ArraySet<>();
Selection normalizedSelection = Selection.column(BlockedNumbers.COLUMN_E164_NUMBER).in(partitionedNumbers.validE164Numbers());
try (Cursor cursor = appContext.getContentResolver().query(BlockedNumbers.CONTENT_URI, new String[] { BlockedNumbers.COLUMN_E164_NUMBER }, normalizedSelection.getSelection(), normalizedSelection.getSelectionArgs(), null)) {
while (cursor != null && cursor.moveToNext()) {
blockedNumbers.addAll(partitionedNumbers.dialerPhoneNumbersForValidE164(cursor.getString(0)));
}
}
Selection rawSelection = Selection.column(BlockedNumbers.COLUMN_ORIGINAL_NUMBER).in(partitionedNumbers.invalidNumbers());
try (Cursor cursor = appContext.getContentResolver().query(BlockedNumbers.CONTENT_URI, new String[] { BlockedNumbers.COLUMN_ORIGINAL_NUMBER }, rawSelection.getSelection(), rawSelection.getSelectionArgs(), null)) {
while (cursor != null && cursor.moveToNext()) {
blockedNumbers.addAll(partitionedNumbers.dialerPhoneNumbersForInvalid(cursor.getString(0)));
}
}
ImmutableMap.Builder<DialerPhoneNumber, SystemBlockedNumberInfo> result = ImmutableMap.builder();
for (DialerPhoneNumber number : numbers) {
result.put(number, SystemBlockedNumberInfo.newBuilder().setBlockedState(blockedNumbers.contains(number) ? BlockedState.BLOCKED : BlockedState.NOT_BLOCKED).build());
}
return result.build();
}
Aggregations