Ensure nri is satisfied before returning.
When a network preference is set, the highest priority nri will
be a managed default request that disallows default networking.
In the case where there is no satisfying network,
mNoServiceNetwork is used as the satisfier instead of null.
(see computeNetworkReassignment)
mNoServiceNetwork should not be returned in any public API.
Check for the nri being satisfied before returning the satisfier
to ensure mNoServiceNetwork is not returned.
Fixes: 301222648
Test: atest FrameworksNetTests
Change-Id: I22d67a7e8d0274d8ad4f6123fbedf6d37eed18e7
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index 85507f6..3a4d055 100755
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -8021,6 +8021,7 @@
}
}
}
+ if (!highestPriorityNri.isBeingSatisfied()) return null;
return highestPriorityNri.getSatisfier();
}
diff --git a/tests/unit/java/com/android/server/ConnectivityServiceTest.java b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
index f85705c..af0220e 100755
--- a/tests/unit/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
@@ -10230,9 +10230,8 @@
// request so LOST callback is received.
defaultCallback.expect(LOST, mCellAgent);
// Due to the VPN default request, getActiveNetworkInfo() gets the mNoServiceNetwork
- // as the network satisfier which has TYPE_NONE.
- // TODO: This should not be TYPE_NONE, see ConnectivityManager#getActiveNetworkInfo
- assertActiveNetworkInfo(TYPE_NONE, DetailedState.BLOCKED);
+ // as the network satisfier.
+ assertNull(mCm.getActiveNetworkInfo());
} else {
assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED);
}
@@ -10314,9 +10313,8 @@
// While the VPN is reconnecting on the new network, everything is blocked.
if (expectSetVpnDefaultForUids) {
// Due to the VPN default request, getActiveNetworkInfo() gets the mNoServiceNetwork
- // as the network satisfier which has TYPE_NONE.
- // TODO: This should not be TYPE_NONE, see ConnectivityManager#getActiveNetworkInfo
- assertActiveNetworkInfo(TYPE_NONE, DetailedState.BLOCKED);
+ // as the network satisfier.
+ assertNull(mCm.getActiveNetworkInfo());
} else {
assertActiveNetworkInfo(TYPE_WIFI, DetailedState.BLOCKED);
}