MediaMetrics: Prepare statistics for protos

1) Add AudioRecord to Analytics trigger.
2) Log RecordThread statistics.
3) Rename DURATIONNS to EXECUTETIMENS to avoid confusion.
4) Use streamType from server not client.
5) Split MMAP types to MMAP_PLAYBACK and MMAP_CAPTURE.
6) Use string flags for AudioTrack and AudioRecord.
7) Compute underrun frames for MixerThread.
8) Log BT connection state.

Test: adb shell dumpsys media.metrics
Test: atest mediametrics_tests
Test: adb shell dumpsys stats --metadata
Bug: 149850236
Change-Id: Iacf3f117c00ec9f377e62862080252aef9dc084f
diff --git a/media/libmediametrics/include/MediaMetricsConstants.h b/media/libmediametrics/include/MediaMetricsConstants.h
index 586a1a3..b916a78 100644
--- a/media/libmediametrics/include/MediaMetricsConstants.h
+++ b/media/libmediametrics/include/MediaMetricsConstants.h
@@ -37,6 +37,9 @@
 // They must be appended with another value to make a key.
 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO "audio."
 
+// Device related key prefix.
+#define AMEDIAMETRICS_KEY_PREFIX_AUDIO_DEVICE  AMEDIAMETRICS_KEY_PREFIX_AUDIO "device."
+
 // The AudioMmap key appends the "trackId" to the prefix.
 // This is the AudioFlinger equivalent of the AAudio Stream.
 // TODO: unify with AMEDIAMETRICS_KEY_PREFIX_AUDIO_STREAM
@@ -113,6 +116,7 @@
 #define AMEDIAMETRICS_PROP_DURATIONNS     "durationNs"     // int64 duration time span
 #define AMEDIAMETRICS_PROP_ENCODING       "encoding"       // string value of format
 #define AMEDIAMETRICS_PROP_EVENT          "event#"         // string value (often func name)
+#define AMEDIAMETRICS_PROP_EXECUTIONTIMENS "executionTimeNs"  // time to execute the event
 
 // TODO: fix inconsistency in flags: AudioRecord / AudioTrack int32,  AudioThread string
 #define AMEDIAMETRICS_PROP_FLAGS          "flags"