Merge "Revert "Refactor CallFilteringResult to use a builder""
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index ca673ad..bc09c3a 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -79,7 +79,6 @@
import com.android.server.telecom.callfiltering.BlockCheckerAdapter;
import com.android.server.telecom.callfiltering.CallFilterResultCallback;
import com.android.server.telecom.callfiltering.CallFilteringResult;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import com.android.server.telecom.callfiltering.CallScreeningServiceController;
import com.android.server.telecom.callfiltering.DirectToVoicemailCallFilter;
import com.android.server.telecom.callfiltering.IncomingCallFilter;
@@ -610,12 +609,7 @@
incomingCall.hasProperty(Connection.PROPERTY_EMERGENCY_CALLBACK_MODE),
incomingCall.isSelfManaged(),
extras.getBoolean(PhoneAccount.EXTRA_SKIP_CALL_FILTERING));
- onCallFilteringComplete(incomingCall, new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build());
+ onCallFilteringComplete(incomingCall, new CallFilteringResult(true, false, true, true));
incomingCall.setIsUsingCallFiltering(false);
return;
}
diff --git a/src/com/android/server/telecom/callfiltering/AsyncBlockCheckFilter.java b/src/com/android/server/telecom/callfiltering/AsyncBlockCheckFilter.java
index edc68dd..0abd15d 100644
--- a/src/com/android/server/telecom/callfiltering/AsyncBlockCheckFilter.java
+++ b/src/com/android/server/telecom/callfiltering/AsyncBlockCheckFilter.java
@@ -30,7 +30,6 @@
import com.android.server.telecom.Call;
import com.android.server.telecom.CallerInfoLookupHelper;
import com.android.server.telecom.LogUtils;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import com.android.server.telecom.settings.BlockedNumbersUtil;
/**
@@ -122,15 +121,15 @@
try {
CallFilteringResult result;
if (isBlocked) {
- result = new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(false)
- .setCallBlockReason(convertBlockStatusToReason())
- .setCallScreeningAppName(null)
- .setCallScreeningComponentName(null)
- .build();
+ result = new CallFilteringResult(
+ false, // shouldAllowCall
+ true, //shouldReject
+ true, //shouldAddToCallLog
+ false, // shouldShowNotification
+ convertBlockStatusToReason(), //callBlockReason
+ null, //callScreeningAppName
+ null //callScreeningComponentName
+ );
if (mCallBlockListener != null) {
String number = mIncomingCall.getHandle() == null ? null
: mIncomingCall.getHandle().getSchemeSpecificPart();
@@ -138,12 +137,12 @@
mIncomingCall.getInitiatingUser());
}
} else {
- result = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ result = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ );
}
Log.addEvent(mIncomingCall, LogUtils.Events.BLOCK_CHECK_FINISHED,
BlockedNumberContract.SystemContract.blockStatusToString(mBlockStatus) + " "
diff --git a/src/com/android/server/telecom/callfiltering/CallFilteringResult.java b/src/com/android/server/telecom/callfiltering/CallFilteringResult.java
index 028fbf5..af3ee1e 100644
--- a/src/com/android/server/telecom/callfiltering/CallFilteringResult.java
+++ b/src/com/android/server/telecom/callfiltering/CallFilteringResult.java
@@ -21,73 +21,47 @@
import android.text.TextUtils;
public class CallFilteringResult {
- public static class Builder {
- private boolean mShouldAllowCall;
- private boolean mShouldReject;
- private boolean mShouldAddToCallLog;
- private boolean mShouldShowNotification;
- private boolean mShouldSilence = false;
- private int mCallBlockReason = Calls.BLOCK_REASON_NOT_BLOCKED;
- private CharSequence mCallScreeningAppName = null;
- private String mCallScreeningComponentName = null;
-
- public Builder setShouldAllowCall(boolean shouldAllowCall) {
- mShouldAllowCall = shouldAllowCall;
- return this;
- }
-
- public Builder setShouldReject(boolean shouldReject) {
- mShouldReject = shouldReject;
- return this;
- }
-
- public Builder setShouldAddToCallLog(boolean shouldAddToCallLog) {
- mShouldAddToCallLog = shouldAddToCallLog;
- return this;
- }
-
- public Builder setShouldShowNotification(boolean shouldShowNotification) {
- mShouldShowNotification = shouldShowNotification;
- return this;
- }
-
- public Builder setShouldSilence(boolean shouldSilence) {
- mShouldSilence = shouldSilence;
- return this;
- }
-
- public Builder setCallBlockReason(int callBlockReason) {
- mCallBlockReason = callBlockReason;
- return this;
- }
-
- public Builder setCallScreeningAppName(CharSequence callScreeningAppName) {
- mCallScreeningAppName = callScreeningAppName;
- return this;
- }
-
- public Builder setCallScreeningComponentName(String callScreeningComponentName) {
- mCallScreeningComponentName = callScreeningComponentName;
- return this;
- }
-
- public CallFilteringResult build() {
- return new CallFilteringResult(mShouldAllowCall, mShouldReject, mShouldSilence,
- mShouldAddToCallLog, mShouldShowNotification, mCallBlockReason,
- mCallScreeningAppName, mCallScreeningComponentName);
- }
- }
-
public boolean shouldAllowCall;
public boolean shouldReject;
public boolean shouldSilence;
public boolean shouldAddToCallLog;
public boolean shouldShowNotification;
- public int mCallBlockReason;
- public CharSequence mCallScreeningAppName;
- public String mCallScreeningComponentName;
+ public int mCallBlockReason = CallLog.Calls.BLOCK_REASON_NOT_BLOCKED;
+ public CharSequence mCallScreeningAppName = null;
+ public String mCallScreeningComponentName = null;
- private CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
+ public CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
+ shouldAddToCallLog, boolean shouldShowNotification) {
+ this.shouldAllowCall = shouldAllowCall;
+ this.shouldReject = shouldReject;
+ this.shouldSilence = false;
+ this.shouldAddToCallLog = shouldAddToCallLog;
+ this.shouldShowNotification = shouldShowNotification;
+ }
+
+ public CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
+ shouldAddToCallLog, boolean shouldShowNotification, int callBlockReason,
+ CharSequence callScreeningAppName, String callScreeningComponentName) {
+ this.shouldAllowCall = shouldAllowCall;
+ this.shouldReject = shouldReject;
+ this.shouldSilence = false;
+ this.shouldAddToCallLog = shouldAddToCallLog;
+ this.shouldShowNotification = shouldShowNotification;
+ this.mCallBlockReason = callBlockReason;
+ this.mCallScreeningAppName = callScreeningAppName;
+ this.mCallScreeningComponentName = callScreeningComponentName;
+ }
+
+ public CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
+ shouldSilence, boolean shouldAddToCallLog, boolean shouldShowNotification) {
+ this.shouldAllowCall = shouldAllowCall;
+ this.shouldReject = shouldReject;
+ this.shouldSilence = shouldSilence;
+ this.shouldAddToCallLog = shouldAddToCallLog;
+ this.shouldShowNotification = shouldShowNotification;
+ }
+
+ public CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
shouldSilence, boolean shouldAddToCallLog, boolean shouldShowNotification, int
callBlockReason, CharSequence callScreeningAppName, String callScreeningComponentName) {
this.shouldAllowCall = shouldAllowCall;
@@ -135,13 +109,12 @@
other.mCallScreeningAppName, other.mCallScreeningComponentName);
}
- return new Builder()
- .setShouldAllowCall(shouldAllowCall && other.shouldAllowCall)
- .setShouldReject(shouldReject || other.shouldReject)
- .setShouldSilence(shouldSilence || other.shouldSilence)
- .setShouldAddToCallLog(shouldAddToCallLog && other.shouldAddToCallLog)
- .setShouldShowNotification(shouldShowNotification && other.shouldShowNotification)
- .build();
+ return new CallFilteringResult(
+ shouldAllowCall && other.shouldAllowCall,
+ shouldReject || other.shouldReject,
+ shouldSilence || other.shouldSilence,
+ shouldAddToCallLog && other.shouldAddToCallLog,
+ shouldShowNotification && other.shouldShowNotification);
}
private boolean isBlockedByProvider(int blockReason) {
@@ -158,16 +131,15 @@
private CallFilteringResult getCombinedCallFilteringResult(CallFilteringResult other,
int callBlockReason, CharSequence callScreeningAppName, String callScreeningComponentName) {
- return new Builder()
- .setShouldAllowCall(shouldAllowCall && other.shouldAllowCall)
- .setShouldReject(shouldReject || other.shouldReject)
- .setShouldSilence(shouldSilence || other.shouldSilence)
- .setShouldAddToCallLog(shouldAddToCallLog && other.shouldAddToCallLog)
- .setShouldShowNotification(shouldShowNotification && other.shouldShowNotification)
- .setCallBlockReason(callBlockReason)
- .setCallScreeningAppName(callScreeningAppName)
- .setCallScreeningComponentName(callScreeningComponentName)
- .build();
+ return new CallFilteringResult(
+ shouldAllowCall && other.shouldAllowCall,
+ shouldReject || other.shouldReject,
+ shouldSilence|| other.shouldSilence,
+ shouldAddToCallLog && other.shouldAddToCallLog,
+ shouldShowNotification && other.shouldShowNotification,
+ callBlockReason,
+ callScreeningAppName,
+ callScreeningComponentName);
}
diff --git a/src/com/android/server/telecom/callfiltering/CallScreeningServiceController.java b/src/com/android/server/telecom/callfiltering/CallScreeningServiceController.java
index 42d9a59..c2f6720 100644
--- a/src/com/android/server/telecom/callfiltering/CallScreeningServiceController.java
+++ b/src/com/android/server/telecom/callfiltering/CallScreeningServiceController.java
@@ -39,7 +39,6 @@
import com.android.server.telecom.PhoneAccountRegistrar;
import com.android.server.telecom.TelecomServiceImpl;
import com.android.server.telecom.TelecomSystem;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
/**
* This class supports binding to the various {@link android.telecom.CallScreeningService}:
@@ -67,12 +66,12 @@
private Call mCall;
private CallFilterResultCallback mCallback;
- private CallFilteringResult mResult = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ private CallFilteringResult mResult = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ );
private boolean mIsFinished;
private boolean mIsCarrierFinished;
diff --git a/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java b/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java
index 9ea8d70..2a0e338 100644
--- a/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java
+++ b/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java
@@ -24,7 +24,7 @@
import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.provider.CallLog.Calls;
+import android.provider.CallLog;
import android.provider.Settings;
import android.telecom.Log;
import android.telecom.TelecomManager;
@@ -41,7 +41,6 @@
import com.android.server.telecom.PhoneAccountRegistrar;
import com.android.server.telecom.TelecomServiceImpl.SettingsSecureAdapter;
import com.android.server.telecom.TelecomSystem;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
/**
* Binds to {@link ICallScreeningService} to allow call blocking. A single instance of this class
@@ -97,13 +96,13 @@
synchronized (mTelecomLock) {
Log.d(this, "allowCall(%s)", callId);
if (mCall != null && mCall.getId().equals(callId)) {
- mResult = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldSilence(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ mResult = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, //shouldReject
+ false, //shouldSilence
+ true, //shouldAddToCallLog
+ true // shouldShowNotification
+ );
} else {
Log.w(this, "allowCall, unknown call id: %s", callId);
}
@@ -132,16 +131,16 @@
+ "shouldShowNotification: %b", callId, shouldReject,
isServiceRequestingLogging, shouldShowNotification);
if (mCall != null && mCall.getId().equals(callId)) {
- mResult = new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(shouldReject)
- .setShouldSilence(false)
- .setShouldAddToCallLog(isServiceRequestingLogging)
- .setShouldShowNotification(shouldShowNotification)
- .setCallBlockReason(Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName(mAppName)
- .setCallScreeningComponentName(componentName.flattenToString())
- .build();
+ mResult = new CallFilteringResult(
+ false, // shouldAllowCall
+ shouldReject, //shouldReject
+ false, // shouldSilenceCall
+ isServiceRequestingLogging, //shouldAddToCallLog
+ shouldShowNotification, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE, //callBlockReason
+ mAppName, //callScreeningAppName
+ componentName.flattenToString() //callScreeningComponentName
+ );
} else {
Log.w(this, "disallowCall, unknown call id: %s", callId);
}
@@ -161,13 +160,13 @@
synchronized (mTelecomLock) {
Log.d(this, "silenceCall(%s)", callId);
if (mCall != null && mCall.getId().equals(callId)) {
- mResult = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldSilence(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ mResult = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, //shouldReject
+ true, //shouldSilence
+ true, //shouldAddToCallLog
+ true // shouldShowNotification
+ );
} else {
Log.w(this, "silenceCall, unknown call id: %s", callId);
}
@@ -200,12 +199,12 @@
private boolean mHasFinished = false;
private int mCallScreeningServiceType;
- private CallFilteringResult mResult = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ private CallFilteringResult mResult = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, //shouldReject
+ true, //shouldAddToCallLog
+ true // shouldShowNotification
+ );
public CallScreeningServiceFilter(
Context context,
diff --git a/src/com/android/server/telecom/callfiltering/DirectToVoicemailCallFilter.java b/src/com/android/server/telecom/callfiltering/DirectToVoicemailCallFilter.java
index 16d731b..3a8ff7d 100644
--- a/src/com/android/server/telecom/callfiltering/DirectToVoicemailCallFilter.java
+++ b/src/com/android/server/telecom/callfiltering/DirectToVoicemailCallFilter.java
@@ -17,14 +17,13 @@
package com.android.server.telecom.callfiltering;
import android.net.Uri;
-import android.provider.CallLog.Calls;
+import android.provider.CallLog;
import android.telecom.Log;
import com.android.internal.telephony.CallerInfo;
import com.android.server.telecom.Call;
import com.android.server.telecom.CallerInfoLookupHelper;
import com.android.server.telecom.LogUtils;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import java.util.Objects;
@@ -47,32 +46,33 @@
CallFilteringResult result;
if ((handle != null) && Objects.equals(callHandle, handle)) {
if (info != null && info.shouldSendToVoicemail) {
- result = new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_DIRECT_TO_VOICEMAIL)
- .setCallScreeningAppName(null)
- .setCallScreeningComponentName(null)
- .build();
+ result = new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ true, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_DIRECT_TO_VOICEMAIL,
+ //callBlockReason
+ null, //callScreeningAppName
+ null // callScreeningComponentName
+ );
} else {
- result = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ result = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ );
}
Log.addEvent(call, LogUtils.Events.DIRECT_TO_VM_FINISHED, result);
callback.onCallFilteringComplete(call, result);
} else {
- result = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ result = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ );
Log.addEvent(call, LogUtils.Events.DIRECT_TO_VM_FINISHED, result);
Log.w(this, "CallerInfo lookup returned with a different handle than " +
"what was passed in. Was %s, should be %s", handle, callHandle);
diff --git a/src/com/android/server/telecom/callfiltering/IncomingCallFilter.java b/src/com/android/server/telecom/callfiltering/IncomingCallFilter.java
index 860de1f..cc686ab 100644
--- a/src/com/android/server/telecom/callfiltering/IncomingCallFilter.java
+++ b/src/com/android/server/telecom/callfiltering/IncomingCallFilter.java
@@ -27,7 +27,6 @@
import com.android.server.telecom.LogUtils;
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.Timeouts;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import java.util.List;
@@ -54,12 +53,12 @@
private final CallFilterResultCallback mListener;
private final Timeouts.Adapter mTimeoutsAdapter;
- private CallFilteringResult mResult = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ private CallFilteringResult mResult = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ );
private boolean mIsPending = true;
private int mNumPendingFilters;
diff --git a/tests/src/com/android/server/telecom/tests/AsyncBlockCheckFilterTest.java b/tests/src/com/android/server/telecom/tests/AsyncBlockCheckFilterTest.java
index ee34b0c..ebc2826 100644
--- a/tests/src/com/android/server/telecom/tests/AsyncBlockCheckFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/AsyncBlockCheckFilterTest.java
@@ -23,7 +23,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.PersistableBundle;
-import android.provider.CallLog.Calls;
+import android.provider.CallLog;
import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.test.suitebuilder.annotation.SmallTest;
@@ -34,7 +34,6 @@
import com.android.server.telecom.callfiltering.BlockCheckerAdapter;
import com.android.server.telecom.callfiltering.CallFilterResultCallback;
import com.android.server.telecom.callfiltering.CallFilteringResult;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import org.junit.After;
import org.junit.Before;
@@ -62,22 +61,23 @@
@Mock private CarrierConfigManager mCarrierConfigManager;
private AsyncBlockCheckFilter mFilter;
- private static final CallFilteringResult BLOCK_RESULT = new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(false)
- .setCallBlockReason(Calls.BLOCK_REASON_BLOCKED_NUMBER)
- .setCallScreeningAppName(null)
- .setCallScreeningComponentName(null)
- .build();
+ private static final CallFilteringResult BLOCK_RESULT = new CallFilteringResult(
+ false, // shouldAllowCall
+ true, //shouldReject
+ true, //shouldAddToCallLog
+ false, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_BLOCKED_NUMBER, //blockReason
+ null, // callScreeningAppName
+ null //callScreeningComponentName
- private static final CallFilteringResult PASS_RESULT = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ );
+
+ private static final CallFilteringResult PASS_RESULT = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ );
private static final Uri TEST_HANDLE = Uri.parse("tel:1235551234");
private static final int TEST_TIMEOUT = 1000;
diff --git a/tests/src/com/android/server/telecom/tests/CallScreeningServiceControllerTest.java b/tests/src/com/android/server/telecom/tests/CallScreeningServiceControllerTest.java
index 24cc8d2..1f438d5 100644
--- a/tests/src/com/android/server/telecom/tests/CallScreeningServiceControllerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallScreeningServiceControllerTest.java
@@ -29,7 +29,6 @@
import android.os.PersistableBundle;
import android.os.UserHandle;
import android.provider.CallLog;
-import android.provider.CallLog.Calls;
import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.test.suitebuilder.annotation.SmallTest;
@@ -46,7 +45,6 @@
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.callfiltering.CallFilterResultCallback;
import com.android.server.telecom.callfiltering.CallFilteringResult;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import com.android.server.telecom.callfiltering.CallScreeningServiceController;
import org.junit.After;
@@ -72,6 +70,31 @@
@RunWith(JUnit4.class)
public class CallScreeningServiceControllerTest extends TelecomTestCase {
+ @Mock Context mContext;
+ @Mock Call mCall;
+ @Mock private CallFilterResultCallback mCallback;
+ @Mock CallsManager mCallsManager;
+ @Mock RoleManagerAdapter mRoleManagerAdapter;
+ @Mock CarrierConfigManager mCarrierConfigManager;
+ @Mock private TelecomManager mTelecomManager;
+ @Mock PackageManager mPackageManager;
+ @Mock ParcelableCallUtils.Converter mParcelableCallUtilsConverter;
+ @Mock PhoneAccountRegistrar mPhoneAccountRegistrar;
+ @Mock private CallerInfoLookupHelper mCallerInfoLookupHelper;
+
+ CallScreeningServiceHelper.AppLabelProxy mAppLabelProxy =
+ new CallScreeningServiceHelper.AppLabelProxy() {
+ @Override
+ public CharSequence getAppLabel(String packageName) {
+ return APP_NAME;
+ }
+ };
+
+ private ResolveInfo mResolveInfo;
+ private TelecomServiceImpl.SettingsSecureAdapter mSettingsSecureAdapter =
+ spy(new CallScreeningServiceFilterTest.SettingsSecureAdapterFake());
+ private TelecomSystem.SyncRoot mLock = new TelecomSystem.SyncRoot() { };
+
private static final String CALL_ID = "u89prgt9ps78y5";
private static final Uri TEST_HANDLE = Uri.parse("tel:1235551234");
private static final String DEFAULT_DIALER_PACKAGE = "com.android.dialer";
@@ -84,46 +107,27 @@
"com.android.dialer", "com.android.dialer.callscreeningserviceimpl");
private static final ComponentName USER_CHOSEN_CALL_SCREENING = new ComponentName(
"com.android.userchosen", "com.android.userchosen.callscreeningserviceimpl");
- private static final CallFilteringResult PASS_RESULT = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
- @Mock
- Context mContext;
- @Mock
- Call mCall;
- @Mock
- CallsManager mCallsManager;
- @Mock
- RoleManagerAdapter mRoleManagerAdapter;
- @Mock
- CarrierConfigManager mCarrierConfigManager;
- @Mock
- PackageManager mPackageManager;
- @Mock
- ParcelableCallUtils.Converter mParcelableCallUtilsConverter;
- @Mock
- PhoneAccountRegistrar mPhoneAccountRegistrar;
- CallScreeningServiceHelper.AppLabelProxy mAppLabelProxy =
- new CallScreeningServiceHelper.AppLabelProxy() {
- @Override
- public CharSequence getAppLabel(String packageName) {
- return APP_NAME;
- }
- };
- @Mock
- private CallFilterResultCallback mCallback;
- @Mock
- private TelecomManager mTelecomManager;
- @Mock
- private CallerInfoLookupHelper mCallerInfoLookupHelper;
- private ResolveInfo mResolveInfo;
- private TelecomServiceImpl.SettingsSecureAdapter mSettingsSecureAdapter =
- spy(new CallScreeningServiceFilterTest.SettingsSecureAdapterFake());
- private TelecomSystem.SyncRoot mLock = new TelecomSystem.SyncRoot() {
- };
+
+ private static final CallFilteringResult PASS_RESULT = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ );
+
+ public static class SettingsSecureAdapterFake implements
+ TelecomServiceImpl.SettingsSecureAdapter {
+ @Override
+ public void putStringForUser(ContentResolver resolver, String name, String value,
+ int userHandle) {
+
+ }
+
+ @Override
+ public String getStringForUser(ContentResolver resolver, String name, int userHandle) {
+ return USER_CHOSEN_CALL_SCREENING.flattenToString();
+ }
+ }
@Override
@Before
@@ -141,7 +145,7 @@
when(TelecomManager.from(mContext)).thenReturn(mTelecomManager);
when(mTelecomManager.getDefaultDialerPackage()).thenReturn(DEFAULT_DIALER_PACKAGE);
- mResolveInfo = new ResolveInfo() {{
+ mResolveInfo = new ResolveInfo() {{
serviceInfo = new ServiceInfo();
serviceInfo.packageName = PKG_NAME;
serviceInfo.name = CLS_NAME;
@@ -232,27 +236,30 @@
controller.startFilterLookup(mCall, mCallback);
- CallFilteringResult expectedResult = new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(false)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName(APP_NAME)
- .setCallScreeningComponentName(
- CARRIER_DEFINED_CALL_SCREENING.flattenToString())
- .build();
-
- controller.onCallScreeningFilterComplete(mCall, expectedResult,
- CARRIER_DEFINED_CALL_SCREENING.getPackageName());
+ controller.onCallScreeningFilterComplete(mCall, new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE,
+ APP_NAME,
+ CARRIER_DEFINED_CALL_SCREENING.flattenToString()
+ ), CARRIER_DEFINED_CALL_SCREENING.getPackageName());
verify(mContext, times(1)).bindServiceAsUser(any(Intent.class),
any(ServiceConnection.class),
eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE),
eq(UserHandle.CURRENT));
- verify(mCallback)
- .onCallFilteringComplete(eq(mCall), eq(expectedResult));
+ verify(mCallback).onCallFilteringComplete(eq(mCall), eq(new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE, //callBlockReason
+ APP_NAME, //callScreeningAppName
+ CARRIER_DEFINED_CALL_SCREENING.flattenToString() //callScreeningComponentName
+ )));
}
@SmallTest
@@ -275,31 +282,30 @@
callerInfo.contactExists = false;
queryListener.onCallerInfoQueryComplete(TEST_HANDLE, callerInfo);
- CallFilteringResult.Builder resultBuilder = new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName(APP_NAME)
- .setCallScreeningComponentName(DEFAULT_DIALER_CALL_SCREENING.flattenToString());
-
- CallFilteringResult providedResult = resultBuilder
- .setShouldAddToCallLog(false)
- .build();
-
- controller.onCallScreeningFilterComplete(mCall, providedResult,
- DEFAULT_DIALER_CALL_SCREENING.getPackageName());
+ controller.onCallScreeningFilterComplete(mCall, new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE,
+ APP_NAME,
+ DEFAULT_DIALER_CALL_SCREENING.flattenToString()
+ ), DEFAULT_DIALER_CALL_SCREENING.getPackageName());
verify(mContext, times(3)).bindServiceAsUser(any(Intent.class),
any(ServiceConnection.class),
eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE),
eq(UserHandle.CURRENT));
- CallFilteringResult expectedResult = resultBuilder
- .setShouldAddToCallLog(true)
- .build();
-
- verify(mCallback).onCallFilteringComplete(eq(mCall), eq(expectedResult));
+ verify(mCallback).onCallFilteringComplete(eq(mCall), eq(new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ true, // shouldAddToCallLog (we don't allow services to skip call log)
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE, //callBlockReason
+ APP_NAME, //callScreeningAppName
+ DEFAULT_DIALER_CALL_SCREENING.flattenToString() //callScreeningComponentName
+ )));
}
@SmallTest
@@ -324,31 +330,30 @@
controller.onCallScreeningFilterComplete(mCall, PASS_RESULT,
DEFAULT_DIALER_CALL_SCREENING.getPackageName());
-
- CallFilteringResult.Builder resultBuilder = new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName(APP_NAME)
- .setCallScreeningComponentName(DEFAULT_DIALER_CALL_SCREENING.flattenToString());
- CallFilteringResult providedResult = resultBuilder
- .setShouldAddToCallLog(false)
- .build();
-
- controller.onCallScreeningFilterComplete(mCall, providedResult,
- USER_CHOSEN_CALL_SCREENING.getPackageName());
+ controller.onCallScreeningFilterComplete(mCall, new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE,
+ APP_NAME,
+ USER_CHOSEN_CALL_SCREENING.flattenToString()
+ ), USER_CHOSEN_CALL_SCREENING.getPackageName());
verify(mContext, times(3)).bindServiceAsUser(any(Intent.class),
any(ServiceConnection.class),
eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE),
eq(UserHandle.CURRENT));
- CallFilteringResult expectedResult = resultBuilder
- .setShouldAddToCallLog(true)
- .build();
-
- verify(mCallback).onCallFilteringComplete(eq(mCall), eq(expectedResult));
+ verify(mCallback).onCallFilteringComplete(eq(mCall), eq(new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ true, // shouldAddToCallLog (we don't allow services to skip call log)
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE, //callBlockReason
+ APP_NAME, //callScreeningAppName
+ USER_CHOSEN_CALL_SCREENING.flattenToString() //callScreeningComponentName
+ )));
}
/**
@@ -376,27 +381,25 @@
callerInfo.contactExists = false;
queryListener.onCallerInfoQueryComplete(TEST_HANDLE, callerInfo);
- controller.onCallScreeningFilterComplete(mCall, new CallFilteringResult.Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(false)
- .setShouldShowNotification(true)
- .setCallBlockReason(CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName(APP_NAME)
- .setCallScreeningComponentName(
- DEFAULT_DIALER_CALL_SCREENING.flattenToString())
- .build(),
+ controller.onCallScreeningFilterComplete(mCall, new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE,
+ APP_NAME,
+ DEFAULT_DIALER_CALL_SCREENING.flattenToString()
+ ),
DEFAULT_DIALER_CALL_SCREENING.getPackageName());
-
- controller.onCallScreeningFilterComplete(mCall, new CallFilteringResult.Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(false)
- .setShouldShowNotification(true)
- .setCallBlockReason(CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName(APP_NAME)
- .setCallScreeningComponentName(DEFAULT_DIALER_CALL_SCREENING.flattenToString())
- .build(), USER_CHOSEN_CALL_SCREENING.getPackageName());
+ controller.onCallScreeningFilterComplete(mCall, new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE,
+ APP_NAME,
+ DEFAULT_DIALER_CALL_SCREENING.flattenToString()
+ ), USER_CHOSEN_CALL_SCREENING.getPackageName());
// Expect to bind twice; once to the carrier defined service, and then again to the default
// dialer.
@@ -406,18 +409,15 @@
eq(UserHandle.CURRENT));
// Expect filtering to complete only a single time from the default dialer service.
- verify(mCallback, times(1)).onCallFilteringComplete(eq(mCall),
- eq(new CallFilteringResult.Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .setCallBlockReason(CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName(APP_NAME)
- .setCallScreeningComponentName(
- DEFAULT_DIALER_CALL_SCREENING.flattenToString())
- .build()));
- }
+ verify(mCallback, times(1)).onCallFilteringComplete(eq(mCall), eq(new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ true, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE,
+ APP_NAME,
+ DEFAULT_DIALER_CALL_SCREENING.flattenToString()
+ ))); }
private CallerInfoLookupHelper.OnQueryCompleteListener verifyLookupStart() {
return verifyLookupStart(TEST_HANDLE);
@@ -440,18 +440,4 @@
.thenReturn(mCarrierConfigManager);
when(mCarrierConfigManager.getConfig()).thenReturn(bundle);
}
-
- public static class SettingsSecureAdapterFake implements
- TelecomServiceImpl.SettingsSecureAdapter {
- @Override
- public void putStringForUser(ContentResolver resolver, String name, String value,
- int userHandle) {
-
- }
-
- @Override
- public String getStringForUser(ContentResolver resolver, String name, int userHandle) {
- return USER_CHOSEN_CALL_SCREENING.flattenToString();
- }
- }
}
diff --git a/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java b/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
index 7b3a499..b11b397 100644
--- a/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
@@ -29,7 +29,7 @@
import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.provider.CallLog.Calls;
+import android.provider.CallLog;
import android.telecom.CallScreeningService;
import android.telecom.ParcelableCall;
import android.telecom.TelecomManager;
@@ -44,7 +44,6 @@
import com.android.server.telecom.PhoneAccountRegistrar;
import com.android.server.telecom.TelecomServiceImpl;
import com.android.server.telecom.callfiltering.CallFilteringResult;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import com.android.server.telecom.callfiltering.CallScreeningServiceFilter;
import com.android.server.telecom.TelecomSystem;
@@ -106,20 +105,20 @@
private static final String USER_CHOSEN_CALL_SCREENING_APP_NAME = "UserChosen";
private ResolveInfo mResolveInfo;
- private static final CallFilteringResult PASS_RESULT = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ private static final CallFilteringResult PASS_RESULT = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ );
- private static final CallFilteringResult PASS_RESULT_WITH_SILENCE = new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldSilence(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ private static final CallFilteringResult PASS_RESULT_WITH_SILENCE = new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldSilence
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ );
private CallScreeningServiceFilter mFilter;
@@ -275,17 +274,15 @@
true, // shouldShowNotification
CARRIER_DEFINED_CALL_SCREENING
);
- verify(mCallback).onCallScreeningFilterComplete(eq(mCall), eq(new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(false)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName(CARRIER_DEFINED_CALL_SCREENING_APP_NAME)
- .setCallScreeningComponentName(
- CARRIER_DEFINED_CALL_SCREENING.flattenToString())
- .build()),
- eq(CARRIER_DEFINED_CALL_SCREENING.getPackageName()));
+ verify(mCallback).onCallScreeningFilterComplete(eq(mCall), eq(new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE, //callBlockReason
+ CARRIER_DEFINED_CALL_SCREENING_APP_NAME, //callScreeningAppName
+ CARRIER_DEFINED_CALL_SCREENING.flattenToString() //callScreeningComponentName
+ )), eq(CARRIER_DEFINED_CALL_SCREENING.getPackageName()));
}
@SmallTest
@@ -310,16 +307,15 @@
true, // shouldShowNotification
DEFAULT_DIALER_CALL_SCREENING
);
- verify(mCallback).onCallScreeningFilterComplete(eq(mCall), eq(new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName(DEFAULT_DIALER_APP_NAME)
- .setCallScreeningComponentName(DEFAULT_DIALER_CALL_SCREENING.flattenToString())
- .build()),
- eq(DEFAULT_DIALER_CALL_SCREENING.getPackageName()));
+ verify(mCallback).onCallScreeningFilterComplete(eq(mCall), eq(new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ true, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE, //callBlockReason
+ DEFAULT_DIALER_APP_NAME, //callScreeningAppName
+ DEFAULT_DIALER_CALL_SCREENING.flattenToString() //callScreeningComponentName
+ )), eq(DEFAULT_DIALER_CALL_SCREENING.getPackageName()));
}
@SmallTest
@@ -344,16 +340,15 @@
true, // shouldShowNotification
USER_CHOSEN_CALL_SCREENING
);
- verify(mCallback).onCallScreeningFilterComplete(eq(mCall), eq(new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName(USER_CHOSEN_CALL_SCREENING_APP_NAME)
- .setCallScreeningComponentName(USER_CHOSEN_CALL_SCREENING.flattenToString())
- .build()),
- eq(USER_CHOSEN_CALL_SCREENING.getPackageName()));
+ verify(mCallback).onCallScreeningFilterComplete(eq(mCall), eq(new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ true, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE, //callBlockReason
+ USER_CHOSEN_CALL_SCREENING_APP_NAME, //callScreeningAppName
+ USER_CHOSEN_CALL_SCREENING.flattenToString() //callScreeningComponentName
+ )), eq(USER_CHOSEN_CALL_SCREENING.getPackageName()));
}
private ServiceConnection verifyBindingIntent() {
diff --git a/tests/src/com/android/server/telecom/tests/DirectToVoicemailCallFilterTest.java b/tests/src/com/android/server/telecom/tests/DirectToVoicemailCallFilterTest.java
index e62a9fc..551165d 100644
--- a/tests/src/com/android/server/telecom/tests/DirectToVoicemailCallFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/DirectToVoicemailCallFilterTest.java
@@ -17,14 +17,14 @@
package com.android.server.telecom.tests;
import android.net.Uri;
-import android.provider.CallLog.Calls;
+import android.provider.CallLog;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.internal.telephony.CallerInfo;
import com.android.server.telecom.Call;
import com.android.server.telecom.callfiltering.CallFilterResultCallback;
import com.android.server.telecom.CallerInfoLookupHelper;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
+import com.android.server.telecom.callfiltering.CallFilteringResult;
import com.android.server.telecom.callfiltering.DirectToVoicemailCallFilter;
import org.junit.After;
@@ -68,15 +68,16 @@
callerInfo.shouldSendToVoicemail = true;
queryListener.onCallerInfoQueryComplete(TEST_HANDLE, callerInfo);
- verify(mCallback).onCallFilteringComplete(mCall, new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_DIRECT_TO_VOICEMAIL)
- .setCallScreeningAppName(null)
- .setCallScreeningComponentName(null)
- .build());
+ verify(mCallback).onCallFilteringComplete(mCall,
+ new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ true, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_DIRECT_TO_VOICEMAIL, //callBlockReason
+ null, //callScreeningAppName
+ null // callScreeningComponentName
+ ));
}
@SmallTest
@@ -88,12 +89,13 @@
callerInfo.shouldSendToVoicemail = false;
queryListener.onCallerInfoQueryComplete(TEST_HANDLE, callerInfo);
- verify(mCallback).onCallFilteringComplete(mCall, new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build());
+ verify(mCallback).onCallFilteringComplete(mCall,
+ new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ ));
}
@SmallTest
@@ -102,12 +104,13 @@
CallerInfoLookupHelper.OnQueryCompleteListener queryListener = verifyLookupStart(null);
queryListener.onCallerInfoQueryComplete(null, null);
- verify(mCallback).onCallFilteringComplete(mCall, new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build());
+ verify(mCallback).onCallFilteringComplete(mCall,
+ new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ ));
}
private CallerInfoLookupHelper.OnQueryCompleteListener verifyLookupStart() {
diff --git a/tests/src/com/android/server/telecom/tests/IncomingCallFilterTest.java b/tests/src/com/android/server/telecom/tests/IncomingCallFilterTest.java
index 8e2d11e..76341b2 100644
--- a/tests/src/com/android/server/telecom/tests/IncomingCallFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/IncomingCallFilterTest.java
@@ -17,17 +17,17 @@
package com.android.server.telecom.tests;
import android.content.ContentResolver;
+import android.content.IContentProvider;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
-import android.provider.CallLog.Calls;
+import android.provider.CallLog;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.server.telecom.Call;
import com.android.server.telecom.Timeouts;
import com.android.server.telecom.callfiltering.CallFilterResultCallback;
import com.android.server.telecom.callfiltering.CallFilteringResult;
-import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import com.android.server.telecom.callfiltering.IncomingCallFilter;
import com.android.server.telecom.TelecomSystem;
@@ -68,47 +68,46 @@
private static final long SHORT_TIMEOUT = 100;
private static final CallFilteringResult PASS_CALL_RESULT =
- new Builder()
- .setShouldAllowCall(true)
- .setShouldReject(false)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .build();
+ new CallFilteringResult(
+ true, // shouldAllowCall
+ false, // shouldReject
+ true, // shouldAddToCallLog
+ true // shouldShowNotification
+ );
private static final CallFilteringResult ASYNC_BLOCK_CHECK_BLOCK_RESULT =
- new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(false)
- .setCallBlockReason(Calls.BLOCK_REASON_BLOCKED_NUMBER)
- .setCallScreeningAppName(null)
- .setCallScreeningComponentName(null)
- .build();
+ new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ true, // shouldAddToCallLog
+ false, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_BLOCKED_NUMBER, //callBlockReason
+ null, //callScreeningAppName
+ null //callScreeningComponentName
+ );
private static final CallFilteringResult DIRECT_TO_VOICEMAIL_CALL_BLOCK_RESULT =
- new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(true)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_DIRECT_TO_VOICEMAIL)
- .setCallScreeningAppName(null)
- .setCallScreeningComponentName(null)
- .build();
+ new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ true, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_DIRECT_TO_VOICEMAIL, //callBlockReason
+ null, //callScreeningAppName
+ null //callScreeningComponentName
+ );
private static final CallFilteringResult CALL_SCREENING_SERVICE_BLOCK_RESULT =
- new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(false)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName("com.android.thirdparty")
- .setCallScreeningComponentName(
- "com.android.thirdparty/"
- + "com.android.thirdparty.callscreeningserviceimpl")
- .build();
+ new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE, //callBlockReason
+ "com.android.thirdparty", //callScreeningAppName
+ "com.android.thirdparty/com.android.thirdparty.callscreeningserviceimpl"
+ //callScreeningComponentName
+ );
private static final CallFilteringResult DEFAULT_RESULT = PASS_CALL_RESULT;
private Handler mHandler = new Handler(Looper.getMainLooper());
@@ -208,15 +207,16 @@
testFilter.onCallFilteringComplete(mCall, DIRECT_TO_VOICEMAIL_CALL_BLOCK_RESULT);
testFilter.onCallFilteringComplete(mCall, CALL_SCREENING_SERVICE_BLOCK_RESULT);
waitForHandlerAction(testFilter.getHandler(), SHORT_TIMEOUT * 2);
- verify(mResultCallback).onCallFilteringComplete(eq(mCall), eq(new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(false)
- .setShouldShowNotification(false)
- .setCallBlockReason(Calls.BLOCK_REASON_BLOCKED_NUMBER)
- .setCallScreeningAppName(null)
- .setCallScreeningComponentName(null)
- .build()));
+ verify(mResultCallback).onCallFilteringComplete(eq(mCall), eq(
+ new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ false, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_BLOCKED_NUMBER, //callBlockReason
+ null, //callScreeningAppName
+ null //callScreeningComponentName
+ )));
}
@SmallTest
@@ -239,15 +239,16 @@
testFilter.onCallFilteringComplete(mCall, DIRECT_TO_VOICEMAIL_CALL_BLOCK_RESULT);
testFilter.onCallFilteringComplete(mCall, CALL_SCREENING_SERVICE_BLOCK_RESULT);
waitForHandlerAction(testFilter.getHandler(), SHORT_TIMEOUT * 2);
- verify(mResultCallback).onCallFilteringComplete(eq(mCall), eq(new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(false)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_DIRECT_TO_VOICEMAIL)
- .setCallScreeningAppName(null)
- .setCallScreeningComponentName(null)
- .build()));
+ verify(mResultCallback).onCallFilteringComplete(eq(mCall), eq(
+ new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_DIRECT_TO_VOICEMAIL, //callBlockReason
+ null, ////callScreeningAppName
+ null ////callScreeningComponentName
+ )));
}
@SmallTest
@@ -267,16 +268,17 @@
testFilter.onCallFilteringComplete(mCall, PASS_CALL_RESULT);
testFilter.onCallFilteringComplete(mCall, CALL_SCREENING_SERVICE_BLOCK_RESULT);
waitForHandlerAction(testFilter.getHandler(), SHORT_TIMEOUT * 2);
- verify(mResultCallback).onCallFilteringComplete(eq(mCall), eq(new Builder()
- .setShouldAllowCall(false)
- .setShouldReject(true)
- .setShouldAddToCallLog(false)
- .setShouldShowNotification(true)
- .setCallBlockReason(Calls.BLOCK_REASON_CALL_SCREENING_SERVICE)
- .setCallScreeningAppName("com.android.thirdparty")
- .setCallScreeningComponentName(
- "com.android.thirdparty/com.android.thirdparty.callscreeningserviceimpl")
- .build()));
+ verify(mResultCallback).onCallFilteringComplete(eq(mCall), eq(
+ new CallFilteringResult(
+ false, // shouldAllowCall
+ true, // shouldReject
+ false, // shouldAddToCallLog
+ true, // shouldShowNotification
+ CallLog.Calls.BLOCK_REASON_CALL_SCREENING_SERVICE, //callBlockReason
+ "com.android.thirdparty", //callScreeningAppName
+ "com.android.thirdparty/com.android.thirdparty.callscreeningserviceimpl"
+ //callScreeningComponentName
+ )));
}
@SmallTest