Use WifiEntry.getBandString() to show band for Frequency preference
Display string for Wifi band is now available via WifiEntry.getBandString(), so use this for the Frequency preference in the Network Details page. This API also allows the band string to be shown for disconnected but in-range networks. Bug: 190390803 Test: manually verify Frequency preference is populated in Network Details page for both connected and disconnected but in-range networks. Change-Id: I83bec35c659a9ba04964675e3d800f1dd051d155
This commit is contained in:
@@ -88,7 +88,6 @@ import com.android.settingslib.widget.ActionButtonsPreference;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
import com.android.wifitrackerlib.WifiEntry.ConnectCallback;
|
||||
import com.android.wifitrackerlib.WifiEntry.ConnectedInfo;
|
||||
import com.android.wifitrackerlib.WifiEntry.DisconnectCallback;
|
||||
import com.android.wifitrackerlib.WifiEntry.ForgetCallback;
|
||||
import com.android.wifitrackerlib.WifiEntry.SignInCallback;
|
||||
@@ -624,32 +623,12 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
||||
}
|
||||
|
||||
private void refreshFrequency() {
|
||||
final ConnectedInfo connectedInfo = mWifiEntry.getConnectedInfo();
|
||||
if (connectedInfo == null) {
|
||||
final String bandString = mWifiEntry.getBandString();
|
||||
if (TextUtils.isEmpty(bandString)) {
|
||||
mFrequencyPref.setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(b/190390803): We should get the band string directly from WifiEntry.ConnectedInfo
|
||||
// instead of doing the frequency -> band conversion here.
|
||||
final int frequency = connectedInfo.frequencyMhz;
|
||||
String band = null;
|
||||
if (frequency >= WifiEntry.MIN_FREQ_24GHZ && frequency < WifiEntry.MAX_FREQ_24GHZ) {
|
||||
band = mContext.getResources().getString(R.string.wifi_band_24ghz);
|
||||
} else if (frequency >= WifiEntry.MIN_FREQ_5GHZ && frequency < WifiEntry.MAX_FREQ_5GHZ) {
|
||||
band = mContext.getResources().getString(R.string.wifi_band_5ghz);
|
||||
} else if (frequency >= WifiEntry.MIN_FREQ_6GHZ && frequency < WifiEntry.MAX_FREQ_6GHZ) {
|
||||
band = mContext.getResources().getString(R.string.wifi_band_6ghz);
|
||||
} else {
|
||||
// Connecting state is unstable, make it disappeared if unexpected
|
||||
if (mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTING) {
|
||||
mFrequencyPref.setVisible(false);
|
||||
} else {
|
||||
Log.e(TAG, "Unexpected frequency " + frequency);
|
||||
}
|
||||
return;
|
||||
}
|
||||
mFrequencyPref.setSummary(band);
|
||||
mFrequencyPref.setSummary(bandString);
|
||||
mFrequencyPref.setVisible(true);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user