From 1de59a9c597b0d83f783d9a029f177b123335a9a Mon Sep 17 00:00:00 2001 From: Yomna Nasser Date: Mon, 18 Jan 2021 22:00:55 +0000 Subject: Implementation of "Enable 2G" for Settings. (1) Adds KEY_HIDE_ENABLE_2G_BOOL to CarrierConfigManager, and (2) Adds new reason ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G. Test: manual & atest -c Enable2gPreferenceControllerTest Bug: b/163168917 Change-Id: I81052549f8dde491697c35365320145fd24c3842 Merged-In: I81052549f8dde491697c35365320145fd24c3842 --- telephony/java/android/telephony/CarrierConfigManager.java | 9 +++++++++ telephony/java/android/telephony/TelephonyManager.java | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'telephony') diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 217570e1401c..464d37510034 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -4268,6 +4268,14 @@ public class CarrierConfigManager { public static final String KEY_STORE_SIM_PIN_FOR_UNATTENDED_REBOOT_BOOL = "store_sim_pin_for_unattended_reboot_bool"; + /** + * Determine whether "Enable 2G" toggle can be shown. + * + * Used to trade privacy/security against potentially reduced carrier coverage for some + * carriers. + */ + public static final String KEY_HIDE_ENABLE_2G = "hide_enable_2g_bool"; + /** The default value for every variable. */ private final static PersistableBundle sDefaults; @@ -4825,6 +4833,7 @@ public class CarrierConfigManager { sDefaults.putStringArray(KEY_ALLOWED_INITIAL_ATTACH_APN_TYPES_STRING_ARRAY, new String[]{"ia", "default", "ims", "mms", "dun", "emergency"}); sDefaults.putBoolean(KEY_STORE_SIM_PIN_FOR_UNATTENDED_REBOOT_BOOL, true); + sDefaults.putBoolean(KEY_HIDE_ENABLE_2G, false); } /** diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index e77ee365b4d3..e54877d70816 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -8224,7 +8224,8 @@ public class TelephonyManager { @IntDef({ ALLOWED_NETWORK_TYPES_REASON_USER, ALLOWED_NETWORK_TYPES_REASON_POWER, - ALLOWED_NETWORK_TYPES_REASON_CARRIER + ALLOWED_NETWORK_TYPES_REASON_CARRIER, + ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G }) @Retention(RetentionPolicy.SOURCE) public @interface AllowedNetworkTypesReason { @@ -8260,6 +8261,14 @@ public class TelephonyManager { @SystemApi public static final int ALLOWED_NETWORK_TYPES_REASON_CARRIER = 2; + /** + * To indicate allowed network type change is requested by the user via the 2G toggle. + * + * @hide + */ + @SystemApi + public static final int ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G = 3; + /** * Set the allowed network types of the device and * provide the reason triggering the allowed network change. @@ -8269,6 +8278,8 @@ public class TelephonyManager { *
  • Allowed network types control by power manager * {@link #ALLOWED_NETWORK_TYPES_REASON_POWER} *
  • Allowed network types control by carrier {@link #ALLOWED_NETWORK_TYPES_REASON_CARRIER} + *
  • Allowed network types control by the user-controlled "Allow 2G" toggle + * {@link #ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G} * * This API will result in allowing an intersection of allowed network types for all reasons, * including the configuration done through other reasons. @@ -8358,6 +8369,7 @@ public class TelephonyManager { case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER: case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_POWER: case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER: + case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G: return true; } return false; -- cgit v1.2.3