Merge changes Ie85b6511,I4df65431

* changes:
  lvmtest: Add mono mode for audio effect testing.
  libeffects: Updated test script for higher frequencies and effects
diff --git a/media/libeffects/lvm/tests/build_and_run_all_unit_tests.sh b/media/libeffects/lvm/tests/build_and_run_all_unit_tests.sh
index 340469a..861ee64 100755
--- a/media/libeffects/lvm/tests/build_and_run_all_unit_tests.sh
+++ b/media/libeffects/lvm/tests/build_and_run_all_unit_tests.sh
@@ -20,30 +20,69 @@
 # location of test files
 testdir="/data/local/tmp/lvmTest"
 
-#flags="-bE -tE -eqE -csE"
-flags="-csE -tE -eqE"
-
-
 echo "========================================"
 echo "testing lvm"
-adb shell mkdir $testdir
+adb shell mkdir -p $testdir
 adb push $ANDROID_BUILD_TOP/cts/tests/tests/media/res/raw/sinesweepraw.raw $testdir
 adb push $OUT/testcases/lvmtest/arm64/lvmtest $testdir
 
-# run multichannel effects at different channel counts, saving only the stereo channel pair.
-adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw -o:$testdir/sinesweep_1.raw\
-                          -ch:1 -fs:44100 $flags
-adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw -o:$testdir/sinesweep_2.raw\
-                           -ch:2 -fs:44100 $flags
-adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw -o:$testdir/sinesweep_4.raw\
-                           -ch:4 -fs:44100 $flags
-adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw -o:$testdir/sinesweep_6.raw\
-                           -ch:6 -fs:44100 $flags
-adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw -o:$testdir/sinesweep_8.raw\
-                           -ch:8 -fs:44100 $flags
+flags_arr=(
+    "-csE"
+    "-eqE"
+    "-tE"
+    "-csE -tE -eqE"
+    "-bE"
+    "-csE -tE"
+    "-csE -eqE" "-tE -eqE"
+    "-csE -tE -bE -eqE"
+)
 
-# two channel files should be identical to higher channel computation (first 2 channels).
-adb shell cmp $testdir/sinesweep_2.raw $testdir/sinesweep_2.raw
-adb shell cmp $testdir/sinesweep_2.raw $testdir/sinesweep_4.raw
-adb shell cmp $testdir/sinesweep_2.raw $testdir/sinesweep_6.raw
-adb shell cmp $testdir/sinesweep_2.raw $testdir/sinesweep_8.raw
+fs_arr=(
+    8000
+    11025
+    12000
+    16000
+    22050
+    24000
+    32000
+    44100
+    48000
+    88200
+    96000
+    176400
+    192000
+)
+
+ch_arr=(
+    1
+    2
+    4
+    6
+    8
+)
+
+# run multichannel effects at different configs, saving only the stereo channel
+# pair.
+for flags in "${flags_arr[@]}"
+do
+    for fs in ${fs_arr[*]}
+    do
+        for ch in ${ch_arr[*]}
+        do
+            adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw \
+                -o:$testdir/sinesweep_$((ch))_$((fs)).raw -ch:$ch -fs:$fs $flags
+
+            # two channel files should be identical to higher channel
+            # computation (first 2 channels).
+            # Do not compare cases where -bE is in flags (due to mono computation)
+            if [[ $flags != *"-bE"* ]] && [ "$ch" -gt 2 ]
+            then
+                adb shell cmp $testdir/sinesweep_2_$((fs)).raw \
+                    $testdir/sinesweep_$((ch))_$((fs)).raw
+            fi
+
+        done
+    done
+done
+
+adb shell rm -r $testdir
diff --git a/media/libeffects/lvm/tests/lvmtest.cpp b/media/libeffects/lvm/tests/lvmtest.cpp
index 99551cc..43271d2 100644
--- a/media/libeffects/lvm/tests/lvmtest.cpp
+++ b/media/libeffects/lvm/tests/lvmtest.cpp
@@ -76,6 +76,7 @@
   int              samplingFreq    = 44100;
   int              nrChannels      = 2;
   int              fChannels       = 2;
+  bool             monoMode        = false;
   int              bassEffectLevel = 0;
   int              eqPresetLevel   = 0;
   int              frameLength     = 256;
@@ -98,6 +99,8 @@
   printf("\n");
   printf("\n     -ch:<process_channels> (1 through 8)\n\n");
   printf("\n     -fch:<file_channels> (1 through 8)\n\n");
+  printf("\n     -M");
+  printf("\n           Mono mode (force all input audio channels to be identical)");
   printf("\n     -basslvl:<effect_level>");
   printf("\n           A value that ranges between 0 - 15 default 0");
   printf("\n");
@@ -612,6 +615,15 @@
     }
     memcpy_to_float_from_i16(floatIn.data(), in.data(), frameLength * channelCount);
 
+    // Mono mode will replicate the first channel to all other channels.
+    // This ensures all audio channels are identical. This is useful for testing
+    // Bass Boost, which extracts a mono signal for processing.
+    if (plvmConfigParams->monoMode && channelCount > 1) {
+        for (int i = 0; i < frameLength; ++i) {
+            auto *fp = &floatIn[i * channelCount];
+            std::fill(fp + 1, fp + channelCount, *fp); // replicate ch 0
+        }
+    }
 #if 1
     errCode = lvmExecute(floatIn.data(), floatOut.data(), &context, plvmConfigParams);
     if (errCode) {
@@ -677,6 +689,8 @@
              return -1;
            }
            lvmConfigParams.fChannels = fChannels;
+    } else if (!strcmp(argv[i],"-M")) {
+          lvmConfigParams.monoMode = true;
     } else if (!strncmp(argv[i], "-basslvl:", 9)) {
       const int bassEffectLevel = atoi(argv[i] + 9);
       if (bassEffectLevel > 15 || bassEffectLevel < 0) {