Merge "Captive portal login shows specific network name" am: 01fb05cf62 am: 93fe99aca4 am: 75faf02f04
am: f5b8d18798
Change-Id: I5f7e59c7bcd7df41e0e243612c93c16fb64038c4
diff --git a/packages/CaptivePortalLogin/res/values/strings.xml b/packages/CaptivePortalLogin/res/values/strings.xml
index b1a3852..f486fe4 100644
--- a/packages/CaptivePortalLogin/res/values/strings.xml
+++ b/packages/CaptivePortalLogin/res/values/strings.xml
@@ -5,6 +5,7 @@
<string name="action_use_network">Use this network as is</string>
<string name="action_do_not_use_network">Do not use this network</string>
<string name="action_bar_label">Sign in to network</string>
+ <string name="action_bar_title">Sign in to %1$s</string>
<string name="ssl_error_warning">The network you’re trying to join has security issues.</string>
<string name="ssl_error_example">For example, the login page may not belong to the organization shown.</string>
<string name="ssl_error_continue">Continue anyway via browser</string>
diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
index 582b660..2703fbf 100644
--- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
+++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
@@ -26,6 +26,7 @@
import android.net.ConnectivityManager.NetworkCallback;
import android.net.Network;
import android.net.NetworkCapabilities;
+import android.net.NetworkInfo;
import android.net.NetworkRequest;
import android.net.Proxy;
import android.net.Uri;
@@ -469,7 +470,15 @@
}
private String getHeaderTitle() {
- return getString(R.string.action_bar_label);
+ NetworkInfo info = mCm.getNetworkInfo(mNetwork);
+ if (info == null) {
+ return getString(R.string.action_bar_label);
+ }
+ NetworkCapabilities nc = mCm.getNetworkCapabilities(mNetwork);
+ if (!nc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
+ return getString(R.string.action_bar_label);
+ }
+ return getString(R.string.action_bar_title, info.getExtraInfo().replaceAll("^\"|\"$", ""));
}
private String getHeaderSubtitle(String urlString) {