Fix bug: Add some controllers to AllInOneTetherSettings Lifecycle

These controllers are not added to lifecycle as observers, which caused
the preferences are disabled persistently. Adding them explicitly can
fix the issue.

Bug: 149339076
Test: CodeInspectionTest, AllInOneTetherSettingsTest
Change-Id: Ia53e0845ed38f63a9a370488b028966d6a066889
This commit is contained in:
Zhen Zhang
2020-02-11 16:22:08 -08:00
parent ec966cb7a3
commit aef1e8db96

View File

@@ -46,7 +46,10 @@ import androidx.preference.PreferenceGroup;
import com.android.settings.core.FeatureFlags; import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.RestrictedDashboardFragment; import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.datausage.DataSaverBackend; import com.android.settings.datausage.DataSaverBackend;
import com.android.settings.network.BluetoothTetherPreferenceController;
import com.android.settings.network.TetherEnabler; import com.android.settings.network.TetherEnabler;
import com.android.settings.network.UsbTetherPreferenceController;
import com.android.settings.network.WifiTetherDisablePreferenceController;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar; import com.android.settings.widget.SwitchBar;
import com.android.settings.widget.SwitchBarController; import com.android.settings.widget.SwitchBarController;
@@ -66,7 +69,6 @@ import java.util.concurrent.atomic.AtomicReference;
/** /**
* Displays preferences for all Tethering options. * Displays preferences for all Tethering options.
* TODO(b/147323306): Add tether option preferences into this fragment after controllers created.
*/ */
@SearchIndexable @SearchIndexable
public final class AllInOneTetherSettings extends RestrictedDashboardFragment public final class AllInOneTetherSettings extends RestrictedDashboardFragment
@@ -172,6 +174,9 @@ public final class AllInOneTetherSettings extends RestrictedDashboardFragment
mSecurityPreferenceController = use(WifiTetherSecurityPreferenceController.class); mSecurityPreferenceController = use(WifiTetherSecurityPreferenceController.class);
mPasswordPreferenceController = use(WifiTetherPasswordPreferenceController.class); mPasswordPreferenceController = use(WifiTetherPasswordPreferenceController.class);
mApBandPreferenceController = use(WifiTetherApBandPreferenceController.class); mApBandPreferenceController = use(WifiTetherApBandPreferenceController.class);
getSettingsLifecycle().addObserver(use(UsbTetherPreferenceController.class));
getSettingsLifecycle().addObserver(use(BluetoothTetherPreferenceController.class));
getSettingsLifecycle().addObserver(use(WifiTetherDisablePreferenceController.class));
} }
@Override @Override