Methods Summary |
---|
private java.lang.String | buildNetworkKey(android.net.wifi.ScanResult result)
if (result.SSID == null) {
return null;
}
StringBuilder key = new StringBuilder("\"");
key.append(result.SSID);
key.append("\"");
if (result.BSSID != null) {
key.append(result.BSSID);
}
return key.toString();
|
private java.lang.String | buildNetworkKey(android.net.ScoredNetwork network)
if (network.networkKey == null) return null;
if (network.networkKey.wifiKey == null) return null;
if (network.networkKey.type == NetworkKey.TYPE_WIFI) {
String key = network.networkKey.wifiKey.ssid;
if (key == null) return null;
if (network.networkKey.wifiKey.bssid != null) {
key = key + network.networkKey.wifiKey.bssid;
}
return key;
}
return null;
|
public final void | clearScores()
synchronized (mNetworkCache) {
mNetworkCache.clear();
}
|
protected final void | dump(java.io.FileDescriptor fd, java.io.PrintWriter writer, java.lang.String[] args)
mContext.enforceCallingOrSelfPermission(permission.DUMP, TAG);
writer.println("WifiNetworkScoreCache");
writer.println(" All score curves:");
for (Map.Entry<String, ScoredNetwork> entry : mNetworkCache.entrySet()) {
writer.println(" " + entry.getKey() + ": " + entry.getValue().rssiCurve);
}
writer.println(" Current network scores:");
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
for (ScanResult scanResult : wifiManager.getScanResults()) {
writer.println(" " + buildNetworkKey(scanResult) + ": " + getNetworkScore(scanResult));
}
|
public int | getNetworkScore(android.net.wifi.ScanResult result)
int score = INVALID_NETWORK_SCORE;
ScoredNetwork network = getScoredNetwork(result);
if (network != null && network.rssiCurve != null) {
score = network.rssiCurve.lookupScore(result.level);
if (DBG) {
Log.e(TAG, "getNetworkScore found scored network " + network.networkKey
+ " score " + Integer.toString(score)
+ " RSSI " + result.level);
}
}
return score;
|
public int | getNetworkScore(android.net.wifi.ScanResult result, boolean isActiveNetwork)
int score = INVALID_NETWORK_SCORE;
ScoredNetwork network = getScoredNetwork(result);
if (network != null && network.rssiCurve != null) {
score = network.rssiCurve.lookupScore(result.level, isActiveNetwork);
if (DBG) {
Log.e(TAG, "getNetworkScore found scored network " + network.networkKey
+ " score " + Integer.toString(score)
+ " RSSI " + result.level
+ " isActiveNetwork " + isActiveNetwork);
}
}
return score;
|
private android.net.ScoredNetwork | getScoredNetwork(android.net.wifi.ScanResult result)
String key = buildNetworkKey(result);
if (key == null) return null;
//find it
synchronized(mNetworkCache) {
ScoredNetwork network = mNetworkCache.get(key);
return network;
}
|
public boolean | hasScoreCurve(android.net.wifi.ScanResult result)Returns whether there is a non-null score curve for the given ScanResult.
A null score curve has special meaning - we should never connect to an ephemeral network if
the score curve is null.
ScoredNetwork network = getScoredNetwork(result);
return network != null && network.rssiCurve != null;
|
public boolean | isScoredNetwork(android.net.wifi.ScanResult result)Returns whether there is any score info for the given ScanResult.
This includes null-score info, so it should only be used when determining whether to request
scores from the network scorer.
return getScoredNetwork(result) != null;
|
public final void | updateScores(java.util.List networks)
if (networks == null) {
return;
}
Log.e(TAG, "updateScores list size=" + networks.size());
synchronized(mNetworkCache) {
for (ScoredNetwork network : networks) {
String networkKey = buildNetworkKey(network);
if (networkKey == null) continue;
mNetworkCache.put(networkKey, network);
}
}
|