From ab571a1ba4d1e3299bfe5208bb2286d3e2bff50b Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Wed, 17 May 2017 23:53:59 -0700 Subject: [PATCH] Fix up upstream interface types for case DUN_UNSPECIFIED The existing logic will add TYPE_MOBILE and TYPE_MOBILE_HIPRI even if the carrier config has TYPE_DUN for DUN_UNSPECIFIED. A check is added not to modify the upstream interface types if there is already a cellular interface type. Add TYPE_MOBILE and TYPE_MOBILE_HIPRI if there is no cellular types found. Test: Hotspot on Verizon and T-Mobile US. Verified the requestNetwork has the DUN capability. Bug: 38186915 Change-Id: I74fc5c791fee2885bf66df8975e92c2b48f1668c --- .../tethering/TetheringConfiguration.java | 15 +++++++++++++-- .../tethering/TetheringConfigurationTest.java | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java b/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java index 44c61f0160e79..69411936eb1a0 100644 --- a/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java +++ b/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java @@ -163,20 +163,31 @@ public class TetheringConfiguration { } // Fix up upstream interface types for DUN or mobile. NOTE: independent - // of the value of |requiresDun|, cell data of one form or another is + // of the value of |dunCheck|, cell data of one form or another is // *always* an upstream, regardless of the upstream interface types // specified by configuration resources. if (dunCheck == DUN_REQUIRED) { if (!upstreamIfaceTypes.contains(TYPE_MOBILE_DUN)) { upstreamIfaceTypes.add(TYPE_MOBILE_DUN); } - } else { + } else if (dunCheck == DUN_NOT_REQUIRED) { if (!upstreamIfaceTypes.contains(TYPE_MOBILE)) { upstreamIfaceTypes.add(TYPE_MOBILE); } if (!upstreamIfaceTypes.contains(TYPE_MOBILE_HIPRI)) { upstreamIfaceTypes.add(TYPE_MOBILE_HIPRI); } + } else { + // Fix upstream interface types for case DUN_UNSPECIFIED. + // Do not modify if a cellular interface type is already present in the + // upstream interface types. Add TYPE_MOBILE and TYPE_MOBILE_HIPRI if no + // cellular interface types are found in the upstream interface types. + if (!(upstreamIfaceTypes.contains(TYPE_MOBILE_DUN) + || upstreamIfaceTypes.contains(TYPE_MOBILE) + || upstreamIfaceTypes.contains(TYPE_MOBILE_HIPRI))) { + upstreamIfaceTypes.add(TYPE_MOBILE); + upstreamIfaceTypes.add(TYPE_MOBILE_HIPRI); + } } return upstreamIfaceTypes; diff --git a/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java b/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java index 9fcd1b52b8fef..ddceea20ad218 100644 --- a/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java +++ b/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java @@ -128,5 +128,8 @@ public class TetheringConfigurationTest { assertTrue(cfg.preferredUpstreamIfaceTypes.contains(TYPE_MOBILE_DUN)); // Just to prove we haven't clobbered Wi-Fi: assertTrue(cfg.preferredUpstreamIfaceTypes.contains(TYPE_WIFI)); + // Check that we have not added new cellular interface types + assertFalse(cfg.preferredUpstreamIfaceTypes.contains(TYPE_MOBILE)); + assertFalse(cfg.preferredUpstreamIfaceTypes.contains(TYPE_MOBILE_HIPRI)); } }