summaryrefslogtreecommitdiff
path: root/framework/src/android/net/NetworkRequest.java
diff options
context:
space:
mode:
authorRemi NGUYEN VAN <reminv@google.com>2021-03-11 23:51:49 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-03-11 23:51:49 +0000
commitde3d545cf10a8d98dfe9498718b0205a1bfdfbbc (patch)
treed06d0905c62902924d403513af07a0c8ae0b3273 /framework/src/android/net/NetworkRequest.java
parentdbb7046923f7a3752242e98800dc3574adaf8265 (diff)
parentea33ac97f6ddc3d8350b4bdf030354c02309ce03 (diff)
Merge changes from topic "ethernet_specifier"
* changes: Fix common tests on Q and R Add Ethernet, TestNetworkSpecifier API
Diffstat (limited to 'framework/src/android/net/NetworkRequest.java')
-rw-r--r--framework/src/android/net/NetworkRequest.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/framework/src/android/net/NetworkRequest.java b/framework/src/android/net/NetworkRequest.java
index 59b539af39..aa6975678a 100644
--- a/framework/src/android/net/NetworkRequest.java
+++ b/framework/src/android/net/NetworkRequest.java
@@ -31,6 +31,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVIT
import static android.net.NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED;
import static android.net.NetworkCapabilities.NET_CAPABILITY_TRUSTED;
import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
+import static android.net.NetworkCapabilities.TRANSPORT_TEST;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -387,11 +388,17 @@ public class NetworkRequest implements Parcelable {
return setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
.setSubscriptionId(subId).build());
} catch (NumberFormatException nfe) {
- // A StringNetworkSpecifier does not accept null or empty ("") strings. When network
- // specifiers were strings a null string and an empty string were considered
- // equivalent. Hence no meaning is attached to a null or empty ("") string.
- return setNetworkSpecifier(TextUtils.isEmpty(networkSpecifier) ? null
- : new StringNetworkSpecifier(networkSpecifier));
+ // An EthernetNetworkSpecifier or TestNetworkSpecifier does not accept null or empty
+ // ("") strings. When network specifiers were strings a null string and an empty
+ // string were considered equivalent. Hence no meaning is attached to a null or
+ // empty ("") string.
+ if (TextUtils.isEmpty(networkSpecifier)) {
+ return setNetworkSpecifier((NetworkSpecifier) null);
+ } else if (mNetworkCapabilities.hasTransport(TRANSPORT_TEST)) {
+ return setNetworkSpecifier(new TestNetworkSpecifier(networkSpecifier));
+ } else {
+ return setNetworkSpecifier(new EthernetNetworkSpecifier(networkSpecifier));
+ }
}
}