Loading src/com/android/server/telecom/callredirection/CallRedirectionProcessor.java +36 −28 Original line number Diff line number Diff line Loading @@ -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" Loading Loading @@ -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(); } Loading @@ -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; Loading @@ -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. Loading Loading @@ -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(); Loading @@ -280,6 +288,8 @@ public class CallRedirectionProcessor implements CallRedirectionCallback { mAllowInteractiveResponse = !callsManager.getSystemStateHelper().isCarMode(); mCallRedirectionProcessorHelper = new CallRedirectionProcessorHelper( context, callsManager, phoneAccountRegistrar); mProcessedDestinationUri = mCallRedirectionProcessorHelper.formatNumberForRedirection( mDestinationUri); } @Override Loading @@ -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(); } Loading @@ -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()); Loading @@ -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(); } } Loading Loading @@ -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); } } Loading Loading @@ -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; } Loading src/com/android/server/telecom/callredirection/CallRedirectionProcessorHelper.java +8 −23 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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, Loading Loading @@ -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(); Loading Loading @@ -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; } } tests/src/com/android/server/telecom/tests/CallRedirectionProcessorTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); } Loading Loading
src/com/android/server/telecom/callredirection/CallRedirectionProcessor.java +36 −28 Original line number Diff line number Diff line Loading @@ -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" Loading Loading @@ -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(); } Loading @@ -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; Loading @@ -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. Loading Loading @@ -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(); Loading @@ -280,6 +288,8 @@ public class CallRedirectionProcessor implements CallRedirectionCallback { mAllowInteractiveResponse = !callsManager.getSystemStateHelper().isCarMode(); mCallRedirectionProcessorHelper = new CallRedirectionProcessorHelper( context, callsManager, phoneAccountRegistrar); mProcessedDestinationUri = mCallRedirectionProcessorHelper.formatNumberForRedirection( mDestinationUri); } @Override Loading @@ -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(); } Loading @@ -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()); Loading @@ -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(); } } Loading Loading @@ -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); } } Loading Loading @@ -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; } Loading
src/com/android/server/telecom/callredirection/CallRedirectionProcessorHelper.java +8 −23 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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, Loading Loading @@ -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(); Loading Loading @@ -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; } }
tests/src/com/android/server/telecom/tests/CallRedirectionProcessorTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); } Loading