Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b2bd16c authored by Weng Su's avatar Weng Su
Browse files

[Provider Model] Avoid running changes to WiFi level

- Because getWifiDrawable() has avoided the WIFI_LEVEL_UNREACHABLE(-1)
level design.

- But it might have a chance to changes in the short time after the
level checking above.

- Use the local variable to avoid the risk of changes in WiFi level
operation.

Bug: 210369886
Test: manual test
atest -c InternetAdapterTest \
         InternetDialogControllerTest \
         InternetDialogTest

Change-Id: Id3f27ac7e4cc52fa3eea640eddd34d49863df8d2
parent 1ff5a29a
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -133,7 +133,8 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
        }

        void onBind(@NonNull WifiEntry wifiEntry) {
            mWifiIcon.setImageDrawable(getWifiDrawable(wifiEntry));
            mWifiIcon.setImageDrawable(
                    getWifiDrawable(wifiEntry.getLevel(), wifiEntry.shouldShowXLevelIcon()));
            setWifiNetworkLayout(wifiEntry.getTitle(),
                    Html.fromHtml(wifiEntry.getSummary(false), Html.FROM_HTML_MODE_LEGACY));

@@ -170,12 +171,13 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
            mWifiSummaryText.setText(summary);
        }

        Drawable getWifiDrawable(@NonNull WifiEntry wifiEntry) {
            if (wifiEntry.getLevel() == WifiEntry.WIFI_LEVEL_UNREACHABLE) {
        Drawable getWifiDrawable(int level, boolean hasNoInternet) {
            // If the Wi-Fi level is equal to WIFI_LEVEL_UNREACHABLE(-1), then a null drawable
            // will be returned.
            if (level == WifiEntry.WIFI_LEVEL_UNREACHABLE) {
                return null;
            }
            final Drawable drawable = mWifiIconInjector.getIcon(wifiEntry.shouldShowXLevelIcon(),
                    wifiEntry.getLevel());
            final Drawable drawable = mWifiIconInjector.getIcon(hasNoInternet, level);
            if (drawable == null) {
                return null;
            }