Loading src/com/android/server/telecom/CallAnomalyWatchdog.java +9 −7 Original line number Diff line number Diff line Loading @@ -153,8 +153,12 @@ public class CallAnomalyWatchdog extends CallsManagerListenerBase implements Cal mClockProxy = clockProxy; } /** * Start tracking a call that we're waiting for a ConnectionService to create. * @param call the call. */ @Override public void onCallCreated(Call call) { public void onStartCreateConnection(Call call) { maybeTrackCall(call); call.addListener(this); } Loading @@ -165,15 +169,13 @@ public class CallAnomalyWatchdog extends CallsManagerListenerBase implements Cal } /** * Override of {@link CallsManagerListenerBase} to track when calls are created but * intentionally not added to mCalls. These calls should no longer be tracked by the * CallAnomalyWatchdog. * Override of {@link CallsManagerListenerBase} to track when calls have failed to be created by * a ConnectionService. These calls should no longer be tracked by the CallAnomalyWatchdog. * @param call the call */ @Override public void onCallCreatedButNeverAdded(Call call) { Log.i(this, "onCallCreatedButNeverAdded: call=%s", call.toString()); public void onCreateConnectionFailed(Call call) { Log.i(this, "onCreateConnectionFailed: call=%s", call.toString()); stopTrackingCall(call); } Loading src/com/android/server/telecom/CallsManager.java +17 −22 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ import android.media.MediaPlayer; import android.media.ToneGenerator; import android.net.Uri; import android.os.AsyncTask; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; Loading Loading @@ -109,7 +108,6 @@ import android.util.Pair; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import android.widget.Button; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -176,14 +174,13 @@ public class CallsManager extends Call.ListenerBase @VisibleForTesting public interface CallsManagerListener { /** * Informs listeners when a {@link Call} is newly created but not yet added to * {@link #mCalls}. This is where the call has not yet been created by the underlying * {@link ConnectionService}. * Informs listeners when a {@link Call} is newly created, but not yet returned by a * {@link android.telecom.ConnectionService} implementation. * @param call the call. */ default void onCallCreated(Call call) {} default void onStartCreateConnection(Call call) {} void onCallAdded(Call call); void onCallCreatedButNeverAdded(Call call); void onCreateConnectionFailed(Call call); void onCallRemoved(Call call); void onCallStateChanged(Call call, int oldState, int newState); void onConnectionServiceChanged( Loading Loading @@ -1397,7 +1394,6 @@ public class CallsManager extends Call.ListenerBase isConference, /* isConference */ mClockProxy, mToastFactory); notifyCallCreated(call); // set properties for transactional call if (extras.containsKey(TelecomManager.TRANSACTION_CALL_ID_KEY)) { Loading Loading @@ -1565,6 +1561,7 @@ public class CallsManager extends Call.ListenerBase call.setIsCreateConnectionComplete(true); addCall(call); } else { notifyStartCreateConnection(call); call.startCreateConnection(mPhoneAccountRegistrar); } return call; Loading @@ -1591,12 +1588,11 @@ public class CallsManager extends Call.ListenerBase false, /* isConference */ mClockProxy, mToastFactory); notifyCallCreated(call); call.initAnalytics(); setIntentExtrasAndStartTime(call, extras); call.addListener(this); notifyStartCreateConnection(call); call.startCreateConnection(mPhoneAccountRegistrar); } Loading Loading @@ -1719,8 +1715,6 @@ public class CallsManager extends Call.ListenerBase } call.initAnalytics(callingPackage, creationLogs.toString()); // Let listeners know that we just created a new call but haven't added it yet. notifyCallCreated(call); // Ensure new calls related to self-managed calls/connections are set as such. This // will be overridden when the actual connection is returned in startCreateConnection, Loading Loading @@ -1959,7 +1953,7 @@ public class CallsManager extends Call.ListenerBase Log.i(CallsManager.this, "Aborting call since there are no" + " available accounts."); showErrorMessage(R.string.cant_call_due_to_no_supported_service); mListeners.forEach(l -> l.onCallCreatedButNeverAdded(callToPlace)); mListeners.forEach(l -> l.onCreateConnectionFailed(callToPlace)); if (callToPlace.isEmergencyCall()){ mAnomalyReporter.reportAnomaly( EMERGENCY_CALL_ABORTED_NO_PHONE_ACCOUNTS_ERROR_UUID, Loading Loading @@ -2671,6 +2665,7 @@ public class CallsManager extends Call.ListenerBase disconnectSelfManagedCalls("place emerg call" /* reason */); } try { notifyStartCreateConnection(call); call.startCreateConnection(mPhoneAccountRegistrar); } catch (Exception exception) { // If an exceptions is thrown while creating the connection, prompt the user to Loading Loading @@ -3560,7 +3555,7 @@ public class CallsManager extends Call.ListenerBase EMERGENCY_CALL_DISCONNECTED_BEFORE_BEING_ADDED_ERROR_UUID, EMERGENCY_CALL_DISCONNECTED_BEFORE_BEING_ADDED_ERROR_MSG); } mListeners.forEach(l -> l.onCallCreatedButNeverAdded(call)); mListeners.forEach(l -> l.onCreateConnectionFailed(call)); } // If a call diagnostic service is in use, we will log the original telephony-provided Loading Loading @@ -5524,7 +5519,7 @@ public class CallsManager extends Call.ListenerBase call.setConnectionService(service); service.createConnectionFailed(call); if (!mCalls.contains(call)){ mListeners.forEach(l -> l.onCallCreatedButNeverAdded(call)); mListeners.forEach(l -> l.onCreateConnectionFailed(call)); } } } Loading @@ -5549,18 +5544,18 @@ public class CallsManager extends Call.ListenerBase call.setConnectionService(service); service.createConferenceFailed(call); if (!mCalls.contains(call)){ mListeners.forEach(l -> l.onCallCreatedButNeverAdded(call)); mListeners.forEach(l -> l.onCreateConnectionFailed(call)); } } } /** * Notify interested parties that a new call has been created, but not yet added to * CallsManager. * Notify interested parties that a new call is about to be handed off to a ConnectionService to * be created. * @param theCall the new call. */ private void notifyCallCreated(final Call theCall) { mListeners.forEach(l -> l.onCallCreated(theCall)); private void notifyStartCreateConnection(final Call theCall) { mListeners.forEach(l -> l.onStartCreateConnection(theCall)); } /** Loading Loading @@ -5725,7 +5720,7 @@ public class CallsManager extends Call.ListenerBase // Disconnect all self-managed calls to make priority for emergency call. disconnectSelfManagedCalls("emergency call"); } notifyStartCreateConnection(call); call.startCreateConnection(mPhoneAccountRegistrar); } Loading Loading @@ -5902,7 +5897,7 @@ public class CallsManager extends Call.ListenerBase extras.putBoolean(TelecomManager.EXTRA_IS_HANDOVER_CONNECTION, true); extras.putParcelable(TelecomManager.EXTRA_HANDOVER_FROM_PHONE_ACCOUNT, fromCall.getTargetPhoneAccount()); notifyStartCreateConnection(call); call.startCreateConnection(mPhoneAccountRegistrar); } Loading src/com/android/server/telecom/CallsManagerListenerBase.java +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ public abstract class CallsManagerListenerBase implements CallsManager.CallsMana } @Override public void onCallCreatedButNeverAdded(Call call) { public void onCreateConnectionFailed(Call call) { } @Override Loading tests/src/com/android/server/telecom/tests/CallAnomalyWatchdogTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -767,7 +767,7 @@ public class CallAnomalyWatchdogTest extends TelecomTestCase { Call call = getCall(); call.setState(CallState.NEW, "foo"); call.setIsCreateConnectionComplete(false); mCallAnomalyWatchdog.onCallCreated(call); mCallAnomalyWatchdog.onStartCreateConnection(call); //The connection fails before being added to CallsManager for a known reason: call.handleCreateConnectionFailure(new DisconnectCause(DisconnectCause.CANCELED)); Loading Loading @@ -795,7 +795,7 @@ public class CallAnomalyWatchdogTest extends TelecomTestCase { call.setCallDirection(Call.CALL_DIRECTION_OUTGOING); call.setState(CallState.NEW, "foo"); call.setIsCreateConnectionComplete(false); mCallAnomalyWatchdog.onCallCreated(call); mCallAnomalyWatchdog.onStartCreateConnection(call); //The connection fails before being added to CallsManager for a known reason. call.handleCreateConnectionFailure(new DisconnectCause(DisconnectCause.CANCELED)); Loading @@ -814,8 +814,8 @@ public class CallAnomalyWatchdogTest extends TelecomTestCase { /** * Emulate the case where a new incoming call is created but the connection fails for a known * reason before being added to CallsManager and CallsManager notifies the watchdog by invoking * onCallCreatedButNeverAdded(). In this case, the watchdog should stop tracking * the call and not trigger an anomaly report. * {@link CallsManager.CallsManagerListener#onCreateConnectionFailed(Call)}. * In this case, the watchdog should stop tracking the call and not trigger an anomaly report. */ @Test public void testCallCreatedButNotAddedPreventsAnomalyReport() { Loading @@ -823,10 +823,10 @@ public class CallAnomalyWatchdogTest extends TelecomTestCase { Call call = getCall(); call.setState(CallState.NEW, "foo"); call.setIsCreateConnectionComplete(false); mCallAnomalyWatchdog.onCallCreated(call); mCallAnomalyWatchdog.onStartCreateConnection(call); //Telecom cancels the connection before adding it to CallsManager: mCallAnomalyWatchdog.onCallCreatedButNeverAdded(call); mCallAnomalyWatchdog.onCreateConnectionFailed(call); // Move the clock forward: when(mMockClockProxy.elapsedRealtime()). Loading tests/src/com/android/server/telecom/tests/CallsManagerTest.java +5 −7 Original line number Diff line number Diff line Loading @@ -135,10 +135,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; Loading Loading @@ -2016,13 +2014,13 @@ public class CallsManagerTest extends TelecomTestCase { incomingCall.handleCreateConnectionFailure(new DisconnectCause(DisconnectCause.CANCELED)); //Ensure the listener is notified properly: verify(listener).onCallCreatedButNeverAdded(incomingCall); verify(listener).onCreateConnectionFailed(incomingCall); } /** * Emulate the case where a new incoming call is created but the connection fails for a known * reason after being added to CallsManager. Since the call was added to CallsManager, the * listeners should not be notified via onCallCreatedButNeverAdded(). * listeners should not be notified via onCreateConnectionFailed(). */ @Test public void testIncomingCallCreatedAndAddedDoNotNotifyListener() { Loading @@ -2037,8 +2035,8 @@ public class CallsManagerTest extends TelecomTestCase { //The connection fails after being added to CallsManager for a known reason: incomingCall.handleCreateConnectionFailure(new DisconnectCause(DisconnectCause.CANCELED)); //Since the call was added to CallsManager, onCallCreatedButNeverAdded shouldn't be invoked: verify(listener, never()).onCallCreatedButNeverAdded(incomingCall); //Since the call was added to CallsManager, onCreateConnectionFailed shouldn't be invoked: verify(listener, never()).onCreateConnectionFailed(incomingCall); } /** Loading Loading @@ -2069,7 +2067,7 @@ public class CallsManagerTest extends TelecomTestCase { Call result = callFuture.get(TEST_TIMEOUT, TimeUnit.MILLISECONDS); //Ensure the listener is notified properly: verify(listener).onCallCreatedButNeverAdded(any()); verify(listener).onCreateConnectionFailed(any()); assertNull(result); } Loading Loading
src/com/android/server/telecom/CallAnomalyWatchdog.java +9 −7 Original line number Diff line number Diff line Loading @@ -153,8 +153,12 @@ public class CallAnomalyWatchdog extends CallsManagerListenerBase implements Cal mClockProxy = clockProxy; } /** * Start tracking a call that we're waiting for a ConnectionService to create. * @param call the call. */ @Override public void onCallCreated(Call call) { public void onStartCreateConnection(Call call) { maybeTrackCall(call); call.addListener(this); } Loading @@ -165,15 +169,13 @@ public class CallAnomalyWatchdog extends CallsManagerListenerBase implements Cal } /** * Override of {@link CallsManagerListenerBase} to track when calls are created but * intentionally not added to mCalls. These calls should no longer be tracked by the * CallAnomalyWatchdog. * Override of {@link CallsManagerListenerBase} to track when calls have failed to be created by * a ConnectionService. These calls should no longer be tracked by the CallAnomalyWatchdog. * @param call the call */ @Override public void onCallCreatedButNeverAdded(Call call) { Log.i(this, "onCallCreatedButNeverAdded: call=%s", call.toString()); public void onCreateConnectionFailed(Call call) { Log.i(this, "onCreateConnectionFailed: call=%s", call.toString()); stopTrackingCall(call); } Loading
src/com/android/server/telecom/CallsManager.java +17 −22 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ import android.media.MediaPlayer; import android.media.ToneGenerator; import android.net.Uri; import android.os.AsyncTask; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; Loading Loading @@ -109,7 +108,6 @@ import android.util.Pair; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import android.widget.Button; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -176,14 +174,13 @@ public class CallsManager extends Call.ListenerBase @VisibleForTesting public interface CallsManagerListener { /** * Informs listeners when a {@link Call} is newly created but not yet added to * {@link #mCalls}. This is where the call has not yet been created by the underlying * {@link ConnectionService}. * Informs listeners when a {@link Call} is newly created, but not yet returned by a * {@link android.telecom.ConnectionService} implementation. * @param call the call. */ default void onCallCreated(Call call) {} default void onStartCreateConnection(Call call) {} void onCallAdded(Call call); void onCallCreatedButNeverAdded(Call call); void onCreateConnectionFailed(Call call); void onCallRemoved(Call call); void onCallStateChanged(Call call, int oldState, int newState); void onConnectionServiceChanged( Loading Loading @@ -1397,7 +1394,6 @@ public class CallsManager extends Call.ListenerBase isConference, /* isConference */ mClockProxy, mToastFactory); notifyCallCreated(call); // set properties for transactional call if (extras.containsKey(TelecomManager.TRANSACTION_CALL_ID_KEY)) { Loading Loading @@ -1565,6 +1561,7 @@ public class CallsManager extends Call.ListenerBase call.setIsCreateConnectionComplete(true); addCall(call); } else { notifyStartCreateConnection(call); call.startCreateConnection(mPhoneAccountRegistrar); } return call; Loading @@ -1591,12 +1588,11 @@ public class CallsManager extends Call.ListenerBase false, /* isConference */ mClockProxy, mToastFactory); notifyCallCreated(call); call.initAnalytics(); setIntentExtrasAndStartTime(call, extras); call.addListener(this); notifyStartCreateConnection(call); call.startCreateConnection(mPhoneAccountRegistrar); } Loading Loading @@ -1719,8 +1715,6 @@ public class CallsManager extends Call.ListenerBase } call.initAnalytics(callingPackage, creationLogs.toString()); // Let listeners know that we just created a new call but haven't added it yet. notifyCallCreated(call); // Ensure new calls related to self-managed calls/connections are set as such. This // will be overridden when the actual connection is returned in startCreateConnection, Loading Loading @@ -1959,7 +1953,7 @@ public class CallsManager extends Call.ListenerBase Log.i(CallsManager.this, "Aborting call since there are no" + " available accounts."); showErrorMessage(R.string.cant_call_due_to_no_supported_service); mListeners.forEach(l -> l.onCallCreatedButNeverAdded(callToPlace)); mListeners.forEach(l -> l.onCreateConnectionFailed(callToPlace)); if (callToPlace.isEmergencyCall()){ mAnomalyReporter.reportAnomaly( EMERGENCY_CALL_ABORTED_NO_PHONE_ACCOUNTS_ERROR_UUID, Loading Loading @@ -2671,6 +2665,7 @@ public class CallsManager extends Call.ListenerBase disconnectSelfManagedCalls("place emerg call" /* reason */); } try { notifyStartCreateConnection(call); call.startCreateConnection(mPhoneAccountRegistrar); } catch (Exception exception) { // If an exceptions is thrown while creating the connection, prompt the user to Loading Loading @@ -3560,7 +3555,7 @@ public class CallsManager extends Call.ListenerBase EMERGENCY_CALL_DISCONNECTED_BEFORE_BEING_ADDED_ERROR_UUID, EMERGENCY_CALL_DISCONNECTED_BEFORE_BEING_ADDED_ERROR_MSG); } mListeners.forEach(l -> l.onCallCreatedButNeverAdded(call)); mListeners.forEach(l -> l.onCreateConnectionFailed(call)); } // If a call diagnostic service is in use, we will log the original telephony-provided Loading Loading @@ -5524,7 +5519,7 @@ public class CallsManager extends Call.ListenerBase call.setConnectionService(service); service.createConnectionFailed(call); if (!mCalls.contains(call)){ mListeners.forEach(l -> l.onCallCreatedButNeverAdded(call)); mListeners.forEach(l -> l.onCreateConnectionFailed(call)); } } } Loading @@ -5549,18 +5544,18 @@ public class CallsManager extends Call.ListenerBase call.setConnectionService(service); service.createConferenceFailed(call); if (!mCalls.contains(call)){ mListeners.forEach(l -> l.onCallCreatedButNeverAdded(call)); mListeners.forEach(l -> l.onCreateConnectionFailed(call)); } } } /** * Notify interested parties that a new call has been created, but not yet added to * CallsManager. * Notify interested parties that a new call is about to be handed off to a ConnectionService to * be created. * @param theCall the new call. */ private void notifyCallCreated(final Call theCall) { mListeners.forEach(l -> l.onCallCreated(theCall)); private void notifyStartCreateConnection(final Call theCall) { mListeners.forEach(l -> l.onStartCreateConnection(theCall)); } /** Loading Loading @@ -5725,7 +5720,7 @@ public class CallsManager extends Call.ListenerBase // Disconnect all self-managed calls to make priority for emergency call. disconnectSelfManagedCalls("emergency call"); } notifyStartCreateConnection(call); call.startCreateConnection(mPhoneAccountRegistrar); } Loading Loading @@ -5902,7 +5897,7 @@ public class CallsManager extends Call.ListenerBase extras.putBoolean(TelecomManager.EXTRA_IS_HANDOVER_CONNECTION, true); extras.putParcelable(TelecomManager.EXTRA_HANDOVER_FROM_PHONE_ACCOUNT, fromCall.getTargetPhoneAccount()); notifyStartCreateConnection(call); call.startCreateConnection(mPhoneAccountRegistrar); } Loading
src/com/android/server/telecom/CallsManagerListenerBase.java +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ public abstract class CallsManagerListenerBase implements CallsManager.CallsMana } @Override public void onCallCreatedButNeverAdded(Call call) { public void onCreateConnectionFailed(Call call) { } @Override Loading
tests/src/com/android/server/telecom/tests/CallAnomalyWatchdogTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -767,7 +767,7 @@ public class CallAnomalyWatchdogTest extends TelecomTestCase { Call call = getCall(); call.setState(CallState.NEW, "foo"); call.setIsCreateConnectionComplete(false); mCallAnomalyWatchdog.onCallCreated(call); mCallAnomalyWatchdog.onStartCreateConnection(call); //The connection fails before being added to CallsManager for a known reason: call.handleCreateConnectionFailure(new DisconnectCause(DisconnectCause.CANCELED)); Loading Loading @@ -795,7 +795,7 @@ public class CallAnomalyWatchdogTest extends TelecomTestCase { call.setCallDirection(Call.CALL_DIRECTION_OUTGOING); call.setState(CallState.NEW, "foo"); call.setIsCreateConnectionComplete(false); mCallAnomalyWatchdog.onCallCreated(call); mCallAnomalyWatchdog.onStartCreateConnection(call); //The connection fails before being added to CallsManager for a known reason. call.handleCreateConnectionFailure(new DisconnectCause(DisconnectCause.CANCELED)); Loading @@ -814,8 +814,8 @@ public class CallAnomalyWatchdogTest extends TelecomTestCase { /** * Emulate the case where a new incoming call is created but the connection fails for a known * reason before being added to CallsManager and CallsManager notifies the watchdog by invoking * onCallCreatedButNeverAdded(). In this case, the watchdog should stop tracking * the call and not trigger an anomaly report. * {@link CallsManager.CallsManagerListener#onCreateConnectionFailed(Call)}. * In this case, the watchdog should stop tracking the call and not trigger an anomaly report. */ @Test public void testCallCreatedButNotAddedPreventsAnomalyReport() { Loading @@ -823,10 +823,10 @@ public class CallAnomalyWatchdogTest extends TelecomTestCase { Call call = getCall(); call.setState(CallState.NEW, "foo"); call.setIsCreateConnectionComplete(false); mCallAnomalyWatchdog.onCallCreated(call); mCallAnomalyWatchdog.onStartCreateConnection(call); //Telecom cancels the connection before adding it to CallsManager: mCallAnomalyWatchdog.onCallCreatedButNeverAdded(call); mCallAnomalyWatchdog.onCreateConnectionFailed(call); // Move the clock forward: when(mMockClockProxy.elapsedRealtime()). Loading
tests/src/com/android/server/telecom/tests/CallsManagerTest.java +5 −7 Original line number Diff line number Diff line Loading @@ -135,10 +135,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; Loading Loading @@ -2016,13 +2014,13 @@ public class CallsManagerTest extends TelecomTestCase { incomingCall.handleCreateConnectionFailure(new DisconnectCause(DisconnectCause.CANCELED)); //Ensure the listener is notified properly: verify(listener).onCallCreatedButNeverAdded(incomingCall); verify(listener).onCreateConnectionFailed(incomingCall); } /** * Emulate the case where a new incoming call is created but the connection fails for a known * reason after being added to CallsManager. Since the call was added to CallsManager, the * listeners should not be notified via onCallCreatedButNeverAdded(). * listeners should not be notified via onCreateConnectionFailed(). */ @Test public void testIncomingCallCreatedAndAddedDoNotNotifyListener() { Loading @@ -2037,8 +2035,8 @@ public class CallsManagerTest extends TelecomTestCase { //The connection fails after being added to CallsManager for a known reason: incomingCall.handleCreateConnectionFailure(new DisconnectCause(DisconnectCause.CANCELED)); //Since the call was added to CallsManager, onCallCreatedButNeverAdded shouldn't be invoked: verify(listener, never()).onCallCreatedButNeverAdded(incomingCall); //Since the call was added to CallsManager, onCreateConnectionFailed shouldn't be invoked: verify(listener, never()).onCreateConnectionFailed(incomingCall); } /** Loading Loading @@ -2069,7 +2067,7 @@ public class CallsManagerTest extends TelecomTestCase { Call result = callFuture.get(TEST_TIMEOUT, TimeUnit.MILLISECONDS); //Ensure the listener is notified properly: verify(listener).onCallCreatedButNeverAdded(any()); verify(listener).onCreateConnectionFailed(any()); assertNull(result); } Loading