summaryrefslogtreecommitdiffstats
path: root/wifi/java/android/net
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@google.com>2010-08-18 22:09:07 -0400
committerDaniel Sandler <dsandler@google.com>2010-08-19 01:25:32 -0400
commit4c0d81b8add0372cc7194b17cc6d2bfc58baacd1 (patch)
tree5c46b070e5102e16b43a3b15540ee517d1ee1abc /wifi/java/android/net
parent13984a253de7b32d803c2c216759cd7b730ee7fe (diff)
downloadframeworks_base-4c0d81b8add0372cc7194b17cc6d2bfc58baacd1.zip
frameworks_base-4c0d81b8add0372cc7194b17cc6d2bfc58baacd1.tar.gz
frameworks_base-4c0d81b8add0372cc7194b17cc6d2bfc58baacd1.tar.bz2
Fix divide-by-zero when calculating signal level over a large output range.
Change-Id: I17eff6fb458532465a836414e1973a8d5b7c715b
Diffstat (limited to 'wifi/java/android/net')
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index a774c12..9156358 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -765,8 +765,9 @@ public class WifiManager {
} else if (rssi >= MAX_RSSI) {
return numLevels - 1;
} else {
- int partitionSize = (MAX_RSSI - MIN_RSSI) / (numLevels - 1);
- return (rssi - MIN_RSSI) / partitionSize;
+ float inputRange = (MAX_RSSI - MIN_RSSI);
+ float outputRange = (numLevels - 1);
+ return (int)((float)(rssi - MIN_RSSI) * outputRange / inputRange);
}
}