From 138b4a620d68d0051183bbfa1b78c4bee4b893bd Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Tue, 20 Jun 2017 16:29:50 -0700 Subject: Check Various IMS interfaces before returning cached value If the ImsService goes down, the stale binder interfaces to the old service still get returned by ImsManager. This change triggers the ImsManager to fetch the binder interfaces again if the cached one is dead. Bug: 62723694 Test: Manual, test procedure outlined in bug Merged-In: I90e3df344785a5bc3818bc9bb24a2735f068058a Change-Id: I64c1c668602d88663220a50c2e45ae4f970ac302 --- src/java/com/android/ims/ImsEcbm.java | 4 + src/java/com/android/ims/ImsManager.java | 106 +++++++++++++------------ src/java/com/android/ims/ImsMultiEndpoint.java | 4 + src/java/com/android/ims/ImsUt.java | 7 ++ 4 files changed, 69 insertions(+), 52 deletions(-) diff --git a/src/java/com/android/ims/ImsEcbm.java b/src/java/com/android/ims/ImsEcbm.java index 9fa9598d..53549bf0 100644 --- a/src/java/com/android/ims/ImsEcbm.java +++ b/src/java/com/android/ims/ImsEcbm.java @@ -78,6 +78,10 @@ public class ImsEcbm { } } + public boolean isBinderAlive() { + return miEcbm.asBinder().isBinderAlive(); + } + /** * Adapter class for {@link IImsEcbmListener}. */ diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java index 52d356e2..7c258291 100644 --- a/src/java/com/android/ims/ImsManager.java +++ b/src/java/com/android/ims/ImsManager.java @@ -1615,24 +1615,24 @@ public class ImsManager { public ImsUtInterface getSupplementaryServiceConfiguration() throws ImsException { // FIXME: manage the multiple Ut interfaces based on the session id - if (mUt == null || !mImsServiceProxy.isBinderAlive()) { - checkAndThrowExceptionIfServiceUnavailable(); - - try { - IImsUt iUt = mImsServiceProxy.getUtInterface(); + if (mUt != null && mUt.isBinderAlive()) { + return mUt; + } - if (iUt == null) { - throw new ImsException("getSupplementaryServiceConfiguration()", - ImsReasonInfo.CODE_UT_NOT_SUPPORTED); - } + checkAndThrowExceptionIfServiceUnavailable(); + try { + IImsUt iUt = mImsServiceProxy.getUtInterface(); - mUt = new ImsUt(iUt); - } catch (RemoteException e) { - throw new ImsException("getSupplementaryServiceConfiguration()", e, - ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); + if (iUt == null) { + throw new ImsException("getSupplementaryServiceConfiguration()", + ImsReasonInfo.CODE_UT_NOT_SUPPORTED); } - } + mUt = new ImsUt(iUt); + } catch (RemoteException e) { + throw new ImsException("getSupplementaryServiceConfiguration()", e, + ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); + } return mUt; } @@ -1810,23 +1810,22 @@ public class ImsManager { * @throws ImsException if getting the setting interface results in an error. */ public ImsConfig getConfigInterface() throws ImsException { + if (mConfig != null && mConfig.isBinderAlive()) { + return mConfig; + } - if (mConfig == null || !mImsServiceProxy.isBinderAlive()) { - checkAndThrowExceptionIfServiceUnavailable(); - - try { - IImsConfig config = mImsServiceProxy.getConfigInterface(); - if (config == null) { - throw new ImsException("getConfigInterface()", - ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); - } - mConfig = new ImsConfig(config, mContext); - } catch (RemoteException e) { - throw new ImsException("getConfigInterface()", e, - ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); + checkAndThrowExceptionIfServiceUnavailable(); + try { + IImsConfig config = mImsServiceProxy.getConfigInterface(); + if (config == null) { + throw new ImsException("getConfigInterface()", + ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); } + mConfig = new ImsConfig(config, mContext); + } catch (RemoteException e) { + throw new ImsException("getConfigInterface()", e, + ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); } - if (DBG) log("getConfigInterface(), mConfig= " + mConfig); return mConfig; } @@ -2369,21 +2368,22 @@ public class ImsManager { * @throws ImsException if getting the ECBM interface results in an error */ public ImsEcbm getEcbmInterface(int serviceId) throws ImsException { - if (mEcbm == null || !mImsServiceProxy.isBinderAlive()) { - checkAndThrowExceptionIfServiceUnavailable(); + if (mEcbm != null && mEcbm.isBinderAlive()) { + return mEcbm; + } - try { - IImsEcbm iEcbm = mImsServiceProxy.getEcbmInterface(); + checkAndThrowExceptionIfServiceUnavailable(); + try { + IImsEcbm iEcbm = mImsServiceProxy.getEcbmInterface(); - if (iEcbm == null) { - throw new ImsException("getEcbmInterface()", - ImsReasonInfo.CODE_ECBM_NOT_SUPPORTED); - } - mEcbm = new ImsEcbm(iEcbm); - } catch (RemoteException e) { - throw new ImsException("getEcbmInterface()", e, - ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); + if (iEcbm == null) { + throw new ImsException("getEcbmInterface()", + ImsReasonInfo.CODE_ECBM_NOT_SUPPORTED); } + mEcbm = new ImsEcbm(iEcbm); + } catch (RemoteException e) { + throw new ImsException("getEcbmInterface()", e, + ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); } return mEcbm; } @@ -2396,22 +2396,24 @@ public class ImsManager { * @throws ImsException if getting the multi-endpoint interface results in an error */ public ImsMultiEndpoint getMultiEndpointInterface(int serviceId) throws ImsException { - if (mMultiEndpoint == null || !mImsServiceProxy.isBinderAlive()) { - checkAndThrowExceptionIfServiceUnavailable(); + if (mMultiEndpoint != null && mMultiEndpoint.isBinderAlive()) { + return mMultiEndpoint; + } - try { - IImsMultiEndpoint iImsMultiEndpoint = mImsServiceProxy.getMultiEndpointInterface(); + checkAndThrowExceptionIfServiceUnavailable(); + try { + IImsMultiEndpoint iImsMultiEndpoint = mImsServiceProxy.getMultiEndpointInterface(); - if (iImsMultiEndpoint == null) { - throw new ImsException("getMultiEndpointInterface()", - ImsReasonInfo.CODE_MULTIENDPOINT_NOT_SUPPORTED); - } - mMultiEndpoint = new ImsMultiEndpoint(iImsMultiEndpoint); - } catch (RemoteException e) { - throw new ImsException("getMultiEndpointInterface()", e, - ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); + if (iImsMultiEndpoint == null) { + throw new ImsException("getMultiEndpointInterface()", + ImsReasonInfo.CODE_MULTIENDPOINT_NOT_SUPPORTED); } + mMultiEndpoint = new ImsMultiEndpoint(iImsMultiEndpoint); + } catch (RemoteException e) { + throw new ImsException("getMultiEndpointInterface()", e, + ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); } + return mMultiEndpoint; } diff --git a/src/java/com/android/ims/ImsMultiEndpoint.java b/src/java/com/android/ims/ImsMultiEndpoint.java index 2cc19b1b..96926960 100644 --- a/src/java/com/android/ims/ImsMultiEndpoint.java +++ b/src/java/com/android/ims/ImsMultiEndpoint.java @@ -78,4 +78,8 @@ public class ImsMultiEndpoint { ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); } } + + public boolean isBinderAlive() { + return mImsMultiendpoint.asBinder().isBinderAlive(); + } } diff --git a/src/java/com/android/ims/ImsUt.java b/src/java/com/android/ims/ImsUt.java index 4cc7011b..d8d70b05 100644 --- a/src/java/com/android/ims/ImsUt.java +++ b/src/java/com/android/ims/ImsUt.java @@ -508,6 +508,13 @@ public class ImsUt implements ImsUtInterface { } } + /** + * @return returns true if the binder is alive, false otherwise. + */ + public boolean isBinderAlive() { + return miUt.asBinder().isBinderAlive(); + } + public void transact(Bundle ssInfo, Message result) { if (DBG) { log("transact :: Ut=" + miUt + ", ssInfo=" + ssInfo); -- cgit v1.2.3