Merge "Allow NetworkAgent "immutable updates" to NetworkCapabilities"
am: b35719a057 Change-Id: I0ab76de59e87c46a6961229399ff7200bce49838
This commit is contained in:
@@ -770,7 +770,6 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
|
||||
// TODO: consider only enforcing that capabilities are not removed, allowing addition.
|
||||
// Ignore NOT_METERED being added or removed as it is effectively dynamic. http://b/63326103
|
||||
// TODO: properly support NOT_METERED as a mutable and requestable capability.
|
||||
final long mask = ~MUTABLE_CAPABILITIES & ~(1 << NET_CAPABILITY_NOT_METERED);
|
||||
|
||||
@@ -4574,11 +4574,15 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
*/
|
||||
private void updateCapabilities(
|
||||
int oldScore, NetworkAgentInfo nai, NetworkCapabilities networkCapabilities) {
|
||||
// Sanity check: a NetworkAgent should not change its static capabilities or parameters.
|
||||
if (nai.everConnected) {
|
||||
// Once a NetworkAgent is connected, complain if some immutable capabilities are removed.
|
||||
if (nai.everConnected &&
|
||||
!nai.networkCapabilities.satisfiedByNetworkCapabilities(networkCapabilities)) {
|
||||
// TODO: consider not complaining when a network agent degrade its capabilities if this
|
||||
// does not cause any request (that is not a listen) currently matching that agent to
|
||||
// stop being matched by the updated agent.
|
||||
String diff = nai.networkCapabilities.describeImmutableDifferences(networkCapabilities);
|
||||
if (!TextUtils.isEmpty(diff)) {
|
||||
Slog.wtf(TAG, "BUG: " + nai + " changed immutable capabilities:" + diff);
|
||||
Slog.wtf(TAG, "BUG: " + nai + " lost immutable capabilities:" + diff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user