Search in sources :

Example 1 with SystemBlockedNumberInfo

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();
}
Also used : SystemBlockedNumberInfo(com.android.dialer.phonelookup.PhoneLookupInfo.SystemBlockedNumberInfo) PartitionedNumbers(com.android.dialer.phonenumberproto.PartitionedNumbers) ArraySet(android.util.ArraySet) Selection(com.android.dialer.common.database.Selection) DialerPhoneNumber(com.android.dialer.DialerPhoneNumber) Cursor(android.database.Cursor) ImmutableMap(com.google.common.collect.ImmutableMap) WorkerThread(android.support.annotation.WorkerThread)

Aggregations

Cursor (android.database.Cursor)1 WorkerThread (android.support.annotation.WorkerThread)1 ArraySet (android.util.ArraySet)1 DialerPhoneNumber (com.android.dialer.DialerPhoneNumber)1 Selection (com.android.dialer.common.database.Selection)1 SystemBlockedNumberInfo (com.android.dialer.phonelookup.PhoneLookupInfo.SystemBlockedNumberInfo)1 PartitionedNumbers (com.android.dialer.phonenumberproto.PartitionedNumbers)1 ImmutableMap (com.google.common.collect.ImmutableMap)1