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
This commit is contained in:
virkumar
2022-10-06 15:57:02 +00:00
parent dc7b608720
commit 85b387b5a2
2 changed files with 11 additions and 7 deletions

View File

@@ -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);

View File

@@ -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);
}
}
/**