log connectivity state change

log when networks become available and lost, for all transport types
In statsd, we can use net id to uniquely identify a network. We should
be able to count connectivity state changes similar to what BatteryStats
does.

Bug: 115561340
Test: cts test
Change-Id: Ieac4d243e27d5d368a77e5607dec51964912240d
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 5620184..6939c66 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -147,6 +147,7 @@
         PhoneStateChanged phone_state_changed = 95;
         UserRestrictionChanged user_restriction_changed = 96;
         SettingsUIChanged settings_ui_changed = 97;
+        ConnectivityStateChanged connectivity_state_changed = 98;
     }
 
     // Pulled events will start at field 10000.
@@ -2128,6 +2129,22 @@
     optional int64 visible_millis = 16;
 }
 
+/*
+ * Logs when a connection becomes available and lost.
+ * Logged in StatsCompanionService.java
+ */
+message ConnectivityStateChanged {
+    // Id of the network.
+    optional int32 net_id = 1;
+
+    enum State {
+        UNKNOWN = 0;
+        CONNECTED = 1;
+        DISCONNECTED = 2;
+    }
+    // Connected state of a network.
+    optional State state = 2;
+}
 
 //////////////////////////////////////////////////////////////////////
 // Pulled atoms below this line //