Merge "add and incorporate TetheringConfiguration.dump()" am: 9eb959320f am: 9e46faff07
am: d9f71bcf6d
Change-Id: I6b2a5aa4054fc0a2a465b940aea11194d3bc39a8
diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java
index 5258b87..be770a3 100644
--- a/services/core/java/com/android/server/connectivity/Tethering.java
+++ b/services/core/java/com/android/server/connectivity/Tethering.java
@@ -1581,14 +1581,14 @@
pw.println("Tethering:");
pw.increaseIndent();
- final TetheringConfiguration cfg = mConfig;
- pw.print("preferredUpstreamIfaceTypes:");
- synchronized (mPublicSync) {
- for (Integer netType : cfg.preferredUpstreamIfaceTypes) {
- pw.print(" " + ConnectivityManager.getNetworkTypeName(netType));
- }
- pw.println();
+ pw.println("Configuration:");
+ pw.increaseIndent();
+ final TetheringConfiguration cfg = mConfig;
+ cfg.dump(pw);
+ pw.decreaseIndent();
+
+ synchronized (mPublicSync) {
pw.println("Tether state:");
pw.increaseIndent();
for (int i = 0; i < mTetherStates.size(); i++) {
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 14d06cc..d38beb3 100644
--- a/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java
+++ b/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java
@@ -22,12 +22,15 @@
import android.content.Context;
import android.content.res.Resources;
+import android.net.ConnectivityManager;
import android.telephony.TelephonyManager;
import android.util.Log;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.StringJoiner;
/**
@@ -97,6 +100,44 @@
return matchesDownstreamRegexs(iface, tetherableBluetoothRegexs);
}
+ public void dump(PrintWriter pw) {
+ dumpStringArray(pw, "tetherableUsbRegexs", tetherableUsbRegexs);
+ dumpStringArray(pw, "tetherableWifiRegexs", tetherableWifiRegexs);
+ dumpStringArray(pw, "tetherableBluetoothRegexs", tetherableBluetoothRegexs);
+
+ pw.print("isDunRequired: ");
+ pw.println(isDunRequired);
+
+ String[] upstreamTypes = null;
+ if (preferredUpstreamIfaceTypes != null) {
+ upstreamTypes = new String[preferredUpstreamIfaceTypes.size()];
+ int i = 0;
+ for (Integer netType : preferredUpstreamIfaceTypes) {
+ upstreamTypes[i] = ConnectivityManager.getNetworkTypeName(netType);
+ i++;
+ }
+ }
+ dumpStringArray(pw, "preferredUpstreamIfaceTypes", upstreamTypes);
+
+ dumpStringArray(pw, "dhcpRanges", dhcpRanges);
+ dumpStringArray(pw, "defaultIPv4DNS", defaultIPv4DNS);
+ }
+
+ private static void dumpStringArray(PrintWriter pw, String label, String[] values) {
+ pw.print(label);
+ pw.print(": ");
+
+ if (values != null) {
+ final StringJoiner sj = new StringJoiner(", ", "[", "]");
+ for (String value : values) { sj.add(value); }
+ pw.print(sj.toString());
+ } else {
+ pw.print("null");
+ }
+
+ pw.println();
+ }
+
private static boolean checkDunRequired(Context ctx) {
final TelephonyManager tm = ctx.getSystemService(TelephonyManager.class);
final int secureSetting =