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

Commit 38938279 authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by android-build-merger
Browse files

Display "Sign into network" in settings when on a captive portal.

am: 1317e049

Change-Id: I9d15780cb49e365da98e09ba0149a8d31df4373c
parents 6ba22b5d 1317e049
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -805,18 +805,21 @@ public class AccessPoint implements Comparable<AccessPoint> {
        if (state == DetailedState.CONNECTED) {
            IWifiManager wifiManager = IWifiManager.Stub.asInterface(
                    ServiceManager.getService(Context.WIFI_SERVICE));
            Network nw;
            NetworkCapabilities nc = null;

            try {
                nw = wifiManager.getCurrentNetwork();
            } catch (RemoteException e) {
                nw = null;
            }
            NetworkCapabilities nc = cm.getNetworkCapabilities(nw);
            if (nc != null && !nc.hasCapability(nc.NET_CAPABILITY_VALIDATED)) {
                nc = cm.getNetworkCapabilities(wifiManager.getCurrentNetwork());
            } catch (RemoteException e) {}

            if (nc != null) {
                if (nc.hasCapability(nc.NET_CAPABILITY_CAPTIVE_PORTAL)) {
                    return context.getString(
                        com.android.internal.R.string.network_available_sign_in);
                } else if (!nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) {
                    return context.getString(R.string.wifi_connected_no_internet);
                }
            }
        }
        if (state == null) {
            Log.w(TAG, "state is null, returning empty summary");
            return "";