summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuo Qian <shuoq@google.com>2019-04-09 11:40:51 -0700
committerShuo Qian <shuoq@google.com>2019-04-09 21:30:42 +0000
commitc8f2b3adf900efa882d22a4b6c05f69a04670114 (patch)
tree3bd87b703fbbce5f9cdd2fc0b5b2793db20e8e72
parentf1a141982f7e3b459d5b2f7c79bd88ce8ca6b08f (diff)
downloadandroid_packages_services_Telecomm-c8f2b3adf900efa882d22a4b6c05f69a04670114.tar.gz
android_packages_services_Telecomm-c8f2b3adf900efa882d22a4b6c05f69a04670114.tar.bz2
android_packages_services_Telecomm-c8f2b3adf900efa882d22a4b6c05f69a04670114.zip
Use Received Uri as Gateway Uri
Gateway information is the core component to perform redirection. We should clarify the uri we received from CallRedirectionService is gateway Uri. And apply it in Telecom. Test: Manual; Treehugger Bug: 130048865 Change-Id: Ie7b16411e6d26c88e990009733a9f5a0514d4902 Merged-In: Ie7b16411e6d26c88e990009733a9f5a0514d4902
-rw-r--r--src/com/android/server/telecom/callredirection/CallRedirectionProcessor.java64
-rw-r--r--src/com/android/server/telecom/callredirection/CallRedirectionProcessorHelper.java31
-rw-r--r--tests/src/com/android/server/telecom/tests/CallRedirectionProcessorTest.java4
3 files changed, 48 insertions, 51 deletions
diff --git a/src/com/android/server/telecom/callredirection/CallRedirectionProcessor.java b/src/com/android/server/telecom/callredirection/CallRedirectionProcessor.java
index 28ecbc76..6e4f87fe 100644
--- a/src/com/android/server/telecom/callredirection/CallRedirectionProcessor.java
+++ b/src/com/android/server/telecom/callredirection/CallRedirectionProcessor.java
@@ -92,15 +92,15 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
private void onServiceBound(ICallRedirectionService service) {
mService = service;
try {
- mHandle = mCallRedirectionProcessorHelper.formatNumberForRedirection(mHandle);
// Telecom does not perform user interactions for carrier call redirection.
- mService.placeCall(new CallRedirectionAdapter(), mHandle, mPhoneAccountHandle,
- mAllowInteractiveResponse
+ mService.placeCall(new CallRedirectionAdapter(), mProcessedDestinationUri,
+ mPhoneAccountHandle, mAllowInteractiveResponse
&& mServiceType.equals(SERVICE_TYPE_USER_DEFINED));
Log.addEvent(mCall, mServiceType.equals(SERVICE_TYPE_USER_DEFINED)
? LogUtils.Events.REDIRECTION_SENT_USER
: LogUtils.Events.REDIRECTION_SENT_CARRIER, mComponentName);
- Log.d(this, "Requested placeCall with [handle]" + Log.pii(mHandle)
+ Log.d(this, "Requested placeCall with [Destination Uri] "
+ + Log.pii(mProcessedDestinationUri)
+ " [phoneAccountHandle]" + mPhoneAccountHandle);
} catch (RemoteException e) {
Log.e(this, e, "Failed to request with the found " + mServiceType + " call"
@@ -187,19 +187,22 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
}
@Override
- public void redirectCall(Uri handle, PhoneAccountHandle targetPhoneAccount,
+ public void redirectCall(Uri gatewayUri, PhoneAccountHandle targetPhoneAccount,
boolean confirmFirst) {
Log.startSession("CRA.rC");
long token = Binder.clearCallingIdentity();
try {
synchronized (mTelecomLock) {
- mHandle = handle;
+ mRedirectionGatewayInfo = mCallRedirectionProcessorHelper
+ .getGatewayInfoFromGatewayUri(mComponentName.getPackageName(),
+ gatewayUri, mDestinationUri);
mPhoneAccountHandle = targetPhoneAccount;
mUiAction = (confirmFirst && mServiceType.equals(SERVICE_TYPE_USER_DEFINED)
&& mAllowInteractiveResponse)
? UI_TYPE_USER_DEFINED_ASK_FOR_CONFIRM : mUiAction;
- Log.d(this, "Received redirectCall with [handle]" + Log.pii(mHandle)
- + " [phoneAccountHandle]" + mPhoneAccountHandle + " from "
+ Log.d(this, "Received redirectCall with [gatewayUri]"
+ + Log.pii(gatewayUri) + " [phoneAccountHandle]"
+ + mPhoneAccountHandle + "[confirmFirst]" + confirmFirst + " from "
+ mServiceType + " call redirection service");
finishCallRedirection();
}
@@ -215,7 +218,7 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
private final CallsManager mCallsManager;
private final Call mCall;
private final boolean mAllowInteractiveResponse;
- private final GatewayInfo mGatewayInfo;
+ private GatewayInfo mRedirectionGatewayInfo;
private final boolean mSpeakerphoneOn;
private final int mVideoState;
private final Timeouts.Adapter mTimeoutsAdapter;
@@ -233,7 +236,12 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
= "user_defined_ask_for_confirm";
private PhoneAccountHandle mPhoneAccountHandle;
- private Uri mHandle;
+ private Uri mDestinationUri;
+ /**
+ * Try to send the implemented service with processed destination uri by formatting it to E.164
+ * and removing post dial digits.
+ */
+ private Uri mProcessedDestinationUri;
/**
* Indicates if Telecom should cancel the call when the whole call redirection finishes.
@@ -266,9 +274,9 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
mContext = context;
mCallsManager = callsManager;
mCall = call;
- mHandle = handle;
+ mDestinationUri = handle;
mPhoneAccountHandle = call.getTargetPhoneAccount();
- mGatewayInfo = gatewayInfo;
+ mRedirectionGatewayInfo = gatewayInfo;
mSpeakerphoneOn = speakerphoneOn;
mVideoState = videoState;
mTimeoutsAdapter = callsManager.getTimeoutsAdapter();
@@ -280,6 +288,8 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
mAllowInteractiveResponse = !callsManager.getSystemStateHelper().isCarMode();
mCallRedirectionProcessorHelper = new CallRedirectionProcessorHelper(
context, callsManager, phoneAccountRegistrar);
+ mProcessedDestinationUri = mCallRedirectionProcessorHelper.formatNumberForRedirection(
+ mDestinationUri);
}
@Override
@@ -288,15 +298,13 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
mHandler.post(new Runnable("CRP.oCRC", mTelecomLock) {
@Override
public void loggedRun() {
- mHandle = mCallRedirectionProcessorHelper.processNumberWhenRedirectionComplete(
- mHandle);
if (mIsUserDefinedRedirectionPending) {
Log.addEvent(mCall, LogUtils.Events.REDIRECTION_COMPLETED_USER);
mIsUserDefinedRedirectionPending = false;
if (mShouldCancelCall) {
- mCallsManager.onCallRedirectionComplete(mCall, mHandle,
- mPhoneAccountHandle, mGatewayInfo, mSpeakerphoneOn, mVideoState,
- mShouldCancelCall, mUiAction);
+ mCallsManager.onCallRedirectionComplete(mCall, mDestinationUri,
+ mPhoneAccountHandle, mRedirectionGatewayInfo, mSpeakerphoneOn,
+ mVideoState, mShouldCancelCall, mUiAction);
} else {
performCarrierCallRedirection();
}
@@ -304,9 +312,9 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
if (mIsCarrierRedirectionPending) {
Log.addEvent(mCall, LogUtils.Events.REDIRECTION_COMPLETED_CARRIER);
mIsCarrierRedirectionPending = false;
- mCallsManager.onCallRedirectionComplete(mCall, mHandle,
- mPhoneAccountHandle, mGatewayInfo, mSpeakerphoneOn, mVideoState,
- mShouldCancelCall, mUiAction);
+ mCallsManager.onCallRedirectionComplete(mCall, mDestinationUri,
+ mPhoneAccountHandle, mRedirectionGatewayInfo, mSpeakerphoneOn,
+ mVideoState, mShouldCancelCall, mUiAction);
}
}
}.prepare());
@@ -316,12 +324,12 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
* The entry to perform call redirection of the call from (@link CallsManager)
*/
public void performCallRedirection() {
- // If the Gateway Info is set with intent, do not perform call redirection.
- if (mGatewayInfo != null) {
- mCallsManager.onCallRedirectionComplete(mCall, mHandle, mPhoneAccountHandle,
- mGatewayInfo, mSpeakerphoneOn, mVideoState, mShouldCancelCall, mUiAction);
+ // If the Gateway Info is set with intent, do not request more call redirection.
+ if (mRedirectionGatewayInfo != null) {
+ mCallsManager.onCallRedirectionComplete(mCall, mDestinationUri, mPhoneAccountHandle,
+ mRedirectionGatewayInfo, mSpeakerphoneOn, mVideoState, mShouldCancelCall,
+ mUiAction);
} else {
- mCallRedirectionProcessorHelper.storePostDialDigits(mHandle);
performUserDefinedCallRedirection();
}
}
@@ -355,8 +363,8 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
} else {
Log.i(this, "There are no carrier call redirection services installed on this"
+ " device.");
- mCallsManager.onCallRedirectionComplete(mCall, mHandle,
- mPhoneAccountHandle, mGatewayInfo, mSpeakerphoneOn, mVideoState,
+ mCallsManager.onCallRedirectionComplete(mCall, mDestinationUri,
+ mPhoneAccountHandle, mRedirectionGatewayInfo, mSpeakerphoneOn, mVideoState,
mShouldCancelCall, mUiAction);
}
}
@@ -398,7 +406,7 @@ public class CallRedirectionProcessor implements CallRedirectionCallback {
mCallRedirectionProcessorHelper.getUserDefinedCallRedirectionService() != null
|| mCallRedirectionProcessorHelper.getCarrierCallRedirectionService(
mPhoneAccountHandle) != null;
- Log.w(this, "Can make call redirection with any available service: "
+ Log.i(this, "Can make call redirection with any available service: "
+ canMakeCallRedirectionWithService);
return canMakeCallRedirectionWithService;
}
diff --git a/src/com/android/server/telecom/callredirection/CallRedirectionProcessorHelper.java b/src/com/android/server/telecom/callredirection/CallRedirectionProcessorHelper.java
index 855d0227..12c8c573 100644
--- a/src/com/android/server/telecom/callredirection/CallRedirectionProcessorHelper.java
+++ b/src/com/android/server/telecom/callredirection/CallRedirectionProcessorHelper.java
@@ -22,9 +22,9 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
-import android.os.Binder;
import android.os.PersistableBundle;
import android.telecom.CallRedirectionService;
+import android.telecom.GatewayInfo;
import android.telecom.Log;
import android.telecom.PhoneAccountHandle;
import android.telephony.CarrierConfigManager;
@@ -42,7 +42,6 @@ public class CallRedirectionProcessorHelper {
private final Context mContext;
private final CallsManager mCallsManager;
private final PhoneAccountRegistrar mPhoneAccountRegistrar;
- private String mOriginalPostDialDigits = "";
public CallRedirectionProcessorHelper(
Context context,
@@ -130,27 +129,6 @@ public class CallRedirectionProcessorHelper {
return removePostDialDigits(formatNumberToE164(handle));
}
- protected Uri processNumberWhenRedirectionComplete(Uri handle) {
- return appendStoredPostDialDigits(formatNumberForRedirection(handle));
- }
-
- protected void storePostDialDigits(Uri handle) {
- String number = handle.getSchemeSpecificPart();
- String postDialPortion = PhoneNumberUtils.extractPostDialPortion(number);
- if (postDialPortion != null) {
- mOriginalPostDialDigits = postDialPortion;
- }
- Log.i(this, "storePostDialDigits, stored post dial digits: "
- + Log.pii(mOriginalPostDialDigits));
- }
-
- protected Uri appendStoredPostDialDigits(Uri handle) {
- String number = handle.getSchemeSpecificPart();
- number += mOriginalPostDialDigits;
- Log.i(this, "appendStoredPostDialDigits, appended number: " + Log.pii(number));
- return Uri.fromParts(handle.getScheme(), number, null);
- }
-
protected Uri formatNumberToE164(Uri handle) {
String number = handle.getSchemeSpecificPart();
@@ -185,4 +163,11 @@ public class CallRedirectionProcessorHelper {
}
}
+ protected GatewayInfo getGatewayInfoFromGatewayUri(
+ String gatewayPackageName, Uri gatewayUri, Uri destinationUri) {
+ if (!TextUtils.isEmpty(gatewayPackageName) && gatewayUri != null) {
+ return new GatewayInfo(gatewayPackageName, gatewayUri, destinationUri);
+ }
+ return null;
+ }
}
diff --git a/tests/src/com/android/server/telecom/tests/CallRedirectionProcessorTest.java b/tests/src/com/android/server/telecom/tests/CallRedirectionProcessorTest.java
index fa78383d..f0f0fe45 100644
--- a/tests/src/com/android/server/telecom/tests/CallRedirectionProcessorTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallRedirectionProcessorTest.java
@@ -27,6 +27,7 @@ import android.os.IBinder;
import android.os.UserHandle;
import android.telecom.GatewayInfo;
import android.telecom.PhoneAccountHandle;
+import android.telephony.TelephonyManager;
import com.android.internal.telecom.ICallRedirectionService;
import com.android.server.telecom.Call;
import com.android.server.telecom.CallsManager;
@@ -66,6 +67,7 @@ public class CallRedirectionProcessorTest extends TelecomTestCase {
@Mock private Call mCall;
@Mock private PackageManager mPackageManager;
+ @Mock private TelephonyManager mTelephonyManager;
@Mock private IBinder mBinder;
@Mock private ICallRedirectionService mCallRedirectionService;
@@ -118,6 +120,8 @@ public class CallRedirectionProcessorTest extends TelecomTestCase {
.thenReturn(CARRIER_SHORT_TIMEOUT_MS);
when(mCallsManager.getLock()).thenReturn(mLock);
when(mCallsManager.getCurrentUserHandle()).thenReturn(mUserHandle);
+ when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
+ when(mTelephonyManager.getNetworkCountryIso()).thenReturn("");
when(mContext.bindServiceAsUser(nullable(Intent.class), nullable(ServiceConnection.class),
anyInt(), eq(UserHandle.CURRENT))).thenReturn(true);
}