Merge "Show "Not available" summary when hotspot speed is unavailable" into udc-d1-dev am: a99c52e160

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23601566

Change-Id: I5b91a44f9c947d6686a28cb2acb2c41f58e8fe01
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-06-09 05:02:25 +00:00
committed by Automerger Merge Worker
5 changed files with 137 additions and 47 deletions

View File

@@ -623,9 +623,11 @@ public class WifiHotspotRepository {
@VisibleForTesting
class SoftApCallback implements WifiManager.SoftApCallback {
private static final String TAG = "SoftApCallback";
@Override
public void onStateChanged(int state, int failureReason) {
log("onStateChanged(), state:" + state + ", failureReason:" + failureReason);
Log.d(TAG, "onStateChanged(), state:" + state + ", failureReason:" + failureReason);
mWifiApState = state;
if (!mIsRestarting) {
return;

View File

@@ -108,15 +108,17 @@ public class WifiHotspotSpeedSettings extends DashboardFragment implements
if (radioButton == null) {
continue;
}
if (radioButton.isChecked() != speedInfo.mIsChecked) {
radioButton.setChecked(speedInfo.mIsChecked);
if (!speedInfo.mIsVisible) {
radioButton.setVisible(false);
continue;
}
if (radioButton.isEnabled() != speedInfo.mIsEnabled) {
radioButton.setEnabled(speedInfo.mIsEnabled);
}
if (radioButton.isVisible() != speedInfo.mIsVisible) {
radioButton.setVisible(speedInfo.mIsVisible);
radioButton.setEnabled(speedInfo.mIsEnabled);
radioButton.setChecked(speedInfo.mIsChecked);
if (speedInfo.mSummary != null) {
radioButton.setSummary(speedInfo.mSummary);
}
// setVisible at the end to avoid UI flickering
radioButton.setVisible(true);
}
}

View File

@@ -22,12 +22,15 @@ import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_5
import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_6GHZ;
import android.app.Application;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Observer;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.wifi.repository.WifiHotspotRepository;
@@ -41,6 +44,12 @@ import java.util.Map;
*/
public class WifiHotspotSpeedViewModel extends AndroidViewModel {
private static final String TAG = "WifiHotspotSpeedViewModel";
@VisibleForTesting
static final int RES_SPEED_5G_SUMMARY = R.string.wifi_hotspot_speed_5g_summary;
@VisibleForTesting
static final int RES_SPEED_6G_SUMMARY = R.string.wifi_hotspot_speed_6g_summary;
@VisibleForTesting
static final int RES_SUMMARY_UNAVAILABLE = R.string.wifi_hotspot_speed_summary_unavailable;
protected final WifiHotspotRepository mWifiHotspotRepository;
protected Map<Integer, SpeedInfo> mSpeedInfoMap = new HashMap<>();
@@ -75,14 +84,18 @@ public class WifiHotspotSpeedViewModel extends AndroidViewModel {
}
protected void on6gAvailableChanged(Boolean available) {
log("on6gAvailableChanged(), available:" + available);
Log.d(TAG, "on6gAvailableChanged(), available:" + available);
mSpeedInfo6g.mIsEnabled = available;
mSpeedInfo6g.mSummary = getApplication()
.getString(available ? RES_SPEED_6G_SUMMARY : RES_SUMMARY_UNAVAILABLE);
updateSpeedInfoMapData();
}
protected void on5gAvailableChanged(Boolean available) {
log("on5gAvailableChanged(), available:" + available);
Log.d(TAG, "on5gAvailableChanged(), available:" + available);
mSpeedInfo5g.mIsEnabled = available;
mSpeedInfo5g.mSummary = getApplication()
.getString(available ? RES_SPEED_5G_SUMMARY : RES_SUMMARY_UNAVAILABLE);
boolean showDualBand = mWifiHotspotRepository.isDualBand() && available;
log("on5gAvailableChanged(), showDualBand:" + showDualBand);
@@ -144,6 +157,7 @@ public class WifiHotspotSpeedViewModel extends AndroidViewModel {
Boolean mIsChecked;
boolean mIsEnabled;
boolean mIsVisible;
String mSummary;
public SpeedInfo(boolean isChecked, boolean isEnabled, boolean isVisible) {
this.mIsChecked = isChecked;
@@ -157,6 +171,7 @@ public class WifiHotspotSpeedViewModel extends AndroidViewModel {
.append("isChecked:").append(mIsChecked)
.append(",isEnabled:").append(mIsEnabled)
.append(",isVisible:").append(mIsVisible)
.append(",mSummary:").append(mSummary)
.append('}').toString();
}
}