Android AudioRecord: AttributionSource fixup

Add missing token to the AttributionSource passed when
creating the Android AudioRecord and AudioEffect objects.

Bug: 190334899
Test: repro steps in bug.
Test: manual audio record regression
Change-Id: Id0af0de2b34bff7ab117127c69f8cb9e3b6cc42c
diff --git a/src/Android.bp b/src/Android.bp
index 9b22260..827b4a4 100644
--- a/src/Android.bp
+++ b/src/Android.bp
@@ -233,6 +233,7 @@
         "libmedia",
         "libmedia_codeclist",
         "libaudioclient",
+        "libaudioclient_aidl_conversion",
         "libaudiofoundation",
         "libaudiomanager",
         "libbinder",
diff --git a/src/android/AudioRecorder_to_android.cpp b/src/android/AudioRecorder_to_android.cpp
index 3d4ad75..411beff 100644
--- a/src/android/AudioRecorder_to_android.cpp
+++ b/src/android/AudioRecorder_to_android.cpp
@@ -689,13 +689,19 @@
     SL_LOGV("SLES channel mask %#x converted to Android mask %#x", df_pcm->channelMask,
             channelMask);
 
+    // TODO b/182392769: use attribution source util
+    AttributionSourceState attributionSource;
+    attributionSource.uid = VALUE_OR_FATAL(android::legacy2aidl_uid_t_int32_t(getuid()));
+    attributionSource.pid = VALUE_OR_FATAL(android::legacy2aidl_pid_t_int32_t(getpid()));
+    attributionSource.token = android::sp<android::BBinder>::make();
+
     // initialize platform-specific CAudioRecorder fields
     ar->mAudioRecord = new android::AudioRecord(
             ar->mRecordSource,     // source
             sampleRate,            // sample rate in Hertz
             sles_to_android_sampleFormat(df_pcm),               // format
             channelMask,           // channel mask
-            AttributionSourceState(), // client attribution source (will be filled in later)
+            attributionSource,
             0,                     // frameCount
             audioRecorder_callback,// callback_t
             (void*)ar,             // user, callback data, here the AudioRecorder
diff --git a/src/android/android_Effect.cpp b/src/android/android_Effect.cpp
index a152f4a..2b5582f 100644
--- a/src/android/android_Effect.cpp
+++ b/src/android/android_Effect.cpp
@@ -667,7 +667,14 @@
         const effect_uuid_t *type) {
     //SL_LOGV("android_fx_initEffectObj on session %d", sessionId);
 
-    effect = new android::AudioEffect(AttributionSourceState());
+    // TODO b/182392769: use attribution source util
+    AttributionSourceState attributionSource;
+    attributionSource.uid = VALUE_OR_FATAL(android::legacy2aidl_uid_t_int32_t(getuid()));
+    attributionSource.pid = VALUE_OR_FATAL(android::legacy2aidl_pid_t_int32_t(getpid()));
+    attributionSource.token = android::sp<android::BBinder>::make();
+
+    effect = android::sp<android::AudioEffect>::make(attributionSource);
+
     effect->set(type, EFFECT_UUID_NULL,
             0,// priority
             0,// effect callback
@@ -808,7 +815,14 @@
     }
 
     // create new effect
-    android::sp<android::AudioEffect> pFx = new android::AudioEffect(AttributionSourceState());
+    // TODO b/182392769: use attribution source util
+    AttributionSourceState attributionSource;
+    attributionSource.uid = VALUE_OR_FATAL(android::legacy2aidl_uid_t_int32_t(getuid()));
+    attributionSource.pid = VALUE_OR_FATAL(android::legacy2aidl_pid_t_int32_t(getpid()));
+    attributionSource.token = android::sp<android::BBinder>::make();
+
+    const auto pFx = android::sp<android::AudioEffect>::make(attributionSource);
+
     pFx->set(NULL, // not using type to create effect
             (const effect_uuid_t*)pUuid,
             0,// priority