Add static IpClient logging

Support keeping IpClient logs around and dumping them
during dumpsys.  Previously we got this benefit for
wifi by virtue of WifiStateMachine's long-lived nature.
Now that this is changing we need to be sure we have
logs, and this method gets us Ethernet logs as well.

Bug: 62476366
Bug: 77999594
Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-net passes
    - dumpsys connmetrics [ipclient] works
Change-Id: I1136a83de8097fdb4130debe1eaf689be7132fe5
diff --git a/services/core/java/com/android/server/connectivity/IpConnectivityMetrics.java b/services/core/java/com/android/server/connectivity/IpConnectivityMetrics.java
index f427819..ac74598 100644
--- a/services/core/java/com/android/server/connectivity/IpConnectivityMetrics.java
+++ b/services/core/java/com/android/server/connectivity/IpConnectivityMetrics.java
@@ -20,6 +20,7 @@
 import android.net.ConnectivityMetricsEvent;
 import android.net.IIpConnectivityMetrics;
 import android.net.INetdEventCallback;
+import android.net.ip.IpClient;
 import android.net.metrics.ApfProgramEvent;
 import android.net.metrics.IpConnectivityLog;
 import android.os.Binder;
@@ -269,10 +270,12 @@
         // Dump the rolling buffer of metrics event and pretty print events using a human readable
         // format. Also print network dns/connect statistics and default network event time series.
         static final String CMD_LIST = "list";
-        // By default any other argument will fall into the default case which is remapped to the
-        // "list" command. This includes most notably bug reports collected by dumpsys.cpp with
-        // the "-a" argument.
-        static final String CMD_DEFAULT = CMD_LIST;
+        // Dump all IpClient logs ("ipclient").
+        static final String CMD_IPCLIENT = IpClient.DUMP_ARG;
+        // By default any other argument will fall into the default case which is the equivalent
+        // of calling both the "list" and "ipclient" commands. This includes most notably bug
+        // reports collected by dumpsys.cpp with the "-a" argument.
+        static final String CMD_DEFAULT = "";
 
         @Override
         public int logEvent(ConnectivityMetricsEvent event) {
@@ -292,9 +295,20 @@
                 case CMD_PROTO:
                     cmdListAsProto(pw);
                     return;
-                case CMD_LIST: // fallthrough
+                case CMD_IPCLIENT: {
+                    final String[] ipclientArgs = ((args != null) && (args.length > 1))
+                            ? Arrays.copyOfRange(args, 1, args.length)
+                            : null;
+                    IpClient.dumpAllLogs(pw, ipclientArgs);
+                    return;
+                }
+                case CMD_LIST:
+                    cmdList(pw);
+                    return;
                 default:
                     cmdList(pw);
+                    pw.println("");
+                    IpClient.dumpAllLogs(pw, null);
                     return;
             }
         }