Data only device(without FEATURE_TELEPHON_CALLING) : Add try/catch to handle UnsupportedOperationException
If the device does not have Telephony feature calling, the some of interfaces in TelephonyManager throw UnsupportedOperationException. Bug: 297989574 Test: oriole with ATT SIM, boot completed APM/data/wifi on/off, browse setting menu Change-Id: Ifa9092cd8d9a00039e9d93d5fd9fc4dabed633c8
This commit is contained in:
@@ -31,6 +31,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
|
||||
import com.android.internal.telephony.flags.Flags;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.MobileDataEnabledListener;
|
||||
import com.android.settings.network.ims.VolteQueryImsState;
|
||||
@@ -195,7 +196,16 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
|
||||
}
|
||||
// assign current call state so that it helps to show correct preference state even
|
||||
// before first onCallStateChanged() by initial registration.
|
||||
mCallState = mTelephonyManager.getCallState(subId);
|
||||
if (Flags.enforceTelephonyFeatureMappingForPublicApis()) {
|
||||
try {
|
||||
mCallState = mTelephonyManager.getCallState(subId);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// Device doesn't support FEATURE_TELEPHONY_CALLING
|
||||
mCallState = TelephonyManager.CALL_STATE_IDLE;
|
||||
}
|
||||
} else {
|
||||
mCallState = mTelephonyManager.getCallState(subId);
|
||||
}
|
||||
mTelephonyManager.registerTelephonyCallback(context.getMainExecutor(), this);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user