summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-03-28 21:44:26 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-03-28 21:44:26 +0000
commitae2c5425e43082c375981768f99dc56eab51269d (patch)
tree43b7ac6e633d042a855b8d246d55e4a21f1c4ac6
parentb48f2ab459b70917f749a3b701f3b0c267e7fbf4 (diff)
parentc9e06d9dd4c210bf7ed7cc3cf81d1acaa8d6089f (diff)
Merge "Delete dialer blocking in NUI"
-rw-r--r--java/com/android/dialer/phonelookup/PhoneLookupModule.java3
-rw-r--r--java/com/android/dialer/phonelookup/blockednumber/DialerBlockedNumberPhoneLookup.java190
-rw-r--r--java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java5
-rw-r--r--java/com/android/dialer/phonelookup/phone_lookup_info.proto7
4 files changed, 1 insertions, 204 deletions
diff --git a/java/com/android/dialer/phonelookup/PhoneLookupModule.java b/java/com/android/dialer/phonelookup/PhoneLookupModule.java
index a4cc5c7a4..273a2d092 100644
--- a/java/com/android/dialer/phonelookup/PhoneLookupModule.java
+++ b/java/com/android/dialer/phonelookup/PhoneLookupModule.java
@@ -16,7 +16,6 @@
package com.android.dialer.phonelookup;
-import com.android.dialer.phonelookup.blockednumber.DialerBlockedNumberPhoneLookup;
import com.android.dialer.phonelookup.blockednumber.SystemBlockedNumberPhoneLookup;
import com.android.dialer.phonelookup.cp2.Cp2DefaultDirectoryPhoneLookup;
import com.android.dialer.phonelookup.cp2.Cp2ExtendedDirectoryPhoneLookup;
@@ -34,13 +33,11 @@ public abstract class PhoneLookupModule {
static ImmutableList<PhoneLookup> providePhoneLookupList(
Cp2DefaultDirectoryPhoneLookup cp2DefaultDirectoryPhoneLookup,
Cp2ExtendedDirectoryPhoneLookup cp2ExtendedDirectoryPhoneLookup,
- DialerBlockedNumberPhoneLookup dialerBlockedNumberPhoneLookup,
SystemBlockedNumberPhoneLookup systemBlockedNumberPhoneLookup,
SpamPhoneLookup spamPhoneLookup) {
return ImmutableList.of(
cp2DefaultDirectoryPhoneLookup,
cp2ExtendedDirectoryPhoneLookup,
- dialerBlockedNumberPhoneLookup,
systemBlockedNumberPhoneLookup,
spamPhoneLookup);
}
diff --git a/java/com/android/dialer/phonelookup/blockednumber/DialerBlockedNumberPhoneLookup.java b/java/com/android/dialer/phonelookup/blockednumber/DialerBlockedNumberPhoneLookup.java
deleted file mode 100644
index ce879a995..000000000
--- a/java/com/android/dialer/phonelookup/blockednumber/DialerBlockedNumberPhoneLookup.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.dialer.phonelookup.blockednumber;
-
-import android.content.Context;
-import android.database.Cursor;
-import android.support.annotation.WorkerThread;
-import android.util.ArraySet;
-import com.android.dialer.DialerPhoneNumber;
-import com.android.dialer.blocking.FilteredNumberCompat;
-import com.android.dialer.calllog.observer.MarkDirtyObserver;
-import com.android.dialer.common.Assert;
-import com.android.dialer.common.LogUtil;
-import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor;
-import com.android.dialer.common.database.Selection;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumber;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns;
-import com.android.dialer.database.FilteredNumberContract.FilteredNumberTypes;
-import com.android.dialer.inject.ApplicationContext;
-import com.android.dialer.phonelookup.PhoneLookup;
-import com.android.dialer.phonelookup.PhoneLookupInfo;
-import com.android.dialer.phonelookup.PhoneLookupInfo.BlockedState;
-import com.android.dialer.phonelookup.PhoneLookupInfo.DialerBlockedNumberInfo;
-import com.android.dialer.phonenumberproto.PartitionedNumbers;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import java.util.Set;
-import javax.inject.Inject;
-
-/**
- * Lookup blocked numbers in the dialer internal database. This is used when the system database is
- * not yet available.
- */
-public final class DialerBlockedNumberPhoneLookup implements PhoneLookup<DialerBlockedNumberInfo> {
-
- private final Context appContext;
- private final ListeningExecutorService executorService;
- private final MarkDirtyObserver markDirtyObserver;
-
- @Inject
- DialerBlockedNumberPhoneLookup(
- @ApplicationContext Context appContext,
- @BackgroundExecutor ListeningExecutorService executorService,
- MarkDirtyObserver markDirtyObserver) {
- this.appContext = appContext;
- this.executorService = executorService;
- this.markDirtyObserver = markDirtyObserver;
- }
-
- @Override
- public ListenableFuture<DialerBlockedNumberInfo> lookup(DialerPhoneNumber dialerPhoneNumber) {
- if (FilteredNumberCompat.useNewFiltering(appContext)) {
- return Futures.immediateFuture(DialerBlockedNumberInfo.getDefaultInstance());
- }
- return executorService.submit(
- () -> queryNumbers(ImmutableSet.of(dialerPhoneNumber)).get(dialerPhoneNumber));
- }
-
- @Override
- public ListenableFuture<Boolean> isDirty(ImmutableSet<DialerPhoneNumber> phoneNumbers) {
- // Dirty state is recorded with PhoneLookupDataSource.markDirtyAndNotify(), which will force
- // rebuild with the CallLogFramework
- return Futures.immediateFuture(false);
- }
-
- @Override
- public ListenableFuture<ImmutableMap<DialerPhoneNumber, DialerBlockedNumberInfo>>
- getMostRecentInfo(ImmutableMap<DialerPhoneNumber, DialerBlockedNumberInfo> existingInfoMap) {
- if (FilteredNumberCompat.useNewFiltering(appContext)) {
- return Futures.immediateFuture(existingInfoMap);
- }
- LogUtil.enterBlock("DialerBlockedNumberPhoneLookup.getMostRecentPhoneLookupInfo");
- return executorService.submit(() -> queryNumbers(existingInfoMap.keySet()));
- }
-
- @Override
- public void setSubMessage(
- PhoneLookupInfo.Builder phoneLookupInfo, DialerBlockedNumberInfo subMessage) {
- phoneLookupInfo.setDialerBlockedNumberInfo(subMessage);
- }
-
- @Override
- public DialerBlockedNumberInfo getSubMessage(PhoneLookupInfo phoneLookupInfo) {
- return phoneLookupInfo.getDialerBlockedNumberInfo();
- }
-
- @Override
- public ListenableFuture<Void> onSuccessfulBulkUpdate() {
- return Futures.immediateFuture(null);
- }
-
- @WorkerThread
- private ImmutableMap<DialerPhoneNumber, DialerBlockedNumberInfo> queryNumbers(
- ImmutableSet<DialerPhoneNumber> numbers) {
- Assert.isWorkerThread();
- PartitionedNumbers partitionedNumbers = new PartitionedNumbers(numbers);
-
- Set<DialerPhoneNumber> blockedNumbers = new ArraySet<>();
-
- Selection normalizedSelection =
- Selection.column(FilteredNumberColumns.NORMALIZED_NUMBER)
- .in(partitionedNumbers.validE164Numbers());
- try (Cursor cursor =
- appContext
- .getContentResolver()
- .query(
- FilteredNumber.CONTENT_URI,
- new String[] {FilteredNumberColumns.NORMALIZED_NUMBER, FilteredNumberColumns.TYPE},
- normalizedSelection.getSelection(),
- normalizedSelection.getSelectionArgs(),
- null)) {
- while (cursor != null && cursor.moveToNext()) {
- if (cursor.getInt(1) == FilteredNumberTypes.BLOCKED_NUMBER) {
- blockedNumbers.addAll(
- partitionedNumbers.dialerPhoneNumbersForValidE164(cursor.getString(0)));
- }
- }
- }
-
- Selection rawSelection =
- Selection.column(FilteredNumberColumns.NUMBER).in(partitionedNumbers.invalidNumbers());
- try (Cursor cursor =
- appContext
- .getContentResolver()
- .query(
- FilteredNumber.CONTENT_URI,
- new String[] {FilteredNumberColumns.NUMBER, FilteredNumberColumns.TYPE},
- rawSelection.getSelection(),
- rawSelection.getSelectionArgs(),
- null)) {
- while (cursor != null && cursor.moveToNext()) {
- if (cursor.getInt(1) == FilteredNumberTypes.BLOCKED_NUMBER) {
- blockedNumbers.addAll(
- partitionedNumbers.dialerPhoneNumbersForInvalid(cursor.getString(0)));
- }
- }
- }
-
- ImmutableMap.Builder<DialerPhoneNumber, DialerBlockedNumberInfo> result =
- ImmutableMap.builder();
-
- for (DialerPhoneNumber number : numbers) {
- result.put(
- number,
- DialerBlockedNumberInfo.newBuilder()
- .setBlockedState(
- blockedNumbers.contains(number) ? BlockedState.BLOCKED : BlockedState.NOT_BLOCKED)
- .build());
- }
-
- return result.build();
- }
-
- @Override
- public void registerContentObservers() {
- appContext
- .getContentResolver()
- .registerContentObserver(
- FilteredNumber.CONTENT_URI,
- true, // FilteredNumberProvider notifies on the item
- markDirtyObserver);
- }
-
- @Override
- public void unregisterContentObservers() {
- appContext.getContentResolver().unregisterContentObserver(markDirtyObserver);
- }
-
- @Override
- public ListenableFuture<Void> clearData() {
- return Futures.immediateFuture(null);
- }
-}
diff --git a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
index f9ffd0404..4b994e725 100644
--- a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
+++ b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java
@@ -278,10 +278,7 @@ public final class PhoneLookupInfoConsolidator {
.getBlockedState()
.equals(BlockedState.BLOCKED);
}
- return phoneLookupInfo
- .getDialerBlockedNumberInfo()
- .getBlockedState()
- .equals(BlockedState.BLOCKED);
+ return false;
}
/**
diff --git a/java/com/android/dialer/phonelookup/phone_lookup_info.proto b/java/com/android/dialer/phonelookup/phone_lookup_info.proto
index 44c237bd1..5fa33d4d4 100644
--- a/java/com/android/dialer/phonelookup/phone_lookup_info.proto
+++ b/java/com/android/dialer/phonelookup/phone_lookup_info.proto
@@ -145,11 +145,4 @@ message PhoneLookupInfo {
optional BlockedState blocked_state = 1;
}
optional SystemBlockedNumberInfo system_blocked_number_info = 4;
-
- // Message for the dialer fallback for blocked number. Used in M or when the
- // migration to the system has not been completed.
- message DialerBlockedNumberInfo {
- optional BlockedState blocked_state = 1;
- }
- optional DialerBlockedNumberInfo dialer_blocked_number_info = 5;
} \ No newline at end of file