Show WiFi minimum level when the Wi-Fi level is UNREACHABLE
- Use WIFI_LEVEL_MIN instead of WIFI_LEVEL_UNREACHABLE to get the Wi-Fi icon resource to avoid app crashing because no valid Wi-Fi icon could be found. Bug: 213294802 Test: manual test make RunSettingsRoboTests ROBOTEST_FILTER=AddAppNetworksFragmentTest Change-Id: Ia805e902716c25db3276b96116a84d0dd2d96a1b
This commit is contained in:
@@ -60,6 +60,7 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
import com.android.settings.wifi.WifiUtils;
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
import com.android.wifitrackerlib.WifiPickerTracker;
|
import com.android.wifitrackerlib.WifiPickerTracker;
|
||||||
|
|
||||||
@@ -419,8 +420,7 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: Check level of the network to show signal icon.
|
// TODO: Check level of the network to show signal icon.
|
||||||
final Drawable wifiIcon = mActivity.getDrawable(
|
final Drawable wifiIcon = mActivity.getDrawable(getWifiIconResource(level)).mutate();
|
||||||
Utils.getWifiIconResource(level)).mutate();
|
|
||||||
final Drawable wifiIconDark = wifiIcon.getConstantState().newDrawable().mutate();
|
final Drawable wifiIconDark = wifiIcon.getConstantState().newDrawable().mutate();
|
||||||
wifiIconDark.setTintList(
|
wifiIconDark.setTintList(
|
||||||
Utils.getColorAttr(mActivity, android.R.attr.colorControlNormal));
|
Utils.getColorAttr(mActivity, android.R.attr.colorControlNormal));
|
||||||
@@ -566,8 +566,7 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
|
|||||||
final PreferenceImageView imageView = view.findViewById(android.R.id.icon);
|
final PreferenceImageView imageView = view.findViewById(android.R.id.icon);
|
||||||
if (imageView != null) {
|
if (imageView != null) {
|
||||||
final Drawable drawable = getContext().getDrawable(
|
final Drawable drawable = getContext().getDrawable(
|
||||||
com.android.settingslib.Utils.getWifiIconResource(
|
getWifiIconResource(uiConfigurationItem.mLevel));
|
||||||
uiConfigurationItem.mLevel));
|
|
||||||
drawable.setTintList(
|
drawable.setTintList(
|
||||||
com.android.settingslib.Utils.getColorAttr(getContext(),
|
com.android.settingslib.Utils.getColorAttr(getContext(),
|
||||||
android.R.attr.colorControlNormal));
|
android.R.attr.colorControlNormal));
|
||||||
@@ -755,8 +754,6 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void updateScanResultsToUi() {
|
void updateScanResultsToUi() {
|
||||||
if (mUiToRequestedList == null) {
|
if (mUiToRequestedList == null) {
|
||||||
@@ -825,4 +822,9 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
|
|||||||
public void onNumSavedNetworksChanged() {
|
public void onNumSavedNetworksChanged() {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
static int getWifiIconResource(int level) {
|
||||||
|
return WifiUtils.getInternetIconResource(level, false /* noInternet */);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -485,6 +485,11 @@ public class AddAppNetworksFragmentTest {
|
|||||||
assertThat(item.mDisplayedSsid).isEqualTo(FAKE_NEW_WPA_SSID);
|
assertThat(item.mDisplayedSsid).isEqualTo(FAKE_NEW_WPA_SSID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWifiIconResource_wifiLevelIsUnreachable_shouldNotCrash() {
|
||||||
|
AddAppNetworksFragment.getWifiIconResource(WifiEntry.WIFI_LEVEL_UNREACHABLE);
|
||||||
|
}
|
||||||
|
|
||||||
private void setUpOneScannedNetworkWithScanedLevel4() {
|
private void setUpOneScannedNetworkWithScanedLevel4() {
|
||||||
final ArrayList list = new ArrayList<>();
|
final ArrayList list = new ArrayList<>();
|
||||||
list.add(mWifiEntry);
|
list.add(mWifiEntry);
|
||||||
|
Reference in New Issue
Block a user