From 445ea4822f1b3fd48b890b34aba89d7d3c42a718 Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Tue, 13 Jun 2017 16:21:35 -0700 Subject: Fix ImsManager double callback registration MMTelFeature has two ways of registering registration callbacks, through startSession and addRegistrationListener. startSession requires a registration listener, which can cause double registration if addRegistrationListener happens before startSession in ImsManager. This fix temporarily solves that problem by registering a Stub implementation of the registration callback in startSession. This will be fixed later by modifying the MMTelFeature APIs to remove the registration listener from the arg list. Bug: 62207372 Test: Telephony unit tests and manual IMS registration Change-Id: I00fdbae1baaf77cca5156a442ea109f998a8d5a5 --- src/java/com/android/ims/ImsManager.java | 76 +++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 7 deletions(-) (limited to 'src/java/com/android/ims/ImsManager.java') diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java index f7753a8a..328f393c 100644 --- a/src/java/com/android/ims/ImsManager.java +++ b/src/java/com/android/ims/ImsManager.java @@ -1504,12 +1504,14 @@ public class ImsManager { int result = 0; try { + // Register a stub implementation of the ImsRegistrationListener. There is the + // possibility that if we use the real implementation of the ImsRegistrationListener, + // it will be added twice. + // TODO: Remove ImsRegistrationListener from startSession API (b/62588776) result = mImsServiceProxy.startSession(incomingCallPendingIntent, - mRegistrationListenerProxy); - synchronized (mHasRegisteredLock) { - mHasRegisteredForProxy = true; - addRegistrationListener(listener); - } + new ImsRegistrationListenerBase()); + addRegistrationListener(listener); + log("open: Session started and registration listener added."); } catch (RemoteException e) { throw new ImsException("open()", e, ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); @@ -1550,16 +1552,17 @@ public class ImsManager { */ public void addRegistrationListener(ImsConnectionStateListener listener) throws ImsException { - checkAndThrowExceptionIfServiceUnavailable(); if (listener == null) { throw new NullPointerException("listener can't be null"); } - // We only want this Proxy registered once. It can either happen here or in open(). + // We only want this Proxy registered once. synchronized (mHasRegisteredLock) { if (!mHasRegisteredForProxy) { try { + checkAndThrowExceptionIfServiceUnavailable(); mImsServiceProxy.addRegistrationListener(mRegistrationListenerProxy); + log("RegistrationListenerProxy registered."); // Only record if there isn't a RemoteException. mHasRegisteredForProxy = true; } catch (RemoteException e) { @@ -1569,6 +1572,7 @@ public class ImsManager { } } synchronized (mRegistrationListeners) { + log("Local registration listener added: " + listener); mRegistrationListeners.add(listener); } } @@ -1588,6 +1592,7 @@ public class ImsManager { } synchronized (mRegistrationListeners) { + log("Local registration listener removed: " + listener); mRegistrationListeners.remove(listener); } } @@ -2216,6 +2221,63 @@ public class ImsManager { } } + /** + * Stub implementation of the Registration listener that provides no functionality. + */ + private class ImsRegistrationListenerBase extends IImsRegistrationListener.Stub { + + @Override + public void registrationConnected() throws RemoteException { + } + + @Override + public void registrationProgressing() throws RemoteException { + } + + @Override + public void registrationConnectedWithRadioTech(int imsRadioTech) throws RemoteException { + } + + @Override + public void registrationProgressingWithRadioTech(int imsRadioTech) throws RemoteException { + } + + @Override + public void registrationDisconnected(ImsReasonInfo imsReasonInfo) throws RemoteException { + } + + @Override + public void registrationResumed() throws RemoteException { + } + + @Override + public void registrationSuspended() throws RemoteException { + } + + @Override + public void registrationServiceCapabilityChanged(int serviceClass, int event) + throws RemoteException { + } + + @Override + public void registrationFeatureCapabilityChanged(int serviceClass, int[] enabledFeatures, + int[] disabledFeatures) throws RemoteException { + } + + @Override + public void voiceMessageCountUpdate(int count) throws RemoteException { + } + + @Override + public void registrationAssociatedUriChanged(Uri[] uris) throws RemoteException { + } + + @Override + public void registrationChangeFailed(int targetAccessTech, ImsReasonInfo imsReasonInfo) + throws RemoteException { + } + } + /** * Adapter class for {@link IImsRegistrationListener}. */ -- cgit v1.2.3