From 2cf2c3484c5f8dd11e6ad32633f7254119525413 Mon Sep 17 00:00:00 2001 From: erfanian Date: Thu, 21 Dec 2017 12:01:33 -0800 Subject: Update assisted dialing extras in preparation for platform implementation. * Use only one extra as if we were going to make a request of the Platform. * Modify the incallui to handle instances where the platform may not supply TransformationInfo. This should accommodate instances where the platform "used" assisted dialing, but did not provide the necessary TransformationInfo. Test: unit tests PiperOrigin-RevId: 179841752 Change-Id: I06411dc00812dba8978a2a090d8769dcce9b2ad6 --- java/com/android/incallui/call/DialerCall.java | 43 +++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'java/com/android/incallui/call/DialerCall.java') diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index 812024904..94c79e904 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -20,6 +20,7 @@ import android.Manifest.permission; import android.content.Context; import android.hardware.camera2.CameraCharacteristics; import android.net.Uri; +import android.os.Build; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.os.Bundle; @@ -43,6 +44,7 @@ import android.telecom.VideoProfile; import android.text.TextUtils; import com.android.contacts.common.compat.CallCompat; import com.android.contacts.common.compat.telecom.TelecomManagerCompat; +import com.android.dialer.assisteddialing.ConcreteCreator; import com.android.dialer.assisteddialing.TransformationInfo; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentParser; @@ -1073,19 +1075,50 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa return mLogState.isIncoming; } + /** + * Try and determine if the call used assisted dialing. + * + *

We will not be able to verify a call underwent assisted dialing until the Platform + * implmentation is complete in P+. + * + * @return a boolean indicating assisted dialing may have been performed + */ public boolean isAssistedDialed() { if (getIntentExtras() != null) { - return getIntentExtras().getBoolean(TelephonyManagerCompat.IS_ASSISTED_DIALED, false); + // O_MR1 and below uses the existence of USE_ASSISTED_DIALING to indicate assisted dialing + // was used. The Dialer client is responsible for performing assisted dialing before + // placing the outgoing call. + // + // The existence of the assisted dialing extras indicates that assisted dialing took place. + if (getIntentExtras().getBoolean(TelephonyManagerCompat.USE_ASSISTED_DIALING, false) + && getAssistedDialingExtras() != null + && Build.VERSION.SDK_INT <= ConcreteCreator.BUILD_CODE_CEILING) { + return true; + } + } + + // Starting in P+ USE_ASSISTED_DIALING indicates that the client requested the platform + // perform assisted dialing. PROPERTY_ASSISTED_DIALING_USED indicates assisted dialing took + // place. + if (hasProperty(TelephonyManagerCompat.PROPERTY_ASSISTED_DIALING_USED) + && Build.VERSION.SDK_INT > ConcreteCreator.BUILD_CODE_CEILING) { + return true; } return false; } + @Nullable public TransformationInfo getAssistedDialingExtras() { - if (isAssistedDialed()) { - return TransformationInfo.newInstanceFromBundle( - getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS)); + if (getIntentExtras() == null) { + return null; } - return null; + + if (getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS) == null) { + return null; + } + + return TransformationInfo.newInstanceFromBundle( + getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS)); } public LatencyReport getLatencyReport() { -- cgit v1.2.3