From 460cb45f32b7657129737c0fd133210dbf4364df Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Tue, 15 Feb 2022 12:49:06 -0800 Subject: Throw IllegalStateException when IMS is not ready for callback registration Simulate existing behavior for when IMS is not ready by throwing an IllegalStateException until IMS callbacks can be registered. This will ensure there is no way that a callback can be registered and then removed invisibly once the IMS stack catches up to the state of telephony. Bug: 219529364 Test: atest FrameworksTelephonyTests; manual Change-Id: Ic0e1ea2c9ab81dd9c7bb99825be317f8703a5f67 --- src/java/com/android/ims/ImsCallbackAdapterManager.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/java') diff --git a/src/java/com/android/ims/ImsCallbackAdapterManager.java b/src/java/com/android/ims/ImsCallbackAdapterManager.java index 08ca1c3e..931ce579 100644 --- a/src/java/com/android/ims/ImsCallbackAdapterManager.java +++ b/src/java/com/android/ims/ImsCallbackAdapterManager.java @@ -18,14 +18,10 @@ package com.android.ims; import android.content.Context; import android.os.IInterface; -import android.os.Looper; import android.os.RemoteCallbackList; import android.telephony.SubscriptionManager; import android.util.Log; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; public abstract class ImsCallbackAdapterManager { private static final String TAG = "ImsCallbackAM"; @@ -67,10 +63,15 @@ public abstract class ImsCallbackAdapterManager { } if (mSubId != subId) { // In some cases, telephony has changed sub id and IMS is still catching up to the - // state change. Since some devices do not check for IMS READY state before adding - // callbacks, still allow this condition. + // state change. Ensure that the device does not try to register a callback on an + // inactive subscription, because this can cause a condition where we remove the + // callback invisibly when the new subscription loads. Instead, simulate the existing + // IllegalStateException that happens when the ImsService is not ready/active for + // backwards compatibility. Log.w(TAG + " [" + mSlotId + ", " + mSubId + "]", "add callback: inactive" + " subID detected: " + subId); + throw new IllegalStateException("ImsService is not available for the subscription " + + "specified."); } synchronized (mLock) { addCallback(localCallback); -- cgit v1.2.3