1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.dialer.spam; 18 19 import com.android.dialer.DialerPhoneNumber; 20 import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor; 21 import com.android.dialer.logging.ContactLookupResult; 22 import com.android.dialer.logging.ContactSource; 23 import com.android.dialer.logging.ReportingLocation; 24 import com.google.common.base.Optional; 25 import com.google.common.collect.ImmutableMap; 26 import com.google.common.collect.ImmutableSet; 27 import com.google.common.util.concurrent.Futures; 28 import com.google.common.util.concurrent.ListenableFuture; 29 import com.google.common.util.concurrent.ListeningExecutorService; 30 import javax.inject.Inject; 31 32 /** Default implementation of Spam. */ 33 public class SpamStub implements Spam { 34 35 private final ListeningExecutorService backgroundExecutorService; 36 37 @Inject SpamStub(@ackgroundExecutor ListeningExecutorService backgroundExecutorService)38 public SpamStub(@BackgroundExecutor ListeningExecutorService backgroundExecutorService) { 39 this.backgroundExecutorService = backgroundExecutorService; 40 } 41 42 @Override isSpamEnabled()43 public boolean isSpamEnabled() { 44 return false; 45 } 46 47 @Override isSpamNotificationEnabled()48 public boolean isSpamNotificationEnabled() { 49 return false; 50 } 51 52 @Override isDialogEnabledForSpamNotification()53 public boolean isDialogEnabledForSpamNotification() { 54 return false; 55 } 56 57 @Override isDialogReportSpamCheckedByDefault()58 public boolean isDialogReportSpamCheckedByDefault() { 59 return false; 60 } 61 62 @Override percentOfSpamNotificationsToShow()63 public int percentOfSpamNotificationsToShow() { 64 return 0; 65 } 66 67 @Override percentOfNonSpamNotificationsToShow()68 public int percentOfNonSpamNotificationsToShow() { 69 return 0; 70 } 71 72 @Override batchCheckSpamStatus( ImmutableSet<DialerPhoneNumber> dialerPhoneNumbers)73 public ListenableFuture<ImmutableMap<DialerPhoneNumber, SpamStatus>> batchCheckSpamStatus( 74 ImmutableSet<DialerPhoneNumber> dialerPhoneNumbers) { 75 return backgroundExecutorService.submit( 76 () -> { 77 ImmutableMap.Builder<DialerPhoneNumber, SpamStatus> resultBuilder = 78 new ImmutableMap.Builder<>(); 79 for (DialerPhoneNumber dialerPhoneNumber : dialerPhoneNumbers) { 80 resultBuilder.put( 81 dialerPhoneNumber, 82 new SpamStatus() { 83 @Override 84 public boolean isSpam() { 85 return false; 86 } 87 88 @Override 89 public Optional<Long> getTimestampMillis() { 90 return Optional.absent(); 91 } 92 }); 93 } 94 return resultBuilder.build(); 95 }); 96 } 97 98 @Override checkSpamStatus(String number, String countryIso, Listener listener)99 public void checkSpamStatus(String number, String countryIso, Listener listener) { 100 listener.onComplete(false); 101 } 102 103 @Override checkUserMarkedNonSpamStatus(String number, String countryIso, Listener listener)104 public void checkUserMarkedNonSpamStatus(String number, String countryIso, Listener listener) { 105 listener.onComplete(false); 106 } 107 108 @Override checkUserMarkedSpamStatus(String number, String countryIso, Listener listener)109 public void checkUserMarkedSpamStatus(String number, String countryIso, Listener listener) { 110 listener.onComplete(false); 111 } 112 113 @Override checkGlobalSpamListStatus(String number, String countryIso, Listener listener)114 public void checkGlobalSpamListStatus(String number, String countryIso, Listener listener) { 115 listener.onComplete(false); 116 } 117 118 @Override checkSpamStatusSynchronous(String number, String countryIso)119 public boolean checkSpamStatusSynchronous(String number, String countryIso) { 120 return false; 121 } 122 123 @Override dataUpdatedSince(long timestampMillis)124 public ListenableFuture<Boolean> dataUpdatedSince(long timestampMillis) { 125 return Futures.immediateFuture(false); 126 } 127 128 @Override reportSpamFromAfterCallNotification( String number, String countryIso, int callType, ReportingLocation.Type from, ContactLookupResult.Type contactLookupResultType)129 public void reportSpamFromAfterCallNotification( 130 String number, 131 String countryIso, 132 int callType, 133 ReportingLocation.Type from, 134 ContactLookupResult.Type contactLookupResultType) {} 135 136 @Override reportSpamFromCallHistory( String number, String countryIso, int callType, ReportingLocation.Type from, ContactSource.Type contactSourceType)137 public void reportSpamFromCallHistory( 138 String number, 139 String countryIso, 140 int callType, 141 ReportingLocation.Type from, 142 ContactSource.Type contactSourceType) {} 143 144 @Override reportNotSpamFromAfterCallNotification( String number, String countryIso, int callType, ReportingLocation.Type from, ContactLookupResult.Type contactLookupResultType)145 public void reportNotSpamFromAfterCallNotification( 146 String number, 147 String countryIso, 148 int callType, 149 ReportingLocation.Type from, 150 ContactLookupResult.Type contactLookupResultType) {} 151 152 @Override reportNotSpamFromCallHistory( String number, String countryIso, int callType, ReportingLocation.Type from, ContactSource.Type contactSourceType)153 public void reportNotSpamFromCallHistory( 154 String number, 155 String countryIso, 156 int callType, 157 ReportingLocation.Type from, 158 ContactSource.Type contactSourceType) {} 159 } 160