Fix NPE in dump and add additional dump data

This change fixes a NPE when the VcnGatwayConnection attempts to print
for a null underlying network. Additionally, it also prints the existing
configs in order to better identify whether a VCN config is failing to
be privisoned, or failing to start.

Test: manual testing
Change-Id: I44d65633364a5f16d75519cead6729969eb1c06f
diff --git a/services/core/java/com/android/server/VcnManagementService.java b/services/core/java/com/android/server/VcnManagementService.java
index 45717f2..6eb6a0e 100644
--- a/services/core/java/com/android/server/VcnManagementService.java
+++ b/services/core/java/com/android/server/VcnManagementService.java
@@ -955,6 +955,14 @@
             pw.decreaseIndent();
             pw.println();
 
+            pw.println("mConfigs:");
+            pw.increaseIndent();
+            for (Entry<ParcelUuid, VcnConfig> entry : mConfigs.entrySet()) {
+                pw.println(entry.getKey() + ": " + entry.getValue().getProvisioningPackageName());
+            }
+            pw.decreaseIndent();
+            pw.println();
+
             pw.println("mVcns:");
             pw.increaseIndent();
             for (Vcn vcn : mVcns.values()) {
diff --git a/services/core/java/com/android/server/vcn/VcnGatewayConnection.java b/services/core/java/com/android/server/vcn/VcnGatewayConnection.java
index 38f5dd6..77bfc5f 100644
--- a/services/core/java/com/android/server/vcn/VcnGatewayConnection.java
+++ b/services/core/java/com/android/server/vcn/VcnGatewayConnection.java
@@ -2046,7 +2046,11 @@
         pw.println("VcnGatewayConnection (" + mConnectionConfig.getGatewayConnectionName() + "):");
         pw.increaseIndent();
 
-        pw.println("Current state: " + getCurrentState().getClass().getSimpleName());
+        pw.println(
+                "Current state: "
+                        + (getCurrentState() == null
+                                ? null
+                                : getCurrentState().getClass().getSimpleName()));
         pw.println("mIsQuitting: " + mIsQuitting);
         pw.println("mIsInSafeMode: " + mIsInSafeMode);
         pw.println("mCurrentToken: " + mCurrentToken);
@@ -2057,7 +2061,11 @@
 
         pw.println("mUnderlying:");
         pw.increaseIndent();
-        mUnderlying.dump(pw);
+        if (mUnderlying != null) {
+            mUnderlying.dump(pw);
+        } else {
+            pw.println("null");
+        }
         pw.decreaseIndent();
         pw.println();