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

Commit 9db1b546 authored by Erik Kline's avatar Erik Kline
Browse files

add and incorporate TetheringConfiguration.dump()

Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - "runtest frameworks-net" passes
    - "adb shell dumpsys connectivity" shows expected output
Bug: 36216864
Change-Id: I2b34bdd286e9b04ffaa5f7d28f3befa0c31a0f5b
parent 027a6706
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -1584,14 +1584,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 =