diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-03-22 07:21:23 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-03-22 07:21:23 +0000 |
commit | ce6c2a74e8fb11d64e8c65c5087a81d9fa011dc1 (patch) | |
tree | e8c876ffc3f6ecb145e3e0256751aa33d11b80d9 | |
parent | 6f41b848138354a0d5d65d0ef8443e284078cb6a (diff) | |
parent | 0c4576e097e851931e2edc42fc5d096941216f95 (diff) | |
download | ims-ce6c2a74e8fb11d64e8c65c5087a81d9fa011dc1.tar.gz |
Snap for 4670666 from 0c4576e097e851931e2edc42fc5d096941216f95 to pi-release
Change-Id: I99721350fd1cd61b3e9aba5ce431e2a8f99ff84e
-rw-r--r-- | src/java/com/android/ims/ImsManager.java | 2 | ||||
-rw-r--r-- | src/java/com/android/ims/MmTelFeatureConnection.java | 70 |
2 files changed, 54 insertions, 18 deletions
diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java index 2a35fd37..2b348960 100644 --- a/src/java/com/android/ims/ImsManager.java +++ b/src/java/com/android/ims/ImsManager.java @@ -771,7 +771,7 @@ public class ImsManager { if (enabled) { log("setVtSetting(b) : turnOnIms"); turnOnIms(); - } else if (isVolteEnabledByPlatform() + } else if (isTurnOffImsAllowedByPlatform() && (!isVolteEnabledByPlatform() || !isEnhanced4gLteModeSettingEnabledByUser())) { log("setVtSetting(b) : imsServiceAllowTurnOff -> turnOffIms"); diff --git a/src/java/com/android/ims/MmTelFeatureConnection.java b/src/java/com/android/ims/MmTelFeatureConnection.java index 276688c4..de8f9282 100644 --- a/src/java/com/android/ims/MmTelFeatureConnection.java +++ b/src/java/com/android/ims/MmTelFeatureConnection.java @@ -68,7 +68,10 @@ public class MmTelFeatureConnection { // Updated by IImsServiceFeatureCallback when FEATURE_EMERGENCY_MMTEL is sent. private boolean mSupportsEmergencyCalling = false; - private MmTelFeature.Listener mMmTelFeatureListener; + // Cache the Registration and Config interfaces as long as the MmTel feature is connected. If + // it becomes disconnected, invalidate. + private IImsRegistration mRegistrationBinder; + private IImsConfig mConfigBinder; private abstract class CallbackAdapterManager<T> { private static final String TAG = "CallbackAdapterManager"; @@ -333,6 +336,7 @@ public class MmTelFeatureConnection { if (mIsAvailable) { Log.i(TAG, "MmTel disabled on slotId: " + slotId); mIsAvailable = false; + mmTelFeatureRemoved(); if (mStatusCallback != null) { mStatusCallback.notifyUnavailable(); } @@ -368,14 +372,53 @@ public class MmTelFeatureConnection { mContext = context; } + // Called when the MmTelFeatureConnection has received an unavailable notification. + private void mmTelFeatureRemoved() { + synchronized (mLock) { + // invalidate caches. + mRegistrationBinder = null; + mConfigBinder = null; + } + } + private @Nullable IImsRegistration getRegistration() { + synchronized (mLock) { + // null if cache is invalid; + if (mRegistrationBinder != null) { + return mRegistrationBinder; + } + } TelephonyManager tm = getTelephonyManager(mContext); - return tm != null ? tm.getImsRegistration(mSlotId, ImsFeature.FEATURE_MMTEL) : null; + // We don't want to synchronize on a binder call to another process. + IImsRegistration regBinder = tm != null + ? tm.getImsRegistration(mSlotId, ImsFeature.FEATURE_MMTEL) : null; + synchronized (mLock) { + // mRegistrationBinder may have changed while we tried to get the registration + // interface. + if (mRegistrationBinder == null) { + mRegistrationBinder = regBinder; + } + } + return mRegistrationBinder; } private IImsConfig getConfig() { + synchronized (mLock) { + // null if cache is invalid; + if (mConfigBinder != null) { + return mConfigBinder; + } + } TelephonyManager tm = getTelephonyManager(mContext); - return tm != null ? tm.getImsConfig(mSlotId, ImsFeature.FEATURE_MMTEL) : null; + IImsConfig configBinder = tm != null + ? tm.getImsConfig(mSlotId, ImsFeature.FEATURE_MMTEL) : null; + synchronized (mLock) { + // mConfigBinder may have changed while we tried to get the config interface. + if (mConfigBinder == null) { + mConfigBinder = configBinder; + } + } + return mConfigBinder; } public boolean isEmergencyMmTelAvailable() { @@ -400,8 +443,7 @@ public class MmTelFeatureConnection { public void openConnection(MmTelFeature.Listener listener) throws RemoteException { synchronized (mLock) { checkServiceIsReady(); - mMmTelFeatureListener = listener; - getServiceInterface(mBinder).setListener(mMmTelFeatureListener); + getServiceInterface(mBinder).setListener(listener); } } @@ -484,22 +526,16 @@ public class MmTelFeatureConnection { } public IImsConfig getConfigInterface() throws RemoteException { - synchronized (mLock) { - checkServiceIsReady(); - return getConfig(); - } + return getConfig(); } public @ImsRegistrationImplBase.ImsRegistrationTech int getRegistrationTech() - throws RemoteException { - synchronized (mLock) { - checkServiceIsReady(); - IImsRegistration registration = getRegistration(); - if (registration != null) { + throws RemoteException { + IImsRegistration registration = getRegistration(); + if (registration != null) { return registration.getRegistrationTechnology(); - } else { - return ImsRegistrationImplBase.REGISTRATION_TECH_NONE; - } + } else { + return ImsRegistrationImplBase.REGISTRATION_TECH_NONE; } } |