diff options
author | Brad Ebinger <breadley@google.com> | 2017-06-13 16:21:35 -0700 |
---|---|---|
committer | Brad Ebinger <breadley@google.com> | 2017-09-20 16:31:52 +0000 |
commit | 57b1189a541cfd69bb7865aa7539d3b4d1414087 (patch) | |
tree | 5a26255e9662ee9942c72c1adf1a22aa0cb9153e | |
parent | 9a0280cf270a254b62dfdabe7475ad1b70aeec4b (diff) | |
download | ims-57b1189a541cfd69bb7865aa7539d3b4d1414087.tar.gz |
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
Merged-In: Ieeff249e05777bdb9135e9ddd6e08a15416d5a1f
Change-Id: I00fdbae1baaf77cca5156a442ea109f998a8d5a5
-rw-r--r-- | src/java/com/android/ims/ImsManager.java | 76 |
1 files changed, 69 insertions, 7 deletions
diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java index 7c1c1822..8e250863 100644 --- a/src/java/com/android/ims/ImsManager.java +++ b/src/java/com/android/ims/ImsManager.java @@ -1592,12 +1592,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); @@ -1638,16 +1640,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) { @@ -1657,6 +1660,7 @@ public class ImsManager { } } synchronized (mRegistrationListeners) { + log("Local registration listener added: " + listener); mRegistrationListeners.add(listener); } } @@ -1676,6 +1680,7 @@ public class ImsManager { } synchronized (mRegistrationListeners) { + log("Local registration listener removed: " + listener); mRegistrationListeners.remove(listener); } } @@ -2313,6 +2318,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}. */ private class ImsRegistrationListenerProxy extends IImsRegistrationListener.Stub { |