Loading src/com/android/server/telecom/CallsManager.java +19 −14 Original line number Diff line number Diff line Loading @@ -3275,25 +3275,30 @@ public class CallsManager extends Call.ListenerBase } /** * Given a {@link PhoneAccountHandle} determines if there are calls owned by any other * {@link PhoneAccountHandle}. * Given a {@link PhoneAccountHandle} determines if there are other unholdable calls owned by * another connection service. * @param phoneAccountHandle The {@link PhoneAccountHandle} to check. * @return {@code true} if there are other calls, {@code false} otherwise. * @return {@code true} if there are other unholdable calls, {@code false} otherwise. */ public boolean hasCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle) { return getNumCallsForOtherPhoneAccount(phoneAccountHandle) > 0; public boolean hasUnholdableCallsForOtherConnectionService( PhoneAccountHandle phoneAccountHandle) { return getNumUnholdableCallsForOtherConnectionService(phoneAccountHandle) > 0; } /** * Determines the number of calls present for PhoneAccounts other than the one specified. * Determines the number of unholdable calls present in a connection service other than the one * the passed phone account belonds to. * @param phoneAccountHandle The handle of the PhoneAccount. * @return Number of calls owned by other PhoneAccounts. * @return Number of unholdable calls owned by other connection service. */ public int getNumCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle) { public int getNumUnholdableCallsForOtherConnectionService( PhoneAccountHandle phoneAccountHandle) { return (int) mCalls.stream().filter(call -> !phoneAccountHandle.equals(call.getTargetPhoneAccount()) && call.getParentCall() == null && !call.isExternalCall()).count(); !phoneAccountHandle.getComponentName().equals( call.getTargetPhoneAccount().getComponentName()) && call.getParentCall() == null && !call.isExternalCall() && !canHold(call)).count(); } /** Loading Loading @@ -3345,9 +3350,9 @@ public class CallsManager extends Call.ListenerBase * @return {@code true} if the system incoming call UI should be shown, {@code false} otherwise. */ public boolean shouldShowSystemIncomingCallUi(Call incomingCall) { return incomingCall.isIncoming() && incomingCall.isSelfManaged() && hasCallsForOtherPhoneAccount(incomingCall.getTargetPhoneAccount()) && incomingCall.getHandoverSourceCall() == null; return incomingCall.isIncoming() && incomingCall.isSelfManaged() && hasUnholdableCallsForOtherConnectionService(incomingCall.getTargetPhoneAccount()) && incomingCall.getHandoverSourceCall() == null; } private boolean makeRoomForOutgoingCall(Call call, boolean isEmergency) { Loading src/com/android/server/telecom/TelecomSystem.java +8 −8 Original line number Diff line number Diff line Loading @@ -35,15 +35,11 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.location.Country; import android.location.CountryDetector; import android.net.Uri; import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.telecom.Log; import android.telecom.PhoneAccountHandle; import android.telephony.PhoneNumberUtils; import java.io.FileNotFoundException; import java.io.InputStream; Loading Loading @@ -297,13 +293,17 @@ public class TelecomSystem { mIncomingCallNotifier = incomingCallNotifier; incomingCallNotifier.setCallsManagerProxy(new IncomingCallNotifier.CallsManagerProxy() { @Override public boolean hasCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle) { return mCallsManager.hasCallsForOtherPhoneAccount(phoneAccountHandle); public boolean hasUnholdableCallsForOtherConnectionService( PhoneAccountHandle phoneAccountHandle) { return mCallsManager.hasUnholdableCallsForOtherConnectionService( phoneAccountHandle); } @Override public int getNumCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle) { return mCallsManager.getNumCallsForOtherPhoneAccount(phoneAccountHandle); public int getNumUnholdableCallsForOtherConnectionService( PhoneAccountHandle phoneAccountHandle) { return mCallsManager.getNumUnholdableCallsForOtherConnectionService( phoneAccountHandle); } @Override Loading src/com/android/server/telecom/ui/IncomingCallNotifier.java +4 −4 Original line number Diff line number Diff line Loading @@ -58,8 +58,8 @@ public class IncomingCallNotifier extends CallsManagerListenerBase { * Eliminates strict dependency between this class and CallsManager. */ public interface CallsManagerProxy { boolean hasCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle); int getNumCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle); boolean hasUnholdableCallsForOtherConnectionService(PhoneAccountHandle phoneAccountHandle); int getNumUnholdableCallsForOtherConnectionService(PhoneAccountHandle phoneAccountHandle); Call getActiveCall(); } Loading Loading @@ -137,7 +137,7 @@ public class IncomingCallNotifier extends CallsManagerListenerBase { .findFirst(); Call incomingCall = incomingCallOp.orElse(null); if (incomingCall != null && mCallsManagerProxy != null && !mCallsManagerProxy.hasCallsForOtherPhoneAccount( !mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService( incomingCallOp.get().getTargetPhoneAccount())) { // If there is no calls in any other ConnectionService, we can rely on the // third-party app to display its own incoming call UI. Loading Loading @@ -210,7 +210,7 @@ public class IncomingCallNotifier extends CallsManagerListenerBase { boolean isOngoingVideo = ongoingCall != null ? VideoProfile.isVideo(ongoingCall.getVideoState()) : false; int numOtherCalls = ongoingCall != null ? mCallsManagerProxy.getNumCallsForOtherPhoneAccount( mCallsManagerProxy.getNumUnholdableCallsForOtherConnectionService( incomingCall.getTargetPhoneAccount()) : 1; // Build the "IncomingApp call from John Smith" message. Loading tests/src/com/android/server/telecom/tests/IncomingCallNotifierTest.java +9 −9 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public class IncomingCallNotifierTest extends TelecomTestCase { @SmallTest @Test public void testIncomingDuringOngoingCall() { when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(false); when(mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService(any())).thenReturn(false); mIncomingCallNotifier.onCallAdded(mRingingCall); verify(mNotificationManager, never()).notify(eq(IncomingCallNotifier.NOTIFICATION_TAG), eq(IncomingCallNotifier.NOTIFICATION_INCOMING_CALL), any()); Loading @@ -110,8 +110,8 @@ public class IncomingCallNotifierTest extends TelecomTestCase { @SmallTest @Test public void testIncomingDuringOngoingCall2() { when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(false); when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(0); when(mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService(any())).thenReturn(false); when(mCallsManagerProxy.getNumUnholdableCallsForOtherConnectionService(any())).thenReturn(0); when(mCallsManagerProxy.getActiveCall()).thenReturn(mAudioCall); mIncomingCallNotifier.onCallAdded(mAudioCall); Loading @@ -126,8 +126,8 @@ public class IncomingCallNotifierTest extends TelecomTestCase { @SmallTest @Test public void testCallRemoved() { when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(true); when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(1); when(mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService(any())).thenReturn(true); when(mCallsManagerProxy.getNumUnholdableCallsForOtherConnectionService(any())).thenReturn(1); when(mCallsManagerProxy.getActiveCall()).thenReturn(mAudioCall); mIncomingCallNotifier.onCallAdded(mAudioCall); Loading @@ -145,8 +145,8 @@ public class IncomingCallNotifierTest extends TelecomTestCase { @SmallTest @Test public void testDontShowDuringHandover1() { when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(true); when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(1); when(mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService(any())).thenReturn(true); when(mCallsManagerProxy.getNumUnholdableCallsForOtherConnectionService(any())).thenReturn(1); when(mCallsManagerProxy.getActiveCall()).thenReturn(mAudioCall); when(mRingingCall.getHandoverState()).thenReturn(HandoverState.HANDOVER_FROM_STARTED); Loading @@ -164,8 +164,8 @@ public class IncomingCallNotifierTest extends TelecomTestCase { @SmallTest @Test public void testDontShowDuringHandover2() { when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(true); when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(1); when(mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService(any())).thenReturn(true); when(mCallsManagerProxy.getNumUnholdableCallsForOtherConnectionService(any())).thenReturn(1); when(mCallsManagerProxy.getActiveCall()).thenReturn(mAudioCall); when(mRingingCall.getHandoverState()).thenReturn(HandoverState.HANDOVER_COMPLETE); Loading Loading
src/com/android/server/telecom/CallsManager.java +19 −14 Original line number Diff line number Diff line Loading @@ -3275,25 +3275,30 @@ public class CallsManager extends Call.ListenerBase } /** * Given a {@link PhoneAccountHandle} determines if there are calls owned by any other * {@link PhoneAccountHandle}. * Given a {@link PhoneAccountHandle} determines if there are other unholdable calls owned by * another connection service. * @param phoneAccountHandle The {@link PhoneAccountHandle} to check. * @return {@code true} if there are other calls, {@code false} otherwise. * @return {@code true} if there are other unholdable calls, {@code false} otherwise. */ public boolean hasCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle) { return getNumCallsForOtherPhoneAccount(phoneAccountHandle) > 0; public boolean hasUnholdableCallsForOtherConnectionService( PhoneAccountHandle phoneAccountHandle) { return getNumUnholdableCallsForOtherConnectionService(phoneAccountHandle) > 0; } /** * Determines the number of calls present for PhoneAccounts other than the one specified. * Determines the number of unholdable calls present in a connection service other than the one * the passed phone account belonds to. * @param phoneAccountHandle The handle of the PhoneAccount. * @return Number of calls owned by other PhoneAccounts. * @return Number of unholdable calls owned by other connection service. */ public int getNumCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle) { public int getNumUnholdableCallsForOtherConnectionService( PhoneAccountHandle phoneAccountHandle) { return (int) mCalls.stream().filter(call -> !phoneAccountHandle.equals(call.getTargetPhoneAccount()) && call.getParentCall() == null && !call.isExternalCall()).count(); !phoneAccountHandle.getComponentName().equals( call.getTargetPhoneAccount().getComponentName()) && call.getParentCall() == null && !call.isExternalCall() && !canHold(call)).count(); } /** Loading Loading @@ -3345,9 +3350,9 @@ public class CallsManager extends Call.ListenerBase * @return {@code true} if the system incoming call UI should be shown, {@code false} otherwise. */ public boolean shouldShowSystemIncomingCallUi(Call incomingCall) { return incomingCall.isIncoming() && incomingCall.isSelfManaged() && hasCallsForOtherPhoneAccount(incomingCall.getTargetPhoneAccount()) && incomingCall.getHandoverSourceCall() == null; return incomingCall.isIncoming() && incomingCall.isSelfManaged() && hasUnholdableCallsForOtherConnectionService(incomingCall.getTargetPhoneAccount()) && incomingCall.getHandoverSourceCall() == null; } private boolean makeRoomForOutgoingCall(Call call, boolean isEmergency) { Loading
src/com/android/server/telecom/TelecomSystem.java +8 −8 Original line number Diff line number Diff line Loading @@ -35,15 +35,11 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.location.Country; import android.location.CountryDetector; import android.net.Uri; import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.telecom.Log; import android.telecom.PhoneAccountHandle; import android.telephony.PhoneNumberUtils; import java.io.FileNotFoundException; import java.io.InputStream; Loading Loading @@ -297,13 +293,17 @@ public class TelecomSystem { mIncomingCallNotifier = incomingCallNotifier; incomingCallNotifier.setCallsManagerProxy(new IncomingCallNotifier.CallsManagerProxy() { @Override public boolean hasCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle) { return mCallsManager.hasCallsForOtherPhoneAccount(phoneAccountHandle); public boolean hasUnholdableCallsForOtherConnectionService( PhoneAccountHandle phoneAccountHandle) { return mCallsManager.hasUnholdableCallsForOtherConnectionService( phoneAccountHandle); } @Override public int getNumCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle) { return mCallsManager.getNumCallsForOtherPhoneAccount(phoneAccountHandle); public int getNumUnholdableCallsForOtherConnectionService( PhoneAccountHandle phoneAccountHandle) { return mCallsManager.getNumUnholdableCallsForOtherConnectionService( phoneAccountHandle); } @Override Loading
src/com/android/server/telecom/ui/IncomingCallNotifier.java +4 −4 Original line number Diff line number Diff line Loading @@ -58,8 +58,8 @@ public class IncomingCallNotifier extends CallsManagerListenerBase { * Eliminates strict dependency between this class and CallsManager. */ public interface CallsManagerProxy { boolean hasCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle); int getNumCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle); boolean hasUnholdableCallsForOtherConnectionService(PhoneAccountHandle phoneAccountHandle); int getNumUnholdableCallsForOtherConnectionService(PhoneAccountHandle phoneAccountHandle); Call getActiveCall(); } Loading Loading @@ -137,7 +137,7 @@ public class IncomingCallNotifier extends CallsManagerListenerBase { .findFirst(); Call incomingCall = incomingCallOp.orElse(null); if (incomingCall != null && mCallsManagerProxy != null && !mCallsManagerProxy.hasCallsForOtherPhoneAccount( !mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService( incomingCallOp.get().getTargetPhoneAccount())) { // If there is no calls in any other ConnectionService, we can rely on the // third-party app to display its own incoming call UI. Loading Loading @@ -210,7 +210,7 @@ public class IncomingCallNotifier extends CallsManagerListenerBase { boolean isOngoingVideo = ongoingCall != null ? VideoProfile.isVideo(ongoingCall.getVideoState()) : false; int numOtherCalls = ongoingCall != null ? mCallsManagerProxy.getNumCallsForOtherPhoneAccount( mCallsManagerProxy.getNumUnholdableCallsForOtherConnectionService( incomingCall.getTargetPhoneAccount()) : 1; // Build the "IncomingApp call from John Smith" message. Loading
tests/src/com/android/server/telecom/tests/IncomingCallNotifierTest.java +9 −9 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public class IncomingCallNotifierTest extends TelecomTestCase { @SmallTest @Test public void testIncomingDuringOngoingCall() { when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(false); when(mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService(any())).thenReturn(false); mIncomingCallNotifier.onCallAdded(mRingingCall); verify(mNotificationManager, never()).notify(eq(IncomingCallNotifier.NOTIFICATION_TAG), eq(IncomingCallNotifier.NOTIFICATION_INCOMING_CALL), any()); Loading @@ -110,8 +110,8 @@ public class IncomingCallNotifierTest extends TelecomTestCase { @SmallTest @Test public void testIncomingDuringOngoingCall2() { when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(false); when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(0); when(mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService(any())).thenReturn(false); when(mCallsManagerProxy.getNumUnholdableCallsForOtherConnectionService(any())).thenReturn(0); when(mCallsManagerProxy.getActiveCall()).thenReturn(mAudioCall); mIncomingCallNotifier.onCallAdded(mAudioCall); Loading @@ -126,8 +126,8 @@ public class IncomingCallNotifierTest extends TelecomTestCase { @SmallTest @Test public void testCallRemoved() { when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(true); when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(1); when(mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService(any())).thenReturn(true); when(mCallsManagerProxy.getNumUnholdableCallsForOtherConnectionService(any())).thenReturn(1); when(mCallsManagerProxy.getActiveCall()).thenReturn(mAudioCall); mIncomingCallNotifier.onCallAdded(mAudioCall); Loading @@ -145,8 +145,8 @@ public class IncomingCallNotifierTest extends TelecomTestCase { @SmallTest @Test public void testDontShowDuringHandover1() { when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(true); when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(1); when(mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService(any())).thenReturn(true); when(mCallsManagerProxy.getNumUnholdableCallsForOtherConnectionService(any())).thenReturn(1); when(mCallsManagerProxy.getActiveCall()).thenReturn(mAudioCall); when(mRingingCall.getHandoverState()).thenReturn(HandoverState.HANDOVER_FROM_STARTED); Loading @@ -164,8 +164,8 @@ public class IncomingCallNotifierTest extends TelecomTestCase { @SmallTest @Test public void testDontShowDuringHandover2() { when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(true); when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(1); when(mCallsManagerProxy.hasUnholdableCallsForOtherConnectionService(any())).thenReturn(true); when(mCallsManagerProxy.getNumUnholdableCallsForOtherConnectionService(any())).thenReturn(1); when(mCallsManagerProxy.getActiveCall()).thenReturn(mAudioCall); when(mRingingCall.getHandoverState()).thenReturn(HandoverState.HANDOVER_COMPLETE); Loading