From 4c69fb3d7b913f4870959314e9572f4ba80c2afe Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Fri, 17 May 2019 10:49:16 -0700 Subject: [PATCH] Make queryRemoteConnectionServices DSDS aware. The method queryRemoteConnectionServices had the issue that it assumes there is a single connection manager for the device. This assumption does not work on a multisim device. Since the ConnectionManager is associated with a particular carrier, this means that the connection mgr for one carrier could try to impact calls destined for another carrier. This change ensures that the calling package is passed into Telecom so that we can determine which RemoteConnectionServices which are available to the calling connection manager. Test: Manual test on DSDS with a connection mgr carrier and another carrier. Bug: 131856987 Change-Id: I46d80dc68adaab7fd4374f023d7ba4242804c253 --- .../java/android/telecom/ConnectionService.java | 4 +++- .../android/telecom/ConnectionServiceAdapter.java | 4 ++-- .../telecom/ConnectionServiceAdapterServant.java | 14 +++++++++++--- .../android/telecom/RemoteConnectionService.java | 2 +- .../telecom/IConnectionServiceAdapter.aidl | 3 ++- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java index 49b34b38c663b..c66e92b5e0998 100644 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -1937,6 +1937,8 @@ public abstract class ConnectionService extends Service { return; } + String callingPackage = getOpPackageName(); + mAdapter.queryRemoteConnectionServices(new RemoteServiceCallback.Stub() { @Override public void onResult( @@ -1965,7 +1967,7 @@ public abstract class ConnectionService extends Service { } }.prepare()); } - }); + }, callingPackage); } /** diff --git a/telecomm/java/android/telecom/ConnectionServiceAdapter.java b/telecomm/java/android/telecom/ConnectionServiceAdapter.java index 6c3f4f34ff2db..3acd83a41396d 100644 --- a/telecomm/java/android/telecom/ConnectionServiceAdapter.java +++ b/telecomm/java/android/telecom/ConnectionServiceAdapter.java @@ -316,11 +316,11 @@ final class ConnectionServiceAdapter implements DeathRecipient { /** * Retrieves a list of remote connection services usable to place calls. */ - void queryRemoteConnectionServices(RemoteServiceCallback callback) { + void queryRemoteConnectionServices(RemoteServiceCallback callback, String callingPackage) { // Only supported when there is only one adapter. if (mAdapters.size() == 1) { try { - mAdapters.iterator().next().queryRemoteConnectionServices(callback, + mAdapters.iterator().next().queryRemoteConnectionServices(callback, callingPackage, Log.getExternalSession()); } catch (RemoteException e) { Log.e(this, e, "Exception trying to query for remote CSs"); diff --git a/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java b/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java index f99b218bd9b96..b28158913dc41 100644 --- a/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java +++ b/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java @@ -186,8 +186,13 @@ final class ConnectionServiceAdapterServant { break; } case MSG_QUERY_REMOTE_CALL_SERVICES: - mDelegate.queryRemoteConnectionServices((RemoteServiceCallback) msg.obj, - null /*Session.Info*/); + SomeArgs args2 = (SomeArgs) msg.obj; + try { + mDelegate.queryRemoteConnectionServices((RemoteServiceCallback) args2.arg1, + (String) args2.arg2, null /*Session.Info*/); + } finally { + args2.recycle(); + } break; case MSG_SET_VIDEO_STATE: mDelegate.setVideoState((String) msg.obj, msg.arg1, null /*Session.Info*/); @@ -468,7 +473,10 @@ final class ConnectionServiceAdapterServant { @Override public void queryRemoteConnectionServices(RemoteServiceCallback callback, - Session.Info sessionInfo) { + String callingPackage, Session.Info sessionInfo) { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callback; + args.arg2 = callingPackage; mHandler.obtainMessage(MSG_QUERY_REMOTE_CALL_SERVICES, callback).sendToTarget(); } diff --git a/telecomm/java/android/telecom/RemoteConnectionService.java b/telecomm/java/android/telecom/RemoteConnectionService.java index 744544eb01f17..1e73bd61d68e2 100644 --- a/telecomm/java/android/telecom/RemoteConnectionService.java +++ b/telecomm/java/android/telecom/RemoteConnectionService.java @@ -288,7 +288,7 @@ final class RemoteConnectionService { @Override public void queryRemoteConnectionServices(RemoteServiceCallback callback, - Session.Info sessionInfo) { + String callingPackage, Session.Info sessionInfo) { // Not supported from remote connection service. } diff --git a/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl b/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl index 76ac88e9fbaa6..9cf098c751774 100644 --- a/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl +++ b/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl @@ -78,7 +78,8 @@ oneway interface IConnectionServiceAdapter { void onPostDialChar(String callId, char nextChar, in Session.Info sessionInfo); - void queryRemoteConnectionServices(RemoteServiceCallback callback, in Session.Info sessionInfo); + void queryRemoteConnectionServices(RemoteServiceCallback callback, String callingPackage, + in Session.Info sessionInfo); void setVideoProvider(String callId, IVideoProvider videoProvider, in Session.Info sessionInfo);