Stop honoring CarrierConfigManager.KEY_HIDE_ENABLE_2G
KEY_HIDE_ENABLE_2G is soft removed in Android API level 35 because it hides a security feature. This patch introduces simplified logic that ignores the carrier config value. The new behavior is behind a feature flag. This patch also includes some cleanup. 1. It removes an unneeded check for null carrier config 2. It removes test logic that set the value of KEY_HIDE_ENABLE_2G in places where it had no impact on the test. Bug: 300248708 Test: atest Enable2gPreferenceControllerTest Change-Id: I892d115d1ae173d2f3cd69e8f8b97bc5bfa7c67b
This commit is contained in:
@@ -29,6 +29,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
@@ -111,19 +112,25 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
||||
return;
|
||||
}
|
||||
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(mSubId);
|
||||
boolean isDisabledByCarrier =
|
||||
carrierConfig != null
|
||||
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENABLE_2G);
|
||||
preference.setEnabled(!isDisabledByCarrier);
|
||||
String summary;
|
||||
if (isDisabledByCarrier) {
|
||||
summary = mContext.getString(R.string.enable_2g_summary_disabled_carrier,
|
||||
getSimCardName());
|
||||
// TODO: b/303411083 remove all dynamic logic and rely on summary in resource file once flag
|
||||
// is no longer needed
|
||||
if (Flags.removeKeyHideEnable2g()) {
|
||||
preference.setSummary(mContext.getString(R.string.enable_2g_summary));
|
||||
} else {
|
||||
summary = mContext.getString(R.string.enable_2g_summary);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(mSubId);
|
||||
boolean isDisabledByCarrier =
|
||||
carrierConfig != null
|
||||
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENABLE_2G);
|
||||
preference.setEnabled(!isDisabledByCarrier);
|
||||
String summary;
|
||||
if (isDisabledByCarrier) {
|
||||
summary = mContext.getString(R.string.enable_2g_summary_disabled_carrier,
|
||||
getSimCardName());
|
||||
} else {
|
||||
summary = mContext.getString(R.string.enable_2g_summary);
|
||||
}
|
||||
preference.setSummary(summary);
|
||||
}
|
||||
preference.setSummary(summary);
|
||||
}
|
||||
|
||||
private String getSimCardName() {
|
||||
@@ -154,14 +161,12 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
||||
*/
|
||||
@Override
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
||||
if (mTelephonyManager == null) {
|
||||
Log.w(LOG_TAG, "Telephony manager not yet initialized");
|
||||
mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
|
||||
}
|
||||
boolean visible =
|
||||
SubscriptionManager.isUsableSubscriptionId(subId)
|
||||
&& carrierConfig != null
|
||||
&& mTelephonyManager.isRadioInterfaceCapabilitySupported(
|
||||
mTelephonyManager.CAPABILITY_USES_ALLOWED_NETWORK_TYPES_BITMASK);
|
||||
return visible ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
|
Reference in New Issue
Block a user