diff options
author | Brad Ebinger <breadley@google.com> | 2019-03-04 12:20:27 -0800 |
---|---|---|
committer | Brad Ebinger <breadley@google.com> | 2019-03-05 09:44:46 -0800 |
commit | fcd9bdc84c04a135f95ec1ce180d94655be4bfff (patch) | |
tree | 3a42c37872aeac33b48a3a96a33f42c61ed60a96 | |
parent | d2c788c1d8e7838c016bcde85a66191e14b61e02 (diff) | |
download | ims-fcd9bdc84c04a135f95ec1ce180d94655be4bfff.tar.gz |
Fix ImsManager NPE encountered during GTS testing
ImsManager was throwing a NPE because multiple requests to get
ImsService look to be getting scheduled in a race condition where
we are internally scheduling a retry and the binder thread is
scheduling a retry.
Fix synchronization in retry block and check for null ImsManager
just in case.
Test: atest GtsTelephonyTestCases
Change-Id: I5e4b5bf656642c1d26a88fe77726c44f2cfe8607
-rw-r--r-- | src/java/com/android/ims/ImsManager.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java index 0b540e82..5996c9a6 100644 --- a/src/java/com/android/ims/ImsManager.java +++ b/src/java/com/android/ims/ImsManager.java @@ -332,15 +332,18 @@ public class ImsManager { private void retryGetImsService() { synchronized (mLock) { - // remove callback so we do not receive updates from old ImsServiceProxy when - // switching between ImsServices. - mImsManager.removeNotifyStatusChangedCallback(mNotifyStatusChangedCallback); - //Leave mImsManager as null, then CallStateException will be thrown when dialing - mImsManager = null; + if (mImsManager != null) { + // remove callback so we do not receive updates from old ImsServiceProxy when + // switching between ImsServices. + mImsManager.removeNotifyStatusChangedCallback(mNotifyStatusChangedCallback); + //Leave mImsManager as null, then CallStateException will be thrown when dialing + mImsManager = null; + } + + // Exponential backoff during retry, limited to 32 seconds. + removeCallbacks(mGetServiceRunnable); + postDelayed(mGetServiceRunnable, mRetryTimeout.get()); } - // Exponential backoff during retry, limited to 32 seconds. - removeCallbacks(mGetServiceRunnable); - postDelayed(mGetServiceRunnable, mRetryTimeout.get()); } private void getImsService() throws ImsException { |