Merge "Change string for connected via WFA."

This commit is contained in:
TreeHugger Robot
2017-03-21 03:15:10 +00:00
committed by Android (Google) Code Review
2 changed files with 15 additions and 3 deletions

View File

@@ -73,8 +73,10 @@
<!-- Summary for saved networks -->
<string name="saved_network">Saved by <xliff:g id="name">%1$s</xliff:g></string>
<!-- Status message of Wi-Fi when it is connected by a Wi-Fi assistant application. [CHAR LIMIT=NONE] -->
<string name="connected_via_wfa">Connected via Wi\u2011Fi assistant</string>
<!-- Status message of Wi-Fi when it is automatically connected by a network recommendation provider. [CHAR LIMIT=NONE] -->
<string name="connected_via_network_scorer">Automatically connected via %1$s</string>
<!-- Status message of Wi-Fi when it is automatically connected by a default network recommendation provider. [CHAR LIMIT=NONE] -->
<string name="connected_via_network_scorer_default">Automatically connected via Network Quality Scorer</string>
<!-- Status message of Wi-Fi when it is connected by Passpoint configuration. [CHAR LIMIT=NONE] -->
<string name="connected_via_passpoint">Connected via %1$s</string>
<!-- Status message of Wi-Fi when network has matching passpoint credentials. [CHAR LIMIT=NONE] -->

View File

@@ -27,6 +27,8 @@ import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
import android.net.NetworkInfo.State;
import android.net.NetworkScoreManager;
import android.net.NetworkScorerAppData;
import android.net.ScoredNetwork;
import android.net.wifi.IWifiManager;
import android.net.wifi.ScanResult;
@@ -949,7 +951,15 @@ public class AccessPoint implements Comparable<AccessPoint> {
return String.format(format, passpointProvider);
} else if (isEphemeral) {
// Special case for connected + ephemeral networks.
return context.getString(R.string.connected_via_wfa);
final NetworkScoreManager networkScoreManager = context.getSystemService(
NetworkScoreManager.class);
NetworkScorerAppData scorer = networkScoreManager.getActiveScorer();
if (scorer != null && scorer.getRecommendationServiceLabel() != null) {
String format = context.getString(R.string.connected_via_network_scorer);
return String.format(format, scorer.getRecommendationServiceLabel());
} else {
return context.getString(R.string.connected_via_network_scorer_default);
}
}
}