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

Commit 87d2ba36 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Register ConnectivityService with dumpsys priorities"

parents 11df5436 5c010903
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ import com.android.server.connectivity.tethering.TetheringDependencies;
import com.android.server.net.BaseNetworkObserver;
import com.android.server.net.LockdownVpnTracker;
import com.android.server.net.NetworkPolicyManagerInternal;
import com.android.server.utils.PriorityDump;

import com.google.android.collect.Lists;

@@ -682,6 +683,28 @@ public class ConnectivityService extends IConnectivityManager.Stub
    }
    private LegacyTypeTracker mLegacyTypeTracker = new LegacyTypeTracker();

    /**
     * Helper class which parses out priority arguments and dumps sections according to their
     * priority. If priority arguments are omitted, function calls the legacy dump command.
     */
    private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() {
        @Override
        public void dumpHigh(FileDescriptor fd, PrintWriter pw, String[] args, boolean asProto) {
            doDump(fd, pw, new String[] {DIAG_ARG}, asProto);
            doDump(fd, pw, new String[] {SHORT_ARG}, asProto);
        }

        @Override
        public void dumpNormal(FileDescriptor fd, PrintWriter pw, String[] args, boolean asProto) {
            doDump(fd, pw, args, asProto);
        }

        @Override
        public void dump(FileDescriptor fd, PrintWriter pw, String[] args, boolean asProto) {
           doDump(fd, pw, args, asProto);
        }
    };

    public ConnectivityService(Context context, INetworkManagementService netManager,
            INetworkStatsService statsService, INetworkPolicyManager policyManager) {
        this(context, netManager, statsService, policyManager, new IpConnectivityLog());
@@ -1862,8 +1885,13 @@ public class ConnectivityService extends IConnectivityManager.Stub

    @Override
    protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
        PriorityDump.dump(mPriorityDumper, fd, writer, args);
    }

    private void doDump(FileDescriptor fd, PrintWriter writer, String[] args, boolean asProto) {
        final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
        if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
        if (asProto) return;

        if (argsContain(args, DIAG_ARG)) {
            dumpNetworkDiagnostics(pw);
+3 −1
Original line number Diff line number Diff line
@@ -1138,7 +1138,9 @@ public final class SystemServer {
                try {
                    connectivity = new ConnectivityService(
                            context, networkManagement, networkStats, networkPolicy);
                    ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity);
                    ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity,
                            /* allowIsolated= */ false,
                            DUMP_FLAG_PRIORITY_HIGH | DUMP_FLAG_PRIORITY_NORMAL);
                    networkStats.bindConnectivityManager(connectivity);
                    networkPolicy.bindConnectivityManager(connectivity);
                } catch (Throwable e) {