Modify dialog message for partial connectivity

In some networks, network validation may only get success
result for http probe but fail result for https probe.
For this kind of network, it may still work at some websites
or apps, but user didn't know about that. In order to fix this
issue, we will check if network has partial connectivity and
notify user to make a choice if they want to use this partial
connectivity or not.

Bug: 113450764
Bug: 128489091
Test: 1. Build pass.
      2. make -j44 RunSettingsRoboTests
      ROBOTEST_FILTER=WifiDetailPreferenceControllerTest
      3. Change captive_portal_https_url to https://invalid.com
      to simulate partial connectivity.

Change-Id: I0e87f6f2ede173f45a7b6fcf842b4f9a83d8efa1
This commit is contained in:
lucaslin
2019-03-20 11:41:21 +08:00
parent e230d19810
commit 7335c594be
5 changed files with 40 additions and 9 deletions

View File

@@ -17,6 +17,7 @@
package com.android.settings.wifi;
import static android.net.ConnectivityManager.ACTION_PROMPT_LOST_VALIDATION;
import static android.net.ConnectivityManager.ACTION_PROMPT_PARTIAL_CONNECTIVITY;
import static android.net.ConnectivityManager.ACTION_PROMPT_UNVALIDATED;
import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
@@ -53,8 +54,9 @@ public final class WifiNoInternetDialog extends AlertActivity implements
private String mAction;
private boolean isKnownAction(Intent intent) {
return intent.getAction().equals(ACTION_PROMPT_UNVALIDATED) ||
intent.getAction().equals(ACTION_PROMPT_LOST_VALIDATION);
return intent.getAction().equals(ACTION_PROMPT_UNVALIDATED)
|| intent.getAction().equals(ACTION_PROMPT_LOST_VALIDATION)
|| intent.getAction().equals(ACTION_PROMPT_PARTIAL_CONNECTIVITY);
}
@Override
@@ -131,6 +133,11 @@ public final class WifiNoInternetDialog extends AlertActivity implements
ap.mMessage = getString(R.string.no_internet_access_text);
ap.mPositiveButtonText = getString(R.string.yes);
ap.mNegativeButtonText = getString(R.string.no);
} else if (ACTION_PROMPT_PARTIAL_CONNECTIVITY.equals(mAction)) {
ap.mTitle = mNetworkName;
ap.mMessage = getString(R.string.partial_connectivity_text);
ap.mPositiveButtonText = getString(R.string.yes);
ap.mNegativeButtonText = getString(R.string.no);
} else {
ap.mTitle = getString(R.string.lost_internet_access_title);
ap.mMessage = getString(R.string.lost_internet_access_text);
@@ -146,7 +153,8 @@ public final class WifiNoInternetDialog extends AlertActivity implements
ap.mView = checkbox;
mAlwaysAllow = (CheckBox) checkbox.findViewById(com.android.internal.R.id.alwaysUse);
if (ACTION_PROMPT_UNVALIDATED.equals(mAction)) {
if (ACTION_PROMPT_UNVALIDATED.equals(mAction)
|| ACTION_PROMPT_PARTIAL_CONNECTIVITY.equals(mAction)) {
mAlwaysAllow.setText(getString(R.string.no_internet_access_remember));
} else {
mAlwaysAllow.setText(getString(R.string.lost_internet_access_persist));
@@ -174,6 +182,11 @@ public final class WifiNoInternetDialog extends AlertActivity implements
final boolean accept = (which == BUTTON_POSITIVE);
action = (accept ? "Connect" : "Ignore");
mCM.setAcceptUnvalidated(mNetwork, accept, always);
} else if (ACTION_PROMPT_PARTIAL_CONNECTIVITY.equals(mAction)) {
what = "PARTIAL_CONNECTIVITY";
final boolean accept = (which == BUTTON_POSITIVE);
action = (accept ? "Connect" : "Ignore");
mCM.setAcceptPartialConnectivity(mNetwork, accept, always);
} else {
what = "LOST_INTERNET";
final boolean avoid = (which == BUTTON_POSITIVE);