Fallback to "Extended Compatibility" if Speed feature is not ready
- Fallback to the "Extended Compatibility" design when the following conditions occur - 5 GHz band is not supported on the device - 5 GHz SAP available channels cannot be obtained from WifiManager - 6 GHz SAP available channels cannot be obtained from WifiManager Bug: 272450463 Test: manual test atest -c WifiTetherSettingsTest atest -c WifiTetherViewModelTest \ WifiHotspotRepositoryTest \ WifiTetherSecurityPreferenceControllerTest.java \ WifiTetherMaximizeCompatibilityPreferenceControllerTest Change-Id: If7c8c41ebe86f5e7d8e4737ab7a82d38c9d633de
This commit is contained in:
@@ -25,6 +25,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
/**
|
||||
* This controller helps to manage the state of maximize compatibility switch preference.
|
||||
@@ -36,13 +37,30 @@ public class WifiTetherMaximizeCompatibilityPreferenceController extends
|
||||
public static final String PREF_KEY = "wifi_tether_maximize_compatibility";
|
||||
|
||||
private boolean mIsChecked;
|
||||
@VisibleForTesting
|
||||
boolean mShouldHidePreference;
|
||||
|
||||
public WifiTetherMaximizeCompatibilityPreferenceController(Context context,
|
||||
WifiTetherBasePreferenceController.OnTetherConfigUpdateListener listener) {
|
||||
super(context, listener);
|
||||
// If the Wi-Fi Hotspot Speed Feature available, then hide this controller.
|
||||
mShouldHidePreference = FeatureFactory.getFactory(context)
|
||||
.getWifiFeatureProvider().getWifiHotspotRepository().isSpeedFeatureAvailable();
|
||||
Log.d(TAG, "mShouldHidePreference:" + mShouldHidePreference);
|
||||
if (mShouldHidePreference) {
|
||||
return;
|
||||
}
|
||||
mIsChecked = isMaximizeCompatibilityEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
if (mShouldHidePreference) {
|
||||
return false;
|
||||
}
|
||||
return super.isAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return PREF_KEY;
|
||||
|
@@ -32,6 +32,7 @@ import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -48,10 +49,19 @@ public class WifiTetherSecurityPreferenceController extends WifiTetherBasePrefer
|
||||
private int mSecurityValue;
|
||||
@VisibleForTesting
|
||||
boolean mIsWpa3Supported = true;
|
||||
@VisibleForTesting
|
||||
boolean mShouldHidePreference;
|
||||
|
||||
public WifiTetherSecurityPreferenceController(Context context,
|
||||
OnTetherConfigUpdateListener listener) {
|
||||
super(context, listener);
|
||||
// If the Wi-Fi Hotspot Speed Feature available, then hide this controller.
|
||||
mShouldHidePreference = FeatureFactory.getFactory(context)
|
||||
.getWifiFeatureProvider().getWifiHotspotRepository().isSpeedFeatureAvailable();
|
||||
Log.d(TAG, "shouldHidePreference():" + mShouldHidePreference);
|
||||
if (mShouldHidePreference) {
|
||||
return;
|
||||
}
|
||||
final String[] securityNames = mContext.getResources().getStringArray(
|
||||
R.array.wifi_tether_security);
|
||||
final String[] securityValues = mContext.getResources().getStringArray(
|
||||
@@ -62,6 +72,14 @@ public class WifiTetherSecurityPreferenceController extends WifiTetherBasePrefer
|
||||
mWifiManager.registerSoftApCallback(context.getMainExecutor(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
if (mShouldHidePreference) {
|
||||
return false;
|
||||
}
|
||||
return super.isAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE)
|
||||
|
@@ -136,12 +136,22 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
|
||||
mWifiTetherViewModel = FeatureFactory.getFactory(getContext()).getWifiFeatureProvider()
|
||||
.getWifiTetherViewModel(this);
|
||||
mWifiHotspotSecurity = findPreference(KEY_WIFI_HOTSPOT_SECURITY);
|
||||
if (mWifiHotspotSecurity != null && mWifiHotspotSecurity.isVisible()) {
|
||||
mWifiTetherViewModel.getSecuritySummary().observe(this, this::onSecuritySummaryChanged);
|
||||
if (mWifiTetherViewModel != null) {
|
||||
setupSpeedFeature(mWifiTetherViewModel.isSpeedFeatureAvailable());
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setupSpeedFeature(boolean isSpeedFeatureAvailable) {
|
||||
mWifiHotspotSecurity = findPreference(KEY_WIFI_HOTSPOT_SECURITY);
|
||||
mWifiHotspotSpeed = findPreference(KEY_WIFI_HOTSPOT_SPEED);
|
||||
if (mWifiHotspotSpeed != null && mWifiHotspotSpeed.isVisible()) {
|
||||
if (mWifiHotspotSecurity == null || mWifiHotspotSpeed == null) {
|
||||
return;
|
||||
}
|
||||
mWifiHotspotSecurity.setVisible(isSpeedFeatureAvailable);
|
||||
mWifiHotspotSpeed.setVisible(isSpeedFeatureAvailable);
|
||||
if (isSpeedFeatureAvailable) {
|
||||
mWifiTetherViewModel.getSecuritySummary().observe(this, this::onSecuritySummaryChanged);
|
||||
mWifiTetherViewModel.getSpeedSummary().observe(this, this::onSpeedSummaryChanged);
|
||||
}
|
||||
}
|
||||
|
@@ -83,8 +83,21 @@ public class WifiTetherViewModel extends AndroidViewModel {
|
||||
|
||||
@Override
|
||||
protected void onCleared() {
|
||||
mWifiHotspotRepository.getSecurityType().removeObserver(mSecurityTypeObserver);
|
||||
mWifiHotspotRepository.getSpeedType().removeObserver(mSpeedTypeObserver);
|
||||
if (mSecuritySummary != null) {
|
||||
mWifiHotspotRepository.getSecurityType().removeObserver(mSecurityTypeObserver);
|
||||
}
|
||||
if (mSpeedSummary != null) {
|
||||
mWifiHotspotRepository.getSpeedType().removeObserver(mSpeedTypeObserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether Wi-Fi Hotspot Speed Feature is available or not.
|
||||
*
|
||||
* @return {@code true} if Wi-Fi Hotspot Speed Feature is available
|
||||
*/
|
||||
public boolean isSpeedFeatureAvailable() {
|
||||
return mWifiHotspotRepository.isSpeedFeatureAvailable();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user