Snap for 7468467 from 9295ee9399de493260d441038efedcf7c18b8dae to mainline-mediaprovider-release

Change-Id: Idbe3f72b0251caaa862a1a4cd212518fbd1d0023
diff --git a/Android.bp b/Android.bp
index a0baea7..e003d69 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,6 +12,34 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    default_applicable_licenses: ["frameworks_wilhelm_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+// See: http://go/android-license-faq
+license {
+    name: "frameworks_wilhelm_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-MIT",
+    ],
+    // large-scale-change unable to identify any license_text files
+}
+
 ndk_headers {
     name: "libOpenMAXAL_headers",
     from: "include",
diff --git a/OWNERS b/OWNERS
index b90ae5a..8e61fa7 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,3 +1,4 @@
 # TODO: add more owners
 gkasten@google.com
 elaurent@google.com
+philburk@google.com
diff --git a/src/Android.bp b/src/Android.bp
index dedd809..827b4a4 100644
--- a/src/Android.bp
+++ b/src/Android.bp
@@ -1,3 +1,13 @@
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "frameworks_wilhelm_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    //   SPDX-license-identifier-MIT
+    default_applicable_licenses: ["frameworks_wilhelm_license"],
+}
+
 cc_library_static {
     name: "libOpenSLESUT",
 
@@ -7,7 +17,10 @@
         "ut/slesutResult.c",
     ],
 
-    header_libs: ["libOpenSLES_headers"],
+    header_libs: [
+        "jni_headers",
+        "libOpenSLES_headers",
+    ],
     export_header_lib_headers: ["libOpenSLES_headers"],
     export_include_dirs: ["ut"],
 
@@ -195,12 +208,14 @@
     ],
 
     header_libs: [
+        "jni_headers",
         "libmediametrics_headers",
         "libOpenSLES_headers",
         "media_plugin_headers",
     ],
 
     export_header_lib_headers: [
+        "jni_headers",
         "libOpenSLES_headers",
         "media_plugin_headers",
     ],
