Settings: Forcefully enable Hotspot Speed setting

* Follows device's configurations, not country code

Change-Id: Ifbbd3a746345da2790cc6582ac0d3e0524bf4ba8
Signed-off-by: someone5678 <someone5678@users.noreply.github.com>
This commit is contained in:
someone5678
2024-06-05 20:19:29 +09:00
committed by Joey
parent b04df88ac3
commit aedee4b1db
2 changed files with 2 additions and 63 deletions

View File

@@ -104,7 +104,6 @@ public class WifiHotspotRepository {
protected Boolean mIs6gBandSupported; protected Boolean mIs6gBandSupported;
protected SapBand mBand6g = new SapBand(WifiScanner.WIFI_BAND_6_GHZ); protected SapBand mBand6g = new SapBand(WifiScanner.WIFI_BAND_6_GHZ);
protected MutableLiveData<Boolean> m6gAvailable; protected MutableLiveData<Boolean> m6gAvailable;
protected ActiveCountryCodeChangedCallback mActiveCountryCodeChangedCallback;
@VisibleForTesting @VisibleForTesting
Boolean mIsConfigShowSpeed; Boolean mIsConfigShowSpeed;
@@ -205,25 +204,11 @@ public class WifiHotspotRepository {
updateSpeedType(); updateSpeedType();
} }
/**
* Set to auto refresh data.
*
* @param enabled whether the auto refresh should be enabled or not.
*/
public void setAutoRefresh(boolean enabled) {
if (enabled) {
startAutoRefresh();
} else {
stopAutoRefresh();
}
}
/** /**
* Gets SecurityType LiveData * Gets SecurityType LiveData
*/ */
public LiveData<Integer> getSecurityType() { public LiveData<Integer> getSecurityType() {
if (mSecurityType == null) { if (mSecurityType == null) {
startAutoRefresh();
mSecurityType = new MutableLiveData<>(); mSecurityType = new MutableLiveData<>();
updateSecurityType(); updateSecurityType();
log("getSecurityType():" + mSecurityType.getValue()); log("getSecurityType():" + mSecurityType.getValue());
@@ -276,7 +261,6 @@ public class WifiHotspotRepository {
*/ */
public LiveData<Integer> getSpeedType() { public LiveData<Integer> getSpeedType() {
if (mSpeedType == null) { if (mSpeedType == null) {
startAutoRefresh();
mSpeedType = new MutableLiveData<>(); mSpeedType = new MutableLiveData<>();
updateSpeedType(); updateSpeedType();
log("getSpeedType():" + mSpeedType.getValue()); log("getSpeedType():" + mSpeedType.getValue());
@@ -398,10 +382,7 @@ public class WifiHotspotRepository {
* @return {@code true} if Wi-Fi Hotspot 5 GHz Band is available * @return {@code true} if Wi-Fi Hotspot 5 GHz Band is available
*/ */
public boolean is5gAvailable() { public boolean is5gAvailable() {
if (!mBand5g.isChannelsReady && is5GHzBandSupported()) { return is5GHzBandSupported();
isChannelAvailable(mBand5g);
}
return mBand5g.isAvailable();
} }
/** /**
@@ -440,10 +421,7 @@ public class WifiHotspotRepository {
* @return {@code true} if Wi-Fi Hotspot 6 GHz Band is available * @return {@code true} if Wi-Fi Hotspot 6 GHz Band is available
*/ */
public boolean is6gAvailable() { public boolean is6gAvailable() {
if (!mBand6g.isChannelsReady && is6GHzBandSupported()) { return is6GHzBandSupported();
isChannelAvailable(mBand6g);
}
return mBand6g.isAvailable();
} }
/** /**
@@ -531,44 +509,6 @@ public class WifiHotspotRepository {
return true; return true;
} }
protected void purgeRefreshData() {
mBand5g.isChannelsReady = false;
mBand6g.isChannelsReady = false;
}
protected void startAutoRefresh() {
if (mActiveCountryCodeChangedCallback != null) {
return;
}
log("startMonitorSoftApConfiguration()");
mActiveCountryCodeChangedCallback = new ActiveCountryCodeChangedCallback();
mWifiManager.registerActiveCountryCodeChangedCallback(mAppContext.getMainExecutor(),
mActiveCountryCodeChangedCallback);
}
protected void stopAutoRefresh() {
if (mActiveCountryCodeChangedCallback == null) {
return;
}
log("stopMonitorSoftApConfiguration()");
mWifiManager.unregisterActiveCountryCodeChangedCallback(mActiveCountryCodeChangedCallback);
mActiveCountryCodeChangedCallback = null;
}
protected class ActiveCountryCodeChangedCallback implements
WifiManager.ActiveCountryCodeChangedCallback {
@Override
public void onActiveCountryCodeChanged(String country) {
log("onActiveCountryCodeChanged(), country:" + country);
purgeRefreshData();
refresh();
}
@Override
public void onCountryCodeInactive() {
}
}
/** /**
* Gets Restarting LiveData * Gets Restarting LiveData
*/ */

View File

@@ -70,7 +70,6 @@ public class WifiHotspotSpeedViewModel extends AndroidViewModel {
mWifiHotspotRepository.get6gAvailable().observeForever(m6gAvailableObserver); mWifiHotspotRepository.get6gAvailable().observeForever(m6gAvailableObserver);
mWifiHotspotRepository.get5gAvailable().observeForever(m5gAvailableObserver); mWifiHotspotRepository.get5gAvailable().observeForever(m5gAvailableObserver);
mWifiHotspotRepository.getSpeedType().observeForever(mSpeedTypeObserver); mWifiHotspotRepository.getSpeedType().observeForever(mSpeedTypeObserver);
mWifiHotspotRepository.setAutoRefresh(true);
// The visibility of the 6 GHz speed option will not change on a Pixel device. // The visibility of the 6 GHz speed option will not change on a Pixel device.
mSpeedInfo6g.mIsVisible = mWifiHotspotRepository.is6GHzBandSupported(); mSpeedInfo6g.mIsVisible = mWifiHotspotRepository.is6GHzBandSupported();