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

Commit b9647ebb authored by Sundeep Ghuman's avatar Sundeep Ghuman
Browse files

Fix broken AccessPointTests.

Bug: None
Test: runtest --path
frameworks/base/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/AccessPointTest.java

Change-Id: I5d5da5e7e0faf1c124816f0dd8ab5f0249e54637
parent 4d8781e6
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -79,19 +79,16 @@ public class TestAccessPointBuilder {
    * setting the level will also make it reachable.
    */
    public TestAccessPointBuilder setLevel(int level) {
        int outputRange = AccessPoint.SIGNAL_LEVELS - 1;

        if (level > outputRange) {
            level = outputRange;
        } else if (level < 0) {
            level = 0;
        // Reversal of WifiManager.calculateSignalLevels
        if (level == 0) {
            mRssi = MIN_RSSI;
        } else if (level >= AccessPoint.SIGNAL_LEVELS) {
            mRssi = MAX_RSSI;
        } else {
            float inputRange = MAX_RSSI - MIN_RSSI;
            float outputRange = AccessPoint.SIGNAL_LEVELS - 1;
            mRssi = (int) (level * inputRange / outputRange + MIN_RSSI);
        }

        int inputRange = MAX_RSSI - MIN_RSSI;

        // calculate the rssi required to get the level we want.
        // this is a rearrangement of the formula from WifiManager.calculateSignalLevel()
        mRssi = (int)((float)(level * inputRange) / (float)outputRange) + MIN_RSSI;
        return this;
    }