@@ -212,11 +227,13 @@
     ],
 
     shared_libs: [
+        "framework-permission-aidl-cpp",
         "liblog",
         "libutils",
         "libmedia",
         "libmedia_codeclist",
         "libaudioclient",
+        "libaudioclient_aidl_conversion",
         "libaudiofoundation",
         "libaudiomanager",
         "libbinder",
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp
index 9dc0a8a..a324b4a 100644
--- a/src/android/AudioPlayer_to_android.cpp
+++ b/src/android/AudioPlayer_to_android.cpp
@@ -49,9 +49,10 @@
 
 //-----------------------------------------------------------------------------
 // Inline functions to communicate with AudioService through the native AudioManager interface
-inline void audioManagerPlayerEvent(CAudioPlayer* ap, android::player_state_t event) {
+inline void audioManagerPlayerEvent(CAudioPlayer* ap, android::player_state_t event,
+        audio_port_handle_t deviceId) {
     if (ap->mObject.mEngine->mAudioManager != 0) {
-        ap->mObject.mEngine->mAudioManager->playerEvent(ap->mPIId, event);
+        ap->mObject.mEngine->mAudioManager->playerEvent(ap->mPIId, event, deviceId);
     }
 }
 
@@ -878,7 +879,7 @@
         if ((ap->mTrackPlayer->mAudioTrack != 0) && (!ap->mSeek.mLoopEnabled)) {
             ap->mTrackPlayer->mAudioTrack->stop();
         }
-        ap->mTrackPlayer->reportEvent(android::PLAYER_STATE_STOPPED);
+        ap->mTrackPlayer->reportEvent(android::PLAYER_STATE_STOPPED, AUDIO_PORT_HANDLE_NONE);
         }
         break;
 
@@ -1514,15 +1515,15 @@
     // no need to check the buffer queue size, application side
     // double-buffering (and more) is not a requirement for using fast tracks
 
-    // Check a blacklist of interfaces that are incompatible with fast tracks.
-    // The alternative, to check a whitelist of compatible interfaces, is
+    // Check a denylist of interfaces that are incompatible with fast tracks.
+    // The alternative, to check a allowlist of compatible interfaces, is
     // more maintainable but is too slow.  As a compromise, in a debug build
     // we use both methods and warn if they produce different results.
-    // In release builds, we only use the blacklist method.
-    // If a blacklisted interface is added after realization using
+    // In release builds, we only use the denylist method.
+    // If a denylisted interface is added after realization using
     // DynamicInterfaceManagement::AddInterface,
     // then this won't be detected but the interface will be ineffective.
-    static const unsigned blacklist[] = {
+    static const unsigned denylist[] = {
         MPH_BASSBOOST,
         MPH_EFFECTSEND,
         MPH_ENVIRONMENTALREVERB,
@@ -1532,10 +1533,10 @@
         MPH_VIRTUALIZER,
         MPH_ANDROIDEFFECT,
         MPH_ANDROIDEFFECTSEND,
-        // FIXME The problem with a blacklist is remembering to add new interfaces here
+        // FIXME The problem with a denylist is remembering to add new interfaces here
     };
-    for (unsigned i = 0; i < sizeof(blacklist)/sizeof(blacklist[0]); ++i) {
-        if (IsInterfaceInitialized(&pAudioPlayer->mObject, blacklist[i])) {
+    for (unsigned i = 0; i < sizeof(denylist)/sizeof(denylist[0]); ++i) {
+        if (IsInterfaceInitialized(&pAudioPlayer->mObject, denylist[i])) {
             //TODO: query effect for EFFECT_FLAG_HW_ACC_xx flag to refine mode
             allowedModes &=
                     ~(ANDROID_PERFORMANCE_MODE_LATENCY|ANDROID_PERFORMANCE_MODE_LATENCY_EFFECTS);
@@ -1543,11 +1544,11 @@
         }
     }
 #if LOG_NDEBUG == 0
-    bool blacklistResult = (
+    bool denylistResult = (
             (allowedModes &
                 (ANDROID_PERFORMANCE_MODE_LATENCY|ANDROID_PERFORMANCE_MODE_LATENCY_EFFECTS)) != 0);
-    bool whitelistResult = true;
-    static const unsigned whitelist[] = {
+    bool allowlistResult = true;
+    static const unsigned allowlist[] = {
         MPH_BUFFERQUEUE,
         MPH_DYNAMICINTERFACEMANAGEMENT,
         MPH_METADATAEXTRACTION,
@@ -1561,19 +1562,19 @@
         MPH_ANDROIDBUFFERQUEUESOURCE,
     };
     for (unsigned mph = MPH_MIN; mph < MPH_MAX; ++mph) {
-        for (unsigned i = 0; i < sizeof(whitelist)/sizeof(whitelist[0]); ++i) {
-            if (mph == whitelist[i]) {
+        for (unsigned i = 0; i < sizeof(allowlist)/sizeof(allowlist[0]); ++i) {
+            if (mph == allowlist[i]) {
                 goto compatible;
             }
         }
         if (IsInterfaceInitialized(&pAudioPlayer->mObject, mph)) {
-            whitelistResult = false;
+            allowlistResult = false;
             break;
         }
 compatible: ;
     }
-    if (whitelistResult != blacklistResult) {
-        SL_LOGW("whitelistResult != blacklistResult");
+    if (allowlistResult != denylistResult) {
+        SL_LOGW("allowlistResult != denylistResult");
     }
 #endif
     if (pAudioPlayer->mPerformanceMode == ANDROID_PERFORMANCE_MODE_LATENCY) {
@@ -1711,7 +1712,7 @@
         }
 
         pAudioPlayer->mTrackPlayer->init(pat, android::PLAYER_TYPE_SLES_AUDIOPLAYER_BUFFERQUEUE,
-                usageForStreamType(pAudioPlayer->mStreamType));
+                usageForStreamType(pAudioPlayer->mStreamType), pAudioPlayer->mSessionId);
 
         // update performance mode according to actual flags granted to AudioTrack
         checkAndSetPerformanceModePost(pAudioPlayer);
@@ -1812,7 +1813,7 @@
             pAudioPlayer->mPIId = pAudioPlayer->mObject.mEngine->mAudioManager->trackPlayer(
                     android::PLAYER_TYPE_SLES_AUDIOPLAYER_URI_FD,
                     usageForStreamType(pAudioPlayer->mStreamType), AUDIO_CONTENT_TYPE_UNKNOWN,
-                    pAudioPlayer->mTrackPlayer);
+                    pAudioPlayer->mTrackPlayer, pAudioPlayer->mSessionId);
         }
         }
         break;
@@ -2232,6 +2233,11 @@
 
     SLuint32 playState = ap->mPlay.mState;
 
+    audio_port_handle_t deviceId = AUDIO_PORT_HANDLE_NONE;
+    if (ap->mTrackPlayer != 0 && ap->mTrackPlayer->mAudioTrack != 0) {
+        deviceId = ap->mTrackPlayer->mAudioTrack->getRoutedDeviceId();
+    }
+
     switch (ap->mAndroidObjType) {
     case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE:
         switch (playState) {
@@ -2249,7 +2255,7 @@
                 // instead of ap->mTrackPlayer->mAudioTrack->start();
                 if (!ap->mDeferredStart) {
                     // state change
-                    ap->mTrackPlayer->reportEvent(android::PLAYER_STATE_STARTED);
+                    ap->mTrackPlayer->reportEvent(android::PLAYER_STATE_STARTED, deviceId);
                 }
                 ap->mDeferredStart = true;
             }
@@ -2264,14 +2270,14 @@
         switch (playState) {
         case SL_PLAYSTATE_STOPPED:
             aplayer_setPlayState(ap->mAPlayer, playState, &ap->mAndroidObjState);
-            audioManagerPlayerEvent(ap, android::PLAYER_STATE_STOPPED);
+            audioManagerPlayerEvent(ap, android::PLAYER_STATE_STOPPED, AUDIO_PORT_HANDLE_NONE);
             break;
         case SL_PLAYSTATE_PAUSED:
             aplayer_setPlayState(ap->mAPlayer, playState, &ap->mAndroidObjState);
-            audioManagerPlayerEvent(ap, android::PLAYER_STATE_PAUSED);
+            audioManagerPlayerEvent(ap, android::PLAYER_STATE_PAUSED, AUDIO_PORT_HANDLE_NONE);
             break;
         case SL_PLAYSTATE_PLAYING:
-            audioManagerPlayerEvent(ap, android::PLAYER_STATE_STARTED);
+            audioManagerPlayerEvent(ap, android::PLAYER_STATE_STARTED, deviceId);
             aplayer_setPlayState(ap->mAPlayer, playState, &ap->mAndroidObjState);
             break;
         }
@@ -2481,7 +2487,8 @@
     // queue was stopped when the queue become empty, we restart as soon as a new buffer
     // has been enqueued since we're in playing state
     if (ap->mTrackPlayer->mAudioTrack != 0) {
-        ap->mTrackPlayer->reportEvent(android::PLAYER_STATE_STARTED);
+        ap->mTrackPlayer->reportEvent(android::PLAYER_STATE_STARTED,
+                            ap->mTrackPlayer->mAudioTrack->getRoutedDeviceId());
         // instead of ap->mTrackPlayer->mAudioTrack->start();
         ap->mDeferredStart = true;
     }
diff --git a/src/android/AudioRecorder_to_android.cpp b/src/android/AudioRecorder_to_android.cpp
index 2595112..411beff 100644
--- a/src/android/AudioRecorder_to_android.cpp
+++ b/src/android/AudioRecorder_to_android.cpp
@@ -29,6 +29,8 @@
 #define KEY_RECORDING_PRESET_PARAMSIZE  sizeof(SLuint32)
 #define KEY_PERFORMANCE_MODE_PARAMSIZE  sizeof(SLuint32)
 
+using android::content::AttributionSourceState;
+
 //-----------------------------------------------------------------------------
 // Internal utility functions
 //----------------------------
@@ -515,32 +517,32 @@
     // no need to check the buffer queue size, application side
     // double-buffering (and more) is not a requirement for using fast tracks
 
-    // Check a blacklist of interfaces that are incompatible with fast tracks.
-    // The alternative, to check a whitelist of compatible interfaces, is
+    // Check a denylist of interfaces that are incompatible with fast tracks.
+    // The alternative, to check a allowlist of compatible interfaces, is
     // more maintainable but is too slow.  As a compromise, in a debug build
     // we use both methods and warn if they produce different results.
-    // In release builds, we only use the blacklist method.
-    // If a blacklisted interface is added after realization using
+    // In release builds, we only use the denylist method.
+    // If a denylisted interface is added after realization using
     // DynamicInterfaceManagement::AddInterface,
     // then this won't be detected but the interface will be ineffective.
-    static const unsigned blacklist[] = {
+    static const unsigned denylist[] = {
         MPH_ANDROIDACOUSTICECHOCANCELLATION,
         MPH_ANDROIDAUTOMATICGAINCONTROL,
         MPH_ANDROIDNOISESUPPRESSION,
         MPH_ANDROIDEFFECT,
-        // FIXME The problem with a blacklist is remembering to add new interfaces here
+        // FIXME The problem with a denylist is remembering to add new interfaces here
     };
 
-    for (unsigned i = 0; i < sizeof(blacklist)/sizeof(blacklist[0]); ++i) {
-        if (IsInterfaceInitialized(&ar->mObject, blacklist[i])) {
+    for (unsigned i = 0; i < sizeof(denylist)/sizeof(denylist[0]); ++i) {
+        if (IsInterfaceInitialized(&ar->mObject, denylist[i])) {
             uint32_t flags = 0;
 
             allowedModes &= ~ANDROID_PERFORMANCE_MODE_LATENCY;
 
             // if generic effect interface is used we don't know which effect will be used and
             // disable all low latency performance modes
-            if (blacklist[i] != MPH_ANDROIDEFFECT) {
-                switch (blacklist[i]) {
+            if (denylist[i] != MPH_ANDROIDEFFECT) {
+                switch (denylist[i]) {
                 case MPH_ANDROIDACOUSTICECHOCANCELLATION:
                     SL_LOGV("checkAndSetPerformanceModePre found AEC name %s",
                             ar->mAcousticEchoCancellation.mAECDescriptor.name);
@@ -567,11 +569,11 @@
         }
     }
 #if LOG_NDEBUG == 0
-    bool blacklistResult = (
+    bool denylistResult = (
             (allowedModes &
                 (ANDROID_PERFORMANCE_MODE_LATENCY|ANDROID_PERFORMANCE_MODE_LATENCY_EFFECTS)) != 0);
-    bool whitelistResult = true;
-    static const unsigned whitelist[] = {
+    bool allowlistResult = true;
+    static const unsigned allowlist[] = {
         MPH_BUFFERQUEUE,
         MPH_DYNAMICINTERFACEMANAGEMENT,
         MPH_OBJECT,
@@ -580,19 +582,19 @@
         MPH_ANDROIDSIMPLEBUFFERQUEUE,
     };
     for (unsigned mph = MPH_MIN; mph < MPH_MAX; ++mph) {
-        for (unsigned i = 0; i < sizeof(whitelist)/sizeof(whitelist[0]); ++i) {
-            if (mph == whitelist[i]) {
+        for (unsigned i = 0; i < sizeof(allowlist)/sizeof(allowlist[0]); ++i) {
+            if (mph == allowlist[i]) {
                 goto compatible;
             }
         }
         if (IsInterfaceInitialized(&ar->mObject, mph)) {
-            whitelistResult = false;
+            allowlistResult = false;
             break;
         }
 compatible: ;
     }
-    if (whitelistResult != blacklistResult) {
-        SL_LOGW("whitelistResult != blacklistResult");
+    if (allowlistResult != denylistResult) {
+        SL_LOGW("allowlistResult != denylistResult");
     }
 #endif
     if (ar->mPerformanceMode == ANDROID_PERFORMANCE_MODE_LATENCY) {
@@ -687,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
-            android::String16(),   // app ops
+            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 ca0a1c5..2b5582f 100644
--- a/src/android/android_Effect.cpp
+++ b/src/android/android_Effect.cpp
@@ -32,6 +32,8 @@
 
 #include <system/audio.h>
 
+using android::content::AttributionSourceState;
+
 static const int EQUALIZER_PARAM_SIZE_MAX = sizeof(effect_param_t) + 2 * sizeof(int32_t)
         + EFFECT_STRING_LEN_MAX;
 
@@ -665,12 +667,20 @@
         const effect_uuid_t *type) {
     //SL_LOGV("android_fx_initEffectObj on session %d", sessionId);
 
-    effect = new android::AudioEffect(type, android::String16(), EFFECT_UUID_NULL,
+    // 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
             0,// callback data
             sessionId,// session ID
-            0 );// output
+            0); // output
 
     android::status_t status = effect->initCheck();
     if (android::NO_ERROR != status) {
@@ -805,9 +815,15 @@
     }
 
     // create new effect
-    android::sp<android::AudioEffect> pFx = new android::AudioEffect(
-            NULL, // not using type to create effect
-            android::String16(),
+    // 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
             0,// effect callback
diff --git a/src/android/channels.cpp b/src/android/channels.cpp
index 4f3e976..f0eeb7c 100644
--- a/src/android/channels.cpp
+++ b/src/android/channels.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "sles_allinclusive.h"
+#include <cutils/bitops.h>
 #include <system/audio.h>
 #include <SLES/OpenSLES_Android.h>
 #include "channels.h"
@@ -191,7 +192,7 @@
         SL_LOGE("Unrecognized channel representation %#x", rep);
     }
 
-    uint32_t result = audio_channel_mask_from_representation_and_bits(
+    audio_channel_mask_t result = audio_channel_mask_from_representation_and_bits(
             rep,
             bitsOut);
 
diff --git a/src/itf/IPlay.cpp b/src/itf/IPlay.cpp
index acee3ff..3dcffcd 100644
--- a/src/itf/IPlay.cpp
+++ b/src/itf/IPlay.cpp
@@ -75,7 +75,7 @@
 
             case (SL_PLAYSTATE_STOPPING << 2) | SL_PLAYSTATE_PAUSED:
             case (SL_PLAYSTATE_STOPPING << 2) | SL_PLAYSTATE_PLAYING:
-                // wait for other guy to finish his transition, then retry ours
+                // wait for someone else to finish their transition, then retry ours
                 continue;
 
             case (SL_PLAYSTATE_PAUSED   << 2) | SL_PLAYSTATE_STOPPED:
diff --git a/src/itfstruct.h b/src/itfstruct.h
index a717f46..ab8a4d0 100644
--- a/src/itfstruct.h
+++ b/src/itfstruct.h
@@ -69,7 +69,7 @@
     const struct SL3DCommitItf_ *mItf;
     IObject *mThis;
     SLboolean mDeferred;
-    SLuint32 mGeneration;   // incremented each master clock cycle
+    SLuint32 mGeneration;   // incremented each main clock cycle
     SLuint32 mWaiting;      // number of threads waiting in Commit
 } I3DCommit;
 
diff --git a/tests/Android.bp b/tests/Android.bp
index fb33c08..9241d9e 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -1,4 +1,14 @@
 // Build the unit tests.
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "frameworks_wilhelm_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    //   SPDX-license-identifier-MIT
+    default_applicable_licenses: ["frameworks_wilhelm_license"],
+}
+
 cc_test {
     name: "libopenslestests",
 
diff --git a/tests/automated/Android.bp b/tests/automated/Android.bp
index 6b78d5d..6e3b1bc 100644
--- a/tests/automated/Android.bp
+++ b/tests/automated/Android.bp
@@ -1,5 +1,9 @@
 // Build the unit tests.
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_test {
     name: "BufferQueue_test",
 
diff --git a/tests/automated/README.md b/tests/automated/README.md
new file mode 100644
index 0000000..9e22a22
--- /dev/null
+++ b/tests/automated/README.md
@@ -0,0 +1,5 @@
+How to run BufferQueue\_test
+
+Run either /data/nativetest/BufferQueue\_test/BufferQueue\_test
+or /data/nativetest64/BufferQueue\_test/BufferQueue\_test
+then expect to hear several sine sweeps, and see PASSED at end.
diff --git a/tests/examples/Android.bp b/tests/examples/Android.bp
index 77b96d9..9603c26 100644
--- a/tests/examples/Android.bp
+++ b/tests/examples/Android.bp
@@ -1,5 +1,15 @@
 // slesTest_recBuffQueue
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "frameworks_wilhelm_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    //   SPDX-license-identifier-MIT
+    default_applicable_licenses: ["frameworks_wilhelm_license"],
+}
+
 cc_test {
     name: "slesTest_recBuffQueue",
     gtest: false,
diff --git a/tests/listening/Android.bp b/tests/listening/Android.bp
index c0ba682..0771be3 100644
--- a/tests/listening/Android.bp
+++ b/tests/listening/Android.bp
@@ -1,3 +1,7 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_test {
     name: "slesTest_seekTorture",
     gtest: false,
diff --git a/tests/mimeUri/Android.bp b/tests/mimeUri/Android.bp
index 00ddd90..5e6fafd 100644
--- a/tests/mimeUri/Android.bp
+++ b/tests/mimeUri/Android.bp
@@ -1,5 +1,15 @@
 // slesTest_playStates
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "frameworks_wilhelm_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    //   SPDX-license-identifier-MIT
+    default_applicable_licenses: ["frameworks_wilhelm_license"],
+}
+
 cc_test {
     name: "slesTest_playStates",
     gtest: false,
diff --git a/tests/native-media/Android.bp b/tests/native-media/Android.bp
index d7f5549..66ff198 100644
--- a/tests/native-media/Android.bp
+++ b/tests/native-media/Android.bp
@@ -1,3 +1,7 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 android_test {
     name: "native-media",
     srcs: [
diff --git a/tests/native-media/jni/Android.bp b/tests/native-media/jni/Android.bp
index 28350d0..50ece7a 100644
--- a/tests/native-media/jni/Android.bp
+++ b/tests/native-media/jni/Android.bp
@@ -1,3 +1,7 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_test_library {
     name: "libnative-media-jni",
     srcs: ["native-media-jni.c"],
diff --git a/tests/sandbox/Android.bp b/tests/sandbox/Android.bp
index 6188890..2142d19 100644
--- a/tests/sandbox/Android.bp
+++ b/tests/sandbox/Android.bp
@@ -1,5 +1,9 @@
 // intbufq
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_test {
     name: "slesTest_intbufq",
     gtest: false,
diff --git a/tests/sandbox/streamSource/Android.bp b/tests/sandbox/streamSource/Android.bp
index fed7e39..bfbb05a 100644
--- a/tests/sandbox/streamSource/Android.bp
+++ b/tests/sandbox/streamSource/Android.bp
@@ -1,5 +1,9 @@
 // slesTest_playStream
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_test {
     name: "slesTest_playStream",
     gtest: false,