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:
@@ -22,6 +22,7 @@ import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.telephony.flags.Flags;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
@@ -49,8 +50,18 @@ public class HearingAidCompatibilityPreferenceController extends TogglePreferenc
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mTelephonyManager.isHearingAidCompatibilitySupported() ? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
if (Flags.enforceTelephonyFeatureMappingForPublicApis()) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user