diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 2fcd949cc07..d25d7e9dd24 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -16,8 +16,12 @@ package com.android.settings; +import android.content.Context; +import android.content.Intent; import android.os.Bundle; +import android.util.FeatureFlagUtils; +import com.android.settings.core.FeatureFlags; import com.android.settings.enterprise.EnterprisePrivacySettings; /** @@ -33,8 +37,43 @@ public class Settings extends SettingsActivity { public static class CreateShortcutActivity extends SettingsActivity { /* empty */ } public static class FaceSettingsActivity extends SettingsActivity { /* empty */ } public static class FingerprintSettingsActivity extends SettingsActivity { /* empty */ } - public static class TetherSettingsActivity extends SettingsActivity { /* empty */ } - public static class WifiTetherSettingsActivity extends SettingsActivity { /* empty */ } + public static class TetherSettingsActivity extends SettingsActivity { + // TODO(b/147675042): Clean the override up when we enable the new Fragment persistently. + @Override + public Intent getIntent() { + return wrapIntentWithAllInOneTetherSettingsIfNeeded( + getApplicationContext(), super.getIntent()); + } + } + public static class WifiTetherSettingsActivity extends SettingsActivity { + // TODO(b/147675042): Clean the override up when we enable the new Fragment persistently. + @Override + public Intent getIntent() { + return wrapIntentWithAllInOneTetherSettingsIfNeeded( + getApplicationContext(), super.getIntent()); + } + } + + private static Intent wrapIntentWithAllInOneTetherSettingsIfNeeded( + Context context, Intent superIntent) { + if (!FeatureFlagUtils.isEnabled(context, FeatureFlags.TETHER_ALL_IN_ONE)) { + return superIntent; + } + + final Intent modIntent = new Intent(superIntent); + modIntent.putExtra(EXTRA_SHOW_FRAGMENT, + AllInOneTetherSettings.class.getCanonicalName()); + Bundle args = superIntent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); + if (args != null) { + args = new Bundle(args); + } else { + args = new Bundle(); + } + args.putParcelable("intent", superIntent); + modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args); + return modIntent; + } + public static class VpnSettingsActivity extends SettingsActivity { /* empty */ } public static class DataSaverSummaryActivity extends SettingsActivity{ /* empty */ } public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ } diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java index ae817e7bca5..8c49e580c06 100644 --- a/src/com/android/settings/core/gateway/SettingsGateway.java +++ b/src/com/android/settings/core/gateway/SettingsGateway.java @@ -16,6 +16,7 @@ package com.android.settings.core.gateway; +import com.android.settings.AllInOneTetherSettings; import com.android.settings.DisplaySettings; import com.android.settings.IccLockSettings; import com.android.settings.MasterClear; @@ -169,6 +170,7 @@ public class SettingsGateway { ConfigureWifiSettings.class.getName(), SavedAccessPointsWifiSettings.class.getName(), SavedAccessPointsWifiSettings2.class.getName(), + AllInOneTetherSettings.class.getName(), TetherSettings.class.getName(), WifiP2pSettings.class.getName(), WifiTetherSettings.class.getName(),