Add wifi aware atoms

Add wifi aware attach and NDP atoms.

Bug: 266494138
Bug: 268577875
Test: atest WifiAwareMetricsTest
Change-Id: I47aaa719240a57ae68df0aeb0711378187ed491e
Merged-In: I47aaa719240a57ae68df0aeb0711378187ed491e
diff --git a/stats/Android.bp b/stats/Android.bp
index 62df3c8..306e6e8 100644
--- a/stats/Android.bp
+++ b/stats/Android.bp
@@ -81,6 +81,7 @@
     "atoms/gps/*.proto",
     "atoms/adservices/*.proto",
     "atoms/providers/mediaprovider/*.proto",
+    "atoms/wifi/*.proto",
 ]
 
 cc_library_host_shared {
diff --git a/stats/atoms.proto b/stats/atoms.proto
index 5e06676..5dee6a6 100644
--- a/stats/atoms.proto
+++ b/stats/atoms.proto
@@ -779,6 +779,8 @@
     // The atom definitions are under atoms/<feature>/<feature>_extension_atoms.proto
     extensions 598; // AdServicesBackCompatGetTopicsReported ad_services_back_compat_get_topics_reported
     extensions 599; // AdServicesBackCompatEpochComputationClassifierReported ad_services_back_compat_epoch_computation_classifier_reported
+    extensions 638; // WifiAwareNdpReported wifi_aware_ndp_reported
+    extensions 639; // WifiAwareAttachReported wifi_aware_attach_reported
 
     // Pulled events will start at field 10000.
     // Next: 10169
diff --git a/stats/atoms/wifi/wifi_extension_atoms.proto b/stats/atoms/wifi/wifi_extension_atoms.proto
new file mode 100644
index 0000000..a3cd730
--- /dev/null
+++ b/stats/atoms/wifi/wifi_extension_atoms.proto
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package android.os.statsd.wifi;
+
+import "frameworks/proto_logging/stats/atom_field_options.proto";
+import "frameworks/proto_logging/stats/atoms.proto";
+import "frameworks/proto_logging/stats/enums/wifi/enums.proto";
+
+option java_package = "com.android.os.wifi";
+option java_multiple_files = true;
+
+extend Atom {
+    optional WifiAwareNdpReported wifi_aware_ndp_reported = 638 [(module) = "wifi"];
+    optional WifiAwareAttachReported wifi_aware_attach_reported = 639 [(module) = "wifi"];
+}
+
+/**
+ * Logged when wifi aware data path is completed
+ */
+message WifiAwareNdpReported {
+    enum Role {
+        ROLE_UNKNOWN = 0;
+        ROLE_INITIATOR = 1;
+        ROLE_RESPONDER = 2;
+    }
+    // Role of data path
+    optional Role role = 1;
+    // If it is over out-of-band
+    optional bool is_out_of_band = 2;
+    // Status of NDP
+    optional android.net.wifi.AwareStatus status = 3;
+    // Duration to create NDP in millis.
+    optional int32 ndp_latency_ms= 4;
+    // The latency of discovery + NDP in millis.
+    optional int32 discovery_ndp_latency_ms= 5;
+    // Channel frequency in MHz, 0 if unavailable, >= 2400 otherwise.
+    optional int32 channel_frequency_mhz= 6;
+}
+
+/**
+ * Logged when wifi aware attach is completed
+ */
+message WifiAwareAttachReported {
+    // Status of attach
+    optional android.net.wifi.AwareStatus status = 1;
+}
diff --git a/stats/enums/wifi/enums.proto b/stats/enums/wifi/enums.proto
index e676fef..3ac14cd 100644
--- a/stats/enums/wifi/enums.proto
+++ b/stats/enums/wifi/enums.proto
@@ -109,4 +109,38 @@
     BAND_6G_MIDDLE = 6;
     // Frequencies in the range of [6875, 7125) GHz
     BAND_6G_HIGH = 7;
-}
\ No newline at end of file
+}
+
+// Status of various Aware operations
+enum AwareStatus {
+    // unknown status
+    ST_UNKNOWN = 0;
+    // NAN operation succeeded
+    ST_SUCCESS = 1;
+    // NAN Discovery Engine/Host driver failures
+    ST_INTERNAL_FAILURE = 2;
+    // NAN OTA failures
+    ST_PROTOCOL_FAILURE = 3;
+    // The publish/subscribe discovery session id is invalid
+    ST_INVALID_SESSION_ID = 4;
+    // Out of resources to fufill request
+    ST_NO_RESOURCES_AVAILABLE = 5;
+    // Invalid arguments passed
+    ST_INVALID_ARGS = 6;
+    // Invalid peer id
+    ST_INVALID_PEER_ID = 7;
+    // Invalid NAN data-path (ndp) id
+    ST_INVALID_NDP_ID = 8;
+    // Attempting to enable NAN when not available, e.g. wifi is disabled
+    ST_NAN_NOT_ALLOWED = 9;
+    // Over the air ACK not received
+    ST_NO_OTA_ACK = 10;
+    // Attempting to enable NAN when already enabled
+    ST_ALREADY_ENABLED = 11;
+    // Can't queue tx followup message foor transmission
+    ST_FOLLOWUP_TX_QUEUE_FULL = 12;
+    // Unsupported concurrency of NAN and another feature - NAN disabled
+    ST_UNSUPPORTED_CONCURRENCY = 13;
+    // Other failures
+    ST_GENERIC_FAILURE = 14;
+}