include actual codec used

populate the 'codec' analytics field that tells us which code was
chosen (OMX.google.aac.decoder, for example).
use local declared constants instead of literal strings for our attributes.

Bug: 34935498
Test: examination of generated metrics data
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 5dc9ffa..a332cce 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -59,10 +59,13 @@
 namespace android {
 
 // key for media statistics
-static const char *CodecKeyName = "codec";
+static const char *kCodecKeyName = "codec";
 // attrs for media statistics
-static const char *CodecMime = "mime";
-static const char *CodecCodec = "codec";
+static const char *kCodecCodec = "codec";               /* e.g. OMX.google.aac.decoder */
+static const char *kCodecMime = "mime";                 /* e.g. audio/mime */
+static const char *kCodecMode = "mode";                 /* audio, video */
+static const char *kCodecSecure = "secure";             /* 0, 1 */
+
 
 
 static int64_t getId(const sp<IResourceManagerClient> &client) {
@@ -485,7 +488,7 @@
         mUid = uid;
     }
     // set up our new record, get a sessionID, put it into the in-progress list
-    mAnalyticsItem = new MediaAnalyticsItem(CodecKeyName);
+    mAnalyticsItem = new MediaAnalyticsItem(kCodecKeyName);
     if (mAnalyticsItem != NULL) {
         (void) mAnalyticsItem->generateSessionID();
         // don't record it yet; only at the end, when we have decided that we have
@@ -627,11 +630,11 @@
     if (mAnalyticsItem != NULL) {
         if (nameIsType) {
             // name is the mime type
-            mAnalyticsItem->setCString(CodecMime, name.c_str());
+            mAnalyticsItem->setCString(kCodecMime, name.c_str());
         } else {
-            mAnalyticsItem->setCString(CodecCodec, name.c_str());
+            mAnalyticsItem->setCString(kCodecCodec, name.c_str());
         }
-        mAnalyticsItem->setCString("mode", mIsVideo ? "video" : "audio");
+        mAnalyticsItem->setCString(kCodecMode, mIsVideo ? "video" : "audio");
         //mAnalyticsItem->setInt32("type", nameIsType);
         if (nameIsType)
             mAnalyticsItem->setInt32("encoder", encoder);
@@ -1465,6 +1468,10 @@
 
                     CHECK(msg->findString("componentName", &mComponentName));
 
+                    if (mComponentName.c_str()) {
+                        mAnalyticsItem->setCString(kCodecCodec, mComponentName.c_str());
+                    }
+
                     if (mComponentName.startsWith("OMX.google.")) {
                         mFlags |= kFlagUsesSoftwareRenderer;
                     } else {
@@ -1475,9 +1482,11 @@
                     if (mComponentName.endsWith(".secure")) {
                         mFlags |= kFlagIsSecure;
                         resourceType = MediaResource::kSecureCodec;
+                        mAnalyticsItem->setInt32(kCodecSecure, 1);
                     } else {
                         mFlags &= ~kFlagIsSecure;
                         resourceType = MediaResource::kNonSecureCodec;
+                        mAnalyticsItem->setInt32(kCodecSecure, 0);
                     }
 
                     if (mIsVideo) {