Loading src/com/android/server/telecom/ConnectionServiceWrapper.java +43 −19 Original line number Diff line number Diff line Loading @@ -572,15 +572,16 @@ public class ConnectionServiceWrapper extends ServiceBinder implements @Override public void queryRemoteConnectionServices(RemoteServiceCallback callback, Session.Info sessionInfo) { String callingPackage, Session.Info sessionInfo) { final UserHandle callingUserHandle = Binder.getCallingUserHandle(); Log.startSession(sessionInfo, "CSW.qRCS"); long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { logIncoming("queryRemoteConnectionServices %s", callback); logIncoming("queryRemoteConnectionServices callingPackage=" + callingPackage); ConnectionServiceWrapper.this .queryRemoteConnectionServices(callingUserHandle, callback); .queryRemoteConnectionServices(callingUserHandle, callingPackage, callback); } } catch (Throwable t) { Log.e(ConnectionServiceWrapper.this, t, ""); Loading Loading @@ -1711,21 +1712,26 @@ public class ConnectionServiceWrapper extends ServiceBinder implements } private void queryRemoteConnectionServices(final UserHandle userHandle, final RemoteServiceCallback callback) { // Only give remote connection services to this connection service if it is listed as // the connection manager. PhoneAccountHandle simCallManager = mPhoneAccountRegistrar.getSimCallManager(userHandle); Log.d(this, "queryRemoteConnectionServices finds simCallManager = %s", simCallManager); if (simCallManager == null || !simCallManager.getComponentName().equals(getComponentName())) { noRemoteServices(callback); return; } // Make a list of ConnectionServices that are listed as being associated with SIM accounts final String callingPackage, final RemoteServiceCallback callback) { boolean isCallerConnectionManager = false; // For each Sim ConnectionService, use its subid to find the correct connection manager for // that ConnectionService; return those Sim ConnectionServices which match the connection // manager. final Set<ConnectionServiceWrapper> simServices = Collections.newSetFromMap( new ConcurrentHashMap<ConnectionServiceWrapper, Boolean>(8, 0.9f, 1)); for (PhoneAccountHandle handle : mPhoneAccountRegistrar.getSimPhoneAccounts(userHandle)) { int subId = mPhoneAccountRegistrar.getSubscriptionIdForPhoneAccount(handle); PhoneAccountHandle connectionMgrHandle = mPhoneAccountRegistrar.getSimCallManager(subId, userHandle); if (connectionMgrHandle == null || !connectionMgrHandle.getComponentName().getPackageName().equals( callingPackage)) { Log.v(this, "queryRemoteConnectionServices: callingPackage=%s skipped; " + "doesn't match mgr %s for tfa %s", callingPackage, connectionMgrHandle, handle); continue; } isCallerConnectionManager = true; ConnectionServiceWrapper service = mConnectionServiceRepository.getService( handle.getComponentName(), handle.getUserHandle()); if (service != null) { Loading @@ -1733,10 +1739,17 @@ public class ConnectionServiceWrapper extends ServiceBinder implements } } // Bail early if the caller isn't the sim connection mgr. if (!isCallerConnectionManager) { Log.d(this, "queryRemoteConnectionServices: none; not sim call mgr."); noRemoteServices(callback); return; } final List<ComponentName> simServiceComponentNames = new ArrayList<>(); final List<IBinder> simServiceBinders = new ArrayList<>(); Log.v(this, "queryRemoteConnectionServices, simServices = %s", simServices); Log.i(this, "queryRemoteConnectionServices, simServices = %s", simServices); for (ConnectionServiceWrapper simService : simServices) { if (simService == this) { Loading @@ -1749,7 +1762,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements currentSimService.mBinder.bind(new BindCallback() { @Override public void onSuccess() { Log.d(this, "Adding simService %s", currentSimService.getComponentName()); Log.d(this, "queryRemoteConnectionServices: Adding simService %s", currentSimService.getComponentName()); if (currentSimService.mServiceInterface == null) { // The remote ConnectionService died, so do not add it. // We will still perform maybeComplete() and notify the caller with an empty Loading @@ -1765,7 +1779,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements @Override public void onFailure() { Log.d(this, "Failed simService %s", currentSimService.getComponentName()); Log.d(this, "queryRemoteConnectionServices: Failed simService %s", currentSimService.getComponentName()); // We know maybeComplete() will always be a no-op from now on, so go ahead and // signal failure of the entire request noRemoteServices(callback); Loading @@ -1787,7 +1802,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements try { callback.onResult(componentNames, binders); } catch (RemoteException e) { Log.e(this, e, "Contacting ConnectionService %s", Log.e(this, e, "setRemoteServices: Contacting ConnectionService %s", ConnectionServiceWrapper.this.getComponentName()); } } Loading @@ -1795,4 +1810,13 @@ public class ConnectionServiceWrapper extends ServiceBinder implements private void noRemoteServices(RemoteServiceCallback callback) { setRemoteServices(callback, Collections.EMPTY_LIST, Collections.EMPTY_LIST); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("[ConnectionServiceWrapper componentName="); sb.append(mComponentName); sb.append("]"); return sb.toString(); } } src/com/android/server/telecom/PhoneAccountRegistrar.java +17 −4 Original line number Diff line number Diff line Loading @@ -451,14 +451,15 @@ public class PhoneAccountRegistrar { PhoneAccountHandle retval = dialerSimCallManager != null ? dialerSimCallManager : systemSimCallManager; Log.i(this, "SimCallManager queried, returning: %s", retval); Log.i(this, "getSimCallManager: SimCallManager for subId %d queried, returning: %s", subId, retval); return retval; } /** * If it is a outgoing call, sim call manager of call-initiating user is returned. * If it is a outgoing call, sim call manager associated with the target phone account of the * call is returned (if one exists). * Otherwise, we return the sim call manager of the user associated with the * target phone account. * @return phone account handle of sim call manager based on the ongoing call. Loading @@ -471,7 +472,19 @@ public class PhoneAccountRegistrar { if (userHandle == null) { userHandle = call.getTargetPhoneAccount().getUserHandle(); } return getSimCallManager(userHandle); int subId = getSubscriptionIdForPhoneAccount(call.getTargetPhoneAccount()); if (SubscriptionManager.isValidSubscriptionId(subId) && subId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { PhoneAccountHandle callManagerHandle = getSimCallManager(subId, userHandle); Log.d(this, "getSimCallManagerFromCall: callId=%s, targetPhac=%s, subId=%d, scm=%s", call.getId(), call.getTargetPhoneAccount(), subId, callManagerHandle); return callManagerHandle; } else { PhoneAccountHandle callManagerHandle = getSimCallManager(userHandle); Log.d(this, "getSimCallManagerFromCall: callId=%s, targetPhac=%s, subId(d)=%d, scm=%s", call.getId(), call.getTargetPhoneAccount(), subId, callManagerHandle); return callManagerHandle; } } /** Loading tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java +1 −1 Original line number Diff line number Diff line Loading @@ -574,7 +574,7 @@ public class ConnectionServiceFixture implements TestFixture<IConnectionService> public IBinder asBinder() { return this; } }, null /*Session.Info*/); }, "" /* callingPackage */, null /*Session.Info*/); } } Loading Loading
src/com/android/server/telecom/ConnectionServiceWrapper.java +43 −19 Original line number Diff line number Diff line Loading @@ -572,15 +572,16 @@ public class ConnectionServiceWrapper extends ServiceBinder implements @Override public void queryRemoteConnectionServices(RemoteServiceCallback callback, Session.Info sessionInfo) { String callingPackage, Session.Info sessionInfo) { final UserHandle callingUserHandle = Binder.getCallingUserHandle(); Log.startSession(sessionInfo, "CSW.qRCS"); long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { logIncoming("queryRemoteConnectionServices %s", callback); logIncoming("queryRemoteConnectionServices callingPackage=" + callingPackage); ConnectionServiceWrapper.this .queryRemoteConnectionServices(callingUserHandle, callback); .queryRemoteConnectionServices(callingUserHandle, callingPackage, callback); } } catch (Throwable t) { Log.e(ConnectionServiceWrapper.this, t, ""); Loading Loading @@ -1711,21 +1712,26 @@ public class ConnectionServiceWrapper extends ServiceBinder implements } private void queryRemoteConnectionServices(final UserHandle userHandle, final RemoteServiceCallback callback) { // Only give remote connection services to this connection service if it is listed as // the connection manager. PhoneAccountHandle simCallManager = mPhoneAccountRegistrar.getSimCallManager(userHandle); Log.d(this, "queryRemoteConnectionServices finds simCallManager = %s", simCallManager); if (simCallManager == null || !simCallManager.getComponentName().equals(getComponentName())) { noRemoteServices(callback); return; } // Make a list of ConnectionServices that are listed as being associated with SIM accounts final String callingPackage, final RemoteServiceCallback callback) { boolean isCallerConnectionManager = false; // For each Sim ConnectionService, use its subid to find the correct connection manager for // that ConnectionService; return those Sim ConnectionServices which match the connection // manager. final Set<ConnectionServiceWrapper> simServices = Collections.newSetFromMap( new ConcurrentHashMap<ConnectionServiceWrapper, Boolean>(8, 0.9f, 1)); for (PhoneAccountHandle handle : mPhoneAccountRegistrar.getSimPhoneAccounts(userHandle)) { int subId = mPhoneAccountRegistrar.getSubscriptionIdForPhoneAccount(handle); PhoneAccountHandle connectionMgrHandle = mPhoneAccountRegistrar.getSimCallManager(subId, userHandle); if (connectionMgrHandle == null || !connectionMgrHandle.getComponentName().getPackageName().equals( callingPackage)) { Log.v(this, "queryRemoteConnectionServices: callingPackage=%s skipped; " + "doesn't match mgr %s for tfa %s", callingPackage, connectionMgrHandle, handle); continue; } isCallerConnectionManager = true; ConnectionServiceWrapper service = mConnectionServiceRepository.getService( handle.getComponentName(), handle.getUserHandle()); if (service != null) { Loading @@ -1733,10 +1739,17 @@ public class ConnectionServiceWrapper extends ServiceBinder implements } } // Bail early if the caller isn't the sim connection mgr. if (!isCallerConnectionManager) { Log.d(this, "queryRemoteConnectionServices: none; not sim call mgr."); noRemoteServices(callback); return; } final List<ComponentName> simServiceComponentNames = new ArrayList<>(); final List<IBinder> simServiceBinders = new ArrayList<>(); Log.v(this, "queryRemoteConnectionServices, simServices = %s", simServices); Log.i(this, "queryRemoteConnectionServices, simServices = %s", simServices); for (ConnectionServiceWrapper simService : simServices) { if (simService == this) { Loading @@ -1749,7 +1762,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements currentSimService.mBinder.bind(new BindCallback() { @Override public void onSuccess() { Log.d(this, "Adding simService %s", currentSimService.getComponentName()); Log.d(this, "queryRemoteConnectionServices: Adding simService %s", currentSimService.getComponentName()); if (currentSimService.mServiceInterface == null) { // The remote ConnectionService died, so do not add it. // We will still perform maybeComplete() and notify the caller with an empty Loading @@ -1765,7 +1779,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements @Override public void onFailure() { Log.d(this, "Failed simService %s", currentSimService.getComponentName()); Log.d(this, "queryRemoteConnectionServices: Failed simService %s", currentSimService.getComponentName()); // We know maybeComplete() will always be a no-op from now on, so go ahead and // signal failure of the entire request noRemoteServices(callback); Loading @@ -1787,7 +1802,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements try { callback.onResult(componentNames, binders); } catch (RemoteException e) { Log.e(this, e, "Contacting ConnectionService %s", Log.e(this, e, "setRemoteServices: Contacting ConnectionService %s", ConnectionServiceWrapper.this.getComponentName()); } } Loading @@ -1795,4 +1810,13 @@ public class ConnectionServiceWrapper extends ServiceBinder implements private void noRemoteServices(RemoteServiceCallback callback) { setRemoteServices(callback, Collections.EMPTY_LIST, Collections.EMPTY_LIST); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("[ConnectionServiceWrapper componentName="); sb.append(mComponentName); sb.append("]"); return sb.toString(); } }
src/com/android/server/telecom/PhoneAccountRegistrar.java +17 −4 Original line number Diff line number Diff line Loading @@ -451,14 +451,15 @@ public class PhoneAccountRegistrar { PhoneAccountHandle retval = dialerSimCallManager != null ? dialerSimCallManager : systemSimCallManager; Log.i(this, "SimCallManager queried, returning: %s", retval); Log.i(this, "getSimCallManager: SimCallManager for subId %d queried, returning: %s", subId, retval); return retval; } /** * If it is a outgoing call, sim call manager of call-initiating user is returned. * If it is a outgoing call, sim call manager associated with the target phone account of the * call is returned (if one exists). * Otherwise, we return the sim call manager of the user associated with the * target phone account. * @return phone account handle of sim call manager based on the ongoing call. Loading @@ -471,7 +472,19 @@ public class PhoneAccountRegistrar { if (userHandle == null) { userHandle = call.getTargetPhoneAccount().getUserHandle(); } return getSimCallManager(userHandle); int subId = getSubscriptionIdForPhoneAccount(call.getTargetPhoneAccount()); if (SubscriptionManager.isValidSubscriptionId(subId) && subId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { PhoneAccountHandle callManagerHandle = getSimCallManager(subId, userHandle); Log.d(this, "getSimCallManagerFromCall: callId=%s, targetPhac=%s, subId=%d, scm=%s", call.getId(), call.getTargetPhoneAccount(), subId, callManagerHandle); return callManagerHandle; } else { PhoneAccountHandle callManagerHandle = getSimCallManager(userHandle); Log.d(this, "getSimCallManagerFromCall: callId=%s, targetPhac=%s, subId(d)=%d, scm=%s", call.getId(), call.getTargetPhoneAccount(), subId, callManagerHandle); return callManagerHandle; } } /** Loading
tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java +1 −1 Original line number Diff line number Diff line Loading @@ -574,7 +574,7 @@ public class ConnectionServiceFixture implements TestFixture<IConnectionService> public IBinder asBinder() { return this; } }, null /*Session.Info*/); }, "" /* callingPackage */, null /*Session.Info*/); } } Loading