Loading src/com/android/server/telecom/Call.java +26 −8 Original line number Diff line number Diff line Loading @@ -1734,20 +1734,28 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, disconnect(0); } @VisibleForTesting public void disconnect(String reason) { disconnect(0, reason); } /** * Attempts to disconnect the call through the connection service. */ @VisibleForTesting public void disconnect(long disconnectionTimeout) { disconnect(disconnectionTimeout, "internal" /** callingPackage */); disconnect(disconnectionTimeout, "internal" /** reason */); } /** * Attempts to disconnect the call through the connection service. * @param reason the reason for the disconnect; used for logging purposes only. In some cases * this can be a package name if the disconnect was initiated through an API such * as TelecomManager. */ @VisibleForTesting public void disconnect(long disconnectionTimeout, String callingPackage) { Log.addEvent(this, LogUtils.Events.REQUEST_DISCONNECT, callingPackage); public void disconnect(long disconnectionTimeout, String reason) { Log.addEvent(this, LogUtils.Events.REQUEST_DISCONNECT, reason); // Track that the call is now locally disconnecting. setLocallyDisconnecting(true); Loading Loading @@ -1868,7 +1876,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, */ @VisibleForTesting public void reject(boolean rejectWithMessage, String textMessage) { reject(rejectWithMessage, textMessage, "internal" /** callingPackage */); reject(rejectWithMessage, textMessage, "internal" /** reason */); } /** Loading @@ -1876,9 +1884,11 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, * * @param rejectWithMessage Whether to send a text message as part of the call rejection. * @param textMessage An optional text message to send as part of the rejection. * @param reason The reason for the reject; used for logging purposes. May be a package name * if the reject is initiated from an API such as TelecomManager. */ @VisibleForTesting public void reject(boolean rejectWithMessage, String textMessage, String callingPackage) { public void reject(boolean rejectWithMessage, String textMessage, String reason) { // Check to verify that the call is still in the ringing state. A call can change states // between the time the user hits 'reject' and Telecomm receives the command. if (isRinging("reject")) { Loading @@ -1891,7 +1901,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, Log.e(this, new NullPointerException(), "reject call failed due to null CS callId=%s", getId()); } Log.addEvent(this, LogUtils.Events.REQUEST_REJECT, callingPackage); Log.addEvent(this, LogUtils.Events.REQUEST_REJECT, reason); } } Loading @@ -1900,6 +1910,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, */ @VisibleForTesting public void hold() { hold(null /* reason */); } public void hold(String reason) { if (mState == CallState.ACTIVE) { if (mConnectionService != null) { mConnectionService.hold(this); Loading @@ -1907,7 +1921,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, Log.e(this, new NullPointerException(), "hold call failed due to null CS callId=%s", getId()); } Log.addEvent(this, LogUtils.Events.REQUEST_HOLD); Log.addEvent(this, LogUtils.Events.REQUEST_HOLD, reason); } } Loading @@ -1916,6 +1930,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, */ @VisibleForTesting public void unhold() { unhold(null /* reason */); } public void unhold(String reason) { if (mState == CallState.ON_HOLD) { if (mConnectionService != null) { mConnectionService.unhold(this); Loading @@ -1923,7 +1941,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, Log.e(this, new NullPointerException(), "unhold call failed due to null CS callId=%s", getId()); } Log.addEvent(this, LogUtils.Events.REQUEST_UNHOLD); Log.addEvent(this, LogUtils.Events.REQUEST_UNHOLD, reason); } } Loading src/com/android/server/telecom/CallsManager.java +26 −19 Original line number Diff line number Diff line Loading @@ -286,7 +286,8 @@ public class CallsManager extends Call.ListenerBase ConnectionServiceFocusManager.ConnectionServiceFocus connectionService) { mCalls.stream() .filter(c -> c.getConnectionServiceWrapper().equals(connectionService)) .forEach(c -> c.disconnect()); .forEach(c -> c.disconnect("release " + connectionService.getComponentName().getPackageName())); } @Override Loading Loading @@ -1491,7 +1492,7 @@ public class CallsManager extends Call.ListenerBase // service, then disconnect it, otherwise allow the connection service to // figure out the right states. if (activeCall.getConnectionService() != call.getConnectionService()) { activeCall.disconnect(); activeCall.disconnect("Can't hold when answering " + call.getId()); } } } Loading Loading @@ -1683,25 +1684,27 @@ public class CallsManager extends Call.ListenerBase Log.w(this, "Unknown call (%s) asked to be removed from hold", call); } else { Call activeCall = (Call) mConnectionSvrFocusMgr.getCurrentFocusCall(); String activeCallId = null; if (activeCall != null) { activeCallId = activeCall.getId(); if (canHold(activeCall)) { activeCall.hold(); Log.addEvent(activeCall, LogUtils.Events.SWAP); Log.addEvent(call, LogUtils.Events.SWAP); activeCall.hold("Swap to " + call.getId()); Log.addEvent(activeCall, LogUtils.Events.SWAP, "To " + call.getId()); Log.addEvent(call, LogUtils.Events.SWAP, "From " + activeCall.getId()); } else { // This call does not support hold. If it is from a different connection // service, then disconnect it, otherwise invoke call.hold() and allow the // connection service to handle the situation. if (activeCall.getConnectionService() != call.getConnectionService()) { activeCall.disconnect(); activeCall.disconnect("Swap to " + call.getId()); } else { activeCall.hold(); activeCall.hold("Swap to " + call.getId()); } } } mConnectionSvrFocusMgr.requestFocus( call, new RequestCallback(new ActionUnHoldCall(call))); new RequestCallback(new ActionUnHoldCall(call, activeCallId))); } } Loading Loading @@ -1879,7 +1882,7 @@ public class CallsManager extends Call.ListenerBase if (makeRoomForOutgoingCall(call, false /* isEmergencyCall */)) { call.startCreateConnection(mPhoneAccountRegistrar); } else { call.disconnect(); call.disconnect("no room"); } if (setDefault) { Loading Loading @@ -2838,7 +2841,7 @@ public class CallsManager extends Call.ListenerBase if (isEmergency && !canHold(liveCall)) { call.getAnalytics().setCallIsAdditional(true); liveCall.getAnalytics().setCallIsInterrupted(true); liveCall.disconnect(); liveCall.disconnect("emergency, can't hold"); return true; } Loading Loading @@ -2881,7 +2884,7 @@ public class CallsManager extends Call.ListenerBase Log.i(this, "makeRoomForOutgoingCall: holding live call."); call.getAnalytics().setCallIsAdditional(true); liveCall.getAnalytics().setCallIsInterrupted(true); liveCall.hold(); liveCall.hold("calling " + call.getId()); return true; } Loading Loading @@ -3180,7 +3183,7 @@ public class CallsManager extends Call.ListenerBase // We are going to place the new outgoing call, so disconnect any ongoing self-managed // calls which are ongoing at this time. disconnectSelfManagedCalls(); disconnectSelfManagedCalls("outgoing call " + callId); // Kick of the new outgoing call intent from where it left off prior to confirming the // call. Loading Loading @@ -3242,14 +3245,14 @@ public class CallsManager extends Call.ListenerBase /** * Disconnects all self-managed calls. */ private void disconnectSelfManagedCalls() { private void disconnectSelfManagedCalls(String reason) { // Disconnect all self-managed calls to make priority for emergency call. // Use Call.disconnect() to command the ConnectionService to disconnect the calls. // CallsManager.markCallAsDisconnected doesn't actually tell the ConnectionService to // disconnect. mCalls.stream() .filter(c -> c.isSelfManaged()) .forEach(c -> c.disconnect()); .forEach(c -> c.disconnect(reason)); // When disconnecting all self-managed calls, switch audio routing back to the baseline // route. This ensures if, for example, the self-managed ConnectionService was routed to Loading @@ -3259,11 +3262,13 @@ public class CallsManager extends Call.ListenerBase } private void disconnectCallsHaveDifferentConnectionService(Call exceptCall) { String csPackage = exceptCall.getConnectionService() != null ? exceptCall.getConnectionService().getComponentName().toShortString() : "null"; mCalls.stream().filter(c -> c.getConnectionService() != exceptCall.getConnectionService() && c.getConnectionManagerPhoneAccount() != exceptCall.getConnectionManagerPhoneAccount()) .forEach(c -> c.disconnect()); .forEach(c -> c.disconnect("CS not " + csPackage)); } /** Loading Loading @@ -3392,7 +3397,7 @@ public class CallsManager extends Call.ListenerBase ConnectionServiceWrapper service = call.getConnectionService(); service.handoverFailed(call, reason); call.setDisconnectCause(new DisconnectCause(DisconnectCause.CANCELED)); call.disconnect(); call.disconnect("handover failed"); } /** Loading Loading @@ -3572,7 +3577,7 @@ public class CallsManager extends Call.ListenerBase } else { if (call.isEmergencyCall()) { // Disconnect all self-managed calls to make priority for emergency call. disconnectSelfManagedCalls(); disconnectSelfManagedCalls("emergency call"); } call.startCreateConnection(mPhoneAccountRegistrar); Loading Loading @@ -3789,15 +3794,17 @@ public class CallsManager extends Call.ListenerBase private final class ActionUnHoldCall implements PendingAction { private final Call mCall; private final String mPreviouslyHeldCallId; ActionUnHoldCall(Call call) { ActionUnHoldCall(Call call, String previouslyHeldCallId) { mCall = call; mPreviouslyHeldCallId = previouslyHeldCallId; } @Override public void performAction() { Log.d(this, "perform unhold call for %s", mCall); mCall.unhold(); mCall.unhold("held " + mPreviouslyHeldCallId); } } Loading src/com/android/server/telecom/ConnectionServiceFocusManager.java +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom; import android.annotation.Nullable; import android.content.ComponentName; import android.os.Handler; import android.os.Looper; import android.os.Message; Loading Loading @@ -64,6 +65,12 @@ public class ConnectionServiceFocusManager { * @see {@link ConnectionServiceFocusListener}. */ void setConnectionServiceFocusListener(ConnectionServiceFocusListener listener); /** * Get the {@link ComponentName} of the ConnectionService for logging purposes. * @return the {@link ComponentName}. */ ComponentName getComponentName(); } /** Loading src/com/android/server/telecom/ServiceBinder.java +1 −1 Original line number Diff line number Diff line Loading @@ -309,7 +309,7 @@ abstract class ServiceBinder { } } final ComponentName getComponentName() { public final ComponentName getComponentName() { return mComponentName; } Loading testapps/res/layout/self_managed_call_list_item.xml +5 −0 Original line number Diff line number Diff line Loading @@ -72,5 +72,10 @@ android:layout_height="wrap_content" android:text="Earpiece" android:id="@+id/earpieceButton" /> <CheckBox android:id="@+id/holdable" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="Holdable"/> </LinearLayout> </LinearLayout> No newline at end of file Loading
src/com/android/server/telecom/Call.java +26 −8 Original line number Diff line number Diff line Loading @@ -1734,20 +1734,28 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, disconnect(0); } @VisibleForTesting public void disconnect(String reason) { disconnect(0, reason); } /** * Attempts to disconnect the call through the connection service. */ @VisibleForTesting public void disconnect(long disconnectionTimeout) { disconnect(disconnectionTimeout, "internal" /** callingPackage */); disconnect(disconnectionTimeout, "internal" /** reason */); } /** * Attempts to disconnect the call through the connection service. * @param reason the reason for the disconnect; used for logging purposes only. In some cases * this can be a package name if the disconnect was initiated through an API such * as TelecomManager. */ @VisibleForTesting public void disconnect(long disconnectionTimeout, String callingPackage) { Log.addEvent(this, LogUtils.Events.REQUEST_DISCONNECT, callingPackage); public void disconnect(long disconnectionTimeout, String reason) { Log.addEvent(this, LogUtils.Events.REQUEST_DISCONNECT, reason); // Track that the call is now locally disconnecting. setLocallyDisconnecting(true); Loading Loading @@ -1868,7 +1876,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, */ @VisibleForTesting public void reject(boolean rejectWithMessage, String textMessage) { reject(rejectWithMessage, textMessage, "internal" /** callingPackage */); reject(rejectWithMessage, textMessage, "internal" /** reason */); } /** Loading @@ -1876,9 +1884,11 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, * * @param rejectWithMessage Whether to send a text message as part of the call rejection. * @param textMessage An optional text message to send as part of the rejection. * @param reason The reason for the reject; used for logging purposes. May be a package name * if the reject is initiated from an API such as TelecomManager. */ @VisibleForTesting public void reject(boolean rejectWithMessage, String textMessage, String callingPackage) { public void reject(boolean rejectWithMessage, String textMessage, String reason) { // Check to verify that the call is still in the ringing state. A call can change states // between the time the user hits 'reject' and Telecomm receives the command. if (isRinging("reject")) { Loading @@ -1891,7 +1901,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, Log.e(this, new NullPointerException(), "reject call failed due to null CS callId=%s", getId()); } Log.addEvent(this, LogUtils.Events.REQUEST_REJECT, callingPackage); Log.addEvent(this, LogUtils.Events.REQUEST_REJECT, reason); } } Loading @@ -1900,6 +1910,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, */ @VisibleForTesting public void hold() { hold(null /* reason */); } public void hold(String reason) { if (mState == CallState.ACTIVE) { if (mConnectionService != null) { mConnectionService.hold(this); Loading @@ -1907,7 +1921,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, Log.e(this, new NullPointerException(), "hold call failed due to null CS callId=%s", getId()); } Log.addEvent(this, LogUtils.Events.REQUEST_HOLD); Log.addEvent(this, LogUtils.Events.REQUEST_HOLD, reason); } } Loading @@ -1916,6 +1930,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, */ @VisibleForTesting public void unhold() { unhold(null /* reason */); } public void unhold(String reason) { if (mState == CallState.ON_HOLD) { if (mConnectionService != null) { mConnectionService.unhold(this); Loading @@ -1923,7 +1941,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, Log.e(this, new NullPointerException(), "unhold call failed due to null CS callId=%s", getId()); } Log.addEvent(this, LogUtils.Events.REQUEST_UNHOLD); Log.addEvent(this, LogUtils.Events.REQUEST_UNHOLD, reason); } } Loading
src/com/android/server/telecom/CallsManager.java +26 −19 Original line number Diff line number Diff line Loading @@ -286,7 +286,8 @@ public class CallsManager extends Call.ListenerBase ConnectionServiceFocusManager.ConnectionServiceFocus connectionService) { mCalls.stream() .filter(c -> c.getConnectionServiceWrapper().equals(connectionService)) .forEach(c -> c.disconnect()); .forEach(c -> c.disconnect("release " + connectionService.getComponentName().getPackageName())); } @Override Loading Loading @@ -1491,7 +1492,7 @@ public class CallsManager extends Call.ListenerBase // service, then disconnect it, otherwise allow the connection service to // figure out the right states. if (activeCall.getConnectionService() != call.getConnectionService()) { activeCall.disconnect(); activeCall.disconnect("Can't hold when answering " + call.getId()); } } } Loading Loading @@ -1683,25 +1684,27 @@ public class CallsManager extends Call.ListenerBase Log.w(this, "Unknown call (%s) asked to be removed from hold", call); } else { Call activeCall = (Call) mConnectionSvrFocusMgr.getCurrentFocusCall(); String activeCallId = null; if (activeCall != null) { activeCallId = activeCall.getId(); if (canHold(activeCall)) { activeCall.hold(); Log.addEvent(activeCall, LogUtils.Events.SWAP); Log.addEvent(call, LogUtils.Events.SWAP); activeCall.hold("Swap to " + call.getId()); Log.addEvent(activeCall, LogUtils.Events.SWAP, "To " + call.getId()); Log.addEvent(call, LogUtils.Events.SWAP, "From " + activeCall.getId()); } else { // This call does not support hold. If it is from a different connection // service, then disconnect it, otherwise invoke call.hold() and allow the // connection service to handle the situation. if (activeCall.getConnectionService() != call.getConnectionService()) { activeCall.disconnect(); activeCall.disconnect("Swap to " + call.getId()); } else { activeCall.hold(); activeCall.hold("Swap to " + call.getId()); } } } mConnectionSvrFocusMgr.requestFocus( call, new RequestCallback(new ActionUnHoldCall(call))); new RequestCallback(new ActionUnHoldCall(call, activeCallId))); } } Loading Loading @@ -1879,7 +1882,7 @@ public class CallsManager extends Call.ListenerBase if (makeRoomForOutgoingCall(call, false /* isEmergencyCall */)) { call.startCreateConnection(mPhoneAccountRegistrar); } else { call.disconnect(); call.disconnect("no room"); } if (setDefault) { Loading Loading @@ -2838,7 +2841,7 @@ public class CallsManager extends Call.ListenerBase if (isEmergency && !canHold(liveCall)) { call.getAnalytics().setCallIsAdditional(true); liveCall.getAnalytics().setCallIsInterrupted(true); liveCall.disconnect(); liveCall.disconnect("emergency, can't hold"); return true; } Loading Loading @@ -2881,7 +2884,7 @@ public class CallsManager extends Call.ListenerBase Log.i(this, "makeRoomForOutgoingCall: holding live call."); call.getAnalytics().setCallIsAdditional(true); liveCall.getAnalytics().setCallIsInterrupted(true); liveCall.hold(); liveCall.hold("calling " + call.getId()); return true; } Loading Loading @@ -3180,7 +3183,7 @@ public class CallsManager extends Call.ListenerBase // We are going to place the new outgoing call, so disconnect any ongoing self-managed // calls which are ongoing at this time. disconnectSelfManagedCalls(); disconnectSelfManagedCalls("outgoing call " + callId); // Kick of the new outgoing call intent from where it left off prior to confirming the // call. Loading Loading @@ -3242,14 +3245,14 @@ public class CallsManager extends Call.ListenerBase /** * Disconnects all self-managed calls. */ private void disconnectSelfManagedCalls() { private void disconnectSelfManagedCalls(String reason) { // Disconnect all self-managed calls to make priority for emergency call. // Use Call.disconnect() to command the ConnectionService to disconnect the calls. // CallsManager.markCallAsDisconnected doesn't actually tell the ConnectionService to // disconnect. mCalls.stream() .filter(c -> c.isSelfManaged()) .forEach(c -> c.disconnect()); .forEach(c -> c.disconnect(reason)); // When disconnecting all self-managed calls, switch audio routing back to the baseline // route. This ensures if, for example, the self-managed ConnectionService was routed to Loading @@ -3259,11 +3262,13 @@ public class CallsManager extends Call.ListenerBase } private void disconnectCallsHaveDifferentConnectionService(Call exceptCall) { String csPackage = exceptCall.getConnectionService() != null ? exceptCall.getConnectionService().getComponentName().toShortString() : "null"; mCalls.stream().filter(c -> c.getConnectionService() != exceptCall.getConnectionService() && c.getConnectionManagerPhoneAccount() != exceptCall.getConnectionManagerPhoneAccount()) .forEach(c -> c.disconnect()); .forEach(c -> c.disconnect("CS not " + csPackage)); } /** Loading Loading @@ -3392,7 +3397,7 @@ public class CallsManager extends Call.ListenerBase ConnectionServiceWrapper service = call.getConnectionService(); service.handoverFailed(call, reason); call.setDisconnectCause(new DisconnectCause(DisconnectCause.CANCELED)); call.disconnect(); call.disconnect("handover failed"); } /** Loading Loading @@ -3572,7 +3577,7 @@ public class CallsManager extends Call.ListenerBase } else { if (call.isEmergencyCall()) { // Disconnect all self-managed calls to make priority for emergency call. disconnectSelfManagedCalls(); disconnectSelfManagedCalls("emergency call"); } call.startCreateConnection(mPhoneAccountRegistrar); Loading Loading @@ -3789,15 +3794,17 @@ public class CallsManager extends Call.ListenerBase private final class ActionUnHoldCall implements PendingAction { private final Call mCall; private final String mPreviouslyHeldCallId; ActionUnHoldCall(Call call) { ActionUnHoldCall(Call call, String previouslyHeldCallId) { mCall = call; mPreviouslyHeldCallId = previouslyHeldCallId; } @Override public void performAction() { Log.d(this, "perform unhold call for %s", mCall); mCall.unhold(); mCall.unhold("held " + mPreviouslyHeldCallId); } } Loading
src/com/android/server/telecom/ConnectionServiceFocusManager.java +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom; import android.annotation.Nullable; import android.content.ComponentName; import android.os.Handler; import android.os.Looper; import android.os.Message; Loading Loading @@ -64,6 +65,12 @@ public class ConnectionServiceFocusManager { * @see {@link ConnectionServiceFocusListener}. */ void setConnectionServiceFocusListener(ConnectionServiceFocusListener listener); /** * Get the {@link ComponentName} of the ConnectionService for logging purposes. * @return the {@link ComponentName}. */ ComponentName getComponentName(); } /** Loading
src/com/android/server/telecom/ServiceBinder.java +1 −1 Original line number Diff line number Diff line Loading @@ -309,7 +309,7 @@ abstract class ServiceBinder { } } final ComponentName getComponentName() { public final ComponentName getComponentName() { return mComponentName; } Loading
testapps/res/layout/self_managed_call_list_item.xml +5 −0 Original line number Diff line number Diff line Loading @@ -72,5 +72,10 @@ android:layout_height="wrap_content" android:text="Earpiece" android:id="@+id/earpieceButton" /> <CheckBox android:id="@+id/holdable" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="Holdable"/> </LinearLayout> </LinearLayout> No newline at end of file