Allow passing in acceptUnvalidated without explicitlySelected

This will allow wifi to tell ConnectivityService that partial
connectivity is acceptable even if the network is not explicitly
selected.

This is needed when the user selects a partial connectivity
network and tells the system to connect to the network, and never
to ask again. In such cases, the system must switch to the
network even if it is not explicitly selected.

Bug: 130766237
Test: atest FrameworksNetTests
Test: unit tests in an upcoming CL
Change-Id: I13465090b7b1c0bf5dc83362387a5428d77b7e1d
Merged-In: I13465090b7b1c0bf5dc83362387a5428d77b7e1d
(cherry picked from commit 9a79a6d41e)
This commit is contained in:
Lorenzo Colitti 2019-06-04 14:37:26 +09:00
commit 72792e2f8f

View file

@ -433,7 +433,24 @@ public abstract class NetworkAgent extends Handler {
* {@link #saveAcceptUnvalidated} to respect the user's choice.
*/
public void explicitlySelected(boolean acceptUnvalidated) {
queueOrSendMessage(EVENT_SET_EXPLICITLY_SELECTED, acceptUnvalidated ? 1 : 0, 0);
explicitlySelected(true /* explicitlySelected */, acceptUnvalidated);
}
/**
* Called by the bearer to indicate this network was manually selected by the user.
* This should be called before the NetworkInfo is marked CONNECTED so that this
* Network can be given special treatment at that time. If {@code acceptUnvalidated} is
* {@code true}, then the system will switch to this network. If it is {@code false} and the
* network cannot be validated, the system will ask the user whether to switch to this network.
* If the user confirms and selects "don't ask again", then the system will call
* {@link #saveAcceptUnvalidated} to persist the user's choice. Thus, if the transport ever
* calls this method with {@code acceptUnvalidated} set to {@code false}, it must also implement
* {@link #saveAcceptUnvalidated} to respect the user's choice.
*/
public void explicitlySelected(boolean explicitlySelected, boolean acceptUnvalidated) {
queueOrSendMessage(EVENT_SET_EXPLICITLY_SELECTED,
explicitlySelected ? 1 : 0,
acceptUnvalidated ? 1 : 0);
}
/**