Merge changes from topic 'disabled-reason'

* changes:
  Fix failing WifiConfigManagerTest test.
  Add a disabled reason for recommendation providers
This commit is contained in:
Treehugger Robot
2017-02-23 20:22:06 +00:00
committed by Gerrit Code Review
4 changed files with 62 additions and 0 deletions

View File

@@ -57,6 +57,8 @@
<string name="wifi_disabled_generic">Disabled</string> <string name="wifi_disabled_generic">Disabled</string>
<!-- Status for networked disabled from a DNS or DHCP failure --> <!-- Status for networked disabled from a DNS or DHCP failure -->
<string name="wifi_disabled_network_failure">IP Configuration Failure</string> <string name="wifi_disabled_network_failure">IP Configuration Failure</string>
<!-- Status for networks disabled by the network recommendation provider -->
<string name="wifi_disabled_by_recommendation_provider">Not connected due to low quality network</string>
<!-- Status for networked disabled from a wifi association failure --> <!-- Status for networked disabled from a wifi association failure -->
<string name="wifi_disabled_wifi_failure">WiFi Connection Failure</string> <string name="wifi_disabled_wifi_failure">WiFi Connection Failure</string>
<!-- Status for networks disabled from authentication failure (wrong password <!-- Status for networks disabled from authentication failure (wrong password

View File

@@ -446,6 +446,8 @@ public class AccessPoint implements Comparable<AccessPoint> {
summary.append(mContext.getString(R.string.wifi_disabled_generic)); summary.append(mContext.getString(R.string.wifi_disabled_generic));
break; break;
} }
} else if (config != null && config.getNetworkSelectionStatus().isNotRecommended()) {
summary.append(mContext.getString(R.string.wifi_disabled_by_recommendation_provider));
} else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range } else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
summary.append(mContext.getString(R.string.wifi_not_in_range)); summary.append(mContext.getString(R.string.wifi_not_in_range));
} else { // In range, not disabled. } else { // In range, not disabled.

View File

@@ -845,6 +845,7 @@ public class WifiConfiguration implements Parcelable {
* This network is disabled because EAP-TLS failure * This network is disabled because EAP-TLS failure
*/ */
public static final int DISABLED_TLS_VERSION_MISMATCH = 7; public static final int DISABLED_TLS_VERSION_MISMATCH = 7;
// Values above are for temporary disablement; values below are for permanent disablement.
/** /**
* This network is disabled due to absence of user credentials * This network is disabled due to absence of user credentials
*/ */
@@ -968,6 +969,28 @@ public class WifiConfiguration implements Parcelable {
*/ */
private boolean mHasEverConnected; private boolean mHasEverConnected;
/**
* Boolean indicating whether {@link com.android.server.wifi.RecommendedNetworkEvaluator}
* chose not to connect to this network in the last qualified network selection process.
*/
private boolean mNotRecommended;
/**
* Set whether {@link com.android.server.wifi.RecommendedNetworkEvaluator} does not
* recommend connecting to this network.
*/
public void setNotRecommended(boolean notRecommended) {
mNotRecommended = notRecommended;
}
/**
* Returns whether {@link com.android.server.wifi.RecommendedNetworkEvaluator} does not
* recommend connecting to this network.
*/
public boolean isNotRecommended() {
return mNotRecommended;
}
/** /**
* set whether this network is visible in latest Qualified Network Selection * set whether this network is visible in latest Qualified Network Selection
* @param seen value set to candidate * @param seen value set to candidate
@@ -1272,6 +1295,7 @@ public class WifiConfiguration implements Parcelable {
setConnectChoice(source.getConnectChoice()); setConnectChoice(source.getConnectChoice());
setConnectChoiceTimestamp(source.getConnectChoiceTimestamp()); setConnectChoiceTimestamp(source.getConnectChoiceTimestamp());
setHasEverConnected(source.getHasEverConnected()); setHasEverConnected(source.getHasEverConnected());
setNotRecommended(source.isNotRecommended());
} }
public void writeToParcel(Parcel dest) { public void writeToParcel(Parcel dest) {
@@ -1291,6 +1315,7 @@ public class WifiConfiguration implements Parcelable {
dest.writeInt(CONNECT_CHOICE_NOT_EXISTS); dest.writeInt(CONNECT_CHOICE_NOT_EXISTS);
} }
dest.writeInt(getHasEverConnected() ? 1 : 0); dest.writeInt(getHasEverConnected() ? 1 : 0);
dest.writeInt(isNotRecommended() ? 1 : 0);
} }
public void readFromParcel(Parcel in) { public void readFromParcel(Parcel in) {
@@ -1310,6 +1335,7 @@ public class WifiConfiguration implements Parcelable {
setConnectChoiceTimestamp(INVALID_NETWORK_SELECTION_DISABLE_TIMESTAMP); setConnectChoiceTimestamp(INVALID_NETWORK_SELECTION_DISABLE_TIMESTAMP);
} }
setHasEverConnected(in.readInt() != 0); setHasEverConnected(in.readInt() != 0);
setNotRecommended(in.readInt() != 0);
} }
} }

View File

@@ -20,6 +20,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import android.os.Parcel; import android.os.Parcel;
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -66,4 +67,35 @@ public class WifiConfigurationTest {
assertArrayEquals(bytes, rebytes); assertArrayEquals(bytes, rebytes);
} }
@Test
public void testNetworkSelectionStatusCopy() {
NetworkSelectionStatus networkSelectionStatus = new NetworkSelectionStatus();
networkSelectionStatus.setNotRecommended(true);
NetworkSelectionStatus copy = new NetworkSelectionStatus();
copy.copy(networkSelectionStatus);
assertEquals(networkSelectionStatus.isNotRecommended(), copy.isNotRecommended());
}
@Test
public void testNetworkSelectionStatusParcel() {
NetworkSelectionStatus networkSelectionStatus = new NetworkSelectionStatus();
networkSelectionStatus.setNotRecommended(true);
Parcel parcelW = Parcel.obtain();
networkSelectionStatus.writeToParcel(parcelW);
byte[] bytes = parcelW.marshall();
parcelW.recycle();
Parcel parcelR = Parcel.obtain();
parcelR.unmarshall(bytes, 0, bytes.length);
parcelR.setDataPosition(0);
NetworkSelectionStatus copy = new NetworkSelectionStatus();
copy.readFromParcel(parcelR);
assertEquals(networkSelectionStatus.isNotRecommended(), copy.isNotRecommended());
}
} }