aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Ebinger <breadley@google.com>2017-06-13 16:21:35 -0700
committerBrad Ebinger <breadley@google.com>2017-06-16 15:47:37 -0700
commit445ea4822f1b3fd48b890b34aba89d7d3c42a718 (patch)
tree693daa0499f7d70d4393c57858065eb19b0f560b
parent644709469a340a2054ac8b9ab19484057d2bca2f (diff)
downloadims-445ea4822f1b3fd48b890b34aba89d7d3c42a718.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 Change-Id: I00fdbae1baaf77cca5156a442ea109f998a8d5a5
-rw-r--r--src/java/com/android/ims/ImsManager.java76
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 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);
}
}
@@ -2217,6 +2222,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 {