diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java index e9bf9b08887e..0c5103d0b782 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java @@ -66,6 +66,8 @@ import android.location.LocationListener; import android.location.LocationManager; import android.media.AudioManager; import android.net.ConnectivityManager; +import android.net.LinkProperties; +import android.net.Network; import android.net.NetworkInfo; import android.os.Build; import android.os.Bundle; @@ -1231,6 +1233,27 @@ public class GeckoAppShell { } } + @WrapForJNI(calledFrom = "gecko") + private static String getDNSDomains() { + if (Build.VERSION.SDK_INT < 21) { + return ""; + } + + ConnectivityManager cm = (ConnectivityManager) + getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); + Network net = cm.getActiveNetwork(); + if (net == null) { + return ""; + } + + LinkProperties lp = cm.getLinkProperties(net); + if (lp == null) { + return ""; + } + + return lp.getDomains(); + } + @WrapForJNI(calledFrom = "gecko") private static int[] getSystemColors() { // attrsAppearance[] must correspond to AndroidSystemColors structure in android/AndroidBridge.h diff --git a/netwerk/system/android/nsAndroidNetworkLinkService.cpp b/netwerk/system/android/nsAndroidNetworkLinkService.cpp index cec0209505ce..7751898e27a6 100644 --- a/netwerk/system/android/nsAndroidNetworkLinkService.cpp +++ b/netwerk/system/android/nsAndroidNetworkLinkService.cpp @@ -134,7 +134,22 @@ nsAndroidNetworkLinkService::GetNetworkID(nsACString& aNetworkID) { NS_IMETHODIMP nsAndroidNetworkLinkService::GetDnsSuffixList( nsTArray& aDnsSuffixList) { - return NS_ERROR_NOT_IMPLEMENTED; + aDnsSuffixList.Clear(); + if (!mozilla::AndroidBridge::Bridge()) { + NS_WARNING("GetDnsSuffixList is not supported without a bridge connection"); + return NS_ERROR_NOT_AVAILABLE; + } + + auto suffixList = java::GeckoAppShell::GetDNSDomains(); + if (!suffixList) { + return NS_OK; + } + + nsAutoCString list(suffixList->ToCString()); + for (const nsACString& suffix : list.Split(',')) { + aDnsSuffixList.AppendElement(suffix); + } + return NS_OK; } void nsAndroidNetworkLinkService::OnNetworkChanged() {