Loading src/com/android/server/telecom/Call.java +8 −2 Original line number Diff line number Diff line Loading @@ -1763,7 +1763,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, /** * Puts the call on hold if it is currently active. */ void hold() { @VisibleForTesting public void hold() { if (mState == CallState.ACTIVE) { if (mConnectionService != null) { mConnectionService.hold(this); Loading @@ -1778,7 +1779,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, /** * Releases the call from hold if it is currently active. */ void unhold() { @VisibleForTesting public void unhold() { if (mState == CallState.ON_HOLD) { if (mConnectionService != null) { mConnectionService.unhold(this); Loading Loading @@ -2800,6 +2802,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, return mOriginalConnectionId; } ConnectionServiceFocusManager getConnectionServiceFocusManager() { return mCallsManager.getConnectionServiceFocusManager(); } /** * Determines if a {@link Call}'s capabilities bitmask indicates that video is supported either * remotely or locally. Loading src/com/android/server/telecom/CallsManager.java +237 −131 File changed.Preview size limit exceeded, changes collapsed. Show changes src/com/android/server/telecom/ConnectionServiceFocusManager.java +37 −13 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.Nullable; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.telecom.Log; import com.android.internal.annotations.VisibleForTesting; import java.util.ArrayList; Loading @@ -28,8 +29,12 @@ import java.util.Objects; import java.util.stream.Collectors; public class ConnectionServiceFocusManager { private static final String TAG = "ConnectionSvrFocusMgr"; private static final String TAG = "ConnectionServiceFocusManager"; /** Factory interface used to create the {@link ConnectionServiceFocusManager} instance. */ public interface ConnectionServiceFocusManagerFactory { ConnectionServiceFocusManager create(CallsManagerRequester requester, Looper looper); } /** * Interface used by ConnectionServiceFocusManager to communicate with Loading Loading @@ -191,14 +196,18 @@ public class ConnectionServiceFocusManager { private final ConnectionServiceFocusListener mConnectionServiceFocusListener = new ConnectionServiceFocusListener() { @Override public void onConnectionServiceReleased(ConnectionServiceFocus connectionServiceFocus) { mEventHandler.obtainMessage(MSG_RELEASE_CONNECTION_FOCUS, connectionServiceFocus) public void onConnectionServiceReleased( ConnectionServiceFocus connectionServiceFocus) { mEventHandler .obtainMessage(MSG_RELEASE_CONNECTION_FOCUS, connectionServiceFocus) .sendToTarget(); } @Override public void onConnectionServiceDeath(ConnectionServiceFocus connectionServiceFocus) { mEventHandler.obtainMessage(MSG_CONNECTION_SERVICE_DEATH, connectionServiceFocus) public void onConnectionServiceDeath( ConnectionServiceFocus connectionServiceFocus) { mEventHandler .obtainMessage(MSG_CONNECTION_SERVICE_DEATH, connectionServiceFocus) .sendToTarget(); } }; Loading Loading @@ -257,6 +266,7 @@ public class ConnectionServiceFocusManager { connSvrFocus.connectionServiceFocusGained(); } mCurrentFocus = connSvrFocus; Log.d(this, "updateConnectionServiceFocus connSvr = %s", connSvrFocus); } } Loading @@ -276,10 +286,13 @@ public class ConnectionServiceFocusManager { for (CallFocus call : calls) { if (call.getState() == PRIORITY_FOCUS_CALL_STATE[i]) { mCurrentFocusCall = call; Log.d(this, "updateCurrentFocusCall %s", mCurrentFocusCall); return; } } } Log.d(this, "updateCurrentFocusCall = null"); } private void onRequestFocusDone(FocusRequest focusRequest) { Loading @@ -289,6 +302,7 @@ public class ConnectionServiceFocusManager { } private void handleRequestFocus(FocusRequest focusRequest) { Log.d(this, "handleRequestFocus req = %s", focusRequest); if (mCurrentFocus == null || mCurrentFocus.equals(focusRequest.call.getConnectionServiceWrapper())) { updateConnectionServiceFocus(focusRequest.call.getConnectionServiceWrapper()); Loading @@ -304,6 +318,7 @@ public class ConnectionServiceFocusManager { } private void handleReleasedFocus(ConnectionServiceFocus connectionServiceFocus) { Log.d(this, "handleReleasedFocus connSvr = %s", connectionServiceFocus); // The ConnectionService can call onConnectionServiceFocusReleased even if it's not the // current focus connection service, nothing will be changed in this case. if (Objects.equals(mCurrentFocus, connectionServiceFocus)) { Loading @@ -322,6 +337,7 @@ public class ConnectionServiceFocusManager { } private void handleReleasedFocusTimeout(FocusRequest focusRequest) { Log.d(this, "handleReleasedFocusTimeout req = %s", focusRequest); mCallsManagerRequester.releaseConnectionService(mCurrentFocus); updateConnectionServiceFocus(focusRequest.call.getConnectionServiceWrapper()); updateCurrentFocusCall(); Loading @@ -330,6 +346,7 @@ public class ConnectionServiceFocusManager { } private void handleConnectionServiceDeath(ConnectionServiceFocus connectionServiceFocus) { Log.d(this, "handleConnectionServiceDeath %s", connectionServiceFocus); if (Objects.equals(connectionServiceFocus, mCurrentFocus)) { updateConnectionServiceFocus(null); updateCurrentFocusCall(); Loading @@ -337,6 +354,7 @@ public class ConnectionServiceFocusManager { } private void handleAddedCall(CallFocus call) { Log.d(this, "handleAddedCall %s", call); if (!mCalls.contains(call)) { mCalls.add(call); } Loading @@ -346,6 +364,7 @@ public class ConnectionServiceFocusManager { } private void handleRemovedCall(CallFocus call) { Log.d(this, "handleRemovedCall %s", call); mCalls.remove(call); if (call.equals(mCurrentFocusCall)) { updateCurrentFocusCall(); Loading @@ -353,6 +372,11 @@ public class ConnectionServiceFocusManager { } private void handleCallStateChanged(CallFocus call, int oldState, int newState) { Log.d(this, "handleCallStateChanged %s, oldState = %d, newState = %d", call, oldState, newState); if (mCalls.contains(call) && Objects.equals(mCurrentFocus, call.getConnectionServiceWrapper())) { updateCurrentFocusCall(); Loading src/com/android/server/telecom/ConnectionServiceWrapper.java +42 −4 Original line number Diff line number Diff line Loading @@ -859,8 +859,17 @@ public class ConnectionServiceWrapper extends ServiceBinder implements @Override public void onConnectionServiceFocusReleased(Session.Info sessionInfo) throws RemoteException { // TODO(mpq): This method is added to avoid the compiled error. Add the real // implementation once ag/3273964 done. Log.startSession(sessionInfo, "CSW.oCSFR"); long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { mConnSvrFocusListener.onConnectionServiceReleased( ConnectionServiceWrapper.this); } } finally { Binder.restoreCallingIdentity(token); Log.endSession(); } } } Loading Loading @@ -1421,12 +1430,41 @@ public class ConnectionServiceWrapper extends ServiceBinder implements // Immediately response to the Telecom that it has released the call resources. // TODO(mpq): Change back to the default implementation once b/69651192 done. if (mConnSvrFocusListener != null) { mConnSvrFocusListener.onConnectionServiceReleased(this); mConnSvrFocusListener.onConnectionServiceReleased(ConnectionServiceWrapper.this); } BindCallback callback = new BindCallback() { @Override public void onSuccess() { try { mServiceInterface.connectionServiceFocusLost(Log.getExternalSession()); } catch (RemoteException ignored) { Log.d(this, "failed to inform the focus lost event"); } } @Override public void connectionServiceFocusGained() {} public void onFailure() {} }; mBinder.bind(callback, null /* null call */); } @Override public void connectionServiceFocusGained() { BindCallback callback = new BindCallback() { @Override public void onSuccess() { try { mServiceInterface.connectionServiceFocusGained(Log.getExternalSession()); } catch (RemoteException ignored) { Log.d(this, "failed to inform the focus gained event"); } } @Override public void onFailure() {} }; mBinder.bind(callback, null /* null call */); } @Override public void setConnectionServiceFocusListener( Loading src/com/android/server/telecom/CreateConnectionProcessor.java +17 −1 Original line number Diff line number Diff line Loading @@ -213,8 +213,24 @@ public class CreateConnectionProcessor implements CreateConnectionResponse { mCall.setTargetPhoneAccount(attempt.targetPhoneAccount); mCall.setConnectionService(mService); setTimeoutIfNeeded(mService, attempt); if (mCall.isIncoming()) { mService.createConnection(mCall, CreateConnectionProcessor.this); } else { // Start to create the connection for outgoing call after the ConnectionService // of the call has gained the focus. mCall.getConnectionServiceFocusManager().requestFocus( mCall, new CallsManager.RequestCallback(new CallsManager.PendingAction() { @Override public void performAction() { Log.d(this, "perform create connection"); mService.createConnection( mCall, CreateConnectionProcessor.this); } })); mService.createConnection(mCall, this); } } } else { Log.v(this, "attemptNextPhoneAccount, no more accounts, failing"); Loading Loading
src/com/android/server/telecom/Call.java +8 −2 Original line number Diff line number Diff line Loading @@ -1763,7 +1763,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, /** * Puts the call on hold if it is currently active. */ void hold() { @VisibleForTesting public void hold() { if (mState == CallState.ACTIVE) { if (mConnectionService != null) { mConnectionService.hold(this); Loading @@ -1778,7 +1779,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, /** * Releases the call from hold if it is currently active. */ void unhold() { @VisibleForTesting public void unhold() { if (mState == CallState.ON_HOLD) { if (mConnectionService != null) { mConnectionService.unhold(this); Loading Loading @@ -2800,6 +2802,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, return mOriginalConnectionId; } ConnectionServiceFocusManager getConnectionServiceFocusManager() { return mCallsManager.getConnectionServiceFocusManager(); } /** * Determines if a {@link Call}'s capabilities bitmask indicates that video is supported either * remotely or locally. Loading
src/com/android/server/telecom/CallsManager.java +237 −131 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/com/android/server/telecom/ConnectionServiceFocusManager.java +37 −13 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.Nullable; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.telecom.Log; import com.android.internal.annotations.VisibleForTesting; import java.util.ArrayList; Loading @@ -28,8 +29,12 @@ import java.util.Objects; import java.util.stream.Collectors; public class ConnectionServiceFocusManager { private static final String TAG = "ConnectionSvrFocusMgr"; private static final String TAG = "ConnectionServiceFocusManager"; /** Factory interface used to create the {@link ConnectionServiceFocusManager} instance. */ public interface ConnectionServiceFocusManagerFactory { ConnectionServiceFocusManager create(CallsManagerRequester requester, Looper looper); } /** * Interface used by ConnectionServiceFocusManager to communicate with Loading Loading @@ -191,14 +196,18 @@ public class ConnectionServiceFocusManager { private final ConnectionServiceFocusListener mConnectionServiceFocusListener = new ConnectionServiceFocusListener() { @Override public void onConnectionServiceReleased(ConnectionServiceFocus connectionServiceFocus) { mEventHandler.obtainMessage(MSG_RELEASE_CONNECTION_FOCUS, connectionServiceFocus) public void onConnectionServiceReleased( ConnectionServiceFocus connectionServiceFocus) { mEventHandler .obtainMessage(MSG_RELEASE_CONNECTION_FOCUS, connectionServiceFocus) .sendToTarget(); } @Override public void onConnectionServiceDeath(ConnectionServiceFocus connectionServiceFocus) { mEventHandler.obtainMessage(MSG_CONNECTION_SERVICE_DEATH, connectionServiceFocus) public void onConnectionServiceDeath( ConnectionServiceFocus connectionServiceFocus) { mEventHandler .obtainMessage(MSG_CONNECTION_SERVICE_DEATH, connectionServiceFocus) .sendToTarget(); } }; Loading Loading @@ -257,6 +266,7 @@ public class ConnectionServiceFocusManager { connSvrFocus.connectionServiceFocusGained(); } mCurrentFocus = connSvrFocus; Log.d(this, "updateConnectionServiceFocus connSvr = %s", connSvrFocus); } } Loading @@ -276,10 +286,13 @@ public class ConnectionServiceFocusManager { for (CallFocus call : calls) { if (call.getState() == PRIORITY_FOCUS_CALL_STATE[i]) { mCurrentFocusCall = call; Log.d(this, "updateCurrentFocusCall %s", mCurrentFocusCall); return; } } } Log.d(this, "updateCurrentFocusCall = null"); } private void onRequestFocusDone(FocusRequest focusRequest) { Loading @@ -289,6 +302,7 @@ public class ConnectionServiceFocusManager { } private void handleRequestFocus(FocusRequest focusRequest) { Log.d(this, "handleRequestFocus req = %s", focusRequest); if (mCurrentFocus == null || mCurrentFocus.equals(focusRequest.call.getConnectionServiceWrapper())) { updateConnectionServiceFocus(focusRequest.call.getConnectionServiceWrapper()); Loading @@ -304,6 +318,7 @@ public class ConnectionServiceFocusManager { } private void handleReleasedFocus(ConnectionServiceFocus connectionServiceFocus) { Log.d(this, "handleReleasedFocus connSvr = %s", connectionServiceFocus); // The ConnectionService can call onConnectionServiceFocusReleased even if it's not the // current focus connection service, nothing will be changed in this case. if (Objects.equals(mCurrentFocus, connectionServiceFocus)) { Loading @@ -322,6 +337,7 @@ public class ConnectionServiceFocusManager { } private void handleReleasedFocusTimeout(FocusRequest focusRequest) { Log.d(this, "handleReleasedFocusTimeout req = %s", focusRequest); mCallsManagerRequester.releaseConnectionService(mCurrentFocus); updateConnectionServiceFocus(focusRequest.call.getConnectionServiceWrapper()); updateCurrentFocusCall(); Loading @@ -330,6 +346,7 @@ public class ConnectionServiceFocusManager { } private void handleConnectionServiceDeath(ConnectionServiceFocus connectionServiceFocus) { Log.d(this, "handleConnectionServiceDeath %s", connectionServiceFocus); if (Objects.equals(connectionServiceFocus, mCurrentFocus)) { updateConnectionServiceFocus(null); updateCurrentFocusCall(); Loading @@ -337,6 +354,7 @@ public class ConnectionServiceFocusManager { } private void handleAddedCall(CallFocus call) { Log.d(this, "handleAddedCall %s", call); if (!mCalls.contains(call)) { mCalls.add(call); } Loading @@ -346,6 +364,7 @@ public class ConnectionServiceFocusManager { } private void handleRemovedCall(CallFocus call) { Log.d(this, "handleRemovedCall %s", call); mCalls.remove(call); if (call.equals(mCurrentFocusCall)) { updateCurrentFocusCall(); Loading @@ -353,6 +372,11 @@ public class ConnectionServiceFocusManager { } private void handleCallStateChanged(CallFocus call, int oldState, int newState) { Log.d(this, "handleCallStateChanged %s, oldState = %d, newState = %d", call, oldState, newState); if (mCalls.contains(call) && Objects.equals(mCurrentFocus, call.getConnectionServiceWrapper())) { updateCurrentFocusCall(); Loading
src/com/android/server/telecom/ConnectionServiceWrapper.java +42 −4 Original line number Diff line number Diff line Loading @@ -859,8 +859,17 @@ public class ConnectionServiceWrapper extends ServiceBinder implements @Override public void onConnectionServiceFocusReleased(Session.Info sessionInfo) throws RemoteException { // TODO(mpq): This method is added to avoid the compiled error. Add the real // implementation once ag/3273964 done. Log.startSession(sessionInfo, "CSW.oCSFR"); long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { mConnSvrFocusListener.onConnectionServiceReleased( ConnectionServiceWrapper.this); } } finally { Binder.restoreCallingIdentity(token); Log.endSession(); } } } Loading Loading @@ -1421,12 +1430,41 @@ public class ConnectionServiceWrapper extends ServiceBinder implements // Immediately response to the Telecom that it has released the call resources. // TODO(mpq): Change back to the default implementation once b/69651192 done. if (mConnSvrFocusListener != null) { mConnSvrFocusListener.onConnectionServiceReleased(this); mConnSvrFocusListener.onConnectionServiceReleased(ConnectionServiceWrapper.this); } BindCallback callback = new BindCallback() { @Override public void onSuccess() { try { mServiceInterface.connectionServiceFocusLost(Log.getExternalSession()); } catch (RemoteException ignored) { Log.d(this, "failed to inform the focus lost event"); } } @Override public void connectionServiceFocusGained() {} public void onFailure() {} }; mBinder.bind(callback, null /* null call */); } @Override public void connectionServiceFocusGained() { BindCallback callback = new BindCallback() { @Override public void onSuccess() { try { mServiceInterface.connectionServiceFocusGained(Log.getExternalSession()); } catch (RemoteException ignored) { Log.d(this, "failed to inform the focus gained event"); } } @Override public void onFailure() {} }; mBinder.bind(callback, null /* null call */); } @Override public void setConnectionServiceFocusListener( Loading
src/com/android/server/telecom/CreateConnectionProcessor.java +17 −1 Original line number Diff line number Diff line Loading @@ -213,8 +213,24 @@ public class CreateConnectionProcessor implements CreateConnectionResponse { mCall.setTargetPhoneAccount(attempt.targetPhoneAccount); mCall.setConnectionService(mService); setTimeoutIfNeeded(mService, attempt); if (mCall.isIncoming()) { mService.createConnection(mCall, CreateConnectionProcessor.this); } else { // Start to create the connection for outgoing call after the ConnectionService // of the call has gained the focus. mCall.getConnectionServiceFocusManager().requestFocus( mCall, new CallsManager.RequestCallback(new CallsManager.PendingAction() { @Override public void performAction() { Log.d(this, "perform create connection"); mService.createConnection( mCall, CreateConnectionProcessor.this); } })); mService.createConnection(mCall, this); } } } else { Log.v(this, "attemptNextPhoneAccount, no more accounts, failing"); Loading