Loading src/com/android/server/telecom/Call.java +32 −2 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.telecom; package com.android.server.telecom; import android.annotation.NonNull; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Bitmap; Loading Loading @@ -1642,7 +1643,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, mCreationTimeMillis = time; mCreationTimeMillis = time; } } long getConnectTimeMillis() { public long getConnectTimeMillis() { return mConnectTimeMillis; return mConnectTimeMillis; } } Loading Loading @@ -2806,7 +2807,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, * ensure the InCall UI is updated with the change in parent. * ensure the InCall UI is updated with the change in parent. * @param parentCall The new parent for this call. * @param parentCall The new parent for this call. */ */ void setChildOf(Call parentCall) { public void setChildOf(Call parentCall) { if (parentCall != null && !parentCall.getChildCalls().contains(this)) { if (parentCall != null && !parentCall.getChildCalls().contains(this)) { parentCall.addChildCall(this); parentCall.addChildCall(this); } } Loading Loading @@ -2844,6 +2845,11 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, mConferenceLevelActiveCall = call; mConferenceLevelActiveCall = call; mChildCalls.add(call); mChildCalls.add(call); // When adding a child, we will potentially adjust the various times from the calls // based on the children being added. This ensures the parent of the conference has a // connect time reflective of all the children added. maybeAdjustConnectTime(call); Log.addEvent(this, LogUtils.Events.ADD_CHILD, call); Log.addEvent(this, LogUtils.Events.ADD_CHILD, call); for (Listener l : mListeners) { for (Listener l : mListeners) { Loading @@ -2852,6 +2858,30 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, } } } } /** * Potentially adjust the connect and creation time of this call based on another one. * Ensures that if the other call has an earlier connect time that we adjust the connect time of * this call to match. * <p> * This is important for conference calls; as we add children to the conference we need to * ensure that earlier connect time is reflected on the conference. In the past this * was just done in {@link ParcelableCallUtils} when parceling the calls to the UI, but that * approach would not reflect the right time on the parent as children disconnect. * * @param call the call to potentially use to adjust connect time. */ private void maybeAdjustConnectTime(@NonNull Call call) { long childConnectTimeMillis = call.getConnectTimeMillis(); long currentConnectTimeMillis = getConnectTimeMillis(); // Conference calls typically have a 0 connect time, so we will replace the current connect // time if its zero also. if (childConnectTimeMillis != 0 && (currentConnectTimeMillis == 0 || childConnectTimeMillis < getConnectTimeMillis())) { setConnectTimeMillis(childConnectTimeMillis); } } private void removeChildCall(Call call) { private void removeChildCall(Call call) { if (mChildCalls.remove(call)) { if (mChildCalls.remove(call)) { Log.addEvent(this, LogUtils.Events.REMOVE_CHILD, call); Log.addEvent(this, LogUtils.Events.REMOVE_CHILD, call); Loading src/com/android/server/telecom/ParcelableCallUtils.java +1 −11 Original line number Original line Diff line number Diff line Loading @@ -181,22 +181,12 @@ public class ParcelableCallUtils { parentCallId = parentCall.getId(); parentCallId = parentCall.getId(); } } long connectTimeMillis = call.getConnectTimeMillis(); List<Call> childCalls = call.getChildCalls(); List<Call> childCalls = call.getChildCalls(); List<String> childCallIds = new ArrayList<>(); List<String> childCallIds = new ArrayList<>(); if (!childCalls.isEmpty()) { if (!childCalls.isEmpty()) { long childConnectTimeMillis = Long.MAX_VALUE; for (Call child : childCalls) { for (Call child : childCalls) { if (child.getConnectTimeMillis() > 0) { childConnectTimeMillis = Math.min(child.getConnectTimeMillis(), childConnectTimeMillis); } childCallIds.add(child.getId()); childCallIds.add(child.getId()); } } if (childConnectTimeMillis != Long.MAX_VALUE) { connectTimeMillis = childConnectTimeMillis; } } } Uri handle = call.getHandlePresentation() == TelecomManager.PRESENTATION_ALLOWED ? Uri handle = call.getHandlePresentation() == TelecomManager.PRESENTATION_ALLOWED ? Loading Loading @@ -240,7 +230,7 @@ public class ParcelableCallUtils { .setCapabilities(capabilities) .setCapabilities(capabilities) .setProperties(properties) .setProperties(properties) .setSupportedAudioRoutes(supportedAudioRoutes) .setSupportedAudioRoutes(supportedAudioRoutes) .setConnectTimeMillis(connectTimeMillis) .setConnectTimeMillis(call.getConnectTimeMillis()) .setHandle(handle) .setHandle(handle) .setHandlePresentation(call.getHandlePresentation()) .setHandlePresentation(call.getHandlePresentation()) .setCallerDisplayName(callerDisplayName) .setCallerDisplayName(callerDisplayName) Loading tests/src/com/android/server/telecom/tests/CallsManagerTest.java +28 −0 Original line number Original line Diff line number Diff line Loading @@ -1217,6 +1217,34 @@ public class CallsManagerTest extends TelecomTestCase { assertFalse(outgoingCall.getStartWithSpeakerphoneOn()); assertFalse(outgoingCall.getStartWithSpeakerphoneOn()); } } /** * Verify that a parent call will inherit the connect time of its children. * @throws Exception */ @SmallTest @Test public void testParentInheritsChildConnectTime() throws Exception { Call callSim1 = createCall(SIM_1_HANDLE, null, CallState.ACTIVE); Call callSim2 = createCall(SIM_1_HANDLE, null, CallState.ACTIVE); callSim1.setConnectTimeMillis(100); // Pretend it is a conference made later. callSim2.setConnectTimeMillis(0); // Make the first call a child of the second (pretend conference). callSim1.setChildOf(callSim2); assertEquals(100, callSim2.getConnectTimeMillis()); // Add another later call. Call callSim3 = createCall(SIM_1_HANDLE, null, CallState.ACTIVE); callSim3.setConnectTimeMillis(200); callSim3.setChildOf(callSim2); // Later call shouldn't impact parent. assertEquals(100, callSim2.getConnectTimeMillis()); } /** /** * Make sure that CallsManager handles a screening result that has both * Make sure that CallsManager handles a screening result that has both * silence and screen-further set to true as a request to screen further. * silence and screen-further set to true as a request to screen further. Loading Loading
src/com/android/server/telecom/Call.java +32 −2 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.telecom; package com.android.server.telecom; import android.annotation.NonNull; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Bitmap; Loading Loading @@ -1642,7 +1643,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, mCreationTimeMillis = time; mCreationTimeMillis = time; } } long getConnectTimeMillis() { public long getConnectTimeMillis() { return mConnectTimeMillis; return mConnectTimeMillis; } } Loading Loading @@ -2806,7 +2807,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, * ensure the InCall UI is updated with the change in parent. * ensure the InCall UI is updated with the change in parent. * @param parentCall The new parent for this call. * @param parentCall The new parent for this call. */ */ void setChildOf(Call parentCall) { public void setChildOf(Call parentCall) { if (parentCall != null && !parentCall.getChildCalls().contains(this)) { if (parentCall != null && !parentCall.getChildCalls().contains(this)) { parentCall.addChildCall(this); parentCall.addChildCall(this); } } Loading Loading @@ -2844,6 +2845,11 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, mConferenceLevelActiveCall = call; mConferenceLevelActiveCall = call; mChildCalls.add(call); mChildCalls.add(call); // When adding a child, we will potentially adjust the various times from the calls // based on the children being added. This ensures the parent of the conference has a // connect time reflective of all the children added. maybeAdjustConnectTime(call); Log.addEvent(this, LogUtils.Events.ADD_CHILD, call); Log.addEvent(this, LogUtils.Events.ADD_CHILD, call); for (Listener l : mListeners) { for (Listener l : mListeners) { Loading @@ -2852,6 +2858,30 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, } } } } /** * Potentially adjust the connect and creation time of this call based on another one. * Ensures that if the other call has an earlier connect time that we adjust the connect time of * this call to match. * <p> * This is important for conference calls; as we add children to the conference we need to * ensure that earlier connect time is reflected on the conference. In the past this * was just done in {@link ParcelableCallUtils} when parceling the calls to the UI, but that * approach would not reflect the right time on the parent as children disconnect. * * @param call the call to potentially use to adjust connect time. */ private void maybeAdjustConnectTime(@NonNull Call call) { long childConnectTimeMillis = call.getConnectTimeMillis(); long currentConnectTimeMillis = getConnectTimeMillis(); // Conference calls typically have a 0 connect time, so we will replace the current connect // time if its zero also. if (childConnectTimeMillis != 0 && (currentConnectTimeMillis == 0 || childConnectTimeMillis < getConnectTimeMillis())) { setConnectTimeMillis(childConnectTimeMillis); } } private void removeChildCall(Call call) { private void removeChildCall(Call call) { if (mChildCalls.remove(call)) { if (mChildCalls.remove(call)) { Log.addEvent(this, LogUtils.Events.REMOVE_CHILD, call); Log.addEvent(this, LogUtils.Events.REMOVE_CHILD, call); Loading
src/com/android/server/telecom/ParcelableCallUtils.java +1 −11 Original line number Original line Diff line number Diff line Loading @@ -181,22 +181,12 @@ public class ParcelableCallUtils { parentCallId = parentCall.getId(); parentCallId = parentCall.getId(); } } long connectTimeMillis = call.getConnectTimeMillis(); List<Call> childCalls = call.getChildCalls(); List<Call> childCalls = call.getChildCalls(); List<String> childCallIds = new ArrayList<>(); List<String> childCallIds = new ArrayList<>(); if (!childCalls.isEmpty()) { if (!childCalls.isEmpty()) { long childConnectTimeMillis = Long.MAX_VALUE; for (Call child : childCalls) { for (Call child : childCalls) { if (child.getConnectTimeMillis() > 0) { childConnectTimeMillis = Math.min(child.getConnectTimeMillis(), childConnectTimeMillis); } childCallIds.add(child.getId()); childCallIds.add(child.getId()); } } if (childConnectTimeMillis != Long.MAX_VALUE) { connectTimeMillis = childConnectTimeMillis; } } } Uri handle = call.getHandlePresentation() == TelecomManager.PRESENTATION_ALLOWED ? Uri handle = call.getHandlePresentation() == TelecomManager.PRESENTATION_ALLOWED ? Loading Loading @@ -240,7 +230,7 @@ public class ParcelableCallUtils { .setCapabilities(capabilities) .setCapabilities(capabilities) .setProperties(properties) .setProperties(properties) .setSupportedAudioRoutes(supportedAudioRoutes) .setSupportedAudioRoutes(supportedAudioRoutes) .setConnectTimeMillis(connectTimeMillis) .setConnectTimeMillis(call.getConnectTimeMillis()) .setHandle(handle) .setHandle(handle) .setHandlePresentation(call.getHandlePresentation()) .setHandlePresentation(call.getHandlePresentation()) .setCallerDisplayName(callerDisplayName) .setCallerDisplayName(callerDisplayName) Loading
tests/src/com/android/server/telecom/tests/CallsManagerTest.java +28 −0 Original line number Original line Diff line number Diff line Loading @@ -1217,6 +1217,34 @@ public class CallsManagerTest extends TelecomTestCase { assertFalse(outgoingCall.getStartWithSpeakerphoneOn()); assertFalse(outgoingCall.getStartWithSpeakerphoneOn()); } } /** * Verify that a parent call will inherit the connect time of its children. * @throws Exception */ @SmallTest @Test public void testParentInheritsChildConnectTime() throws Exception { Call callSim1 = createCall(SIM_1_HANDLE, null, CallState.ACTIVE); Call callSim2 = createCall(SIM_1_HANDLE, null, CallState.ACTIVE); callSim1.setConnectTimeMillis(100); // Pretend it is a conference made later. callSim2.setConnectTimeMillis(0); // Make the first call a child of the second (pretend conference). callSim1.setChildOf(callSim2); assertEquals(100, callSim2.getConnectTimeMillis()); // Add another later call. Call callSim3 = createCall(SIM_1_HANDLE, null, CallState.ACTIVE); callSim3.setConnectTimeMillis(200); callSim3.setChildOf(callSim2); // Later call shouldn't impact parent. assertEquals(100, callSim2.getConnectTimeMillis()); } /** /** * Make sure that CallsManager handles a screening result that has both * Make sure that CallsManager handles a screening result that has both * silence and screen-further set to true as a request to screen further. * silence and screen-further set to true as a request to screen further. Loading