Enable auto select only when set by Carriers
Carriers want to avoid users from setting other
networks than their own when in the home network.
This is in some implementations called
"Permanent automatic mode".
Test: Add an entry for carrier X in vendor xml and see
the Settings entry change when you swap sim cards between
carrier X and Y.
Bug: 70499144
Change-Id: I07199f95852159da49c9c27280c0144bc9d8a0b8
diff --git a/res/values/strings.xml b/res/values/strings.xml
index de14389..e909e62 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -382,6 +382,8 @@
<string name="already_auto">Already in automatic selection.</string>
<!-- Available networks screen, name of switch button for whether to select network automatically -->
<string name="select_automatically">Automatically select network</string>
+ <!-- Available networks screen, summary when button disallowed due to permanent automatic mode -->
+ <string name="manual_mode_disallowed_summary">Unavailable when connected to %1$s</string>
<!-- Available networks screen, name of button when user wants to select network manually -->
<string name="network_select_title">Network</string>
<string name="register_automatically">Automatic registration\u2026</string>
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 5a09744..f65250d 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -385,6 +385,7 @@
private Preference mClickedPreference;
private boolean mShow4GForLTE;
private boolean mIsGlobalCdma;
+ private boolean mOnlyAutoSelectInHomeNW;
private boolean mUnavailable;
private class PhoneCallStateListener extends PhoneStateListener {
@@ -1166,6 +1167,8 @@
R.string.enhanced_4g_lte_mode_title_variant :
R.string.enhanced_4g_lte_mode_title;
+ mOnlyAutoSelectInHomeNW = carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_ONLY_AUTO_SELECT_IN_HOME_NETWORK_BOOL);
mButton4glte.setTitle(enhanced4glteModeTitleId);
mLteDataServicePref.setEnabled(hasActiveSubscriptions);
Preference ps;
@@ -1197,6 +1200,20 @@
if (ps != null) {
ps.setEnabled(hasActiveSubscriptions);
}
+ ps = findPreference(NetworkOperators.BUTTON_AUTO_SELECT_KEY);
+ if (ps != null) {
+ ps.setSummary(null);
+ if (mTelephonyManager.getServiceState().getRoaming()) {
+ ps.setEnabled(true);
+ } else {
+ ps.setEnabled(!mOnlyAutoSelectInHomeNW);
+ if (mOnlyAutoSelectInHomeNW) {
+ ps.setSummary(getResources().getString(
+ R.string.manual_mode_disallowed_summary,
+ mTelephonyManager.getSimOperatorName()));
+ }
+ }
+ }
}
// Requires that mSubId is up to date