Udpate setNetworkSpecifier logic support Satellite Transport
Bug: 326373613
Bug: 329385152
Test: atest FrameworksNetTests
Change-Id: I8cf686a6d9a1138d26cb37faa73106afd0e24723
diff --git a/framework/src/android/net/NetworkCapabilities.java b/framework/src/android/net/NetworkCapabilities.java
index 84a0d29..85b1dac 100644
--- a/framework/src/android/net/NetworkCapabilities.java
+++ b/framework/src/android/net/NetworkCapabilities.java
@@ -1775,8 +1775,7 @@
// use the same specifier, TelephonyNetworkSpecifier.
&& mTransportTypes != (1L << TRANSPORT_TEST)
&& Long.bitCount(mTransportTypes & ~(1L << TRANSPORT_TEST)) != 1
- && (mTransportTypes & ~(1L << TRANSPORT_TEST))
- != (1 << TRANSPORT_CELLULAR | 1 << TRANSPORT_SATELLITE)) {
+ && !specifierAcceptableForMultipleTransports(mTransportTypes)) {
throw new IllegalStateException("Must have a single non-test transport specified to "
+ "use setNetworkSpecifier");
}
@@ -1786,6 +1785,12 @@
return this;
}
+ private boolean specifierAcceptableForMultipleTransports(long transportTypes) {
+ return (transportTypes & ~(1L << TRANSPORT_TEST))
+ // Cellular and satellite use the same NetworkSpecifier.
+ == (1 << TRANSPORT_CELLULAR | 1 << TRANSPORT_SATELLITE);
+ }
+
/**
* Sets the optional transport specific information.
*