From 8285ff9bbd576d31b7b0770152578f0c6811a3f5 Mon Sep 17 00:00:00 2001 From: erfanian Date: Wed, 18 Oct 2017 13:56:00 -0700 Subject: Check AD eligibility before utilizing the feature. Bug: 67914094 Test: unit tests PiperOrigin-RevId: 172650441 Change-Id: Ie7df3174a07df2de3a102fb70a126004f704b22f --- .../android/dialer/assisteddialing/AssistedDialingMediator.java | 3 +++ .../dialer/assisteddialing/AssistedDialingMediatorImpl.java | 7 +++++++ .../dialer/assisteddialing/AssistedDialingMediatorStub.java | 5 +++++ java/com/android/dialer/callintent/CallIntentBuilder.java | 4 +++- 4 files changed, 18 insertions(+), 1 deletion(-) (limited to 'java') diff --git a/java/com/android/dialer/assisteddialing/AssistedDialingMediator.java b/java/com/android/dialer/assisteddialing/AssistedDialingMediator.java index 4dc87a772..004d2f7da 100644 --- a/java/com/android/dialer/assisteddialing/AssistedDialingMediator.java +++ b/java/com/android/dialer/assisteddialing/AssistedDialingMediator.java @@ -24,6 +24,9 @@ import java.util.Optional; /** The core interface for the AssistedDialingMediator. */ public interface AssistedDialingMediator { + /** Returns {@code true} if the current client platform supports Assisted Dialing. */ + public boolean isPlatformEligible(); + @SuppressWarnings("AndroidApiChecker") // Use of optional @TargetApi(VERSION_CODES.N) public Optional attemptAssistedDial(@NonNull String numberToTransform); diff --git a/java/com/android/dialer/assisteddialing/AssistedDialingMediatorImpl.java b/java/com/android/dialer/assisteddialing/AssistedDialingMediatorImpl.java index 1692614bb..202760751 100644 --- a/java/com/android/dialer/assisteddialing/AssistedDialingMediatorImpl.java +++ b/java/com/android/dialer/assisteddialing/AssistedDialingMediatorImpl.java @@ -17,6 +17,7 @@ package com.android.dialer.assisteddialing; import android.annotation.TargetApi; +import android.os.Build; import android.os.Build.VERSION_CODES; import android.support.annotation.NonNull; import com.android.dialer.common.LogUtil; @@ -47,6 +48,12 @@ final class AssistedDialingMediatorImpl implements AssistedDialingMediator { this.numberTransformer = numberTransformer; } + @Override + public boolean isPlatformEligible() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N + && Build.VERSION.SDK_INT <= Build.VERSION_CODES.O; + } + /** * Returns an Optional of type String containing the transformed number that was provided. The * transformed number should be capable of dialing out of the User's current country and diff --git a/java/com/android/dialer/assisteddialing/AssistedDialingMediatorStub.java b/java/com/android/dialer/assisteddialing/AssistedDialingMediatorStub.java index c7a821214..fe32e2c9a 100644 --- a/java/com/android/dialer/assisteddialing/AssistedDialingMediatorStub.java +++ b/java/com/android/dialer/assisteddialing/AssistedDialingMediatorStub.java @@ -31,4 +31,9 @@ public final class AssistedDialingMediatorStub implements AssistedDialingMediato public Optional attemptAssistedDial(@NonNull String numberToTransform) { return Optional.empty(); } + + @Override + public boolean isPlatformEligible() { + return false; + } } diff --git a/java/com/android/dialer/callintent/CallIntentBuilder.java b/java/com/android/dialer/callintent/CallIntentBuilder.java index dc239dc6b..2bbd124fb 100644 --- a/java/com/android/dialer/callintent/CallIntentBuilder.java +++ b/java/com/android/dialer/callintent/CallIntentBuilder.java @@ -126,7 +126,9 @@ public class CallIntentBuilder { Intent intent = new Intent(Intent.ACTION_CALL, uri); Bundle extras = new Bundle(); - if (allowAssistedDial && this.assistedDialingMediator != null) { + if (allowAssistedDial + && this.assistedDialingMediator != null + && this.assistedDialingMediator.isPlatformEligible()) { intent = buildAssistedDialingParameters(intent, extras); } intent.putExtra( -- cgit v1.2.3