Not call MainSwitchBar.getSwitch()

This is private implement details, will be removed in future.

Should call MainSwitchBar's isChecked() and setChecked() to ensure
main switch bar's style is set correctly.

Bug: 306658427
Test: manual - on wifi tether
Test: manual - on developer options
Test: m RunSettingsRoboTests
Change-Id: I292ffbcf73da0721fc206e3dac7610a0aeb20047
This commit is contained in:
Chaohui Wang
2023-10-25 13:45:09 +08:00
parent e752f7214b
commit 12ea5afdf1
5 changed files with 22 additions and 35 deletions

View File

@@ -54,7 +54,6 @@ public class WifiTetherSwitchBarController implements
private final Context mContext;
private final SettingsMainSwitchBar mSwitchBar;
private final Switch mSwitch;
private final ConnectivityManager mConnectivityManager;
private final WifiManager mWifiManager;
@@ -78,7 +77,6 @@ public class WifiTetherSwitchBarController implements
WifiTetherSwitchBarController(Context context, SettingsMainSwitchBar switchBar) {
mContext = context;
mSwitchBar = switchBar;
mSwitch = mSwitchBar.getSwitch();
mDataSaverBackend = new DataSaverBackend(context);
mConnectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -153,8 +151,8 @@ public class WifiTetherSwitchBarController implements
if (state == WIFI_AP_STATE_ENABLING || state == WIFI_AP_STATE_DISABLING) return;
final boolean shouldBeChecked = (state == WIFI_AP_STATE_ENABLED);
if (mSwitch.isChecked() != shouldBeChecked) {
mSwitch.setChecked(shouldBeChecked);
if (mSwitchBar.isChecked() != shouldBeChecked) {
mSwitchBar.setChecked(shouldBeChecked);
}
updateWifiSwitch();
}