Loading telecomm/java/android/telecomm/ConnectionService.java +21 −8 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; /** * A {@link android.app.Service} that provides telephone connections to processes running on an Loading @@ -61,7 +60,7 @@ public abstract class ConnectionService extends Service { // Flag controlling whether PII is emitted into the logs private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG); private static final int MSG_ADD_CALL_SERVICE_ADAPTER = 1; private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1; private static final int MSG_CREATE_CONNECTION = 2; private static final int MSG_ABORT = 3; private static final int MSG_ANSWER = 4; Loading @@ -77,6 +76,7 @@ public abstract class ConnectionService extends Service { private static final int MSG_SWAP_WITH_BACKGROUND_CALL = 14; private static final int MSG_ON_POST_DIAL_CONTINUE = 15; private static final int MSG_ON_PHONE_ACCOUNT_CLICKED = 16; private static final int MSG_REMOVE_CONNECTION_SERVICE_ADAPTER = 17; private static Connection sNullConnection; Loading Loading @@ -122,7 +122,11 @@ public abstract class ConnectionService extends Service { private final IBinder mBinder = new IConnectionService.Stub() { @Override public void addConnectionServiceAdapter(IConnectionServiceAdapter adapter) { mHandler.obtainMessage(MSG_ADD_CALL_SERVICE_ADAPTER, adapter).sendToTarget(); mHandler.obtainMessage(MSG_ADD_CONNECTION_SERVICE_ADAPTER, adapter).sendToTarget(); } public void removeConnectionServiceAdapter(IConnectionServiceAdapter adapter) { mHandler.obtainMessage(MSG_REMOVE_CONNECTION_SERVICE_ADAPTER, adapter).sendToTarget(); } @Override Loading Loading @@ -224,10 +228,13 @@ public abstract class ConnectionService extends Service { @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_ADD_CALL_SERVICE_ADAPTER: case MSG_ADD_CONNECTION_SERVICE_ADAPTER: mAdapter.addAdapter((IConnectionServiceAdapter) msg.obj); onAdapterAttached(); break; case MSG_REMOVE_CONNECTION_SERVICE_ADAPTER: mAdapter.removeAdapter((IConnectionServiceAdapter) msg.obj); break; case MSG_CREATE_CONNECTION: { SomeArgs args = (SomeArgs) msg.obj; try { Loading @@ -236,6 +243,7 @@ public abstract class ConnectionService extends Service { final ConnectionRequest request = (ConnectionRequest) args.arg2; final boolean isIncoming = args.argi1 == 1; if (!mAreAccountsInitialized) { Log.d(this, "Enqueueing pre-init request %s", request.getCallId()); mPreInitializationConnectionRequests.add(new Runnable() { @Override public void run() { Loading @@ -246,6 +254,7 @@ public abstract class ConnectionService extends Service { } }); } else { Log.d(this, "Immediately processing request %s", request.getCallId()); createConnection(connectionManagerPhoneAccount, request, isIncoming); } } finally { Loading Loading @@ -490,8 +499,6 @@ public abstract class ConnectionService extends Service { } if (createdConnection != null) { Log.d(this, "adapter handleCreateConnectionSuccessful %s", request.getCallId()); if (createdConnection.getState() == Connection.State.INITIALIZING) { // Wait for the connection to become initialized. createdConnection.addConnectionListener(new Connection.Listener() { Loading @@ -501,11 +508,14 @@ public abstract class ConnectionService extends Service { case Connection.State.FAILED: Log.d(this, "Connection (%s) failed (%d: %s)", request, c.getFailureCode(), c.getFailureMessage()); Log.d(this, "adapter handleCreateConnectionFailed %s", request.getCallId()); mAdapter.handleCreateConnectionFailed(request, c.getFailureCode(), c.getFailureMessage()); break; case Connection.State.CANCELED: Log.d(this, "Connection (%s) canceled", request); Log.d(this, "adapter handleCreateConnectionCanceled %s", request.getCallId()); mAdapter.handleCreateConnectionCancelled(request); break; case Connection.State.INITIALIZING: Loading @@ -531,6 +541,7 @@ public abstract class ConnectionService extends Service { } } else { // Tell telecomm to try a different service. Log.d(this, "adapter handleCreateConnectionFailed %s", request.getCallId()); mAdapter.handleCreateConnectionFailed(request, DisconnectCause.ERROR_UNSPECIFIED, null); } } Loading @@ -544,7 +555,7 @@ public abstract class ConnectionService extends Service { connection.getState(), CallCapabilities.toString(connection.getCallCapabilities())); Log.d(this, "adapter handleCreateConnectionSuccessful %s", request.getCallId()); mAdapter.handleCreateConnectionSuccessful( request, new ParcelableConnection( Loading Loading @@ -859,10 +870,12 @@ public abstract class ConnectionService extends Service { } private void removeConnection(Connection connection) { String id = mIdByConnection.get(connection); connection.removeConnectionListener(mConnectionListener); mConnectionById.remove(mIdByConnection.get(connection)); mIdByConnection.remove(connection); onConnectionRemoved(connection); mAdapter.removeCall(id); } private Connection findConnectionForAction(String callId, String action) { Loading telecomm/java/android/telecomm/RemoteConnectionService.java +20 −6 Original line number Diff line number Diff line Loading @@ -232,7 +232,6 @@ final class RemoteConnectionService { RemoteConnectionService(IConnectionService connectionService) throws RemoteException { mConnectionService = connectionService; mConnectionService.addConnectionServiceAdapter(mServant.getStub()); mConnectionService.asBinder().linkToDeath(mDeathRecipient, 0); } Loading @@ -245,7 +244,7 @@ final class RemoteConnectionService { PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request, boolean isIncoming) { ConnectionRequest newRequest = new ConnectionRequest( final ConnectionRequest newRequest = new ConnectionRequest( request.getAccountHandle(), UUID.randomUUID().toString(), request.getHandle(), Loading @@ -253,14 +252,29 @@ final class RemoteConnectionService { request.getExtras(), request.getVideoState()); try { if (mConnectionById.isEmpty()) { mConnectionService.addConnectionServiceAdapter(mServant.getStub()); } RemoteConnection connection = new RemoteConnection(mConnectionService, newRequest); mPendingConnections.add(connection); mConnectionById.put(newRequest.getCallId(), connection); mConnectionService.createConnection( connectionManagerPhoneAccount, newRequest, isIncoming); RemoteConnection connection = new RemoteConnection(mConnectionService, request); mPendingConnections.add(connection); mConnectionById.put(newRequest.getCallId(), connection); connection.addListener(new RemoteConnection.Listener() { @Override public void onDestroyed(RemoteConnection connection) { mConnectionById.remove(newRequest.getCallId()); if (mConnectionById.isEmpty()) { try { mConnectionService.removeConnectionServiceAdapter(mServant.getStub()); } catch (RemoteException e) { } } } }); return connection; } catch (RemoteException e) { return RemoteConnection.failure(DisconnectCause.ERROR_UNSPECIFIED, e.toString()); Loading telecomm/java/com/android/internal/telecomm/IConnectionService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import com.android.internal.telecomm.IConnectionServiceAdapter; oneway interface IConnectionService { void addConnectionServiceAdapter(in IConnectionServiceAdapter adapter); void removeConnectionServiceAdapter(in IConnectionServiceAdapter adapter); void createConnection( in PhoneAccountHandle connectionManagerPhoneAccount, in ConnectionRequest request, Loading Loading
telecomm/java/android/telecomm/ConnectionService.java +21 −8 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; /** * A {@link android.app.Service} that provides telephone connections to processes running on an Loading @@ -61,7 +60,7 @@ public abstract class ConnectionService extends Service { // Flag controlling whether PII is emitted into the logs private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG); private static final int MSG_ADD_CALL_SERVICE_ADAPTER = 1; private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1; private static final int MSG_CREATE_CONNECTION = 2; private static final int MSG_ABORT = 3; private static final int MSG_ANSWER = 4; Loading @@ -77,6 +76,7 @@ public abstract class ConnectionService extends Service { private static final int MSG_SWAP_WITH_BACKGROUND_CALL = 14; private static final int MSG_ON_POST_DIAL_CONTINUE = 15; private static final int MSG_ON_PHONE_ACCOUNT_CLICKED = 16; private static final int MSG_REMOVE_CONNECTION_SERVICE_ADAPTER = 17; private static Connection sNullConnection; Loading Loading @@ -122,7 +122,11 @@ public abstract class ConnectionService extends Service { private final IBinder mBinder = new IConnectionService.Stub() { @Override public void addConnectionServiceAdapter(IConnectionServiceAdapter adapter) { mHandler.obtainMessage(MSG_ADD_CALL_SERVICE_ADAPTER, adapter).sendToTarget(); mHandler.obtainMessage(MSG_ADD_CONNECTION_SERVICE_ADAPTER, adapter).sendToTarget(); } public void removeConnectionServiceAdapter(IConnectionServiceAdapter adapter) { mHandler.obtainMessage(MSG_REMOVE_CONNECTION_SERVICE_ADAPTER, adapter).sendToTarget(); } @Override Loading Loading @@ -224,10 +228,13 @@ public abstract class ConnectionService extends Service { @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_ADD_CALL_SERVICE_ADAPTER: case MSG_ADD_CONNECTION_SERVICE_ADAPTER: mAdapter.addAdapter((IConnectionServiceAdapter) msg.obj); onAdapterAttached(); break; case MSG_REMOVE_CONNECTION_SERVICE_ADAPTER: mAdapter.removeAdapter((IConnectionServiceAdapter) msg.obj); break; case MSG_CREATE_CONNECTION: { SomeArgs args = (SomeArgs) msg.obj; try { Loading @@ -236,6 +243,7 @@ public abstract class ConnectionService extends Service { final ConnectionRequest request = (ConnectionRequest) args.arg2; final boolean isIncoming = args.argi1 == 1; if (!mAreAccountsInitialized) { Log.d(this, "Enqueueing pre-init request %s", request.getCallId()); mPreInitializationConnectionRequests.add(new Runnable() { @Override public void run() { Loading @@ -246,6 +254,7 @@ public abstract class ConnectionService extends Service { } }); } else { Log.d(this, "Immediately processing request %s", request.getCallId()); createConnection(connectionManagerPhoneAccount, request, isIncoming); } } finally { Loading Loading @@ -490,8 +499,6 @@ public abstract class ConnectionService extends Service { } if (createdConnection != null) { Log.d(this, "adapter handleCreateConnectionSuccessful %s", request.getCallId()); if (createdConnection.getState() == Connection.State.INITIALIZING) { // Wait for the connection to become initialized. createdConnection.addConnectionListener(new Connection.Listener() { Loading @@ -501,11 +508,14 @@ public abstract class ConnectionService extends Service { case Connection.State.FAILED: Log.d(this, "Connection (%s) failed (%d: %s)", request, c.getFailureCode(), c.getFailureMessage()); Log.d(this, "adapter handleCreateConnectionFailed %s", request.getCallId()); mAdapter.handleCreateConnectionFailed(request, c.getFailureCode(), c.getFailureMessage()); break; case Connection.State.CANCELED: Log.d(this, "Connection (%s) canceled", request); Log.d(this, "adapter handleCreateConnectionCanceled %s", request.getCallId()); mAdapter.handleCreateConnectionCancelled(request); break; case Connection.State.INITIALIZING: Loading @@ -531,6 +541,7 @@ public abstract class ConnectionService extends Service { } } else { // Tell telecomm to try a different service. Log.d(this, "adapter handleCreateConnectionFailed %s", request.getCallId()); mAdapter.handleCreateConnectionFailed(request, DisconnectCause.ERROR_UNSPECIFIED, null); } } Loading @@ -544,7 +555,7 @@ public abstract class ConnectionService extends Service { connection.getState(), CallCapabilities.toString(connection.getCallCapabilities())); Log.d(this, "adapter handleCreateConnectionSuccessful %s", request.getCallId()); mAdapter.handleCreateConnectionSuccessful( request, new ParcelableConnection( Loading Loading @@ -859,10 +870,12 @@ public abstract class ConnectionService extends Service { } private void removeConnection(Connection connection) { String id = mIdByConnection.get(connection); connection.removeConnectionListener(mConnectionListener); mConnectionById.remove(mIdByConnection.get(connection)); mIdByConnection.remove(connection); onConnectionRemoved(connection); mAdapter.removeCall(id); } private Connection findConnectionForAction(String callId, String action) { Loading
telecomm/java/android/telecomm/RemoteConnectionService.java +20 −6 Original line number Diff line number Diff line Loading @@ -232,7 +232,6 @@ final class RemoteConnectionService { RemoteConnectionService(IConnectionService connectionService) throws RemoteException { mConnectionService = connectionService; mConnectionService.addConnectionServiceAdapter(mServant.getStub()); mConnectionService.asBinder().linkToDeath(mDeathRecipient, 0); } Loading @@ -245,7 +244,7 @@ final class RemoteConnectionService { PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request, boolean isIncoming) { ConnectionRequest newRequest = new ConnectionRequest( final ConnectionRequest newRequest = new ConnectionRequest( request.getAccountHandle(), UUID.randomUUID().toString(), request.getHandle(), Loading @@ -253,14 +252,29 @@ final class RemoteConnectionService { request.getExtras(), request.getVideoState()); try { if (mConnectionById.isEmpty()) { mConnectionService.addConnectionServiceAdapter(mServant.getStub()); } RemoteConnection connection = new RemoteConnection(mConnectionService, newRequest); mPendingConnections.add(connection); mConnectionById.put(newRequest.getCallId(), connection); mConnectionService.createConnection( connectionManagerPhoneAccount, newRequest, isIncoming); RemoteConnection connection = new RemoteConnection(mConnectionService, request); mPendingConnections.add(connection); mConnectionById.put(newRequest.getCallId(), connection); connection.addListener(new RemoteConnection.Listener() { @Override public void onDestroyed(RemoteConnection connection) { mConnectionById.remove(newRequest.getCallId()); if (mConnectionById.isEmpty()) { try { mConnectionService.removeConnectionServiceAdapter(mServant.getStub()); } catch (RemoteException e) { } } } }); return connection; } catch (RemoteException e) { return RemoteConnection.failure(DisconnectCause.ERROR_UNSPECIFIED, e.toString()); Loading
telecomm/java/com/android/internal/telecomm/IConnectionService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import com.android.internal.telecomm.IConnectionServiceAdapter; oneway interface IConnectionService { void addConnectionServiceAdapter(in IConnectionServiceAdapter adapter); void removeConnectionServiceAdapter(in IConnectionServiceAdapter adapter); void createConnection( in PhoneAccountHandle connectionManagerPhoneAccount, in ConnectionRequest request, Loading