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

Commit 2be41868 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix the number of levels returned by getLevels()."

parents 51d7a8a8 aaa8a1b5
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -113,9 +113,14 @@ public class AccessPoint implements Comparable<AccessPoint> {
    private static final int PSK_WPA2 = 2;
    private static final int PSK_WPA_WPA2 = 3;

    public static final int SIGNAL_LEVELS = 4;
    /**
     * The number of distinct wifi levels.
     *
     * <p>Must keep in sync with {@link R.array.wifi_signal} and {@link WifiManager#RSSI_LEVELS}.
     */
    public static final int SIGNAL_LEVELS = 5;

    static final int UNREACHABLE_RSSI = Integer.MIN_VALUE;
    public static final int UNREACHABLE_RSSI = Integer.MIN_VALUE;

    private final Context mContext;

@@ -370,10 +375,13 @@ public class AccessPoint implements Comparable<AccessPoint> {
        return mInfo;
    }

    /**
     * Returns the number of levels to show for a Wifi icon, from 0 to {@link #SIGNAL_LEVELS}-1.
     *
     * <p>Use {@#isReachable()} to determine if an AccessPoint is in range, as this method will
     * always return at least 0.
     */
    public int getLevel() {
        if (!isReachable()) {
            return -1;
        }
        return WifiManager.calculateSignalLevel(mRssi, SIGNAL_LEVELS);
    }

@@ -923,7 +931,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
    }

    /** Return true if the current RSSI is reachable, and false otherwise. */
    boolean isReachable() {
    public boolean isReachable() {
        return mRssi != UNREACHABLE_RSSI;
    }

+1 −2
Original line number Diff line number Diff line
@@ -223,8 +223,7 @@ public class AccessPointPreference extends Preference {
        }

        final Context context = getContext();
        int level = WifiManager.calculateSignalLevel(
                mAccessPoint.getRssi(), WifiManager.RSSI_LEVELS);
        int level = mAccessPoint.getLevel();
        int wifiBadge = mAccessPoint.getBadge();
        if (level != mLevel || wifiBadge != mWifiBadge) {
            mLevel = level;