Use feature flag to show/hide AllInOneTetherSettings
This partially reverts commit 0ccc849de7b0ce4c208434a60fb231f749044191
which added a config value. Instead, we will use feature flag to switch
between the fragments.
This CL also adds a postfix to keys in all_tether_prefs to
de-duplicate with keys in tether_prefs and wifi_tether_settings.
Bug: 148182953
Change-Id: I92832c786473990065a965409072e4117a7e75a8
Fix: 148618984
Test: make RunSettingsRoboTests
Test: make RunSettingsRoboTests ROBOTEST_FILTER=CodeInspectionTest
diff --git a/src/com/android/settings/AllInOneTetherSettings.java b/src/com/android/settings/AllInOneTetherSettings.java
index 1c7ea1d..098e6fb 100644
--- a/src/com/android/settings/AllInOneTetherSettings.java
+++ b/src/com/android/settings/AllInOneTetherSettings.java
@@ -36,12 +36,14 @@
import android.os.Bundle;
import android.os.UserManager;
import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.datausage.DataSaverBackend;
import com.android.settings.network.TetherEnabler;
@@ -72,19 +74,24 @@
WifiTetherBasePreferenceController.OnTetherConfigUpdateListener,
SharedPreferences.OnSharedPreferenceChangeListener {
- @VisibleForTesting
- static final String KEY_TETHER_PREFS_SCREEN = "tether_prefs_screen";
- @VisibleForTesting
- static final String KEY_WIFI_TETHER_NETWORK_NAME = "wifi_tether_network_name";
- @VisibleForTesting
- static final String KEY_WIFI_TETHER_NETWORK_PASSWORD = "wifi_tether_network_password";
- @VisibleForTesting
- static final String KEY_WIFI_TETHER_AUTO_OFF = "wifi_tether_auto_turn_off";
- @VisibleForTesting
- static final String KEY_WIFI_TETHER_NETWORK_AP_BAND = "wifi_tether_network_ap_band";
+ // TODO(b/148622133): Should clean up the postfix once this fragment replaced TetherSettings.
+ public static final String DEDUP_POSTFIX = "_2";
+ @VisibleForTesting
+ static final String KEY_WIFI_TETHER_NETWORK_NAME = "wifi_tether_network_name" + DEDUP_POSTFIX;
+ @VisibleForTesting
+ static final String KEY_WIFI_TETHER_NETWORK_PASSWORD =
+ "wifi_tether_network_password" + DEDUP_POSTFIX;
+ @VisibleForTesting
+ static final String KEY_WIFI_TETHER_AUTO_OFF = "wifi_tether_auto_turn_off" + DEDUP_POSTFIX;
+ @VisibleForTesting
+ static final String KEY_WIFI_TETHER_NETWORK_AP_BAND =
+ "wifi_tether_network_ap_band" + DEDUP_POSTFIX;
+ @VisibleForTesting
+ static final String KEY_WIFI_TETHER_SECURITY = "wifi_tether_security" + DEDUP_POSTFIX;
+
+ private static final String KEY_DATA_SAVER_FOOTER = "disabled_on_data_saver" + DEDUP_POSTFIX;
private static final String KEY_WIFI_TETHER_GROUP = "wifi_tether_settings_group";
- private static final String KEY_DATA_SAVER_FOOTER = "disabled_on_data_saver";
private static final int EXPANDED_CHILD_COUNT_WITH_SECURITY_NON = 2;
private static final int EXPANDED_CHILD_COUNT_DEFAULT = 3;
private static final String TAG = "AllInOneTetherSettings";
@@ -394,20 +401,18 @@
final List<String> keys = super.getNonIndexableKeys(context);
if (!TetherUtil.isTetherAvailable(context)) {
- keys.add(KEY_TETHER_PREFS_SCREEN);
keys.add(KEY_WIFI_TETHER_NETWORK_NAME);
keys.add(KEY_WIFI_TETHER_NETWORK_PASSWORD);
keys.add(KEY_WIFI_TETHER_AUTO_OFF);
keys.add(KEY_WIFI_TETHER_NETWORK_AP_BAND);
+ keys.add(KEY_WIFI_TETHER_SECURITY);
}
-
return keys;
}
@Override
protected boolean isPageSearchEnabled(Context context) {
- return context.getResources().getBoolean(
- R.bool.config_show_all_in_one_tether_settings);
+ return FeatureFlagUtils.isEnabled(context, FeatureFlags.TETHER_ALL_IN_ONE);
}
@Override
diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java
index da86cbf..a29ec95 100644
--- a/src/com/android/settings/TetherSettings.java
+++ b/src/com/android/settings/TetherSettings.java
@@ -36,11 +36,13 @@
import android.os.Handler;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
+import android.util.FeatureFlagUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.datausage.DataSaverBackend;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.wifi.tether.WifiTetherPreferenceController;
@@ -452,8 +454,7 @@
@Override
protected boolean isPageSearchEnabled(Context context) {
- return !context.getResources().getBoolean(
- R.bool.config_show_all_in_one_tether_settings);
+ return !FeatureFlagUtils.isEnabled(context, FeatureFlags.TETHER_ALL_IN_ONE);
}
@Override
diff --git a/src/com/android/settings/network/TetherPreferenceController.java b/src/com/android/settings/network/TetherPreferenceController.java
index 5e52692..8fc05aa 100644
--- a/src/com/android/settings/network/TetherPreferenceController.java
+++ b/src/com/android/settings/network/TetherPreferenceController.java
@@ -33,13 +33,16 @@
import android.os.Handler;
import android.os.UserHandle;
import android.provider.Settings;
+import android.util.FeatureFlagUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
+import com.android.settings.AllInOneTetherSettings;
import com.android.settings.R;
import com.android.settings.TetherSettings;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.TetherUtil;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -110,8 +113,8 @@
// Grey out if provisioning is not available.
mPreference.setEnabled(!TetherSettings.isProvisioningNeededButUnavailable(mContext));
- if (mContext.getResources().getBoolean(R.bool.config_show_all_in_one_tether_settings)) {
- mPreference.setFragment("com.android.settings.AllInOneTetherSettings");
+ if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE)) {
+ mPreference.setFragment(AllInOneTetherSettings.class.getName());
}
}
}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
index b9b0d64..add40b0 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
@@ -16,9 +16,12 @@
package com.android.settings.wifi.tether;
+import static com.android.settings.AllInOneTetherSettings.DEDUP_POSTFIX;
+
import android.content.Context;
import android.content.res.Resources;
import android.net.wifi.SoftApConfiguration;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -26,6 +29,7 @@
import androidx.preference.Preference;
import com.android.settings.R;
+import com.android.settings.core.FeatureFlags;
public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferenceController {
@@ -87,7 +91,8 @@
@Override
public String getPreferenceKey() {
- return PREF_KEY;
+ return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE)
+ ? PREF_KEY + DEDUP_POSTFIX : PREF_KEY;
}
@Override
diff --git a/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
index 1563e61..03ea121 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
@@ -16,14 +16,18 @@
package com.android.settings.wifi.tether;
+import static com.android.settings.AllInOneTetherSettings.DEDUP_POSTFIX;
+
import android.content.Context;
import android.net.wifi.SoftApConfiguration;
import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
import androidx.preference.EditTextPreference;
import androidx.preference.Preference;
import com.android.settings.R;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.widget.ValidatedEditTextPreference;
import com.android.settings.wifi.WifiUtils;
@@ -43,7 +47,8 @@
@Override
public String getPreferenceKey() {
- return PREF_KEY;
+ return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE)
+ ? PREF_KEY + DEDUP_POSTFIX : PREF_KEY;
}
@Override
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
index 0283b0f..a4289a6 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
@@ -16,16 +16,20 @@
package com.android.settings.wifi.tether;
+import static com.android.settings.AllInOneTetherSettings.DEDUP_POSTFIX;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.SoftApConfiguration;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.EditTextPreference;
import androidx.preference.Preference;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.ValidatedEditTextPreference;
import com.android.settings.wifi.dpp.WifiDppUtils;
@@ -54,7 +58,8 @@
@Override
public String getPreferenceKey() {
- return PREF_KEY;
+ return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE)
+ ? PREF_KEY + DEDUP_POSTFIX : PREF_KEY;
}
@Override
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceController.java
index 9b9617a..56b5031 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceController.java
@@ -1,12 +1,16 @@
package com.android.settings.wifi.tether;
+import static com.android.settings.AllInOneTetherSettings.DEDUP_POSTFIX;
+
import android.content.Context;
import android.net.wifi.SoftApConfiguration;
+import android.util.FeatureFlagUtils;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
+import com.android.settings.core.FeatureFlags;
public class WifiTetherSecurityPreferenceController extends WifiTetherBasePreferenceController {
@@ -23,7 +27,8 @@
@Override
public String getPreferenceKey() {
- return PREF_KEY;
+ return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE)
+ ? PREF_KEY + DEDUP_POSTFIX : PREF_KEY;
}
@Override
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSettings.java b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
index 4665515..66d017a 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSettings.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
@@ -28,6 +28,7 @@
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.UserManager;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -35,6 +36,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
@@ -259,8 +261,7 @@
@Override
protected boolean isPageSearchEnabled(Context context) {
- return !context.getResources().getBoolean(
- R.bool.config_show_all_in_one_tether_settings);
+ return !FeatureFlagUtils.isEnabled(context, FeatureFlags.TETHER_ALL_IN_ONE);
}
@Override