From 85b387b5a27ce669458d812927b7aad5f7c64b1f Mon Sep 17 00:00:00 2001 From: virkumar Date: Thu, 6 Oct 2022 15:57:02 +0000 Subject: [PATCH] Syncronize frameowrk and ImsStack operation for ImsFeatureStatusCallback. Avoid race condition when ImsStack updates the feature status and framework adds callback for ImsFeatureStatus Test: atest CtsTelephonyTestCases:ImsCallingTest Bug: 248215521 Merged-In: I42dfb45e15dda0f2bf6a11263edf3a7920a4140b Change-Id: I42dfb45e15dda0f2bf6a11263edf3a7920a4140b --- .../java/android/telephony/ims/ImsService.java | 4 ++-- .../android/telephony/ims/feature/ImsFeature.java | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/telephony/java/android/telephony/ims/ImsService.java b/telephony/java/android/telephony/ims/ImsService.java index be233b82c4261..bccb6ef2b1e55 100644 --- a/telephony/java/android/telephony/ims/ImsService.java +++ b/telephony/java/android/telephony/ims/ImsService.java @@ -425,8 +425,8 @@ public class ImsService extends Service { } } - private IImsRcsFeature createRcsFeatureInternal(int slotId, int subI) { - RcsFeature f = createRcsFeatureForSubscription(slotId, subI); + private IImsRcsFeature createRcsFeatureInternal(int slotId, int subId) { + RcsFeature f = createRcsFeatureForSubscription(slotId, subId); if (f != null) { f.setDefaultExecutor(mExecutor); setupFeature(f, slotId, ImsFeature.FEATURE_RCS); diff --git a/telephony/java/android/telephony/ims/feature/ImsFeature.java b/telephony/java/android/telephony/ims/feature/ImsFeature.java index f5b158fedd37b..a42327b8a1a9e 100644 --- a/telephony/java/android/telephony/ims/feature/ImsFeature.java +++ b/telephony/java/android/telephony/ims/feature/ImsFeature.java @@ -394,10 +394,12 @@ public abstract class ImsFeature { @VisibleForTesting public void addImsFeatureStatusCallback(@NonNull IImsFeatureStatusCallback c) { try { - // If we have just connected, send queued status. - c.notifyImsFeatureStatus(getFeatureState()); - // Add the callback if the callback completes successfully without a RemoteException. - mStatusCallbacks.register(c); + synchronized (mStatusCallbacks) { + // Add the callback if the callback completes successfully without a RemoteException + mStatusCallbacks.register(c); + // If we have just connected, send queued status. + c.notifyImsFeatureStatus(getFeatureState()); + } } catch (RemoteException e) { Log.w(LOG_TAG, "Couldn't notify feature state: " + e.getMessage()); } @@ -409,7 +411,9 @@ public abstract class ImsFeature { */ @VisibleForTesting public void removeImsFeatureStatusCallback(@NonNull IImsFeatureStatusCallback c) { - mStatusCallbacks.unregister(c); + synchronized (mStatusCallbacks) { + mStatusCallbacks.unregister(c); + } } /**