summaryrefslogtreecommitdiffstats
path: root/telecomm/java
diff options
context:
space:
mode:
authorIhab Awad <ihab@google.com>2014-08-08 17:06:11 -0700
committerIhab Awad <ihab@google.com>2014-08-12 03:27:12 +0000
commit8aecfedb7b5ac1c909a83f97ef8dad7ca4c68d0f (patch)
tree1cd60167b69ee21eed71d02ccb53f578b1a0eba5 /telecomm/java
parent3afd00e9f2b55a21ca378d6e520d24283dbb62e0 (diff)
downloadframeworks_base-8aecfedb7b5ac1c909a83f97ef8dad7ca4c68d0f.zip
frameworks_base-8aecfedb7b5ac1c909a83f97ef8dad7ca4c68d0f.tar.gz
frameworks_base-8aecfedb7b5ac1c909a83f97ef8dad7ca4c68d0f.tar.bz2
Fix incorrect connection ID for remote connection service
Also cleans up incidental issues including: * Remote connection service disconnects from the service it represents if it is not currently handling any connections; hope to avert excessive service pinning in the future. * Fix destroyed connection handling. Bug: 16828152 Change-Id: Id4555f91ddac5e9c1a12ce00bfd1ee0d6d2cb1d9
Diffstat (limited to 'telecomm/java')
-rw-r--r--telecomm/java/android/telecomm/ConnectionService.java29
-rw-r--r--telecomm/java/android/telecomm/RemoteConnectionService.java26
-rw-r--r--telecomm/java/com/android/internal/telecomm/IConnectionService.aidl2
3 files changed, 43 insertions, 14 deletions
diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java
index 34d35bf..80c7bbc 100644
--- a/telecomm/java/android/telecomm/ConnectionService.java
+++ b/telecomm/java/android/telecomm/ConnectionService.java
@@ -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
@@ -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;
@@ -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;
@@ -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
@@ -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 {
@@ -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() {
@@ -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 {
@@ -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() {
@@ -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:
@@ -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);
}
}
@@ -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(
@@ -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) {
diff --git a/telecomm/java/android/telecomm/RemoteConnectionService.java b/telecomm/java/android/telecomm/RemoteConnectionService.java
index 9325bbb..95b62ba 100644
--- a/telecomm/java/android/telecomm/RemoteConnectionService.java
+++ b/telecomm/java/android/telecomm/RemoteConnectionService.java
@@ -232,7 +232,6 @@ final class RemoteConnectionService {
RemoteConnectionService(IConnectionService connectionService) throws RemoteException {
mConnectionService = connectionService;
- mConnectionService.addConnectionServiceAdapter(mServant.getStub());
mConnectionService.asBinder().linkToDeath(mDeathRecipient, 0);
}
@@ -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(),
@@ -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());
diff --git a/telecomm/java/com/android/internal/telecomm/IConnectionService.aidl b/telecomm/java/com/android/internal/telecomm/IConnectionService.aidl
index 4b05fb9..7abb4dd 100644
--- a/telecomm/java/com/android/internal/telecomm/IConnectionService.aidl
+++ b/telecomm/java/com/android/internal/telecomm/IConnectionService.aidl
@@ -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,