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:
@@ -29,6 +29,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
|
import com.android.internal.telephony.flags.Flags;
|
||||||
import com.android.settings.network.GlobalSettingsChangeListener;
|
import com.android.settings.network.GlobalSettingsChangeListener;
|
||||||
import com.android.settings.network.ProxySubscriptionManager;
|
import com.android.settings.network.ProxySubscriptionManager;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
@@ -146,8 +147,19 @@ public class AirplaneModeEnabler extends GlobalSettingsChangeListener {
|
|||||||
* @return any subscription within device is under ECM mode
|
* @return any subscription within device is under ECM mode
|
||||||
*/
|
*/
|
||||||
public boolean isInEcmMode() {
|
public boolean isInEcmMode() {
|
||||||
if (mTelephonyManager.getEmergencyCallbackMode()) {
|
if (Flags.enforceTelephonyFeatureMappingForPublicApis()) {
|
||||||
return true;
|
try {
|
||||||
|
if (mTelephonyManager.getEmergencyCallbackMode()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
// Device doesn't support FEATURE_TELEPHONY_CALLING
|
||||||
|
// Ignore exception, device is not in ECM mode.
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mTelephonyManager.getEmergencyCallbackMode()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final List<SubscriptionInfo> subInfoList =
|
final List<SubscriptionInfo> subInfoList =
|
||||||
ProxySubscriptionManager.getInstance(mContext).getActiveSubscriptionsInfo();
|
ProxySubscriptionManager.getInstance(mContext).getActiveSubscriptionsInfo();
|
||||||
@@ -158,8 +170,18 @@ public class AirplaneModeEnabler extends GlobalSettingsChangeListener {
|
|||||||
final TelephonyManager telephonyManager =
|
final TelephonyManager telephonyManager =
|
||||||
mTelephonyManager.createForSubscriptionId(subInfo.getSubscriptionId());
|
mTelephonyManager.createForSubscriptionId(subInfo.getSubscriptionId());
|
||||||
if (telephonyManager != null) {
|
if (telephonyManager != null) {
|
||||||
if (telephonyManager.getEmergencyCallbackMode()) {
|
if (!Flags.enforceTelephonyFeatureMappingForPublicApis()) {
|
||||||
return true;
|
if (telephonyManager.getEmergencyCallbackMode()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
if (telephonyManager.getEmergencyCallbackMode()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
// Ignore exception, device is not in ECM mode.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import android.provider.Settings;
|
|||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
import com.android.internal.telephony.flags.Flags;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.TogglePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
|
|
||||||
@@ -49,8 +50,18 @@ public class HearingAidCompatibilityPreferenceController extends TogglePreferenc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return mTelephonyManager.isHearingAidCompatibilitySupported() ? AVAILABLE
|
if (Flags.enforceTelephonyFeatureMappingForPublicApis()) {
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
try {
|
||||||
|
return mTelephonyManager.isHearingAidCompatibilitySupported() ? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
// Device doesn't support FEATURE_TELEPHONY_CALLING
|
||||||
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return mTelephonyManager.isHearingAidCompatibilitySupported() ? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -38,8 +38,8 @@ import androidx.preference.ListPreferenceDialogFragmentCompat;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.internal.telephony.flags.Flags;
|
import com.android.internal.telephony.flags.Flags;
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.network.AllowedNetworkTypesListener;
|
import com.android.settings.network.AllowedNetworkTypesListener;
|
||||||
import com.android.settings.network.CarrierConfigCache;
|
import com.android.settings.network.CarrierConfigCache;
|
||||||
import com.android.settings.network.SubscriptionsChangeListener;
|
import com.android.settings.network.SubscriptionsChangeListener;
|
||||||
@@ -924,7 +924,16 @@ public class EnabledNetworkModePreferenceController extends
|
|||||||
|
|
||||||
// assign current call state so that it helps to show correct preference state even
|
// assign current call state so that it helps to show correct preference state even
|
||||||
// before first onCallStateChanged() by initial registration.
|
// 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(
|
mTelephonyManager.registerTelephonyCallback(
|
||||||
mContext.getMainExecutor(), mTelephonyCallback);
|
mContext.getMainExecutor(), mTelephonyCallback);
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.preference.TwoStatePreference;
|
import androidx.preference.TwoStatePreference;
|
||||||
|
|
||||||
|
import com.android.internal.telephony.flags.Flags;
|
||||||
import com.android.internal.telephony.util.ArrayUtils;
|
import com.android.internal.telephony.util.ArrayUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.network.ims.VolteQueryImsState;
|
import com.android.settings.network.ims.VolteQueryImsState;
|
||||||
@@ -234,7 +235,16 @@ public class Enhanced4gBasePreferenceController extends TelephonyTogglePreferenc
|
|||||||
}
|
}
|
||||||
// assign current call state so that it helps to show correct preference state even
|
// assign current call state so that it helps to show correct preference state even
|
||||||
// before first onCallStateChanged() by initial registration.
|
// 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(
|
mTelephonyManager.registerTelephonyCallback(
|
||||||
mContext.getMainExecutor(), mTelephonyCallback);
|
mContext.getMainExecutor(), mTelephonyCallback);
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.preference.TwoStatePreference;
|
import androidx.preference.TwoStatePreference;
|
||||||
|
|
||||||
|
import com.android.internal.telephony.flags.Flags;
|
||||||
import com.android.internal.telephony.util.ArrayUtils;
|
import com.android.internal.telephony.util.ArrayUtils;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||||
@@ -211,7 +212,16 @@ public class NrAdvancedCallingPreferenceController extends TelephonyTogglePrefer
|
|||||||
|
|
||||||
// assign current call state so that it helps to show correct preference state even
|
// assign current call state so that it helps to show correct preference state even
|
||||||
// before first onCallStateChanged() by initial registration.
|
// before first onCallStateChanged() by initial registration.
|
||||||
mCallState = mLocalTelephonyManager.getCallState();
|
if (Flags.enforceTelephonyFeatureMappingForPublicApis()) {
|
||||||
|
try {
|
||||||
|
mCallState = mLocalTelephonyManager.getCallState();
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
// Device doesn't support FEATURE_TELEPHONY_CALLING
|
||||||
|
mCallState = TelephonyManager.CALL_STATE_IDLE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mCallState = mLocalTelephonyManager.getCallState();
|
||||||
|
}
|
||||||
mLocalTelephonyManager.registerTelephonyCallback(
|
mLocalTelephonyManager.registerTelephonyCallback(
|
||||||
mContext.getMainExecutor(), mTelephonyCallback);
|
mContext.getMainExecutor(), mTelephonyCallback);
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.preference.TwoStatePreference;
|
import androidx.preference.TwoStatePreference;
|
||||||
|
|
||||||
|
import com.android.internal.telephony.flags.Flags;
|
||||||
import com.android.settings.network.CarrierConfigCache;
|
import com.android.settings.network.CarrierConfigCache;
|
||||||
import com.android.settings.network.MobileDataEnabledListener;
|
import com.android.settings.network.MobileDataEnabledListener;
|
||||||
import com.android.settings.network.ims.VolteQueryImsState;
|
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
|
// assign current call state so that it helps to show correct preference state even
|
||||||
// before first onCallStateChanged() by initial registration.
|
// 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);
|
mTelephonyManager.registerTelephonyCallback(context.getMainExecutor(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user