Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9f71bcf authored by Erik Kline's avatar Erik Kline Committed by android-build-merger
Browse files

Merge "add and incorporate TetheringConfiguration.dump()" am: 9eb95932

am: 9e46faff

Change-Id: I227d8bcd27ae2970ee65d6cc83faa37ff4e4f17a
parents 0f127ea9 9e46faff
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -1579,14 +1579,14 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering

        pw.println("Tethering:");
        pw.increaseIndent();

        pw.println("Configuration:");
        pw.increaseIndent();
        final TetheringConfiguration cfg = mConfig;
        pw.print("preferredUpstreamIfaceTypes:");
        synchronized (mPublicSync) {
            for (Integer netType : cfg.preferredUpstreamIfaceTypes) {
                pw.print(" " + ConnectivityManager.getNetworkTypeName(netType));
            }
            pw.println();
        cfg.dump(pw);
        pw.decreaseIndent();

        synchronized (mPublicSync) {
            pw.println("Tether state:");
            pw.increaseIndent();
            for (int i = 0; i < mTetherStates.size(); i++) {
+41 −0
Original line number Diff line number Diff line
@@ -22,12 +22,15 @@ import static android.net.ConnectivityManager.TYPE_MOBILE_HIPRI;

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 @@ public class TetheringConfiguration {
        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 =