Merge "Test VCN policies for test Networks with test permissions."
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/car/GearSelectionTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/car/GearSelectionTestActivity.java
index 89197d7..8b0a8b1 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/car/GearSelectionTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/car/GearSelectionTestActivity.java
@@ -38,7 +38,7 @@
public class GearSelectionTestActivity extends PassFailButtons.Activity {
private static final String TAG = GearSelectionTestActivity.class.getSimpleName();
private List<Integer> mSupportedGears;
- private int mGearsAchievedCount = 0;
+ private Integer mGearsAchievedCount = 0;
private TextView mExpectedGearSelectionTextView;
private TextView mCurrentGearSelectionTextView;
@@ -95,7 +95,7 @@
}
// Check to see if new gear matches the expected gear.
- if(newGearSelection == mSupportedGears.get(mGearsAchievedCount)) {
+ if (newGearSelection.equals(mSupportedGears.get(mGearsAchievedCount))) {
mGearsAchievedCount++;
Log.i(TAG, "Matched gear: " + VehicleGear.toString(newGearSelection));
// Check to see if the test is finished.
diff --git a/hostsidetests/appcompat/compatchanges/app/src/com/android/cts/appcompat/compatchanges/CompatChangesTest.java b/hostsidetests/appcompat/compatchanges/app/src/com/android/cts/appcompat/compatchanges/CompatChangesTest.java
index 16214ce..060c8ed 100644
--- a/hostsidetests/appcompat/compatchanges/app/src/com/android/cts/appcompat/compatchanges/CompatChangesTest.java
+++ b/hostsidetests/appcompat/compatchanges/app/src/com/android/cts/appcompat/compatchanges/CompatChangesTest.java
@@ -56,7 +56,8 @@
InstrumentationRegistry.getInstrumentation().getUiAutomation()
.adoptShellPermissionIdentity(Manifest.permission.LOG_COMPAT_CHANGE,
Manifest.permission.READ_COMPAT_CHANGE_CONFIG,
- Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD);
+ Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG_ON_RELEASE_BUILD,
+ Manifest.permission.INTERACT_ACROSS_USERS_FULL);
}
@After
diff --git a/hostsidetests/appcompat/compatchanges/selinuxapp/Android.bp b/hostsidetests/appcompat/compatchanges/selinuxapp/Android.bp
new file mode 100644
index 0000000..e926a75
--- /dev/null
+++ b/hostsidetests/appcompat/compatchanges/selinuxapp/Android.bp
@@ -0,0 +1,53 @@
+//
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+java_library_static {
+ name: "selinux_app_empty",
+ sdk_version: "current",
+ srcs: ["src/**/*.java"],
+}
+
+android_test_helper_app {
+ name: "CtsSelinuxQCompatApp",
+ defaults: ["cts_defaults"],
+ sdk_version: "current",
+ static_libs: ["selinux_app_empty"],
+ manifest: "AndroidManifest_Q.xml",
+ // Tag this module as a cts test artifact
+ test_suites: [
+ "cts",
+ "vts10",
+ "general-tests",
+ ],
+}
+
+android_test_helper_app {
+ name: "CtsSelinuxRCompatApp",
+ defaults: ["cts_defaults"],
+ sdk_version: "current",
+ static_libs: ["selinux_app_empty"],
+ manifest: "AndroidManifest_R.xml",
+ // Tag this module as a cts test artifact
+ test_suites: [
+ "cts",
+ "vts10",
+ "general-tests",
+ ],
+}
diff --git a/hostsidetests/appcompat/compatchanges/selinuxapp/AndroidManifest_Q.xml b/hostsidetests/appcompat/compatchanges/selinuxapp/AndroidManifest_Q.xml
new file mode 100644
index 0000000..5a6c1d3
--- /dev/null
+++ b/hostsidetests/appcompat/compatchanges/selinuxapp/AndroidManifest_Q.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.cts.appcompat.selinux_app">
+ <uses-sdk android:targetSdkVersion="29"/>
+ <application
+ android:debuggable="true">
+ <activity android:name=".Empty"
+ android:exported="true" />
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation
+ android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.cts.appcompat.selinux_app" />
+
+</manifest>
diff --git a/hostsidetests/appcompat/compatchanges/selinuxapp/AndroidManifest_R.xml b/hostsidetests/appcompat/compatchanges/selinuxapp/AndroidManifest_R.xml
new file mode 100644
index 0000000..0fecd4f
--- /dev/null
+++ b/hostsidetests/appcompat/compatchanges/selinuxapp/AndroidManifest_R.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.cts.appcompat.selinux_app">
+ <uses-sdk android:targetSdkVersion="30"/>
+ <application
+ android:debuggable="true">
+ <activity android:name=".Empty"
+ android:exported="true" />
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation
+ android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.cts.appcompat.selinux_app" />
+
+</manifest>
diff --git a/hostsidetests/appcompat/compatchanges/selinuxapp/src/com/android/cts/appcompat/selinux_app/Empty.java b/hostsidetests/appcompat/compatchanges/selinuxapp/src/com/android/cts/appcompat/selinux_app/Empty.java
new file mode 100644
index 0000000..a350bc0
--- /dev/null
+++ b/hostsidetests/appcompat/compatchanges/selinuxapp/src/com/android/cts/appcompat/selinux_app/Empty.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.cts.appcompat.selinux_app;
+
+import android.app.Activity;
+
+public class Empty extends Activity {
+
+}
diff --git a/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/CompatChangesSelinuxTest.java b/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/CompatChangesSelinuxTest.java
new file mode 100644
index 0000000..1006c47
--- /dev/null
+++ b/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/CompatChangesSelinuxTest.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.appcompat;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import android.compat.cts.CompatChangeGatingTestCase;
+
+import com.google.common.collect.ImmutableSet;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Tests for the {@link android.app.compat.CompatChanges} SystemApi.
+ */
+
+public class CompatChangesSelinuxTest extends CompatChangeGatingTestCase {
+
+ protected static final String Q_TEST_APK = "CtsSelinuxQCompatApp.apk";
+ protected static final String R_TEST_APK = "CtsSelinuxRCompatApp.apk";
+
+ protected static final String TEST_PKG = "com.android.cts.appcompat.selinux_app";
+
+ private static final long SELINUX_LATEST_CHANGES = 143539591L;
+ private static final long SELINUX_R_CHANGES = 168782947L;
+
+ private static final Pattern PS_ENTRY_PATTERN = Pattern.compile("^(?<label>\\S+)\\s+(?<name>\\S+)");
+
+
+ public void testTargetSdkQAppIsInQDomainByDefault() throws Exception {
+ installPackage(Q_TEST_APK, false);
+ try {
+ startApp();
+ Map<String, String> packageToDomain = getPackageToDomain();
+
+ assertThat(packageToDomain).containsEntry(TEST_PKG, "untrusted_app_29");
+ } finally {
+ uninstallPackage(TEST_PKG, true);
+ }
+ }
+
+ public void testTargetSdkQAppIsInLatestDomainWithLatestOptin() throws Exception {
+ final Set<Long> enabledChanges = ImmutableSet.of(SELINUX_LATEST_CHANGES);
+ final Set<Long> disabledChanges = ImmutableSet.of();
+ final long configId = getClass().getCanonicalName().hashCode();
+
+ installPackage(Q_TEST_APK, false);
+ Thread.currentThread().sleep(100);
+ setCompatConfig(enabledChanges, disabledChanges, TEST_PKG);
+
+ try {
+ startApp();
+ Map<String, String> packageToDomain = getPackageToDomain();
+
+ assertThat(packageToDomain).containsEntry(TEST_PKG, "untrusted_app");
+
+ } finally {
+ resetCompatConfig(TEST_PKG, enabledChanges, disabledChanges);
+ uninstallPackage(TEST_PKG, true);
+ }
+ }
+
+ public void testTargetSdkQAppIsInRDomainWithROptin() throws Exception {
+ final Set<Long> enabledChanges = ImmutableSet.of(SELINUX_R_CHANGES);
+ final Set<Long> disabledChanges = ImmutableSet.of();
+
+ installPackage(Q_TEST_APK, false);
+ Thread.currentThread().sleep(100);
+ setCompatConfig(enabledChanges, disabledChanges, TEST_PKG);
+
+ try {
+ startApp();
+ Map<String, String> packageToDomain = getPackageToDomain();
+ // TODO(b/168782947): Update domain if/when an R specific one is created to
+ // differentiate from untrusted_app.
+ assertThat(packageToDomain).containsEntry(TEST_PKG, "untrusted_app");
+
+ } finally {
+ resetCompatConfig(TEST_PKG, enabledChanges, disabledChanges);
+ uninstallPackage(TEST_PKG, true);
+ }
+ }
+
+ public void testTargetSdkRAppIsInRDomainByDefault() throws Exception {
+ installPackage(R_TEST_APK, false);
+ try {
+ startApp();
+ Map<String, String> packageToDomain = getPackageToDomain();
+
+ assertThat(packageToDomain).containsEntry(TEST_PKG, "untrusted_app");
+ } finally {
+ uninstallPackage(TEST_PKG, true);
+ }
+ }
+
+ public void testTargetSdkRAppIsInLatestDomainWithLatestOptin() throws Exception {
+ final Set<Long> enabledChanges = ImmutableSet.of(SELINUX_LATEST_CHANGES);
+ final Set<Long> disabledChanges = ImmutableSet.of();
+ installPackage(R_TEST_APK, false);
+ Thread.currentThread().sleep(100);
+ setCompatConfig(enabledChanges, disabledChanges, TEST_PKG);
+
+ try {
+ startApp();
+ Map<String, String> packageToDomain = getPackageToDomain();
+ assertThat(packageToDomain).containsEntry(TEST_PKG, "untrusted_app");
+ } finally {
+ resetCompatConfig(TEST_PKG, enabledChanges, disabledChanges);
+ uninstallPackage(TEST_PKG, true);
+ }
+ }
+
+ private Map<String, String> getPackageToDomain() throws Exception {
+ Map<String, String> packageToDomain = new HashMap<>();
+ String output = getDevice().executeShellCommand("ps -e -o LABEL,NAME");
+ String[] lines = output.split("\n");
+ for (int i = 1; i < lines.length; ++i) {
+ String line = lines[i];
+ Matcher matcher = PS_ENTRY_PATTERN.matcher(line);
+ if (!matcher.matches())
+ continue;
+ String label = matcher.group("label");
+ String domain = label.split(":")[2];
+ String packageName = matcher.group("name");
+ packageToDomain.put(packageName, domain);
+ }
+ return packageToDomain;
+ }
+
+ private void startApp() throws Exception {
+ runCommand("am start -n " + TEST_PKG + "/" + TEST_PKG + ".Empty");
+ Thread.currentThread().sleep(100);
+ }
+
+
+}
diff --git a/hostsidetests/appcompat/host/lib/src/android/compat/cts/CompatChangeGatingTestCase.java b/hostsidetests/appcompat/host/lib/src/android/compat/cts/CompatChangeGatingTestCase.java
index 10803dd..28bd4d7 100644
--- a/hostsidetests/appcompat/host/lib/src/android/compat/cts/CompatChangeGatingTestCase.java
+++ b/hostsidetests/appcompat/host/lib/src/android/compat/cts/CompatChangeGatingTestCase.java
@@ -143,55 +143,53 @@
Set<Long> enabledChanges, Set<Long> disabledChanges,
Set<Long> reportedEnabledChanges, Set<Long> reportedDisabledChanges)
throws DeviceNotAvailableException {
+
// Set compat overrides
setCompatConfig(enabledChanges, disabledChanges, pkgName);
-
// Send statsd config
final long configId = getClass().getCanonicalName().hashCode();
createAndUploadStatsdConfig(configId, pkgName);
- // Run device-side test
- if (testClassName.startsWith(".")) {
- testClassName = pkgName + testClassName;
- }
- RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(pkgName, TEST_RUNNER,
- getDevice().getIDevice());
- testRunner.setMethodName(testClassName, testMethodName);
- CollectingTestListener listener = new CollectingTestListener();
- assertThat(getDevice().runInstrumentationTests(testRunner, listener)).isTrue();
-
- // Clear overrides.
- resetCompatChanges(enabledChanges, pkgName);
- resetCompatChanges(disabledChanges, pkgName);
-
- // Clear statsd report data and remove config
- Map<Long, Boolean> reportedChanges = getReportedChanges(configId, pkgName);
- removeStatsdConfig(configId);
-
- // Check that device side test occurred as expected
- final TestRunResult result = listener.getCurrentRunResults();
- assertWithMessage("Failed to successfully run device tests for %s: %s",
- result.getName(), result.getRunFailureMessage())
- .that(result.isRunFailure()).isFalse();
- assertWithMessage("Should run only exactly one test method!")
- .that(result.getNumTests()).isEqualTo(1);
- if (result.hasFailedTests()) {
- // build a meaningful error message
- StringBuilder errorBuilder = new StringBuilder("On-device test failed:\n");
- for (Map.Entry<TestDescription, TestResult> resultEntry :
- result.getTestResults().entrySet()) {
- if (!resultEntry.getValue().getStatus().equals(TestStatus.PASSED)) {
- errorBuilder.append(resultEntry.getKey().toString());
- errorBuilder.append(":\n");
- errorBuilder.append(resultEntry.getValue().getStackTrace());
- }
+ try {
+ // Run device-side test
+ if (testClassName.startsWith(".")) {
+ testClassName = pkgName + testClassName;
}
- throw new AssertionError(errorBuilder.toString());
+ RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(pkgName, TEST_RUNNER,
+ getDevice().getIDevice());
+ testRunner.setMethodName(testClassName, testMethodName);
+ CollectingTestListener listener = new CollectingTestListener();
+ assertThat(getDevice().runInstrumentationTests(testRunner, listener)).isTrue();
+
+ // Check that device side test occurred as expected
+ final TestRunResult result = listener.getCurrentRunResults();
+ assertWithMessage("Failed to successfully run device tests for %s: %s",
+ result.getName(), result.getRunFailureMessage())
+ .that(result.isRunFailure()).isFalse();
+ assertWithMessage("Should run only exactly one test method!")
+ .that(result.getNumTests()).isEqualTo(1);
+ if (result.hasFailedTests()) {
+ // build a meaningful error message
+ StringBuilder errorBuilder = new StringBuilder("On-device test failed:\n");
+ for (Map.Entry<TestDescription, TestResult> resultEntry :
+ result.getTestResults().entrySet()) {
+ if (!resultEntry.getValue().getStatus().equals(TestStatus.PASSED)) {
+ errorBuilder.append(resultEntry.getKey().toString());
+ errorBuilder.append(":\n");
+ errorBuilder.append(resultEntry.getValue().getStackTrace());
+ }
+ }
+ throw new AssertionError(errorBuilder.toString());
+ }
+
+ } finally {
+ // Cleanup compat overrides
+ resetCompatConfig(pkgName, enabledChanges, disabledChanges);
+ // Validate statsd report
+ validatePostRunStatsdReport(configId, pkgName, reportedEnabledChanges,
+ reportedDisabledChanges);
}
- // Validate statsd report
- validatePostRunStatsdReport(reportedChanges, reportedEnabledChanges,
- reportedDisabledChanges);
}
/**
@@ -218,7 +216,7 @@
* @param pkgName The package name of the app that is expected to report the atom. It will be
* the only allowed log source.
*/
- private void createAndUploadStatsdConfig(long configId, String pkgName)
+ protected void createAndUploadStatsdConfig(long configId, String pkgName)
throws DeviceNotAvailableException {
final String atomName = "Atom" + System.nanoTime();
final String eventName = "Event" + System.nanoTime();
@@ -253,6 +251,8 @@
} catch (IOException e) {
throw new RuntimeException("IO error when writing to temp file.", e);
}
+ // Purge data
+ getReportList(configId);
}
/**
@@ -279,7 +279,7 @@
* @param disabledChanges Changes to be disabled.
* @param packageName Package name for the app whose config is being changed.
*/
- private void setCompatConfig(Set<Long> enabledChanges, Set<Long> disabledChanges,
+ protected void setCompatConfig(Set<Long> enabledChanges, Set<Long> disabledChanges,
@Nonnull String packageName) throws DeviceNotAvailableException {
for (Long enabledChange : enabledChanges) {
runCommand("am compat enable " + enabledChange + " " + packageName);
@@ -292,7 +292,7 @@
/**
* Reset changes to default for a package.
*/
- private void resetCompatChanges(Set<Long> changes, @Nonnull String packageName)
+ protected void resetCompatChanges(Set<Long> changes, @Nonnull String packageName)
throws DeviceNotAvailableException {
for (Long change : changes) {
runCommand("am compat reset " + change + " " + packageName);
@@ -333,16 +333,41 @@
}
/**
- * Validate that all overridden changes were logged while running the test.
+ * Cleanup the altered change ids under test.
+ *
+ * @param pkgName Package name of the app under test.
+ * @param enabledChanges Set of changes that were enabled during the test and need to be
+ * reset to the default value.
+ * @param disabledChanges Set of changes that were disabled during the test and need to
+ * be reset to the default value.
*/
- private void validatePostRunStatsdReport(Map<Long, Boolean> reportedChanges,
- Set<Long> enabledChanges, Set<Long> disabledChanges)
+ protected void resetCompatConfig( String pkgName, Set<Long> enabledChanges,
+ Set<Long> disabledChanges) throws DeviceNotAvailableException {
+ // Clear overrides.
+ resetCompatChanges(enabledChanges, pkgName);
+ resetCompatChanges(disabledChanges, pkgName);
+ }
+
+ /**
+ * Validate that all overridden changes were logged while running the test.
+ *
+ * @param configId The unique config id used to track change id queries.
+ * @param pkgName Package name of the app under test.
+ * @param loggedEnabledChanges Changes expected to be logged as enabled during the test.
+ * @param loggedDisabledChanges Changes expected to be logged as disabled during the test.
+ */
+ protected void validatePostRunStatsdReport(long configId, String pkgName,
+ Set<Long> loggedEnabledChanges, Set<Long> loggedDisabledChanges)
throws DeviceNotAvailableException {
- for (Long enabledChange : enabledChanges) {
+ // Clear statsd report data and remove config
+ Map<Long, Boolean> reportedChanges = getReportedChanges(configId, pkgName);
+ removeStatsdConfig(configId);
+
+ for (Long enabledChange : loggedEnabledChanges) {
assertThat(reportedChanges)
.containsEntry(enabledChange, true);
}
- for (Long disabledChange : disabledChanges) {
+ for (Long disabledChange : loggedDisabledChanges) {
assertThat(reportedChanges)
.containsEntry(disabledChange, false);
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/AuthBoundKeyTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/AuthBoundKeyTest.java
index 13773bc..2952f83 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/AuthBoundKeyTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/AuthBoundKeyTest.java
@@ -54,19 +54,20 @@
assumeTrue("Device does not support secure lock",
getDevice().hasFeature("android.software.secure_lock_screen"));
new InstallMultiple().addFile(APK).run();
- getDevice().executeShellCommand("cmd lock_settings set-pin 1234");
- runDeviceTests(PKG, CLASS, "testGenerateAuthBoundKey");
- getDevice().executeShellCommand("cmd lock_settings clear --old 1234");
- runDeviceTests(PKG, CLASS, "testUseKey");
- getDevice().executeShellCommand("cmd lock_settings set-pin 12345");
- getDevice().executeShellCommand("input keyevent 26"); // Screen on
- getDevice().executeShellCommand("input keyevent 82"); // Bring up lock screen
- getDevice().executeShellCommand("input text 12345"); // Input password
- getDevice().executeShellCommand("input keyevent 66"); // Submit input
- // try:finally clause to ensure the pin is wiped before testing continues
try {
+ // try:finally clause to ensure the pin is wiped before testing continues
+ getDevice().executeShellCommand("cmd lock_settings set-pin 1234");
+ runDeviceTests(PKG, CLASS, "testGenerateAuthBoundKey");
+ getDevice().executeShellCommand("cmd lock_settings clear --old 1234");
+ runDeviceTests(PKG, CLASS, "testUseKey");
+ getDevice().executeShellCommand("cmd lock_settings set-pin 12345");
+ getDevice().executeShellCommand("input keyevent 26"); // Screen on
+ getDevice().executeShellCommand("input keyevent 82"); // Bring up lock screen
+ getDevice().executeShellCommand("input text 12345"); // Input password
+ getDevice().executeShellCommand("input keyevent 66"); // Submit input
runDeviceTests(PKG, CLASS, "testUseKey");
} finally {
+ getDevice().executeShellCommand("cmd lock_settings clear --old 1234");
getDevice().executeShellCommand("cmd lock_settings clear --old 12345");
}
}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java
index e6abac7..8468c37 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java
@@ -36,6 +36,7 @@
import androidx.test.InstrumentationRegistry;
import java.time.Duration;
+import com.android.compatibility.common.util.PollingCheck;
/**
* Test class that is meant to be driven from the host and can't be run alone, which is required
@@ -257,8 +258,10 @@
String activityName =
mActivityManager.getAppTasks().get(0).getTaskInfo().topActivity.getClassName();
assertEquals(LOCK_TASK_ACTIVITY, activityName);
- assertEquals(
- ActivityManager.LOCK_TASK_MODE_LOCKED, mActivityManager.getLockTaskModeState());
+
+ PollingCheck.waitFor(
+ () -> (mActivityManager.getLockTaskModeState()
+ == ActivityManager.LOCK_TASK_MODE_LOCKED));
}
/**
diff --git a/hostsidetests/hdmicec/src/android/hdmicec/cts/targetprep/CecPortDiscoverer.java b/hostsidetests/hdmicec/src/android/hdmicec/cts/targetprep/CecPortDiscoverer.java
index 5d49cb9..51cde47 100644
--- a/hostsidetests/hdmicec/src/android/hdmicec/cts/targetprep/CecPortDiscoverer.java
+++ b/hostsidetests/hdmicec/src/android/hdmicec/cts/targetprep/CecPortDiscoverer.java
@@ -110,7 +110,8 @@
}
serialNo = device.getProperty("ro.serialno");
- String serialNoParam = CecMessage.convertStringToHexParams(serialNo);
+ String serialNoHashCode = String.valueOf(serialNo.hashCode());
+ String serialNoParam = CecMessage.convertStringToHexParams(serialNoHashCode);
/*
* formatParams prefixes with a ':' that we do not want in the vendorcommand
* command line utility.
diff --git a/suite/audio_quality/Android.mk b/suite/audio_quality/Android.mk
deleted file mode 100644
index 9cf5dc8..0000000
--- a/suite/audio_quality/Android.mk
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# build only for linux
-ifeq ($(HOST_OS),linux)
-
-CTS_AUDIO_TOP:= $(call my-dir)
-
-include $(call all-makefiles-under,$(CTS_AUDIO_TOP))
-
-CTS_AUDIO_INSTALL_DIR := $(HOST_OUT)/cts-audio-quality/android-cts-audio-quality
-CTS_AUDIO_QUALITY_ZIP := $(HOST_OUT)/cts-audio-quality/android-cts-audio-quality.zip
-
-cts_audio_quality_client_apk := $(TARGET_OUT_DATA_APPS)/CtsAudioClient/CtsAudioClient.apk
-cts_audio_quality_host_bins := $(ALL_MODULES.cts_audio_quality_test.INSTALLED) $(ALL_MODULES.cts_audio_quality.INSTALLED)
-$(CTS_AUDIO_QUALITY_ZIP): PRIVATE_CLIENT_APK := $(cts_audio_quality_client_apk)
-$(CTS_AUDIO_QUALITY_ZIP): PRIVATE_HOST_BINS := $(cts_audio_quality_host_bins)
-$(CTS_AUDIO_QUALITY_ZIP): PRIVATE_TEST_DESC := $(CTS_AUDIO_TOP)/test_description
-$(CTS_AUDIO_QUALITY_ZIP): $(cts_audio_quality_client_apk) $(cts_audio_quality_host_bins) \
- $(CTS_AUDIO_TOP)/test_description | $(ACP)
- $(hide) rm -rf $@ $(CTS_AUDIO_INSTALL_DIR)
- $(hide) mkdir -p $(CTS_AUDIO_INSTALL_DIR)/client
- $(hide) $(ACP) -fp $(PRIVATE_CLIENT_APK) \
- $(CTS_AUDIO_INSTALL_DIR)/client
- $(hide) $(ACP) -fp $(PRIVATE_HOST_BINS) $(CTS_AUDIO_INSTALL_DIR)
- $(hide) $(ACP) -fr $(PRIVATE_TEST_DESC) $(CTS_AUDIO_INSTALL_DIR)
- $(hide) echo "Package cts_audio: $@"
- $(hide) cd $(dir $@) && \
- zip -rq $(notdir $@) android-cts-audio-quality -x android-cts-audio-quality/reports/\*
-
-cts_audio_quality_client_apk :=
-cts_audio_quality_host_bins :=
-
-# target to build only this package
-.PHONY: cts_audio_quality_package
-cts_audio_quality_package: $(CTS_AUDIO_QUALITY_ZIP)
-
-cts: $(CTS_AUDIO_QUALITY_ZIP)
-
-$(call dist-for-goals, cts, $(CTS_AUDIO_QUALITY_ZIP))
-
-endif # linux
diff --git a/suite/audio_quality/BUILD.txt b/suite/audio_quality/BUILD.txt
deleted file mode 100644
index eff8074..0000000
--- a/suite/audio_quality/BUILD.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-C++: No special library required in host side, but gcc/g++ and std c++ library should be present.
-Python : version 2.6.5 or higher (should be /usr/bin/python)
-Necessary Python libraries:
- - Python SciPy, NumPy
- sudo apt-get install python-scipy python-numpy python-matplotlib
-
-run make cts_audio frop top dir.
\ No newline at end of file
diff --git a/suite/audio_quality/client/Android.mk b/suite/audio_quality/client/Android.mk
deleted file mode 100644
index edef96b..0000000
--- a/suite/audio_quality/client/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CtsAudioClient
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.cfg
-
-# intentional to keep compatibility with ICS
-LOCAL_SDK_VERSION := 15
-
-LOCAL_DEX_PREOPT := false
-
-include $(BUILD_PACKAGE)
diff --git a/suite/audio_quality/client/AndroidManifest.xml b/suite/audio_quality/client/AndroidManifest.xml
deleted file mode 100644
index 70a6b7e..0000000
--- a/suite/audio_quality/client/AndroidManifest.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.cts.audiotest" >
-<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
-<uses-permission android:name="android.permission.INTERNET"/>
-<uses-permission android:name="android.permission.RECORD_AUDIO"/>
-
- <application
- android:label="@string/app_name" >
- <activity
- android:name=".CtsAudioClientActivity"
- android:label="@string/app_name"
- android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
\ No newline at end of file
diff --git a/suite/audio_quality/client/proguard.cfg b/suite/audio_quality/client/proguard.cfg
deleted file mode 100644
index 3d6191f..0000000
--- a/suite/audio_quality/client/proguard.cfg
+++ /dev/null
@@ -1,33 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
-
--keepclasseswithmembernames class * {
- native <methods>;
-}
-
--keepclasseswithmembers class * {
- public <init>(android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public <init>(android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
diff --git a/suite/audio_quality/client/res/layout/main.xml b/suite/audio_quality/client/res/layout/main.xml
deleted file mode 100644
index 60ef9c8..0000000
--- a/suite/audio_quality/client/res/layout/main.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
-</LinearLayout>
\ No newline at end of file
diff --git a/suite/audio_quality/client/src/com/android/cts/audiotest/AudioProtocol.java b/suite/audio_quality/client/src/com/android/cts/audiotest/AudioProtocol.java
deleted file mode 100644
index 3c45a8a..0000000
--- a/suite/audio_quality/client/src/com/android/cts/audiotest/AudioProtocol.java
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.audiotest;
-
-import android.app.Activity;
-import android.media.AudioFormat;
-import android.media.AudioManager;
-import android.media.AudioRecord;
-import android.media.MediaRecorder.AudioSource;
-import android.media.AudioTrack;
-import android.os.Build;
-import android.os.Looper;
-import android.util.Log;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.Thread;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketTimeoutException;
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.concurrent.locks.ReentrantLock;
-
-
-public class AudioProtocol implements AudioTrack.OnPlaybackPositionUpdateListener {
- private static final String TAG = "AudioProtocol";
- private static final int PORT_NUMBER = 15001;
-
- private Thread mThread = new Thread(new ProtocolServer());
- private boolean mExitRequested = false;
-
- private static final int PROTOCOL_HEADER_SIZE = 8; // id + payload length
- private static final int MAX_NON_DATA_PAYLOAD_SIZE = 20;
- private static final int PROTOCOL_SIMPLE_REPLY_SIZE = 12;
- private static final int PROTOCOL_OK = 0;
- private static final int PROTOCOL_ERROR_WRONG_PARAM = 1;
- private static final int PROTOCOL_ERROR_GENERIC = 2;
-
- private static final int CMD_DOWNLOAD = 0x12340001;
- private static final int CMD_START_PLAYBACK = 0x12340002;
- private static final int CMD_STOP_PLAYBACK = 0x12340003;
- private static final int CMD_START_RECORDING = 0x12340004;
- private static final int CMD_STOP_RECORDING = 0x12340005;
- private static final int CMD_GET_DEVICE_INFO = 0x12340006;
-
- private ByteBuffer mHeaderBuffer = ByteBuffer.allocate(PROTOCOL_HEADER_SIZE);
- private ByteBuffer mDataBuffer = ByteBuffer.allocate(MAX_NON_DATA_PAYLOAD_SIZE);
- private ByteBuffer mReplyBuffer = ByteBuffer.allocate(PROTOCOL_SIMPLE_REPLY_SIZE);
-
- // all socket access (accept / read) set this timeout to check exit periodically.
- private static final int SOCKET_ACCESS_TIMEOUT = 2000;
- private Socket mClient = null;
- private InputStream mInput = null;
- private OutputStream mOutput = null;
- // lock to use to write to socket, I/O streams, and also change socket (create, destroy)
- private ReentrantLock mClientLock = new ReentrantLock();
-
- private AudioRecord mRecord = null;
- private LoopThread mRecordThread = null;
- private AudioTrack mPlayback = null;
- private LoopThread mPlaybackThread = null;
- // store recording length
- private int mRecordingLength = 0;
-
- // map for playback data
- private HashMap<Integer, ByteBuffer> mDataMap = new HashMap<Integer, ByteBuffer>();
-
- public boolean start() {
- Log.d(TAG, "start");
- mExitRequested = false;
- mThread.start();
- //Log.d(TAG, "started");
- return true;
- }
-
- public void stop() throws InterruptedException {
- Log.d(TAG, "stop");
- mExitRequested = true;
- try {
- mClientLock.lock();
- if (mClient != null) {
- // wake up from socket read
- mClient.shutdownInput();
- }
- }catch (IOException e) {
- // ignore
- } finally {
- mClientLock.unlock();
- }
- mThread.interrupt(); // this does not bail out from socket in android
- mThread.join();
- reset();
- Log.d(TAG, "stopped");
- }
-
- @Override
- public void onMarkerReached(AudioTrack track) {
- Log.d(TAG, "playback completed");
- track.stop();
- track.flush();
- track.release();
- mPlaybackThread.quitLoop();
- mPlaybackThread = null;
- try {
- sendSimpleReplyHeader(CMD_START_PLAYBACK, PROTOCOL_OK);
- } catch (IOException e) {
- // maybe socket already closed. don't do anything
- Log.e(TAG, "ignore exception", e);
- }
- }
-
- @Override
- public void onPeriodicNotification(AudioTrack arg0) {
- Log.d(TAG, "track periodic notification");
- // TODO Auto-generated method stub
- }
-
- /**
- * Read given amount of data to the buffer
- * @param in
- * @param buffer
- * @param len length to read
- * @return true if header read successfully, false if exit requested
- * @throws IOException
- * @throws ExitRequest
- */
- private void read(InputStream in, ByteBuffer buffer, int len) throws IOException, ExitRequest {
- buffer.clear();
- int totalRead = 0;
- while (totalRead < len) {
- int readNow = in.read(buffer.array(), totalRead, len - totalRead);
- if (readNow < 0) { // end-of-stream, error
- Log.e(TAG, "read returned " + readNow);
- throw new IOException();
- }
- totalRead += readNow;
- if(mExitRequested) {
- throw new ExitRequest();
- }
- }
- }
-
- private class ProtocolError extends Exception {
- public ProtocolError(String message) {
- super(message);
- }
- }
-
- private class ExitRequest extends Exception {
- public ExitRequest() {
- super();
- }
- }
-
- private void assertProtocol(boolean cond, String message) throws ProtocolError {
- if (!cond) {
- throw new ProtocolError(message);
- }
- }
-
- private void reset() {
- // lock only when it is not already locked by this thread
- if (mClientLock.getHoldCount() == 0) {
- mClientLock.lock();
- }
- if (mClient != null) {
- try {
- mClient.close();
- } catch (IOException e) {
- // ignore
- }
- mClient = null;
- }
- mInput = null;
- mOutput = null;
- while (mClientLock.getHoldCount() > 0) {
- mClientLock.unlock();
- }
- if (mRecord != null) {
- if (mRecord.getState() != AudioRecord.STATE_UNINITIALIZED) {
- mRecord.stop();
- }
- mRecord.release();
- mRecord = null;
- }
- if (mRecordThread != null) {
- mRecordThread.quitLoop();
- mRecordThread = null;
- }
- if (mPlayback != null) {
- if (mPlayback.getState() != AudioTrack.STATE_UNINITIALIZED) {
- mPlayback.stop();
- mPlayback.flush();
- }
- mPlayback.release();
- mPlayback = null;
- }
- if (mPlaybackThread != null) {
- mPlaybackThread.quitLoop();
- mPlaybackThread = null;
- }
- mDataMap.clear();
- }
-
- private void handleDownload(int len) throws IOException, ExitRequest {
- read(mInput, mDataBuffer, 4); // only for id
- Integer id = new Integer(mDataBuffer.getInt(0));
- int dataLength = len - 4;
- ByteBuffer data = ByteBuffer.allocate(dataLength);
- read(mInput, data, dataLength);
- mDataMap.put(id, data);
- Log.d(TAG, "downloaded data id " + id + " len " + dataLength);
- sendSimpleReplyHeader(CMD_DOWNLOAD, PROTOCOL_OK);
- }
-
- private void handleStartPlayback(int len) throws ProtocolError, IOException, ExitRequest {
- // this error is too critical, so do not even send reply
- assertProtocol(len == 20, "wrong payload len");
- read(mInput, mDataBuffer, len);
- final Integer id = new Integer(mDataBuffer.getInt(0));
- final int samplingRate = mDataBuffer.getInt(1 * 4);
- final boolean stereo = ((mDataBuffer.getInt(2 * 4) & 0x80000000) != 0);
- final int mode = mDataBuffer.getInt(2 * 4) & 0x7fffffff;
- final int volume = mDataBuffer.getInt(3 * 4);
- final int repeat = mDataBuffer.getInt(4 * 4);
- try {
- final ByteBuffer data = mDataMap.get(id);
- if (data == null) {
- throw new ProtocolError("wrong id");
- }
- if (samplingRate != 44100) {
- throw new ProtocolError("wrong rate");
- }
- //FIXME in MODE_STATIC, setNotificationMarkerPosition does not work with full length
- mPlaybackThread = new LoopThread(new Runnable() {
-
- @Override
- public void run() {
- if (mPlayback != null) {
- mPlayback.release();
- mPlayback = null;
- }
- // STREAM_VOICE_CALL activates different speaker.
- // use MUSIC mode to activate the louder speaker.
- int type = AudioManager.STREAM_MUSIC;
- int bufferSize = AudioTrack.getMinBufferSize(samplingRate,
- stereo ? AudioFormat.CHANNEL_OUT_STEREO : AudioFormat.CHANNEL_OUT_MONO,
- AudioFormat.ENCODING_PCM_16BIT);
- bufferSize = bufferSize * 4;
- if (bufferSize < 256 * 1024) {
- bufferSize = 256 * 1024;
- }
- if (bufferSize > data.capacity()) {
- bufferSize = data.capacity();
- }
- mPlayback = new AudioTrack(type, samplingRate,
- stereo ? AudioFormat.CHANNEL_OUT_STEREO : AudioFormat.CHANNEL_OUT_MONO,
- AudioFormat.ENCODING_PCM_16BIT, bufferSize,
- AudioTrack.MODE_STREAM);
- float minVolume = mPlayback.getMinVolume();
- float maxVolume = mPlayback.getMaxVolume();
- float newVolume = (maxVolume - minVolume) * volume / 100 + minVolume;
- mPlayback.setStereoVolume(newVolume, newVolume);
- Log.d(TAG, "setting volume " + newVolume + " max " + maxVolume +
- " min " + minVolume + " received " + volume);
- int dataWritten = 0;
- int dataToWrite = (bufferSize < data.capacity())? bufferSize : data.capacity();
- mPlayback.write(data.array(), 0, dataToWrite);
- dataWritten = dataToWrite;
- mPlayback.setPlaybackPositionUpdateListener(AudioProtocol.this);
-
- int endMarker = data.capacity()/(stereo ? 4 : 2);
- int res = mPlayback.setNotificationMarkerPosition(endMarker);
- Log.d(TAG, "start playback id " + id + " len " + data.capacity() +
- " set.. res " + res + " stereo? " + stereo + " mode " + mode +
- " end " + endMarker);
- mPlayback.play();
- while (dataWritten < data.capacity()) {
- int dataLeft = data.capacity() - dataWritten;
- dataToWrite = (bufferSize < dataLeft)? bufferSize : dataLeft;
- if (mPlayback == null) { // stopped
- return;
- }
- mPlayback.write(data.array(), dataWritten, dataToWrite);
- dataWritten += dataToWrite;
- }
- }
- });
- mPlaybackThread.start();
- // send reply when play is completed
- } catch (ProtocolError e) {
- sendSimpleReplyHeader(CMD_START_PLAYBACK, PROTOCOL_ERROR_WRONG_PARAM);
- Log.e(TAG, "wrong param", e);
- }
- }
-
- private void handleStopPlayback(int len) throws ProtocolError, IOException {
- Log.d(TAG, "stopPlayback");
- assertProtocol(len == 0, "wrong payload len");
- if (mPlayback != null) {
- Log.d(TAG, "release AudioTrack");
- mPlayback.stop();
- mPlayback.flush();
- mPlayback.release();
- mPlayback = null;
- }
- if (mPlaybackThread != null) {
- mPlaybackThread.quitLoop();
- mPlaybackThread = null;
- }
- sendSimpleReplyHeader(CMD_STOP_PLAYBACK, PROTOCOL_OK);
- }
-
- private void handleStartRecording(int len) throws ProtocolError, IOException, ExitRequest {
- assertProtocol(len == 16, "wrong payload len");
- read(mInput, mDataBuffer, len);
- final int samplingRate = mDataBuffer.getInt(0);
- final boolean stereo = ((mDataBuffer.getInt(1 * 4) & 0x80000000) != 0);
- final int mode = mDataBuffer.getInt(1 * 4) & 0x7fffffff;
- final int volume = mDataBuffer.getInt(2 * 4);
- final int samples = mDataBuffer.getInt(3 * 4);
- try {
- if (samplingRate != 44100) {
- throw new ProtocolError("wrong rate");
- }
- if (stereo) {
- throw new ProtocolError("mono only");
- }
- //TODO volume ?
- mRecordingLength = samples * 2;
- mRecordThread = new LoopThread(new Runnable() {
-
- @Override
- public void run() {
- int minBufferSize = AudioRecord.getMinBufferSize(samplingRate,
- AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
- int type = (mode == 0) ? AudioSource.VOICE_RECOGNITION : AudioSource.DEFAULT;
- mRecord = new AudioRecord(type, samplingRate,
- AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT,
- (minBufferSize > mRecordingLength) ? minBufferSize : mRecordingLength);
-
- mRecord.startRecording();
- Log.d(TAG, "recording started " + " samples " + samples + " mode " + mode +
- " recording state " + mRecord.getRecordingState() + " len " +
- mRecordingLength);
- try {
- boolean recordingOk = true;
- byte[] data = new byte[mRecordingLength];
- int totalRead = 0;
- while (totalRead < mRecordingLength) {
- int lenRead = mRecord.read(data, 0, (mRecordingLength - totalRead));
- if (lenRead < 0) {
- Log.e(TAG, "reading recording failed with error code " + lenRead);
- recordingOk = false;
- break;
- } else if (lenRead == 0) {
- Log.w(TAG, "zero read");
- }
- totalRead += lenRead;
- }
- Log.d(TAG, "reading recording completed");
- sendReplyWithData(
- CMD_START_RECORDING,
- recordingOk ? PROTOCOL_OK : PROTOCOL_ERROR_GENERIC,
- recordingOk ? mRecordingLength : 0,
- recordingOk ? data : null);
- } catch (IOException e) {
- // maybe socket already closed. don't do anything
- Log.e(TAG, "ignore exception", e);
- } finally {
- mRecord.stop();
- mRecord.release();
- mRecord = null;
- }
- }
- });
- mRecordThread.start();
- } catch (ProtocolError e) {
- sendSimpleReplyHeader(CMD_START_RECORDING, PROTOCOL_ERROR_WRONG_PARAM);
- Log.e(TAG, "wrong param", e);
- }
- }
-
- private void handleStopRecording(int len) throws ProtocolError, IOException {
- Log.d(TAG, "stop recording");
- assertProtocol(len == 0, "wrong payload len");
- if (mRecord != null) {
- mRecord.stop();
- mRecord.release();
- mRecord = null;
- }
- if (mRecordThread != null) {
- mRecordThread.quitLoop();
- mRecordThread = null;
- }
- sendSimpleReplyHeader(CMD_STOP_RECORDING, PROTOCOL_OK);
- }
-
- private static final String BUILD_INFO_TAG = "build-info";
-
- private void appendAttrib(StringBuilder builder, String name, String value) {
- builder.append(" " + name + "=\"" + value + "\"");
- }
-
- private void handleGetDeviceInfo(int len) throws ProtocolError, IOException{
- Log.d(TAG, "getDeviceInfo");
- assertProtocol(len == 0, "wrong payload len");
- StringBuilder builder = new StringBuilder();
- builder.append("<build-info");
- appendAttrib(builder, "board", Build.BOARD);
- appendAttrib(builder, "brand", Build.BRAND);
- appendAttrib(builder, "device", Build.DEVICE);
- appendAttrib(builder, "display", Build.DISPLAY);
- appendAttrib(builder, "fingerprint", Build.FINGERPRINT);
- appendAttrib(builder, "id", Build.ID);
- appendAttrib(builder, "model", Build.MODEL);
- appendAttrib(builder, "product", Build.PRODUCT);
- appendAttrib(builder, "release", Build.VERSION.RELEASE);
- appendAttrib(builder, "sdk", Integer.toString(Build.VERSION.SDK_INT));
- builder.append(" />");
- byte[] data = builder.toString().getBytes();
-
- sendReplyWithData(CMD_GET_DEVICE_INFO, PROTOCOL_OK, data.length, data);
- }
- /**
- * send reply without payload.
- * This function is thread-safe.
- * @param out
- * @param command
- * @param errorCode
- * @throws IOException
- */
- private void sendSimpleReplyHeader(int command, int errorCode) throws IOException {
- Log.d(TAG, "sending reply cmd " + command + " err " + errorCode);
- sendReplyWithData(command, errorCode, 0, null);
- }
-
- private void sendReplyWithData(int cmd, int errorCode, int len, byte[] data) throws IOException {
- try {
- mClientLock.lock();
- mReplyBuffer.clear();
- mReplyBuffer.putInt((cmd & 0xffff) | 0x43210000);
- mReplyBuffer.putInt(errorCode);
- mReplyBuffer.putInt(len);
-
- if (mOutput != null) {
- mOutput.write(mReplyBuffer.array(), 0, PROTOCOL_SIMPLE_REPLY_SIZE);
- if (data != null) {
- mOutput.write(data, 0, len);
- }
- }
- } catch (IOException e) {
- throw e;
- } finally {
- mClientLock.unlock();
- }
- }
- private class LoopThread extends Thread {
- private Looper mLooper;
- LoopThread(Runnable runnable) {
- super(runnable);
- }
- public void run() {
- Looper.prepare();
- mLooper = Looper.myLooper();
- Log.d(TAG, "run runnable");
- super.run();
- //Log.d(TAG, "loop");
- Looper.loop();
- }
- // should be called outside this thread
- public void quitLoop() {
- mLooper.quit();
- try {
- if (Thread.currentThread() != this) {
- join();
- }
- } catch (InterruptedException e) {
- // ignore
- }
- Log.d(TAG, "quit thread");
- }
- }
-
- private class ProtocolServer implements Runnable {
-
- @Override
- public void run() {
- ServerSocket server = null;
-
- try { // for catching exception from ServerSocket
- Log.d(TAG, "get new server socket");
- server = new ServerSocket(PORT_NUMBER);
- server.setReuseAddress(true);
- server.setSoTimeout(SOCKET_ACCESS_TIMEOUT);
- while (!mExitRequested) {
- //TODO check already active recording/playback
- try { // for catching exception from Socket, will restart upon exception
- try {
- mClientLock.lock();
- //Log.d(TAG, "will accept");
- mClient = server.accept();
- mClient.setReuseAddress(true);
- mInput = mClient.getInputStream();
- mOutput = mClient.getOutputStream();
- } catch (SocketTimeoutException e) {
- // This will happen frequently if client does not connect.
- // just re-start
- continue;
- } finally {
- mClientLock.unlock();
- }
- Log.i(TAG, "new client connected");
- while (!mExitRequested) {
- read(mInput, mHeaderBuffer, PROTOCOL_HEADER_SIZE);
- int command = mHeaderBuffer.getInt();
- int len = mHeaderBuffer.getInt();
- Log.i(TAG, "received command " + command);
- switch(command) {
- case CMD_DOWNLOAD:
- handleDownload(len);
- break;
- case CMD_START_PLAYBACK:
- handleStartPlayback(len);
- break;
- case CMD_STOP_PLAYBACK:
- handleStopPlayback(len);
- break;
- case CMD_START_RECORDING:
- handleStartRecording(len);
- break;
- case CMD_STOP_RECORDING:
- handleStopRecording(len);
- break;
- case CMD_GET_DEVICE_INFO:
- handleGetDeviceInfo(len);
- }
- }
- } catch (IOException e) {
- Log.e(TAG, "restart from exception", e);
- } catch (ProtocolError e) {
- Log.e(TAG, "restart from exception", e);
- } finally {
- reset();
- }
- }
- } catch (ExitRequest e) {
- Log.e(TAG, "exit requested, will exit", e);
- } catch (IOException e) {
- // error in server socket, just exit the thread and let things fail.
- Log.e(TAG, "error while init, will exit", e);
- } finally {
- if (server != null) {
- try {
- server.close();
- } catch (IOException e) {
- // ignore
- }
- }
- reset();
- }
- }
- }
-}
diff --git a/suite/audio_quality/client/src/com/android/cts/audiotest/CtsAudioClientActivity.java b/suite/audio_quality/client/src/com/android/cts/audiotest/CtsAudioClientActivity.java
deleted file mode 100644
index 7fc4960..0000000
--- a/suite/audio_quality/client/src/com/android/cts/audiotest/CtsAudioClientActivity.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.audiotest;
-
-import android.app.Activity;
-import android.app.KeyguardManager;
-import android.content.Context;
-import android.media.AudioManager;
-import android.os.Bundle;
-
-
-public class CtsAudioClientActivity extends Activity {
- private AudioProtocol mProtocol = null;
- int mVolumeMusic;
- int mVolumeVoice;
- @Override
- protected void onPause() {
- try {
- mProtocol.stop();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- mProtocol = null;
- setVolume(AudioManager.STREAM_MUSIC, mVolumeMusic);
- setVolume(AudioManager.STREAM_VOICE_CALL, mVolumeVoice);
- super.onPause();
- }
-
- @Override
- protected void onResume() {
- // set volume to max
- mVolumeMusic = setVolume(AudioManager.STREAM_MUSIC, -1);
- mVolumeVoice = setVolume(AudioManager.STREAM_VOICE_CALL, -1);
- mProtocol = new AudioProtocol();
- mProtocol.start();
- super.onResume();
- }
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- KeyguardManager keyguardManager =
- (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
- keyguardManager.newKeyguardLock("cts-audio").disableKeyguard();
- }
-
- /**
- * set volume to desired level
- * @param level target level, if -1, set to max
- * @return the original volume level
- */
- int setVolume(int stream, int level) {
- AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- mgr.setStreamMute(stream, false);
- int original = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
- int targetLevel = level;
- if (level == -1) {
- targetLevel = mgr.getStreamMaxVolume(stream);
- }
- mgr.setStreamVolume(stream, targetLevel, 0);
- return original;
- }
-}
\ No newline at end of file
diff --git a/suite/audio_quality/executable/Android.bp b/suite/audio_quality/executable/Android.bp
deleted file mode 100644
index dff1431..0000000
--- a/suite/audio_quality/executable/Android.bp
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// Copyright (C) 2012 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_binary_host {
- name: "cts_audio_quality",
- srcs: ["src/main.cpp"],
- static_libs: [
- "libbase",
- "libutils",
- "liblog",
- "libcutils",
- "libtinyalsa",
- "libtinyxml2",
- ],
- whole_static_libs: ["libcts_audio_quality"],
- cflags: [
- "-Wall",
- "-Werror",
- "-g",
- "-fno-exceptions",
- ],
- ldflags: [
- "-g",
- "-fno-exceptions",
- ],
- stl: "libc++_static",
- target: {
- darwin: {
- enabled: false,
- },
- },
-}
diff --git a/suite/audio_quality/executable/src/main.cpp b/suite/audio_quality/executable/src/main.cpp
deleted file mode 100644
index 0e969d1..0000000
--- a/suite/audio_quality/executable/src/main.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <getopt.h>
-#include <stdio.h>
-
-#include <utils/String8.h>
-
-#include <memory>
-
-#include "GenericFactory.h"
-#include "Log.h"
-#include "Report.h"
-#include "Settings.h"
-#include "task/TaskGeneric.h"
-#include "task/ModelBuilder.h"
-
-// For flushing report and log before exiting
-class CleanupStatics {
-public:
-
- CleanupStatics() {
-
- }
- ~CleanupStatics() {
- Log::Finalize();
- Report::Finalize();
- // create zip file after log and report files are closed.
- android::String8 reportDirPath =
- Settings::Instance()->getSetting(Settings::EREPORT_FILE).getPathDir();
- android::String8 zipFilename = reportDirPath.getPathLeaf();
- android::String8 command = android::String8::format("cd %s;zip -r ../%s.zip *",
- reportDirPath.string(), zipFilename.string());
- fprintf(stderr, "\n\nexecuting %s\n", command.string());
- if (system(command.string()) == -1) {
- fprintf(stderr, "cannot create zip file with command %s\n", command.string());
- }
- Settings::Finalize();
- }
-};
-
-void usage(char* bin)
-{
- fprintf(stderr, "%s [-l log_level][-s serial] test_xml\n", bin);
-}
-int main(int argc, char *argv[])
-{
- if (argc < 2) {
- fprintf(stderr, "%s [-l log_level][-s serial] test_xml\n", argv[0]);
- return 1;
- }
- int logLevel = Log::ELogW;
- char* serial = NULL;
- int opt;
- while ((opt = getopt(argc, argv, "l:s:")) != -1) {
- switch (opt) {
- case 'l':
- logLevel = atoi(optarg);
- break;
- case 's':
- serial = optarg;
- break;
- default:
- usage(argv[0]);
- return 1;
- }
- }
- if (optind >= argc) {
- usage(argv[0]);
- return 1;
- }
-
- android::String8 xmlFile(argv[optind]);
-
- android::String8 dirName;
- if (!FileUtil::prepare(dirName)) {
- fprintf(stderr, "cannot prepare report dir");
- return 1;
- }
-
- std::unique_ptr<CleanupStatics> staticStuffs(new CleanupStatics());
- if (Settings::Instance() == NULL) {
- fprintf(stderr, "caanot create Settings");
- return 1;
- }
- if (serial != NULL) {
- android::String8 strSerial(serial);
- Settings::Instance()->addSetting(Settings::EADB, strSerial);
- }
- if (Log::Instance(dirName.string()) == NULL) {
- fprintf(stderr, "cannot create Log");
- return 1;
- }
- Log::Instance()->setLogLevel((Log::LogLevel)logLevel);
- // Log can be used from here
- if (Report::Instance(dirName.string()) == NULL) {
-
- LOGE("cannot create log");
- return 1;
- }
-
- GenericFactory factory;
- ClientInterface* client = factory.createClientInterface();
- if (client == NULL) {
- fprintf(stderr, "cannot create ClientInterface");
- return 1;
- }
- if (!client->init(Settings::Instance()->getSetting(Settings::EADB))) {
- fprintf(stderr, "cannot init ClientInterface");
- return 1;
- }
- android::String8 deviceInfo;
- if (!client->getAudio()->getDeviceInfo(deviceInfo)) {
- fprintf(stderr, "cannot get device info");
- return 1;
- }
- delete client; // release so that it can be used in tests
- Settings::Instance()->addSetting(Settings::EDEVICE_INFO, deviceInfo);
-
- ModelBuilder modelBuilder;
- std::unique_ptr<TaskGeneric> topTask(modelBuilder.parseTestDescriptionXml(xmlFile));
- if (topTask.get() == NULL) {
- LOGE("Parsing of %x failed", xmlFile.string());
- return 1;
- }
- Settings::Instance()->addSetting(Settings::ETEST_XML, xmlFile);
- topTask->run();
-
- return 0;
-}
-
diff --git a/suite/audio_quality/lib/Android.bp b/suite/audio_quality/lib/Android.bp
deleted file mode 100644
index b07e628..0000000
--- a/suite/audio_quality/lib/Android.bp
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// Copyright (C) 2012 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_host_static {
- name: "libcts_audio_quality",
- srcs: ["**/*.cpp"],
- export_include_dirs: [
- "include",
- "src",
- ],
- static_libs: [
- "libbase",
- "libutils",
- "liblog",
- "libtinyalsa",
- "libcutils",
- "libtinyxml2",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- "-g",
- "-fno-exceptions",
- "-Wno-unused-parameter",
- "-Wno-unused-variable",
- "-Wno-format",
- ],
- ldflags: [
- "-fno-exceptions",
- ],
- target: {
- darwin: {
- enabled: false,
- },
- },
-}
diff --git a/suite/audio_quality/lib/include/BuiltinProcessing.h b/suite/audio_quality/lib/include/BuiltinProcessing.h
deleted file mode 100644
index 6fd1b96..0000000
--- a/suite/audio_quality/lib/include/BuiltinProcessing.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_BUILTINPROCESSING_H
-#define CTSAUDIO_BUILTINPROCESSING_H
-
-#include "task/TaskGeneric.h"
-
-class BuiltinProcessing {
-public:
- BuiltinProcessing();
-
- typedef TaskGeneric::ExecutionResult \
- (BuiltinProcessing::*BuiltinProcessingMemberFn)(void**, void**);
- struct BuiltinInfo {
- const char* mName;
- BuiltinProcessingMemberFn mFunction;
- size_t mNInput;
- const bool* mInputTypes; // true: android::sp<Buffer>*, false: Value*
- size_t mNOutput;
- const bool* mOutputTypes;
- };
-
- static const int N_BUILTIN_FNS = 1;
- static BuiltinInfo BUINTIN_FN_TABLE[N_BUILTIN_FNS];
- /**
- * calculate RMS of given data. The rms is passed to moving average filter
- * And the averaged RMS should be within passMin to passMax to pass the test.
- * Otherwise, it will just return EResultOK.
- * Input: android::sp<Buffer> data, int64_t passMin, int64_t passMax
- * Output:int64_t rms
- */
- TaskGeneric::ExecutionResult rms_mva(void** inputs, void** outputs);
-private:
- static const int RMS_CONTINUOUS_PASSES = 5;
- int mRMSPasses;
-};
-
-
-#endif // CTSAUDIO_BUILTINPROCESSING_H
diff --git a/suite/audio_quality/lib/include/ClientInterface.h b/suite/audio_quality/lib/include/ClientInterface.h
deleted file mode 100644
index 32de0e9..0000000
--- a/suite/audio_quality/lib/include/ClientInterface.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_CLIENTINTERFACE_H
-#define CTSAUDIO_CLIENTINTERFACE_H
-
-#include <utils/String8.h>
-#include <utils/StrongPointer.h>
-
-#include "audio/RemoteAudio.h"
-#include "ClientSocket.h"
-
-class ClientInterface {
-public:
- virtual ~ClientInterface() {};
- /**
- * launch client and perform initial connection
- * @param param parameter for connection. It will be device serial number or zero length string
- */
- virtual bool init(const android::String8& param) = 0;
-
- virtual ClientSocket& getSocket() = 0;
-
- virtual android::sp<RemoteAudio>& getAudio() = 0;
-
-};
-
-
-#endif // CTSAUDIO_CLIENTINTERFACE_H
diff --git a/suite/audio_quality/lib/include/ClientSocket.h b/suite/audio_quality/lib/include/ClientSocket.h
deleted file mode 100644
index 49328bd..0000000
--- a/suite/audio_quality/lib/include/ClientSocket.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTASUDIO_CLIENTSOCKET_H
-#define CTASUDIO_CLIENTSOCKET_H
-
-class ClientSocket {
-public:
- ClientSocket();
- virtual ~ClientSocket();
- virtual bool init(const char* hostIp, int port, bool enableTimeout = false);
- /**
- * @param timeoutInMs 0 means no time-out
- */
- virtual bool readData(char* data, int len, int timeoutInMs = 0);
- virtual bool sendData(const char* data, int len);
- int getFD() {
- return mSocket;
- }
- virtual void release();
-protected:
- int mSocket;
- bool mTimeoutEnabled;
-};
-
-
-#endif // CTASUDIO_CLIENTSOCKET_H
diff --git a/suite/audio_quality/lib/include/FileUtil.h b/suite/audio_quality/lib/include/FileUtil.h
deleted file mode 100644
index df10c54..0000000
--- a/suite/audio_quality/lib/include/FileUtil.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_FILEUTIL_H
-#define CTSAUDIO_FILEUTIL_H
-
-#include <stdarg.h>
-
-#include <utils/String8.h>
-#include <utils/threads.h>
-#include <iostream>
-#include <fstream>
-
-/**
- * Class to write to file and stdout at the same time.
- *
- */
-class FileUtil {
-public:
- /**
- * create log / report dir
- * @param dirPath returns path of created dir
- */
- static bool prepare(android::String8& dirPath);
-
-protected:
- FileUtil();
- virtual ~FileUtil();
-
- /**
- * if fileName is NULL, only stdout output will be supproted
- */
- virtual bool init(const char* fileName);
-
- virtual bool doPrintf(const char* fmt, ...);
- /// fileOnly log only to file
- /// loglevel 0 .., -1 means no log level.
- virtual bool doVprintf(bool fileOnly, int loglevel, const char *fmt, va_list ap);
-
-private:
- // store dirPath to prevent creating multiple times
- static android::String8 mDirPath;
- std::ofstream mFile;
- static const int DEFAULT_BUFFER_SIZE = 1024;
- // buffer for printf. one line longer than this will be truncated.
- char* mBuffer;
- int mBufferSize;
- android::Mutex mWriteLock;
-};
-
-
-#endif // CTSAUDIO_FILEUTIL_H
diff --git a/suite/audio_quality/lib/include/GenericFactory.h b/suite/audio_quality/lib/include/GenericFactory.h
deleted file mode 100644
index 9dc9c02..0000000
--- a/suite/audio_quality/lib/include/GenericFactory.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_GENERIC_FACTORY_H
-#define CTSAUDIO_GENERIC_FACTORY_H
-
-#include "task/TaskGeneric.h"
-#include "ClientInterface.h"
-
-
-/**
- * Factory methods for all abstract classes
- */
-class GenericFactory {
-public:
- virtual ~GenericFactory();
- virtual ClientInterface* createClientInterface();
- virtual TaskGeneric* createTask(TaskGeneric::TaskType type);
-};
-
-
-#endif // CTSAUDIO_GENERIC_FACTORY_H
diff --git a/suite/audio_quality/lib/include/Log.h b/suite/audio_quality/lib/include/Log.h
deleted file mode 100644
index b33c21f..0000000
--- a/suite/audio_quality/lib/include/Log.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_LOG_H
-#define CTSAUDIO_LOG_H
-
-#include <stdio.h>
-#include <iostream>
-#include <fstream>
-
-#include "FileUtil.h"
-
-class Log: public FileUtil {
-public:
- enum LogLevel {
- ELogV = 0,
- ELogD = 1,
- ELogI = 2,
- ELogW = 3,
- ELogE = 4
- };
-
- static Log* Instance(const char* dirName = NULL);
- static void Finalize();
-
-
- void printf(LogLevel level, const char* fmt, ...);
- void setLogLevel(LogLevel level);
- LogLevel getLogLevel() {
- return mLogLevel;
- };
-private:
- Log();
- virtual ~Log();
- virtual bool init(const char* dirName);
-
-private:
- static Log* mInstance;
- LogLevel mLogLevel;
-};
-
-#define LOGE(x...) do { Log::Instance()->printf(Log::ELogE, x); \
- Log::Instance()->printf(Log::ELogE, " file %s line %d", __FILE__, __LINE__); } while(0)
-#define LOGW(x...) do { Log::Instance()->printf(Log::ELogW, x); } while(0)
-#define LOGI(x...) do { Log::Instance()->printf(Log::ELogI, x); } while(0)
-#define LOGD(x...) do { Log::Instance()->printf(Log::ELogD, x); } while(0)
-#define LOGV(x...) do { Log::Instance()->printf(Log::ELogV, x); } while(0)
-
-#define MSG(x...) do { Log::Instance()->printf(Log::ELogE, x); } while(0)
-
-#define ASSERT(cond) if(!(cond)) { Log::Instance()->printf(Log::ELogE, \
- "assertion failed %s %d", __FILE__, __LINE__); \
- Log::Finalize(); \
- abort(); };
-
-#endif // CTSAUDIO_LOG_H
diff --git a/suite/audio_quality/lib/include/Report.h b/suite/audio_quality/lib/include/Report.h
deleted file mode 100644
index e10899f..0000000
--- a/suite/audio_quality/lib/include/Report.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_REPORT_H
-#define CTSAUDIO_REPORT_H
-
-#include <list>
-#include <map>
-
-#include <utils/String8.h>
-#include "FileUtil.h"
-
-class TaskCase;
-/**
- * Class to generate report
- */
-class Report: public FileUtil {
-public:
- /**
- * returns static instance of Report
- * report without dir name, for the 1st call, will only print to stdout.
- * This mode is necessary to prevent creating tons of reports during unit testing
- */
- static Report* Instance(const char* dirName = NULL);
- // should be called before finishing to flush the report to file system
- static void Finalize();
-
- void addCasePassed(const TaskCase* task);
- void addCaseFailed(const TaskCase* task);
-
-
-private:
- Report();
- ~Report();
- bool init(const char* dirName);
- void writeReport();
- void printf(const char* fmt, ...);
- typedef std::pair<android::String8, android::String8> StringPair;
- void writeResult(std::list<StringPair>::const_iterator begin,
- std::list<StringPair>::const_iterator end, bool passed);
-
-private:
- static Report* mInstance;
- std::list<StringPair> mPassedCases;
- std::list<StringPair> mFailedCases;
-};
-
-
-#endif // CTSAUDIO_REPORT_H
diff --git a/suite/audio_quality/lib/include/Semaphore.h b/suite/audio_quality/lib/include/Semaphore.h
deleted file mode 100644
index c4c3e88..0000000
--- a/suite/audio_quality/lib/include/Semaphore.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_SEMAPHORE_H
-#define CTSAUDIO_SEMAPHORE_H
-
-#include <semaphore.h>
-
-#include <Log.h>
-
-/**
- * Simple semaphore interface for synchronization between client and server
- */
-class Semaphore {
-public:
- explicit Semaphore(int count = 0);
-
- ~Semaphore();
-
- /// down semaphore if it is already positive.
- void tryWait();
-
- bool wait();
-
- bool timedWait(int timeInMSec);
-
- void post();
-
-private:
- sem_t mSem;
-};
-
-
-#endif // CTSAUDIO_SEMAPHORE_H
diff --git a/suite/audio_quality/lib/include/Settings.h b/suite/audio_quality/lib/include/Settings.h
deleted file mode 100644
index 6404769..0000000
--- a/suite/audio_quality/lib/include/Settings.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_SETTINGS_H
-#define CTSAUDIO_SETTINGS_H
-
-#include <utils/String8.h>
-
-class Settings {
-public:
- static Settings* Instance();
- static void Finalize();
- enum SettingType {
- EADB = 0, // adb device serial number
- EREPORT_TIME = 1,
- EREPORT_FILE = 2,
- EDEVICE_INFO = 3,
- ETEST_XML = 4, // name of test description xml
- EMAX_SETTINGS = 4 // not real setting
- };
- void addSetting(SettingType type, const android::String8& setting);
- const android::String8& getSetting(SettingType type);
-private:
- static Settings* mInstance;
- android::String8 mSettings[EMAX_SETTINGS + 1];
-};
-
-
-#endif // CTSAUDIO_SETTINGS_H
diff --git a/suite/audio_quality/lib/include/SignalProcessingInterface.h b/suite/audio_quality/lib/include/SignalProcessingInterface.h
deleted file mode 100644
index 202cdf9..0000000
--- a/suite/audio_quality/lib/include/SignalProcessingInterface.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_SIGNALPROCESSINGINTERFACE_H
-#define CTSAUDIO_SIGNALPROCESSINGINTERFACE_H
-
-#include <utils/String8.h>
-
-#include "task/TaskGeneric.h"
-
-/**
- * Interface to Signal processing module to run signal processing script and retrieve the result
- * After construction, init() should be called before doing anything else.
- */
-class SignalProcessingInterface {
-public:
- virtual ~SignalProcessingInterface() {};
-
- virtual bool init(const android::String8& script) = 0;
- /**
- * run the script with given input / output parameters. Note that this function does not
- * do any type check.
- * @param functionScript function name (python script name to run for this call)
- * @param nInputs number of inputs. This is the length of inputTypes and inputs array
- * @param inputTypes represent types of each input.
- * when true: android::sp<Buffer>*, false: Value*
- * @param inputs pointer to input. Either android::sp<Buffer>* or Value*
- * @param nOutputs
- * @param outputTypes
- * @param outputs
- */
- virtual TaskGeneric::ExecutionResult run(const android::String8& functionScript,
- int nInputs, bool* inputTypes, void** inputs,
- int nOutputs, bool* outputTypes, void** outputs) = 0;
-};
-
-#endif //CTSAUDIO_SIGNALPROCESSINGINTERFACE_H
diff --git a/suite/audio_quality/lib/include/StringUtil.h b/suite/audio_quality/lib/include/StringUtil.h
deleted file mode 100644
index 7519a8e..0000000
--- a/suite/audio_quality/lib/include/StringUtil.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_STRINGUTIL_H
-#define CTSAUDIO_STRINGUTIL_H
-
-#include <utils/String8.h>
-#include <vector>
-
-/**
- * Utility class for implementing missing features from android::String8
- */
-class StringUtil {
-public:
- /// split the given string with given delimiter and return the vector of string
- /// it may return NULL if memory alloc fails.
- /// If vector is not NULL, there will be at least one string
- static std::vector<android::String8>* split(const android::String8& str, char delimiter);
- /// This function will return zero length string if pos is invalid.
- static android::String8 substr(const android::String8& str, size_t pos, size_t n);
- static int compare(const android::String8& str, const char* other);
- static bool endsWith(const android::String8& str, const char* other);
-};
-
-
-#endif // CTSAUDIO_STRINGUTIL_H
diff --git a/suite/audio_quality/lib/include/audio/AudioHardware.h b/suite/audio_quality/lib/include/audio/AudioHardware.h
deleted file mode 100644
index c505c31..0000000
--- a/suite/audio_quality/lib/include/audio/AudioHardware.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_AUDIOHARDWARE_H
-#define CTSAUDIO_AUDIOHARDWARE_H
-
-#include <utils/StrongPointer.h>
-#include <utils/RefBase.h>
-#include "Buffer.h"
-
-class TaskCase;
-/**
- * Utility class for H/W detection
- */
-class AudioHardware : virtual public android::RefBase {
-public:
- /** audio length should be multiple of this */
- static const int SAMPLES_PER_ONE_GO = 4096;
-
- enum SamplingRate {
- ESamplingRateInvald = 0,
- ESampleRate_16000 = 16000,
- ESampleRate_44100 = 44100
- };
- enum BytesPerSample {
- E2BPS = 2
- };
- enum AudioMode {
- EModeVoice = 0,
- EModeMusic = 1
- };
-
- /**
- * detect supported audio H/W
- * @return card number of detected H/W. -1 if not found.
- */
- static int detectAudioHw();
-
- /**
- * Factory method
- * options are : local or remote, playback or recording
- * can return NULL(sp.get() == NULL) if H/W not found
- */
- static android::sp<AudioHardware> createAudioHw(bool local, bool playback,
- TaskCase* testCase = NULL);
-
- virtual ~AudioHardware();
- /**
- * prepare playback or recording
- */
- virtual bool prepare(SamplingRate samplingRate, int volume, int mode = EModeVoice) = 0;
-
- /**
- * Convenience API to pass buffer ID. The buffer can be either present in testCase
- * or in remote device (when testCase is NULL)
- */
- virtual bool startPlaybackOrRecordById(const android::String8& id, TaskCase* testCase = NULL);
-
- /**
- * Playback / Record with given buffer
- * @param buffer buffer to play / record
- * @param numberRepetition How many times to repeat playback / record for given buffer.
- * For record, it does not have much meaning as the last recording will always
- * override.
- */
- virtual bool startPlaybackOrRecord(android::sp<Buffer>& buffer,
- int numberRepetition = 1) = 0;
- /**
- * Wait for the playback / recording to complete. return true when successfully finished.
- * Calling waitForCompletion after calling stopPlaybackOrRecord will lead into blocking
- * the calling thread for some time.
- */
- virtual bool waitForCompletion() = 0;
- /// stops the on-going action. The active task can be canceled.
- virtual void stopPlaybackOrRecord() = 0;
-
-protected:
- static int mHwId;
-};
-
-
-#endif // CTSAUDIO_AUDIOHARDWARE_H
diff --git a/suite/audio_quality/lib/include/audio/AudioLocal.h b/suite/audio_quality/lib/include/audio/AudioLocal.h
deleted file mode 100644
index a263528..0000000
--- a/suite/audio_quality/lib/include/audio/AudioLocal.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_AUDIOLOCAL_H
-#define CTSAUDIO_AUDIOLOCAL_H
-
-#include <utils/StrongPointer.h>
-#include <utils/threads.h>
-
-#include <Semaphore.h>
-
-#include "AudioHardware.h"
-
-class Buffer;
-
-/**
- * Basic API for playback and record
- */
-class AudioLocal: public android::Thread, public AudioHardware {
-public:
-
- virtual bool prepare(AudioHardware::SamplingRate samplingRate, int gain,
- int mode = AudioHardware::EModeVoice);
- virtual bool startPlaybackOrRecord(android::sp<Buffer>& buffer, int numberRepetition = 1);
- virtual bool waitForCompletion();
- virtual void stopPlaybackOrRecord();
-
- virtual ~AudioLocal();
-protected:
- AudioLocal();
-
- virtual bool doPrepare(AudioHardware::SamplingRate, int samplesInOneGo) = 0;
- virtual bool doPlaybackOrRecord(android::sp<Buffer>& buffer) = 0;
- virtual void doStop() = 0;
- virtual void releaseHw() {};
-
-private:
-
-
- bool threadLoop();
-
- enum AudioCommand{
- ECmNone = 0,
- ECmInitialize,
- ECmRun,
- ECmStop,
- ECmThreadStop // terminate the thread
- };
-
- bool issueCommandAndWaitForCompletion(AudioCommand command);
-
-protected:
-
-private:
- // only one command at a time.
- // Thus, all parameters can be stored here.
- AudioHardware::SamplingRate mSamplingRate;
-
- android::sp<Buffer> mBuffer;
- int mNumberRepetition;
- int mCurrentRepeat;
-
- enum AudioState{
- EStNone,
- EStCreated,
- EStInitialized,
- EStRunning // playing or recording
- };
- volatile AudioState mState;
- volatile AudioCommand mCurrentCommand;
-
-
- static const int COMMAND_WAIT_TIME_MSEC = 4000;
-
- Semaphore mClientCommandWait;
- Semaphore mClientCompletionWait;
- Semaphore mAudioThreadWait;
-
- bool mCommandResult;
- bool mCompletionResult;
-};
-
-#endif // CTSAUDIO_AUDIOLOCAL_H
diff --git a/suite/audio_quality/lib/include/audio/AudioPlaybackLocal.h b/suite/audio_quality/lib/include/audio/AudioPlaybackLocal.h
deleted file mode 100644
index fcfb270..0000000
--- a/suite/audio_quality/lib/include/audio/AudioPlaybackLocal.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_AUDIOPLAYBACKLOCAL_H
-#define CTSAUDIO_AUDIOPLAYBACKLOCAL_H
-
-#include <utils/String8.h>
-
-#include <tinyalsa/asoundlib.h>
-
-#include "AudioLocal.h"
-
-
-class AudioPlaybackLocal: public AudioLocal {
-public:
- explicit AudioPlaybackLocal(int hwId);
- virtual ~AudioPlaybackLocal();
-protected:
- bool doPrepare(AudioHardware::SamplingRate, int samplesInOneGo);
- bool doPlaybackOrRecord(android::sp<Buffer>& buffer);
- void doStop();
- void releaseHw();
-
-private:
- int mHwId;
- struct pcm* mPcmHandle;
- // unit playback samples
- int mSamples;
- // unit playback sizes
- int mSizes;
-};
-
-
-#endif // CTSAUDIO_AUDIOPLAYBACKLOCAL_H
diff --git a/suite/audio_quality/lib/include/audio/AudioProtocol.h b/suite/audio_quality/lib/include/audio/AudioProtocol.h
deleted file mode 100644
index eaf93a8..0000000
--- a/suite/audio_quality/lib/include/audio/AudioProtocol.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_AUDIOPROTOCOL_H
-#define CTSAUDIO_AUDIOPROTOCOL_H
-
-#include <stdint.h>
-
-#include <utils/StrongPointer.h>
-#include "Log.h"
-#include "audio/Buffer.h"
-#include "ClientSocket.h"
-
-#define U32_ENDIAN_SWAP(x) ( ((x) & 0x000000ff)<<24 | ((x) & 0x0000ff00)<<8 | \
- ((x) & 0x00ff0000)>>8 | ((x) & 0xff000000)>>24 )
-
-class AudioParam {
-public:
- bool mStereo;
- uint32_t mSamplingF;
- uint32_t mMode;
- uint32_t mNumberRepetition; // only for playback
- uint32_t mVolume;
- uint32_t mId;
- android::sp<Buffer> mBuffer;
- void* mExtra; // extra data for whatever purpose
-};
-
-class AudioProtocol {
-public:
- enum CommandId {
- ECmdStart = 0x12340001, //not actual command
- ECmdDownload = 0x12340001,
- ECmdStartPlayback = 0x12340002,
- ECmdStopPlayback = 0x12340003,
- ECmdStartRecording = 0x12340004,
- ECmdStopRecording = 0x12340005,
- ECmdGetDeviceInfo = 0x12340006,
- ECmdLast = 0x12340007, // not actual command
- };
-
- static const uint32_t REPLY_HEADER_SIZE = 12;
- // up to 5 parameters for command / reply
- class ProtocolParam {
- public:
- void* param[5];
- };
-
- virtual ~AudioProtocol() {
- //LOGD("~AudioProtocol %x", this);
- };
-
- /// default implementation, no param, no payload
- virtual bool sendCommand(AudioParam& param);
- /// default implementation, no param, no payload
- virtual bool handleReply(const uint32_t* data, AudioParam* param);
-
- /**
- * read header of reply and returns CommandId of reply.
- * @param socket socket to read
- * @param data pointer to buffer to store header, it should be uint32_t[3]
- * @param id types of reply
- * @return true if everything OK
- */
- static bool handleReplyHeader(ClientSocket& socket, uint32_t* data, CommandId& id);
-
-protected:
- AudioProtocol(ClientSocket& socket, uint32_t command)
- : mCommand(command),
- mSocket(socket) {};
-
- bool sendData(const char* data, int len) {
- return mSocket.sendData(data, len);
- };
-
- bool checkHeaderId(const uint32_t* data, uint32_t command);
- bool readData(char* data, int len) {
- return mSocket.readData(data, len);
- };
-
-protected:
- int mBuffer[8];
-private:
- uint32_t mCommand;
- ClientSocket& mSocket;
-
-};
-
-class CmdDownload: public AudioProtocol {
-public:
- explicit CmdDownload(ClientSocket& socket)
- : AudioProtocol(socket, ECmdDownload) {};
- virtual ~CmdDownload() {};
- virtual bool sendCommand(AudioParam& param);
-};
-
-
-class CmdStartPlayback: public AudioProtocol {
-public:
- explicit CmdStartPlayback(ClientSocket& socket)
- : AudioProtocol(socket, ECmdStartPlayback) {};
- virtual ~CmdStartPlayback() {};
- virtual bool sendCommand(AudioParam& param);
-};
-
-class CmdStopPlayback: public AudioProtocol {
-public:
- explicit CmdStopPlayback(ClientSocket& socket)
- : AudioProtocol(socket, ECmdStopPlayback) {};
- virtual ~CmdStopPlayback() {};
-};
-
-class CmdStartRecording: public AudioProtocol {
-public:
- explicit CmdStartRecording(ClientSocket& socket)
- : AudioProtocol(socket, ECmdStartRecording) {};
- virtual ~CmdStartRecording() {};
-
- virtual bool sendCommand(AudioParam& param);
-
- virtual bool handleReply(const uint32_t* data, AudioParam* param);
-};
-
-class CmdStopRecording: public AudioProtocol {
-public:
- explicit CmdStopRecording(ClientSocket& socket)
- : AudioProtocol(socket, ECmdStopRecording) {};
- virtual ~CmdStopRecording() {};
-};
-
-class CmdGetDeviceInfo: public AudioProtocol {
-public:
- explicit CmdGetDeviceInfo(ClientSocket& socket)
- : AudioProtocol(socket, ECmdGetDeviceInfo) {};
- virtual ~CmdGetDeviceInfo() {};
-
- virtual bool handleReply(const uint32_t* data, AudioParam* param);
-};
-
-#endif // CTSAUDIO_AUDIOPROTOCOL_H
diff --git a/suite/audio_quality/lib/include/audio/AudioRecordingLocal.h b/suite/audio_quality/lib/include/audio/AudioRecordingLocal.h
deleted file mode 100644
index e192812..0000000
--- a/suite/audio_quality/lib/include/audio/AudioRecordingLocal.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_AUDIORECORDINGLOCAL_H
-#define CTSAUDIO_AUDIORECORDINGLOCAL_H
-
-#include <utils/String8.h>
-
-#include <tinyalsa/asoundlib.h>
-
-#include "AudioLocal.h"
-
-
-class AudioRecordingLocal: public AudioLocal {
-public:
- explicit AudioRecordingLocal(int hwId);
- virtual ~AudioRecordingLocal();
-protected:
- bool doPrepare(AudioHardware::SamplingRate, int samplesInOneGo);
- bool doPlaybackOrRecord(android::sp<Buffer>& buffer);
- void doStop();
- void releaseHw();
-
-private:
- int mHwId;
- struct pcm* mPcmHandle;
- // unit recording samples
- int mSamples;
- // unit recording sizes
- int mSizes;
- // alsa buffer size
- int mBufferSize;
-};
-
-
-#endif // CTSAUDIO_AUDIORECORDINGLOCAL_H
diff --git a/suite/audio_quality/lib/include/audio/AudioRemote.h b/suite/audio_quality/lib/include/audio/AudioRemote.h
deleted file mode 100644
index f5e6c2e4..0000000
--- a/suite/audio_quality/lib/include/audio/AudioRemote.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_AUDIOREMOTE_H
-#define CTSAUDIO_AUDIOREMOTE_H
-#include <utils/StrongPointer.h>
-#include "AudioHardware.h"
-// real implementation
-#include "RemoteAudio.h"
-
-
-// wrapper in AudioHardware interface
-class AudioRemote: public AudioHardware {
-public:
- virtual bool prepare(AudioHardware::SamplingRate samplingRate, int volume,
- int mode = AudioHardware::EModeVoice);
-
-protected:
- explicit AudioRemote(android::sp<RemoteAudio>& remote);
- virtual ~AudioRemote() {};
-
-protected:
- android::sp<RemoteAudio> mRemote;
- AudioHardware::SamplingRate mSamplingRate;
- int mVolume;
- int mMode;
-};
-
-class AudioRemotePlayback: public AudioRemote {
-public:
- explicit AudioRemotePlayback(android::sp<RemoteAudio>& remote);
- virtual ~AudioRemotePlayback() {};
- virtual bool startPlaybackOrRecord(android::sp<Buffer>& buffer, int numberRepetition = 1);
- virtual bool waitForCompletion();
- virtual void stopPlaybackOrRecord();
- bool startPlaybackForRemoteData(int id, bool stereo, int numberRepetition = 1);
-};
-
-class AudioRemoteRecording: public AudioRemote {
-public:
- explicit AudioRemoteRecording(android::sp<RemoteAudio>& remote);
- virtual ~AudioRemoteRecording() {};
- virtual bool startPlaybackOrRecord(android::sp<Buffer>& buffer, int numberRepetition = 1);
- virtual bool waitForCompletion();
- virtual void stopPlaybackOrRecord();
-};
-
-
-#endif // CTSAUDIO_AUDIOREMOTE_H
diff --git a/suite/audio_quality/lib/include/audio/AudioSignalFactory.h b/suite/audio_quality/lib/include/audio/AudioSignalFactory.h
deleted file mode 100644
index 1c985cc..0000000
--- a/suite/audio_quality/lib/include/audio/AudioSignalFactory.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_AUDIOSIGNALFACTORY_H
-#define CTSAUDIO_AUDIOSIGNALFACTORY_H
-
-#include <utils/StrongPointer.h>
-
-#include "AudioHardware.h"
-#include "Buffer.h"
-/**
- * factory for creating various audio signals
- */
-class AudioSignalFactory {
-public:
- static android::sp<Buffer> generateSineWave(AudioHardware::BytesPerSample BPS,
- int maxPositive, AudioHardware::SamplingRate samplingRate, int signalFreq, int samples,
- bool stereo = true);
- static android::sp<Buffer> generateWhiteNoise(AudioHardware::BytesPerSample BPS,
- int maxPositive, int samples, bool stereo = true);
- static android::sp<Buffer> generateZeroSound(AudioHardware::BytesPerSample BPS,
- int samples, bool stereo = true);
-};
-
-
-#endif // CTSAUDIO_AUDIOSIGNALFACTORY_H
diff --git a/suite/audio_quality/lib/include/audio/Buffer.h b/suite/audio_quality/lib/include/audio/Buffer.h
deleted file mode 100644
index 17c5679..0000000
--- a/suite/audio_quality/lib/include/audio/Buffer.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_BUFFER_H
-#define CTSAUDIO_BUFFER_H
-
-#include <stdlib.h>
-#include <string.h>
-#include <utils/String8.h>
-
-#include <utils/RefBase.h>
-
-#include <Log.h>
-
-/**
- * Buffer passed for audio playback and recording
- * The buffer is supposed to be used with sp to guarantee that audio thread can
- * access it even if the client thread is dead.
- */
-class Buffer: public virtual android::RefBase {
-public:
- explicit Buffer(size_t capacity, size_t size = 0, bool stereo = true);
-
- virtual ~Buffer();
-
- inline size_t getCapacity() {
- return mCapacity;
- };
-
- inline size_t getSize() {
- return mSize;
- };
-
- inline size_t getSamples() {
- return (getSize() / (isStereo() ? 4 : 2));
- };
-
- inline void setSize(size_t size) {
- mSize = size;
- };
-
- inline void increaseSize(size_t size) {
- mSize += size;
- }
- inline char* getData() {
- return mData;
- };
-
- inline void setData(char* data, size_t len) {
- ASSERT(len <= mCapacity);
- memcpy(mData, data, len);
- mSize = len;
- };
-
- inline char* getUnhanledData() {
- return mData + mHandled;
- };
-
- inline bool bufferHandled() {
- return mSize <= mHandled;
- };
-
- inline void restart() {
- mHandled = 0;
- };
- /// size was recorded
- inline void increaseHandled(size_t size) {
- mHandled += size;
- };
-
- inline void setHandled(size_t size) {
- mHandled = size;
- }
- /// amount recorded
- inline size_t amountHandled() {
- return mHandled;
- };
-
- inline size_t amountToHandle() {
- return mSize - mHandled;
- };
-
- inline bool isStereo() {
- return mStereo;
- };
- enum ConvertOption {
- EKeepCh0 = 0,
- EKeepCh1 = 1,
- EAverage = 2
- };
- /// change stereo buffer to mono
- void changeToMono(ConvertOption option);
- /// change mono buffer to stereo. This does not increase allocated memory.
- /// So it will fail if capacity is not big enough.
- bool changeToStereo();
-
- /// save the buffer to file
- /// extension appropriate for the data type will be appended to file name
- bool saveToFile(const android::String8& filename);
-
- bool operator ==(const Buffer& b) const;
-
- /// load raw data from given file.
- /// data format is decided by extension
- /// .r2s: 16 bps, stereo
- /// .r2m: 16bps, mono
- static Buffer* loadFromFile(const android::String8& filename);
-private:
- // max data that can be hold
- size_t mCapacity;
- // data stored for playback / to store for recording
- size_t mSize;
- // how much data was handled / recorded
- size_t mHandled;
- // stereo or mono
- bool mStereo;
- // payload
- char* mData;
-};
-
-
-
-#endif // CTSAUDIO_BUFFER_H
diff --git a/suite/audio_quality/lib/include/audio/RemoteAudio.h b/suite/audio_quality/lib/include/audio/RemoteAudio.h
deleted file mode 100644
index be977b2..0000000
--- a/suite/audio_quality/lib/include/audio/RemoteAudio.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_REMOTEAUDIO_H
-#define CTSAUDIO_REMOTEAUDIO_H
-
-#include <map>
-
-#include <utils/Looper.h>
-#include <utils/String8.h>
-#include <utils/StrongPointer.h>
-#include <utils/threads.h>
-
-#include "audio/Buffer.h"
-#include "AudioProtocol.h"
-#include "ClientSocket.h"
-#include "Semaphore.h"
-
-class CommandHandler;
-/**
- * Tcp communication runs in a separate thread,
- * and client can communicate using public APIs
- * Assumption: only one command at a time. No other command can come
- * while a command is pending.
- */
-class RemoteAudio: public android::Thread {
-public:
-
- explicit RemoteAudio(ClientSocket& socket);
- virtual ~RemoteAudio();
-
- /** launch a thread, and connect to host */
- bool init(int port);
- bool downloadData(const android::String8& name, android::sp<Buffer>& buffer, int& id);
- // <0 : not found
- int getDataId(const android::String8& name);
- bool startPlayback(bool stereo, int samplingF, int mode, int volume,
- int id, int numberRepetition);
- void stopPlayback();
- bool waitForPlaybackCompletion();
- // buffer.getSize() determines number of samples
- bool startRecording(bool stereo, int samplingF, int mode, int volume,
- android::sp<Buffer>& buffer);
- bool waitForRecordingCompletion();
- void stopRecording();
-
- bool getDeviceInfo(android::String8& data);
- /** should be called before RemoteAudio is destroyed */
- void release();
-
-private:
- RemoteAudio(const RemoteAudio&);
-
- bool threadLoop();
- void wakeClient(bool result);
- void cleanup(bool notifyClient);
-
- bool handlePacket();
- static int socketRxCallback(int fd, int events, void* data);
-
- class CommandHandler;
- void sendCommand(android::sp<android::MessageHandler>& command);
-
- // this is just semaphore wait without any addition
- bool waitForCompletion(android::sp<android::MessageHandler>& command, int timeInMSec);
- // common code for waitForXXXCompletion
- bool waitForPlaybackOrRecordingCompletion(
- android::sp<android::MessageHandler>& commandHandler);
- // common code for stopXXX
- void doStop(android::sp<android::MessageHandler>& commandHandler, AudioProtocol::CommandId id);
-
- CommandHandler* toCommandHandler(android::sp<android::MessageHandler>& command) {
- return reinterpret_cast<CommandHandler*>(command.get());
- };
-
-private:
- bool mExitRequested;
- bool mInitResult;
- // used only for notifying successful init
- Semaphore mInitWait;
-
-
- enum EventId {
- EIdSocket = 1,
- };
- static const int CLIENT_WAIT_TIMEOUT_MSEC = 2000;
- int mPort;
- ClientSocket& mSocket;
-
-
- android::sp<android::Looper> mLooper;
-
- friend class CommandHandler;
-
- class CommandHandler: public android::MessageHandler {
- public:
- enum ClientCommands {
- EExit = 1,
- };
- CommandHandler(RemoteAudio& thread, int command)
- : mThread(thread),
- mMessage(command),
- mNotifyOnReply(false),
- mActive(false) {};
- virtual ~CommandHandler() {};
- void handleMessage(const android::Message& message);
- bool timedWait(int timeInMSec) {
- return mClientWait.timedWait(timeInMSec);
- };
- AudioParam& getParam() {
- return mParam;
- };
- android::Message& getMessage() {
- return mMessage;
- };
-
- private:
- RemoteAudio& mThread;
- AudioParam mParam;
- Semaphore mClientWait;
- android::Mutex mStateLock;
- android::Message mMessage;
- bool mResult;
- bool mNotifyOnReply;
- bool mActive;
- friend class RemoteAudio;
- };
- android::sp<android::MessageHandler> mDownloadHandler;
- android::sp<android::MessageHandler> mPlaybackHandler;
- android::sp<android::MessageHandler> mRecordingHandler;
- android::sp<android::MessageHandler> mDeviceInfoHandler;
-
- AudioProtocol* mCmds[AudioProtocol::ECmdLast - AudioProtocol::ECmdStart];
- int mDownloadId;
- std::map<int, android::sp<Buffer> > mBufferList;
- std::map<android::String8, int> mIdMap;
-};
-
-
-
-#endif // CTSAUDIO_REMOTEAUDIO_H
diff --git a/suite/audio_quality/lib/include/task/ModelBuilder.h b/suite/audio_quality/lib/include/task/ModelBuilder.h
deleted file mode 100644
index c997000..0000000
--- a/suite/audio_quality/lib/include/task/ModelBuilder.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_MODELBUILDER_H
-#define CTSAUDIO_MODELBUILDER_H
-
-#include <utils/String8.h>
-#include "TaskAll.h"
-
-namespace tinyxml2 {
-class XMLElement;
-};
-
-class GenericFactory;
-
-/**
- * Class to parse Test description XML and generate test model with TestCase in top
- */
-
-class ModelBuilder {
-public:
- ModelBuilder();
- explicit ModelBuilder(GenericFactory* factory);
- virtual ~ModelBuilder();
-
- /**
- * parse given xml with test case or batch. When caseOnly is true, only test case can be in.
- */
- virtual TaskGeneric* parseTestDescriptionXml(const android::String8& xmlFileName,
- bool caseOnly = false);
-
- struct ChildInfo {
- TaskGeneric::TaskType type;
- bool mandatory; // whether the child is mandatory or not
- };
-
-private:
- virtual bool parseAttributes(const tinyxml2::XMLElement& elem, TaskGeneric& task);
- virtual TaskGeneric* parseGeneric(const tinyxml2::XMLElement& elem, int tableIndex);
- virtual TaskCase* parseCase(const tinyxml2::XMLElement& root);
- virtual TaskBatch* parseBatch(const tinyxml2::XMLElement& root, const android::String8& xmlFileName);
- virtual TaskCase* parseInclude(const tinyxml2::XMLElement& elem, const android::String8& path);
-
- struct ParsingInfo {
- const char* name; // XML element name
- TaskGeneric::TaskType type;
- const ChildInfo* allowedChildren;
- int Nchildren;
- };
- // no table for batch, and ETaskInvalidLast is not in either (-2)
- static const int PARSING_TABLE_SIZE = TaskGeneric::ETaskInvalidLast - 2;
- static ParsingInfo mParsingTable[PARSING_TABLE_SIZE];
-
- GenericFactory* mFactory;
-
-};
-
-
-#endif // CTSAUDIO_MODELBUILDER_H
diff --git a/suite/audio_quality/lib/include/task/TaskAll.h b/suite/audio_quality/lib/include/task/TaskAll.h
deleted file mode 100644
index 3729ef8..0000000
--- a/suite/audio_quality/lib/include/task/TaskAll.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKALL_H
-#define CTSAUDIO_TASKALL_H
-
-/// convenience header to include all Task stuffs
-#include "TaskGeneric.h"
-#include "TaskBatch.h"
-#include "TaskCase.h"
-#include "TaskSequential.h"
-#include "TaskProcess.h"
-#include "TaskAsync.h"
-#include "TaskInput.h"
-#include "TaskOutput.h"
-#include "TaskSound.h"
-#include "TaskSave.h"
-#include "TaskMessage.h"
-#include "TaskDownload.h"
-
-#endif // CTSAUDIO_TASKALL_H
diff --git a/suite/audio_quality/lib/include/task/TaskAsync.h b/suite/audio_quality/lib/include/task/TaskAsync.h
deleted file mode 100644
index 9651c90..0000000
--- a/suite/audio_quality/lib/include/task/TaskAsync.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKASYNC_H
-#define CTSAUDIO_TASKASYNC_H
-
-#include "audio/AudioHardware.h"
-#include "TaskGeneric.h"
-
-class TaskSequential;
-/**
- * Common parent class for TaskInput and TaskOutput
- */
-class TaskAsync: public TaskGeneric {
-public:
- explicit TaskAsync(TaskType type);
- virtual ~TaskAsync();
- virtual TaskGeneric::ExecutionResult run();
- virtual bool parseAttribute(const android::String8& name, const android::String8& value);
- virtual TaskGeneric::ExecutionResult start() = 0;
- virtual TaskGeneric::ExecutionResult complete() = 0;
-
- bool isAsynchronous() {
- return mAsynchronous;
- }
-
-private:
- void makeAsynchronous() {
- mAsynchronous = true;
- }
- TaskSequential* getParentSequential();
-
-protected:
- android::String8 mId;
- int mVolume;
-
- enum DeviceType {
- EDeviceHost,
- EDeviceDUT
- };
-
- DeviceType mDeviceType;
-
- AudioHardware::AudioMode mMode;
-
-private:
- bool mAsynchronous;
-
-};
-
-
-
-#endif // CTSAUDIO_TASKASYNC_H
diff --git a/suite/audio_quality/lib/include/task/TaskBatch.h b/suite/audio_quality/lib/include/task/TaskBatch.h
deleted file mode 100644
index add8590..0000000
--- a/suite/audio_quality/lib/include/task/TaskBatch.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKBATCH_H
-#define CTSAUDIO_TASKBATCH_H
-
-#include "TaskGeneric.h"
-
-
-class TaskBatch: public TaskGeneric {
-public:
- TaskBatch();
- virtual ~TaskBatch();
- virtual bool addChild(TaskGeneric* child);
- virtual TaskGeneric::ExecutionResult run();
-
-};
-
-
-
-#endif // CTSAUDIO_TASKBATCH_H
diff --git a/suite/audio_quality/lib/include/task/TaskCase.h b/suite/audio_quality/lib/include/task/TaskCase.h
deleted file mode 100644
index 22d94e9..0000000
--- a/suite/audio_quality/lib/include/task/TaskCase.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKCASE_H
-#define CTSAUDIO_TASKCASE_H
-
-#include <stdint.h>
-#include <map>
-#include <list>
-#include <utility>
-#include <utils/String8.h>
-#include <utils/StrongPointer.h>
-#include "Log.h"
-#include "audio/Buffer.h"
-#include "TaskGeneric.h"
-
-class RemoteAudio;
-class ClientInterface;
-
-class TaskCase: public TaskGeneric {
-public:
- TaskCase();
- virtual ~TaskCase();
- virtual bool addChild(TaskGeneric* child);
- virtual TaskGeneric::ExecutionResult run();
-
- bool getCaseName(android::String8& name) const;
-
- bool registerBuffer(const android::String8& name, android::sp<Buffer>& buffer);
- // update already existing buffer. Actually the old buffer will be deleted.
- bool updateBuffer(const android::String8& name, android::sp<Buffer>& buffer);
- /// find buffer with given id. sp will be NULL if not found
- android::sp<Buffer> findBuffer(const android::String8& name);
- typedef std::pair<android::String8, android::sp<Buffer> > BufferPair;
- /// find all buffers with given regular expression. returns NULL if not found
- std::list<BufferPair>* findAllBuffers(const android::String8& re);
-
- android::sp<RemoteAudio>& getRemoteAudio();
-
- class Value {
- public:
- enum Type {
- ETypeDouble,
- ETypeI64
- };
- inline Value(): mType(ETypeDouble) {};
- inline explicit Value(Type type): mType(type) {};
- inline explicit Value(double val): mType(ETypeDouble) {
- setDouble(val);
- };
- inline explicit Value(int64_t val): mType(ETypeI64) {
- setInt64(val);
- };
- inline Type getType() {
- return mType;
- };
- inline void setType(Type type) {
- mType = type;
- };
- inline void setDouble(double val) {
- mValue[0] = val;
- mType = ETypeDouble;
- //LOGD("Value set %f 0x%x", val, this);
- };
- inline double getDouble() {
- //LOGD("Value get %f 0x%x", mValue[0], this);
- return mValue[0];
- };
- inline void setInt64(int64_t val) {
- int64_t* data = reinterpret_cast<int64_t*>(mValue);
- data[0] = val;
- mType = ETypeI64;
- //LOGD("Value set %lld 0x%x", val, this);
- }
- inline int64_t getInt64() {
- int64_t* data = reinterpret_cast<int64_t*>(mValue);
- //LOGD("Value get %lld 0x%x", data[0], this);
- return data[0];
- }
- void* getPtr() {
- return mValue;
- }
- bool operator ==(const Value& b) const {
- return ((mValue[0] == b.mValue[0]) && (mType == b.mType));
- };
-
- private:
- double mValue[1];
- Type mType;
- };
-
- bool registerValue(const android::String8& name, Value& val);
- bool updateValue(const android::String8& name, Value& val);
- bool findValue(const android::String8& name, Value& val);
- typedef std::pair<android::String8, Value> ValuePair;
- /// find all Values with given regular expression. returns NULL if not found
- std::list<ValuePair>* findAllValues(const android::String8& re);
-
- bool registerIndex(const android::String8& name, int value = -1);
- bool updateIndex(const android::String8& name, int value);
- bool findIndex(const android::String8& name, int& val);
- typedef std::pair<android::String8, int> IndexPair;
- /// find all Indices with given regular expression. returns NULL if not found
- std::list<IndexPair>* findAllIndices(const android::String8& re);
-
- /**
- * Translate variable name like $i into index variable
- * All xxxValue and xxxBuffer calls do translation inside.
- */
- bool translateVarName(const android::String8& orig, android::String8& translated);
-
- void setDetails(const android::String8& details);
- const android::String8& getDetails() const;
-private:
- void releaseRemoteAudio();
-
-private:
- std::map<android::String8, android::sp<Buffer> > mBufferList;
- std::map<android::String8, int> mIndexList;
- std::map<android::String8, Value> mValueList;
- ClientInterface* mClient;
- android::String8 mDetails;
-};
-
-
-#endif // CTSAUDIO_TASKCASE_H
diff --git a/suite/audio_quality/lib/include/task/TaskDownload.h b/suite/audio_quality/lib/include/task/TaskDownload.h
deleted file mode 100644
index 64aae45..0000000
--- a/suite/audio_quality/lib/include/task/TaskDownload.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKDOWNLOAD_H
-#define CTSAUDIO_TASKDOWNLOAD_H
-#include <utils/String8.h>
-#include <utils/StrongPointer.h>
-#include "audio/Buffer.h"
-#include "TaskGeneric.h"
-
-
-class TaskDownload: public TaskGeneric {
-public:
- TaskDownload();
- virtual ~TaskDownload();
- virtual TaskGeneric::ExecutionResult run();
-};
-
-
-#endif // CTSAUDIO_TASKDOWNLOAD_H
diff --git a/suite/audio_quality/lib/include/task/TaskGeneric.h b/suite/audio_quality/lib/include/task/TaskGeneric.h
deleted file mode 100644
index af0a500..0000000
--- a/suite/audio_quality/lib/include/task/TaskGeneric.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKGENERIC_H
-#define CTSAUDIO_TASKGENERIC_H
-#include <string.h>
-#include <stdio.h>
-#include <list>
-#include <map>
-#include <set>
-#include <utils/String8.h>
-
-
-class TaskCase;
-
-class TaskGeneric {
-public:
- // internal model for xml tags
- enum TaskType {
- ETaskInvalid = 0,
- ETaskBatch = 1,
- ETaskCase = 2,
- ETaskSetup = 3,
- ETaskAction = 4,
- ETaskSequential = 5,
- ETaskProcess = 6,
- ETaskInput = 7,
- ETaskOutput = 8,
- ETaskSound = 9,
- ETaskSave = 10,
- ETaskMessage = 11,
- ETaskDownload = 12,
- ETaskInvalidLast = 13,
- //no ETaskInclude include does not involve any action.
- };
-
- explicit TaskGeneric(TaskType type);
-
- virtual ~TaskGeneric();
-
- inline TaskType getType() {
- return mType;
- }
-
- enum ExecutionResult {
- EResultOK = 0,
- // continue in the current loop. will result in skipping all subsequent steps
- EResultContinue = 1,
- // get out of the current loop
- EResultBreakOneLoop = 2,
- // error which cannot be continued. effect is the same as fail. stops everything.
- EResultError = 3,
- // test failed. stops everything.
- EResultFail = 4,
- // test passed.
- EResultPass = 5
- };
-
- /**
- * default implementation for adding child action
- * Ownership of the child is passed to this instance, and child will be destroyed in parent's
- * destructor.
- * @return false on error
- */
- virtual bool addChild(TaskGeneric* child);
-
- virtual ExecutionResult run();
-
- /// can be NULL if parent does not exist
- TaskGeneric* getParent();
- /// can be NULL if TestCase does not exist (unit testing?)
- TaskCase* getTestCase();
-
- void setParent(TaskGeneric* parent);
-
- /**
- * parse attribute from XML DOM. name/value pair will be passed for all attributes.
- */
- virtual bool parseAttribute(const android::String8& name, const android::String8& value);
-
- bool forEachChild(bool (*runForEachChild)(TaskGeneric* child, void* data), void* data);
-
-protected:
- /// used by child instance to register allowed attributes
- /// keys array should end with NULL
- void registerSupportedStringAttributes(const android::String8* keys[]);
- bool addStringAttribute(const android::String8& key, const android::String8& value);
- bool findStringAttribute(const android::String8& key, android::String8& value) const;
- inline std::list<TaskGeneric*>& getChildren() {
- return mChildren;
- };
-
-private:
- TaskType mType;
- TaskGeneric* mParent;
- std::list<TaskGeneric*> mChildren;
-
- std::set<android::String8> mAllowedStringAttributes;
- std::map<android::String8, android::String8> mStringAttributes;
-
-};
-
-
-#endif // CTSAUDIO_TASKGENERIC_H
diff --git a/suite/audio_quality/lib/include/task/TaskInput.h b/suite/audio_quality/lib/include/task/TaskInput.h
deleted file mode 100644
index ddb557f..0000000
--- a/suite/audio_quality/lib/include/task/TaskInput.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKINPUT_H
-#define CTSAUDIO_TASKINPUT_H
-
-#include <utils/StrongPointer.h>
-#include "TaskAsync.h"
-#include "audio/AudioHardware.h"
-#include "audio/Buffer.h"
-
-class TaskInput: public TaskAsync {
-public:
- TaskInput();
- virtual ~TaskInput();
- virtual bool parseAttribute(const android::String8& name, const android::String8& value);
- virtual TaskGeneric::ExecutionResult start();
- virtual TaskGeneric::ExecutionResult complete();
-private:
- int mRecordingTimeInMs;
- android::sp<AudioHardware> mHw;
- android::sp<Buffer> mBuffer;
-};
-
-
-#endif // CTSAUDIO_TASKINPUT_H
diff --git a/suite/audio_quality/lib/include/task/TaskMessage.h b/suite/audio_quality/lib/include/task/TaskMessage.h
deleted file mode 100644
index 825bb7e..0000000
--- a/suite/audio_quality/lib/include/task/TaskMessage.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKMESSAGE_H
-#define CTSAUDIO_TASKMESSAGE_H
-
-#include "TaskGeneric.h"
-
-
-class TaskMessage: public TaskGeneric {
-public:
- TaskMessage();
- virtual ~TaskMessage();
- virtual TaskGeneric::ExecutionResult run();
- virtual bool parseAttribute(const android::String8& name, const android::String8& value);
-};
-
-
-#endif // CTSAUDIO_TASKMESSAGE_H
diff --git a/suite/audio_quality/lib/include/task/TaskOutput.h b/suite/audio_quality/lib/include/task/TaskOutput.h
deleted file mode 100644
index 928aae2..0000000
--- a/suite/audio_quality/lib/include/task/TaskOutput.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKOUTPUT_H
-#define CTSAUDIO_TASKOUTPUT_H
-
-#include "TaskAsync.h"
-#include "audio/AudioHardware.h"
-
-class TaskOutput: public TaskAsync {
-public:
- TaskOutput();
- virtual ~TaskOutput();
- virtual bool parseAttribute(const android::String8& name, const android::String8& value);
- virtual TaskGeneric::ExecutionResult start();
- virtual TaskGeneric::ExecutionResult complete();
-
-private:
- android::sp<AudioHardware> mHw;
- bool mWaitForCompletion;
-};
-
-
-#endif // CTSAUDIO_TASKOUTPUT_H
diff --git a/suite/audio_quality/lib/include/task/TaskProcess.h b/suite/audio_quality/lib/include/task/TaskProcess.h
deleted file mode 100644
index 724ebd7..0000000
--- a/suite/audio_quality/lib/include/task/TaskProcess.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKPROCESS_H
-#define CTSAUDIO_TASKPROCESS_H
-
-#include <memory>
-#include <vector>
-
-#include <utils/StrongPointer.h>
-
-#include "audio/Buffer.h"
-#include "TaskGeneric.h"
-#include "TaskCase.h"
-#include "BuiltinProcessing.h"
-#include "SignalProcessingInterface.h"
-
-class TaskProcess: public TaskGeneric {
-public:
- TaskProcess();
- virtual ~TaskProcess();
- virtual TaskGeneric::ExecutionResult run();
- virtual bool parseAttribute(const android::String8& name, const android::String8& value);
-private:
- TaskGeneric::ExecutionResult doRun(bool builtin);
-
- class Param;
- bool parseParams(std::vector<Param>& list, const char* str, bool isInput);
- //typedef necessary to prevent compiler's confusion
- typedef void* void_ptr;
- typedef std::unique_ptr<TaskCase::Value> UniqueValue;
- typedef std::unique_ptr<android::sp<Buffer> > UniqueBuffer;
- /// construct Buffers and Values for calling builtin functions.
- /// all constructed stuffs automatically deleted by the passed std::unique_ptrs.
- bool prepareParams(std::vector<TaskProcess::Param>& list,
- const bool* inputTypes,
- std::unique_ptr<void_ptr[]>& ptrs,
- std::unique_ptr<UniqueValue[]>& values,
- std::unique_ptr<UniqueBuffer[]>& buffers,
- bool isInput);
-
-private:
- enum ProcessType {
- EBuiltin,
- EScript
- };
- ProcessType mType;
- android::String8 mName; // buit-in function or script name
-
- enum ParamType {
- EId,
- EVal,
- EConst
- };
- class Param {
- public:
- Param(ParamType type, android::String8& string);
- explicit Param(TaskCase::Value& val);
- ParamType getType();
- android::String8& getParamString();
- TaskCase::Value& getValue();
- TaskCase::Value* getValuePtr();
- inline bool isIdType() {
- return (mType == EId);
- }
- private:
- ParamType mType;
- android::String8 mString;
- TaskCase::Value mValue;
- };
-
- std::vector<Param> mInput;
- std::vector<Param> mOutput;
- BuiltinProcessing mBuiltin;
- std::unique_ptr<SignalProcessingInterface> mSp;
-};
-
-
-#endif // CTSAUDIO_TASKPROCESS_H
diff --git a/suite/audio_quality/lib/include/task/TaskSave.h b/suite/audio_quality/lib/include/task/TaskSave.h
deleted file mode 100644
index bffc0b5..0000000
--- a/suite/audio_quality/lib/include/task/TaskSave.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKSAVE_H
-#define CTSAUDIO_TASKSAVE_H
-
-#include "TaskGeneric.h"
-
-
-class TaskSave: public TaskGeneric {
-public:
- TaskSave();
- virtual ~TaskSave();
- virtual TaskGeneric::ExecutionResult run();
-
-private:
- bool handleFile();
- bool handleReport();
-};
-
-
-#endif // CTSAUDIO_TASKSAVE_H
diff --git a/suite/audio_quality/lib/include/task/TaskSequential.h b/suite/audio_quality/lib/include/task/TaskSequential.h
deleted file mode 100644
index b5c3ecc..0000000
--- a/suite/audio_quality/lib/include/task/TaskSequential.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKSEQUENTIAL_H
-#define CTSAUDIO_TASKSEQUENTIAL_H
-
-#include <utils/String8.h>
-#include <list>
-#include "TaskGeneric.h"
-
-class TaskAsync;
-
-class TaskSequential: public TaskGeneric {
-public:
- TaskSequential();
- virtual ~TaskSequential();
- virtual TaskGeneric::ExecutionResult run();
- virtual bool parseAttribute(const android::String8& name, const android::String8& value);
- /**
- * Queue async task for asynchronous execution (= call complete later)
- * If the task is already queued, it will not be queued again ,but will just return true.
- */
- bool queueAsyncTask(TaskAsync* task);
-
-private:
- /**
- * Run all async tasks queued (= call complete) and dequeue them.
- * Execution will be continued even for error, and the 1st error result will be returned.
- */
- TaskGeneric::ExecutionResult runAsyncTasksQueued();
-
-private:
- int mRepeatCount;
- android::String8 mIndexName;
- int mRepeatIndex;
- std::list<TaskAsync*> mAsyncTasks;
-};
-
-
-#endif // CTSAUDIO_TASKSEQUENTIAL_H
diff --git a/suite/audio_quality/lib/include/task/TaskSound.h b/suite/audio_quality/lib/include/task/TaskSound.h
deleted file mode 100644
index 0b5ceb5..0000000
--- a/suite/audio_quality/lib/include/task/TaskSound.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKSOUND_H
-#define CTSAUDIO_TASKSOUND_H
-#include <utils/String8.h>
-#include <utils/StrongPointer.h>
-#include "audio/Buffer.h"
-#include "TaskGeneric.h"
-
-
-class TaskSound: public TaskGeneric {
-public:
- TaskSound();
- virtual ~TaskSound();
- virtual TaskGeneric::ExecutionResult run();
- virtual bool parseAttribute(const android::String8& name, const android::String8& value);
-private:
- android::sp<Buffer> mBuffer;
- bool mPreload;
-};
-
-
-#endif // CTSAUDIO_TASKSOUND_H
diff --git a/suite/audio_quality/lib/src/Adb.cpp b/suite/audio_quality/lib/src/Adb.cpp
deleted file mode 100644
index fbfc974..0000000
--- a/suite/audio_quality/lib/src/Adb.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <stdlib.h>
-
-#include <StringUtil.h>
-#include "Adb.h"
-
-Adb::Adb(const android::String8& device)
- : mDevice(device)
-{
-
-}
-
-Adb::~Adb()
-{
-
-}
-
-bool Adb::setPortForwarding(int hostPort, int devicePort)
-{
- android::String8 command;
- if (command.appendFormat("forward tcp:%d tcp:%d", hostPort, devicePort) != 0) {
- return false;
- }
- if (executeCommand(command) != 0) {
- return false;
- }
- return true;
-}
-
-bool Adb::launchClient(const android::String8& clientBinary, const android::String8& component)
-{
- android::String8 command;
- if (command.appendFormat("install -r %s", clientBinary.string()) != 0) {
- return false;
- }
- if (executeCommand(command) != 0) {
- return false;
- }
- command.clear();
- if (command.appendFormat("shell am start -W -n %s", component.string()) != 0) {
- return false;
- }
- if (executeCommand(command) != 0) {
- return false;
- }
- return true;
-}
-
-/** @param command ADB command except adb -s XYZW */
-int Adb::executeCommand(const android::String8& command)
-{
- android::String8 adbCommand;
- if (mDevice.empty()) {
- if (adbCommand.appendFormat("adb %s", command.string()) != 0) {
- return -1;
- }
- } else {
- if (adbCommand.appendFormat("adb -s %s %s", mDevice.string(),
- command.string()) != 0) {
- return -1;
- }
- }
- return system(adbCommand.string());
-}
-
diff --git a/suite/audio_quality/lib/src/Adb.h b/suite/audio_quality/lib/src/Adb.h
deleted file mode 100644
index c85b9f7..0000000
--- a/suite/audio_quality/lib/src/Adb.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_ADB_H
-#define CTSAUDIO_ADB_H
-
-#include <utils/String8.h>
-
-/** ADB interface to set port forwarding and launch client app */
-class Adb {
-public:
- /// device: device number typically passed in adb's -s argument.
- /// if device string is empty, adb command will be called without -s option.
- explicit Adb(const android::String8& device);
- ~Adb();
- bool setPortForwarding(int hostPort, int devicePort);
- /// install given clientBinary to DUT and launch given component.
- bool launchClient(const android::String8& clientBinary, const android::String8& component);
-private:
- int executeCommand(const android::String8& command);
-
-private:
- android::String8 mDevice;
-};
-
-#endif // CTSAUDIO_ADB_H
-
-
-
-
diff --git a/suite/audio_quality/lib/src/BuiltinProcessing.cpp b/suite/audio_quality/lib/src/BuiltinProcessing.cpp
deleted file mode 100644
index 697ce8e..0000000
--- a/suite/audio_quality/lib/src/BuiltinProcessing.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <stdint.h>
-#include <math.h>
-#include <utils/StrongPointer.h>
-#include "audio/Buffer.h"
-#include "BuiltinProcessing.h"
-#include "Log.h"
-#include "task/TaskCase.h"
-
-// Buffer, Value, Value
-static const bool RMS_MVA_INPUT_TYPE[] = {true, false, false};
-// Value
-static const bool RMS_MVA_OUTPUT_TYPE[] = {false};
-
-BuiltinProcessing::BuiltinInfo BuiltinProcessing::BUINTIN_FN_TABLE[N_BUILTIN_FNS] =
-{
- {
- "rms_mva", &BuiltinProcessing::rms_mva,
- sizeof(RMS_MVA_INPUT_TYPE)/sizeof(bool), RMS_MVA_INPUT_TYPE,
- sizeof(RMS_MVA_OUTPUT_TYPE)/sizeof(bool), RMS_MVA_OUTPUT_TYPE,
- }
-};
-
-BuiltinProcessing::BuiltinProcessing()
- : mRMSPasses(0)
-{
-
-}
-
-// pass for 5 consecutive passes
-TaskGeneric::ExecutionResult BuiltinProcessing::rms_mva(void** inputs, void** outputs)
-{
- LOGD("BuiltinProcessing::rms_mva in %x %x %x out %x",
- inputs[0], inputs[1], inputs[2], outputs[0]);
- android::sp<Buffer>& data(*reinterpret_cast<android::sp<Buffer>*>(inputs[0]));
-
- int64_t passMin = (reinterpret_cast<TaskCase::Value*>(inputs[1]))->getInt64();
- int64_t passMax = (reinterpret_cast<TaskCase::Value*>(inputs[2]))->getInt64();
-
- int64_t rms = 0;
- size_t samples = data->getSize()/2;
- int16_t* rawData = reinterpret_cast<int16_t*>(data->getData());
- double energy = 0.0f;
- for (size_t i = 0; i < samples; i++) {
- energy += (rawData[i] * rawData[i]);
- }
- rms = (int64_t)sqrt(energy/samples);
-
- TaskGeneric::ExecutionResult result = TaskGeneric::EResultOK;
- if (rms < passMin) {
- MSG("Volume %lld low compared to min %lld max %lld", rms, passMin, passMax);
- mRMSPasses = 0;
- } else if (rms <= passMax) {
- MSG("Volume %lld OK compared to min %lld max %lld", rms, passMin, passMax);
- mRMSPasses++;
- if (mRMSPasses >= RMS_CONTINUOUS_PASSES) {
- //mRMSPasses = 0;
- result = TaskGeneric::EResultPass;
- }
- } else {
- LOGW("Volume %lld high compared to min %lld max %lld", rms, passMin, passMax);
- mRMSPasses = 0;
- }
- TaskCase::Value* rmsVal = reinterpret_cast<TaskCase::Value*>(outputs[0]);
- rmsVal->setInt64(rms);
-
- return result;
-}
-
-
diff --git a/suite/audio_quality/lib/src/ClientImpl.cpp b/suite/audio_quality/lib/src/ClientImpl.cpp
deleted file mode 100644
index 615cd2a..0000000
--- a/suite/audio_quality/lib/src/ClientImpl.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "Log.h"
-
-#include "Adb.h"
-#include "ClientImpl.h"
-
-
-ClientImpl::ClientImpl()
- : mAudio(new RemoteAudio(mSocket))
-{
-
-}
-
-ClientImpl::~ClientImpl()
-{
- mAudio->release();
-}
-
-bool ClientImpl::init(const android::String8& param)
-{
- Adb adb(param);
- if (!adb.setPortForwarding(HOST_TCP_PORT, CLIENT_TCP_PORT)) {
- LOGE("adb port forwarding failed");
- return false;
- }
- android::String8 clientBinary("client/CtsAudioClient.apk");
- android::String8 componentName("com.android.cts.audiotest/.CtsAudioClientActivity");
- if (!adb.launchClient(clientBinary, componentName)) {
- LOGE("cannot install or launch client");
- return false;
- }
- // now socket connection
- return mAudio->init(HOST_TCP_PORT);
-}
-
-
diff --git a/suite/audio_quality/lib/src/ClientImpl.h b/suite/audio_quality/lib/src/ClientImpl.h
deleted file mode 100644
index 28a7bcc..0000000
--- a/suite/audio_quality/lib/src/ClientImpl.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_CLIENTIMPL_H
-#define CTSAUDIO_CLIENTIMPL_H
-
-#include <utils/StrongPointer.h>
-#include "ClientInterface.h"
-#include "ClientSocket.h"
-#include "audio/RemoteAudio.h"
-
-class ClientImpl: public ClientInterface {
-public:
- static const int HOST_TCP_PORT = 15001;
- static const int CLIENT_TCP_PORT = 15001;
- ClientImpl();
- virtual ~ClientImpl();
- virtual bool init(const android::String8& param);
-
- virtual ClientSocket& getSocket() {
- return mSocket;
- };
-
- virtual android::sp<RemoteAudio>& getAudio() {
- return mAudio;
- };
-
-private:
- ClientSocket mSocket;
- android::sp<RemoteAudio> mAudio;
-
-};
-
-
-#endif // CTSAUDIO_CLIENTIMPL_H
diff --git a/suite/audio_quality/lib/src/ClientSocket.cpp b/suite/audio_quality/lib/src/ClientSocket.cpp
deleted file mode 100644
index 1fa9090..0000000
--- a/suite/audio_quality/lib/src/ClientSocket.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <arpa/inet.h>
-#include <errno.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "Log.h"
-
-#include "ClientSocket.h"
-
-ClientSocket::ClientSocket()
- : mSocket(-1),
- mTimeoutEnabled(false)
-{
-
-}
-
-ClientSocket::~ClientSocket()
-{
- release();
-}
-
-bool ClientSocket::init(const char* hostIp, int port, bool enableTimeout)
-{
- LOGD("ClientSocket::init");
- mSocket = socket(AF_INET, SOCK_STREAM, 0);
- if (mSocket < 0) {
- LOGE("cannot open socket %d", errno);
- return false;
- }
- int reuse = 1;
- if (setsockopt(mSocket, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) == -1) {
- LOGE("setsockopt error %d", errno);
- release();
- return false;
- }
-
- struct sockaddr_in serverAddr;
- bzero((char*)&serverAddr, sizeof(serverAddr));
- serverAddr.sin_family = AF_INET;
- serverAddr.sin_port = htons(port);
- if (inet_pton(AF_INET, hostIp, &serverAddr.sin_addr) != 1) {
- release();
- LOGE("inet_pton failed %d", errno);
- return false;
- }
- if (connect(mSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0) {
- release();
- LOGE("cannot connect socket %d", errno);
- return false;
- }
- mTimeoutEnabled = enableTimeout;
- return true;
-}
-
-const int ZERO_RW_SLEEP_TIME_US = 10;
-
-// make non-blocking mode only during read. This allows supporting time-out for read
-bool ClientSocket::readData(char* data, int len, int timeoutInMs)
-{
- bool useTimeout = (mTimeoutEnabled && (timeoutInMs > 0));
- int flOriginal = 0;
- int timeInSec = 0;
- int timeInUs = 0;
- if (useTimeout) {
- flOriginal = fcntl(mSocket, F_GETFL,0);
- if (flOriginal == -1) {
- LOGE("fcntl error %d", errno);
- return false;
- }
- if (fcntl(mSocket, F_SETFL, flOriginal | O_NONBLOCK) == -1) {
- LOGE("fcntl error %d", errno);
- return false;
- }
- timeInSec = timeoutInMs / 1000;
- timeInUs = (timeoutInMs % 1000) * 1000;
- }
- bool result = true;
- int read;
- int toRead = len;
- while (toRead > 0) {
- if (useTimeout) {
- fd_set rfds;
- struct timeval tv;
- tv.tv_sec = timeInSec;
- tv.tv_usec = timeInUs;
- FD_ZERO(&rfds);
- FD_SET(mSocket, &rfds);
- if (select(mSocket + 1, &rfds, NULL, NULL, &tv) == -1) {
- LOGE("select failed");
- result = false;
- break;
- }
- if (!FD_ISSET(mSocket, &rfds)) {
- LOGE("socket read timeout");
- result = false;
- break;
- }
- }
- read = recv(mSocket, (void*)data, toRead, 0);
- if (read > 0) {
- toRead -= read;
- data += read;
- } else if (read == 0) {
- // in blocking mode, zero read mean's peer closed.
- // in non-blocking mode, select said that there is data. so it should not happen
- LOGE("zero read, peer closed or what?, nonblocking: %d", useTimeout);
- result = false;
- break;
- } else {
- LOGE("recv returned %d", read);
- result = false;
- break;
- }
- }
- if (useTimeout) {
- fcntl(mSocket, F_SETFL, flOriginal); // now blocking again
- }
- return result;
-}
-
-bool ClientSocket::sendData(const char* data, int len)
-{
- int sent;
- int toSend = len;
- while (toSend > 0) {
- sent = send(mSocket, (void*)data, (size_t)toSend, 0);
- if (sent > 0) {
- toSend -= sent;
- data += sent;
- } else if (sent == 0) { // no more buffer?
- usleep(ZERO_RW_SLEEP_TIME_US); // just wait
- } else {
- LOGE("send returned %d, error %d", sent, errno);
- return false;
- }
- }
- return true;
-}
-
-void ClientSocket::release()
-{
- if (mSocket != -1) {
- close(mSocket);
- mSocket = -1;
- }
-}
diff --git a/suite/audio_quality/lib/src/FileUtil.cpp b/suite/audio_quality/lib/src/FileUtil.cpp
deleted file mode 100644
index 3b87016..0000000
--- a/suite/audio_quality/lib/src/FileUtil.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <time.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-
-#include "Log.h"
-#include "Settings.h"
-#include "StringUtil.h"
-#include "FileUtil.h"
-
-
-// This class is used by Log. So we cannot use LOG? macros here.
-#define _LOGD_(x...) do { fprintf(stderr, x); fprintf(stderr, "\n"); } while(0)
-
-// reported generated under reports/YYYY_MM_DD_HH_MM_SS dir
-const char reportTopDir[] = "reports";
-android::String8 FileUtil::mDirPath;
-
-bool FileUtil::prepare(android::String8& dirPath)
-{
- if (mDirPath.length() != 0) {
- dirPath = mDirPath;
- _LOGD_("mDirPath %s", mDirPath.string());
- return true;
- }
-
- time_t timeNow = time(NULL);
- if (timeNow == ((time_t)-1)) {
- _LOGD_("time error");
- return false;
- }
- // tm is allocated in static buffer, and should not be freed.
- struct tm* tm = localtime(&timeNow);
- if (tm == NULL) {
- _LOGD_("localtime error");
- return false;
- }
- int result = mkdir(reportTopDir, S_IRWXU);
- if ((result == -1) && (errno != EEXIST)) {
- _LOGD_("mkdir of topdir failed, error %d", errno);
- return false;
- }
- android::String8 reportTime;
- if (reportTime.appendFormat("%04d_%02d_%02d_%02d_%02d_%02d", tm->tm_year + 1900,
- tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec) != 0) {
- return false;
- }
- Settings::Instance()->addSetting(Settings::EREPORT_TIME, reportTime);
- android::String8 path;
- if (path.appendFormat("%s/%s", reportTopDir, reportTime.string()) != 0) {
- return false;
- }
- result = mkdir(path.string(), S_IRWXU);
- if ((result == -1) && (errno != EEXIST)) {
- _LOGD_("mkdir of report dir failed, error %d", errno);
- return false;
- }
- mDirPath = path;
- dirPath = path;
-
- return true;
-}
-
-FileUtil::FileUtil()
-{
- mBuffer = new char[DEFAULT_BUFFER_SIZE];
- if (mBuffer == NULL) {
- // cannot use ASSERT here, just crash
- abort();
- }
- mBufferSize = DEFAULT_BUFFER_SIZE;
-}
-
-FileUtil::~FileUtil()
-{
- if (mFile.is_open()) {
- mFile.close();
- }
- delete[] mBuffer;
-}
-
-bool FileUtil::init(const char* fileName)
-{
- if (fileName == NULL) {
- return true;
- }
-
- mFile.open(fileName, std::ios::out | std::ios::trunc);
- if (!mFile.is_open()) {
- return false;
- }
- return true;
-}
-
-bool FileUtil::doVprintf(bool fileOnly, int logLevel, const char *fmt, va_list ap)
-{
- // prevent messed up log in multi-thread env. Still multi-line logs can be messed up.
- android::Mutex::Autolock lock(mWriteLock);
- while (1) {
- int start = 0;
- if (logLevel != -1) {
- mBuffer[0] = '0' + logLevel;
- mBuffer[1] = '>';
- start = 2;
- }
- int size;
- size = vsnprintf(mBuffer + start, mBufferSize - start - 2, fmt, ap); // 2 for \n\0
- if (size < 0) {
- fprintf(stderr, "FileUtil::vprintf failed");
- return false;
- }
- if ((size + start + 2) > mBufferSize) {
- //default buffer does not fit, increase buffer size and retry
- delete[] mBuffer;
- mBuffer = new char[2 * size];
- if (mBuffer == NULL) {
- // cannot use ASSERT here, just crash
- abort();
- }
- mBufferSize = 2 * size;
- // re-try
- continue;
- }
- size += start;
- mBuffer[size] = '\n';
- size++;
- mBuffer[size] = 0;
-
- if (!fileOnly) {
- fprintf(stdout, "%s", mBuffer);
- }
- if (mFile.is_open()) {
- mFile<<mBuffer;
- }
- return true;
- }
-}
-
-bool FileUtil::doPrintf(const char* fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- bool result = doVprintf(false, -1, fmt, ap);
- va_end(ap);
- return result;
-}
diff --git a/suite/audio_quality/lib/src/GenericFactory.cpp b/suite/audio_quality/lib/src/GenericFactory.cpp
deleted file mode 100644
index d70d907..0000000
--- a/suite/audio_quality/lib/src/GenericFactory.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include "Log.h"
-#include "GenericFactory.h"
-#include "ClientImpl.h"
-#include "task/TaskAll.h"
-
-ClientInterface* GenericFactory::createClientInterface()
-{
- return new ClientImpl();
-}
-
-TaskGeneric* GenericFactory::createTask(TaskGeneric::TaskType type)
-{
- TaskGeneric* task;
- switch(type) {
- case TaskGeneric::ETaskBatch:
- task = new TaskBatch();
- break;
- case TaskGeneric::ETaskCase:
- task = new TaskCase();
- break;
- case TaskGeneric::ETaskSequential:
- task = new TaskSequential();
- break;
- case TaskGeneric::ETaskProcess:
- task = new TaskProcess();
- break;
- case TaskGeneric::ETaskInput:
- task = new TaskInput();
- break;
- case TaskGeneric::ETaskOutput:
- task = new TaskOutput();
- break;
- case TaskGeneric::ETaskSound:
- task = new TaskSound();
- break;
- case TaskGeneric::ETaskSave:
- task = new TaskSave();
- break;
- // simple elements without its own class
- case TaskGeneric::ETaskSetup:
- case TaskGeneric::ETaskAction:
- task = new TaskGeneric(type);
- break;
- case TaskGeneric::ETaskMessage:
- task = new TaskMessage();
- break;
- case TaskGeneric::ETaskDownload:
- task = new TaskDownload();
- break;
- default:
- LOGE("GenericFactory::createTask unsupported type %d", type);
- return NULL;
- }
- LOGD("GenericFactory::createTask 0x%x, type %d", task, type);
- return task;
-}
-
-GenericFactory::~GenericFactory() {
-}
diff --git a/suite/audio_quality/lib/src/Log.cpp b/suite/audio_quality/lib/src/Log.cpp
deleted file mode 100644
index 1d2434a..0000000
--- a/suite/audio_quality/lib/src/Log.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <stdio.h>
-#include <stdarg.h>
-
-#include "StringUtil.h"
-#include "Log.h"
-
-Log* Log::mInstance = NULL;
-
-#define ASSERT_PLAIN(cond) if(!(cond)) { fprintf(stderr, \
- "assertion failed %s %d", __FILE__, __LINE__); \
- abort(); };
-
-Log* Log::Instance(const char* dirName)
-{
- if (!mInstance) {
- mInstance = new Log();
- ASSERT_PLAIN(mInstance->init(dirName));
- }
- return mInstance;
-}
-void Log::Finalize()
-{
- delete mInstance;
- mInstance = NULL;
-}
-void Log::printf(LogLevel level, const char* fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- FileUtil::doVprintf(level < mLogLevel, level, fmt, ap);
- va_end(ap);
-}
-
-void Log::setLogLevel(LogLevel level)
-{
- mLogLevel = level;
-}
-
-Log::Log()
- : mLogLevel(ELogV)
-{
- ::fprintf(stderr, "Log level %d\n", mLogLevel);
-}
-
-Log::~Log()
-{
-
-}
-
-bool Log::init(const char* dirName)
-{
- if (dirName == NULL) {
- return true;
- }
- android::String8 logFile;
- if (logFile.appendFormat("%s/log.txt", dirName) != 0) {
- return false;
- }
- return FileUtil::init(logFile.string());
-}
-
-
-
diff --git a/suite/audio_quality/lib/src/RWBuffer.h b/suite/audio_quality/lib/src/RWBuffer.h
deleted file mode 100644
index 8065e3e..0000000
--- a/suite/audio_quality/lib/src/RWBuffer.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_RWBUFFER_H
-#define CTSAUDIO_RWBUFFER_H
-
-#include <stdint.h>
-#include <utils/String8.h>
-#include "Log.h"
-
-/// utility for R/W buffer
-class RWBuffer {
-public:
- explicit RWBuffer(int capacity)
- : mCapacity(capacity),
- mWrPoint(0),
- mRdPoint(0) {
- mBuffer = new char[capacity];
- }
-
- ~RWBuffer() {
- delete[] mBuffer;
- }
-
- void reset() {
- mWrPoint = 0;
- mRdPoint = 0;
- }
-
- void resetWr() {
- mWrPoint = 0;
- }
-
- void resetRd() {
- mRdPoint = 0;
- }
-
- const char* getBuffer() {
- return mBuffer;
- }
- char* getUnwrittenBuffer() {
- return mBuffer + mWrPoint;
- }
-
- inline void assertWriteCapacity(int sizeToWrite) {
- ASSERT((mWrPoint + sizeToWrite) <= mCapacity);
- }
- void increaseWritten(int size) {
- assertWriteCapacity(0); // damage already done, but detect and panic if happened
- mWrPoint += size;
- }
-
- int getSizeWritten() {
- return mWrPoint;
- }
-
- int getSizeRead() {
- return mRdPoint;
- }
-
- template <typename T> void write(T v) {
- char* src = (char*)&v;
- assertWriteCapacity(sizeof(T));
- memcpy(mBuffer + mWrPoint, src, sizeof(T));
- mWrPoint += sizeof(T);
- }
- void writeStr(const android::String8& str) {
- size_t len = str.length();
- assertWriteCapacity(len);
- memcpy(mBuffer + mWrPoint, str.string(), len);
- mWrPoint += len;
- }
- template <typename T> T read() {
- T v;
- ASSERT((mRdPoint + sizeof(T)) <= mWrPoint);
- memcpy(&v, mBuffer + mRdPoint, sizeof(T));
- mRdPoint += sizeof(T);
- }
-
-private:
- int mCapacity;
- int mWrPoint;
- int mRdPoint;
- char* mBuffer;
-};
-
-
-#endif // CTSAUDIO_RWBUFFER_H
diff --git a/suite/audio_quality/lib/src/Report.cpp b/suite/audio_quality/lib/src/Report.cpp
deleted file mode 100644
index e47f3aa..0000000
--- a/suite/audio_quality/lib/src/Report.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "Log.h"
-#include "Settings.h"
-#include "StringUtil.h"
-#include "Report.h"
-#include "task/TaskCase.h"
-
-
-Report* Report::mInstance = NULL;
-
-Report* Report::Instance(const char* dirName)
-{
- if (mInstance == NULL) {
- mInstance = new Report();
- ASSERT(mInstance->init(dirName));
- }
- return mInstance;
-}
-void Report::Finalize()
-{
- delete mInstance;
- mInstance = NULL;
-}
-
-
-Report::Report()
-{
-
-}
-
-Report::~Report()
-{
- writeReport();
- mFailedCases.clear();
- mPassedCases.clear();
-}
-
-bool Report::init(const char* dirName)
-{
- if (dirName == NULL) {
- return true;
- }
- android::String8 report;
- if (report.appendFormat("%s/report.xml", dirName) != 0) {
- return false;
- }
- Settings::Instance()->addSetting(Settings::EREPORT_FILE, report);
- return FileUtil::init(report.string());
-}
-
-void Report::printf(const char* fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- FileUtil::doVprintf(false, -1, fmt, ap);
- va_end(ap);
-}
-
-void Report::addCasePassed(const TaskCase* task)
-{
- android::String8 name(" ");
- task->getCaseName(name);
- StringPair pair(name, task->getDetails());
- mPassedCases.push_back(pair);
-}
-
-void Report::addCaseFailed(const TaskCase* task)
-{
- android::String8 name(" ");
- task->getCaseName(name);
- StringPair pair(name, task->getDetails());
- mFailedCases.push_back(pair);
-}
-
-void Report::writeResult(std::list<StringPair>::const_iterator begin,
- std::list<StringPair>::const_iterator end, bool passed)
-{
- std::list<StringPair>::const_iterator it;
- for (it = begin; it != end; it++) {
- if (passed) {
- printf(" <test title=\"%s\" result=\"pass\" >", it->first.string());
- } else {
- printf(" <test title=\"%s\" result=\"fail\" >", it->first.string());
- }
- printf(" <details>\n%s", it->second.string());
- printf(" </details>");
- printf(" </test>");
- }
-}
-
-void Report::writeReport()
-{
- printf("<?xml version='1.0' encoding='utf-8' standalone='yes' ?>");
- printf("<audio-test-results-report report-version=\"1\" creation-time=\"%s\">",
- Settings::Instance()->getSetting(Settings::EREPORT_TIME).string());
- printf(" <verifier-info version-name=\"1\" version-code=\"1\" />");
- printf(" <device-info>");
- printf(" %s", Settings::Instance()->getSetting(Settings::EDEVICE_INFO).string());
- printf(" </device-info>");
- printf(" <audio-test-results xml=\"%s\">",
- Settings::Instance()->getSetting(Settings::ETEST_XML).string());
-
- writeResult(mFailedCases.begin(), mFailedCases.end(), false);
- writeResult(mPassedCases.begin(), mPassedCases.end(), true);
-
- printf(" </audio-test-results>");
- printf("</audio-test-results-report>");
-}
diff --git a/suite/audio_quality/lib/src/Semaphore.cpp b/suite/audio_quality/lib/src/Semaphore.cpp
deleted file mode 100644
index b430cad..0000000
--- a/suite/audio_quality/lib/src/Semaphore.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "Semaphore.h"
-
-
-Semaphore::Semaphore(int count)
-{
- if (sem_init(&mSem, 0, count) != 0) {
- ASSERT(false);
- }
-}
-
-Semaphore::~Semaphore()
-{
- sem_destroy(&mSem);
-}
-
-void Semaphore::tryWait()
-{
- sem_trywait(&mSem);
-}
-
-bool Semaphore::wait()
-{
- if (sem_wait(&mSem) == 0) {
- return true;
- } else {
- return false;
- }
-}
-
-bool Semaphore::timedWait(int timeInMSec)
-{
- const int ONE_SEC_IN_NANOSEC = 1000000000;
- const int ONE_MSEC_IN_NANOSEC = 1000000;
- const int ONE_SEC_IN_MSEC = 1000;
- struct timespec timeOld;
- if (clock_gettime(CLOCK_REALTIME, &timeOld) != 0) {
- return false;
- }
- int secToGo = timeInMSec / ONE_SEC_IN_MSEC;
- int msecToGo = timeInMSec - (ONE_SEC_IN_MSEC * secToGo);
- int nanoSecToGo = ONE_MSEC_IN_NANOSEC * msecToGo;
- struct timespec timeNew = timeOld;
- int nanoTotal = timeOld.tv_nsec + nanoSecToGo;
- //LOGI("secToGo %d, msecToGo %d, nanoTotal %d", secToGo, msecToGo, nanoTotal);
- if (nanoTotal > ONE_SEC_IN_NANOSEC) {
- nanoTotal -= ONE_SEC_IN_NANOSEC;
- secToGo += 1;
- }
- timeNew.tv_sec += secToGo;
- timeNew.tv_nsec = nanoTotal;
- //LOGV("Semaphore::timedWait now %d-%d until %d-%d for %d msecs",
- // timeOld.tv_sec, timeOld.tv_nsec, timeNew.tv_sec, timeNew.tv_nsec, timeInMSec);
- if (sem_timedwait(&mSem, &timeNew) == 0) {
- return true;
- } else {
- return false;
- }
-}
-
-void Semaphore::post()
-{
- sem_post(&mSem);
-}
diff --git a/suite/audio_quality/lib/src/Settings.cpp b/suite/audio_quality/lib/src/Settings.cpp
deleted file mode 100644
index 7af4c08..0000000
--- a/suite/audio_quality/lib/src/Settings.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "Settings.h"
-#include "Log.h"
-
-Settings* Settings::mInstance = NULL;
-
-Settings* Settings::Instance()
-{
- if (mInstance == NULL) {
- mInstance = new Settings();
- }
- return mInstance;
-}
-
-void Settings::Finalize()
-{
- delete mInstance;
- mInstance = NULL;
-}
-
-
-void Settings::addSetting(SettingType type, const android::String8& setting)
-{
- mSettings[type] = setting;
-}
-const android::String8& Settings::getSetting(SettingType type)
-{
- return mSettings[type];
-}
-
-
-
diff --git a/suite/audio_quality/lib/src/SignalProcessingImpl.cpp b/suite/audio_quality/lib/src/SignalProcessingImpl.cpp
deleted file mode 100644
index 21f9702..0000000
--- a/suite/audio_quality/lib/src/SignalProcessingImpl.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <utils/StrongPointer.h>
-
-#include "Log.h"
-#include "audio/Buffer.h"
-#include "StringUtil.h"
-#include "SimpleScriptExec.h"
-#include "SignalProcessingImpl.h"
-#include "task/TaskCase.h"
-
-enum ToPythonCommandType {
- EHeader = 0x0,
- ETerminate = 0x1,
- EFunctionName = 0x2,
- EAudioMono = 0x4,
- EAudioStereo = 0x5,
- EValue64Int = 0x8,
- EValueDouble = 0x9,
- EExecutionResult = 0x10
-};
-
-const android::String8 \
- SignalProcessingImpl::MAIN_PROCESSING_SCRIPT("test_description/processing_main.py");
-
-SignalProcessingImpl::SignalProcessingImpl()
- : mChildRunning(false),
- mBuffer(1024)
-{
-
-}
-
-SignalProcessingImpl::~SignalProcessingImpl()
-{
- if (mSocket.get() != NULL) {
- int terminationCommand [] = {ETerminate, 0};
- send((char*)terminationCommand, sizeof(terminationCommand));
- mSocket->release();
- }
- if (mChildRunning) {
- waitpid(mChildPid, NULL, 0);
- }
-}
-
-#define CHILD_LOGE(x...) do { fprintf(stderr, x); \
- fprintf(stderr, " %s - %d\n", __FILE__, __LINE__); } while(0)
-
-const int CHILD_WAIT_TIME_US = 100000;
-
-bool SignalProcessingImpl::init(const android::String8& script)
-{
- pid_t pid;
- if ((pid = fork()) < 0) {
- LOGE("SignalProcessingImpl::init fork failed %d", errno);
- return false;
- } else if (pid == 0) { // child
- if (execl(SimpleScriptExec::PYTHON_PATH, SimpleScriptExec::PYTHON_PATH,
- script.string(), NULL) < 0) {
- CHILD_LOGE("execl %s %s failed %d", SimpleScriptExec::PYTHON_PATH,
- script.string(), errno);
- exit(EXIT_FAILURE);
- }
- } else { // parent
- mChildPid = pid;
- mChildRunning = true;
- int result = false;
- int retryCount = 0;
- // not that clean, but it takes some time for python side to have socket ready
- const int MAX_RETRY = 20;
- while (retryCount < MAX_RETRY) {
- usleep(CHILD_WAIT_TIME_US);
- mSocket.reset(new ClientSocket());
- if (mSocket.get() == NULL) {
- result = false;
- break;
- }
- if (mSocket->init("127.0.0.1", SCRIPT_PORT, true)) {
- result = true;
- break;
- }
- retryCount++;
- }
- if (!result) {
- LOGE("cannot connect to child");
- mSocket.reset(NULL);
- return result;
- }
- }
- return true;
-}
-
-
-TaskGeneric::ExecutionResult SignalProcessingImpl::run( const android::String8& functionScript,
- int nInputs, bool* inputTypes, void** inputs,
- int nOutputs, bool* outputTypes, void** outputs)
-{
- mBuffer.reset();
- mBuffer.write <int32_t>((int32_t)EHeader);
- mBuffer.write<int32_t>(nInputs + 1);
- mBuffer.write<int32_t>((int32_t)EFunctionName);
- mBuffer.write<int32_t>((int32_t)functionScript.length());
- mBuffer.writeStr(functionScript);
- if (!send(mBuffer.getBuffer(), mBuffer.getSizeWritten())) {
- LOGE("send failed");
- return TaskGeneric::EResultError;
- }
- for (int i = 0; i < nInputs; i++) {
- mBuffer.reset();
- if (inputTypes[i]) { // android::sp<Buffer>*
- android::sp<Buffer>* buffer = reinterpret_cast<android::sp<Buffer>*>(inputs[i]);
- mBuffer.write<int32_t>((int32_t)((*buffer)->isStereo() ? EAudioStereo : EAudioMono));
- int dataLen = (*buffer)->getSize();
- mBuffer.write<int32_t>(dataLen);
- if (!send(mBuffer.getBuffer(), mBuffer.getSizeWritten())) {
- LOGE("send failed");
- return TaskGeneric::EResultError;
- }
- if (!send((*buffer)->getData(), dataLen)) {
- LOGE("send failed");
- return TaskGeneric::EResultError;
- }
- LOGD("%d-th param buffer %d, stereo:%d", i, dataLen, (*buffer)->isStereo());
- } else { //TaskCase::Value*
- TaskCase::Value* val = reinterpret_cast<TaskCase::Value*>(inputs[i]);
- bool isI64 = (val->getType() == TaskCase::Value::ETypeI64);
- mBuffer.write<int32_t>((int32_t)(isI64 ? EValue64Int : EValueDouble));
- if (isI64) {
- mBuffer.write<int64_t>(val->getInt64());
- } else {
- mBuffer.write<double>(val->getDouble());
- }
- if (!send(mBuffer.getBuffer(), mBuffer.getSizeWritten())) {
- LOGE("send failed");
- return TaskGeneric::EResultError;
- }
- LOGD("%d-th param Value", i);
- }
- }
- int32_t header[4]; // id 0 - no of types - id 0x10 - ExecutionResult
- if (!read((char*)header, sizeof(header))) {
- LOGE("read failed");
- return TaskGeneric::EResultError;
- }
- if (header[0] != 0) {
- LOGE("wrong data");
- return TaskGeneric::EResultError;
- }
- if (header[2] != EExecutionResult) {
- LOGE("wrong data");
- return TaskGeneric::EResultError;
- }
- if (header[3] == TaskGeneric::EResultError) {
- LOGE("script returned error %d", header[3]);
- return (TaskGeneric::ExecutionResult)header[3];
- }
- if ((header[1] - 1) != nOutputs) {
- LOGE("wrong data");
- return TaskGeneric::EResultError;
- }
- for (int i = 0; i < nOutputs; i++) {
- int32_t type;
- if (!read((char*)&type, sizeof(type))) {
- LOGE("read failed");
- return TaskGeneric::EResultError;
- }
- if (outputTypes[i]) { // android::sp<Buffer>*
- int32_t dataLen;
- if (!read((char*)&dataLen, sizeof(dataLen))) {
- LOGE("read failed");
- return TaskGeneric::EResultError;
- }
- android::sp<Buffer>* buffer = reinterpret_cast<android::sp<Buffer>*>(outputs[i]);
- if (buffer->get() == NULL) { // data not allocated, this can happen for unknown-length output
- *buffer = new Buffer(dataLen, dataLen, (type == EAudioStereo) ? true: false);
- if (buffer->get() == NULL) {
- LOGE("alloc failed");
- return TaskGeneric::EResultError;
- }
- }
- bool isStereo = (*buffer)->isStereo();
-
- if (((type == EAudioStereo) && isStereo) || ((type == EAudioMono) && !isStereo)) {
- // valid
- } else {
- LOGE("%d-th output wrong type %d stereo: %d", i, type, isStereo);
- return TaskGeneric::EResultError;
- }
-
- if (dataLen > (int)(*buffer)->getSize()) {
- LOGE("%d-th output data too long %d while buffer size %d", i, dataLen,
- (*buffer)->getSize());
- return TaskGeneric::EResultError;
- }
- if (!read((*buffer)->getData(), dataLen)) {
- LOGE("read failed");
- return TaskGeneric::EResultError;
- }
- LOGD("received buffer %x %x", ((*buffer)->getData())[0], ((*buffer)->getData())[1]);
- (*buffer)->setHandled(dataLen);
- (*buffer)->setSize(dataLen);
- } else { //TaskCase::Value*
- TaskCase::Value* val = reinterpret_cast<TaskCase::Value*>(outputs[i]);
- if ((type == EValue64Int) || (type == EValueDouble)) {
- if (!read((char*)val->getPtr(), sizeof(int64_t))) {
- LOGE("read failed");
- return TaskGeneric::EResultError;
- }
- if (type == EValue64Int) {
- val->setType(TaskCase::Value::ETypeI64);
- } else {
- val->setType(TaskCase::Value::ETypeDouble);
- }
- } else {
- LOGE("wrong type %d", type);
- return TaskGeneric::EResultError;
- }
- }
- }
- return (TaskGeneric::ExecutionResult)header[3];
-}
-
-bool SignalProcessingImpl::send(const char* data, int len)
-{
- //LOGD("send %d", len);
- return mSocket->sendData(data, len);
-}
-
-bool SignalProcessingImpl::read(char* data, int len)
-{
- const int READ_TIMEOUT_MS = 60000 * 2; // as some calculation like calc_delay takes almost 20 secs
- //LOGD("read %d", len);
- return mSocket->readData(data, len, READ_TIMEOUT_MS);
-}
-
diff --git a/suite/audio_quality/lib/src/SignalProcessingImpl.h b/suite/audio_quality/lib/src/SignalProcessingImpl.h
deleted file mode 100644
index 2b8b8e0..0000000
--- a/suite/audio_quality/lib/src/SignalProcessingImpl.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_SIGNALPROCESSINGIMPL_H
-#define CTSAUDIO_SIGNALPROCESSINGIMPL_H
-
-#include <memory>
-#include <utils/String8.h>
-
-#include "SignalProcessingInterface.h"
-#include "ClientSocket.h"
-#include "RWBuffer.h"
-
-/**
- * Implements SignalProcessingInterface
- */
-class SignalProcessingImpl: public SignalProcessingInterface {
-public:
- static const android::String8 MAIN_PROCESSING_SCRIPT;
- SignalProcessingImpl();
- virtual ~SignalProcessingImpl();
- /**
- * @param script main script to call function script
- */
- virtual bool init(const android::String8& script);
-
- virtual TaskGeneric::ExecutionResult run(const android::String8& functionScript,
- int nInputs, bool* inputTypes, void** inputs,
- int nOutputs, bool* outputTypes, void** outputs);
-private:
- bool send(const char* data, int len);
- bool read(char* data, int len);
-
-private:
- static const int SCRIPT_PORT = 15010;
- std::unique_ptr<ClientSocket> mSocket;
- pid_t mChildPid;
- bool mChildRunning;
- RWBuffer mBuffer;
-};
-
-
-#endif //CTSAUDIO_SIGNALPROCESSINGIMPL_H
diff --git a/suite/audio_quality/lib/src/SimpleScriptExec.cpp b/suite/audio_quality/lib/src/SimpleScriptExec.cpp
deleted file mode 100644
index 0a2045b..0000000
--- a/suite/audio_quality/lib/src/SimpleScriptExec.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "Log.h"
-#include "StringUtil.h"
-
-#include "SimpleScriptExec.h"
-
-const char* SimpleScriptExec::PYTHON_PATH = "/usr/bin/python";
-const char* PASS_MAGIC_WORD = "___CTS_AUDIO_PASS___";
-
-bool SimpleScriptExec::checkPythonEnv()
-{
- android::String8 script("test_description/conf/check_conf.py");
- android::String8 param;
- android::String8 result;
- if (!runScript(script, param, result)) {
- return false;
- }
-
- android::String8 rePattern;
- return checkIfPassed(result, rePattern);
-}
-
-bool SimpleScriptExec::checkIfPassed(const android::String8& str, const android::String8& reMatch,
- int nmatch, regmatch_t pmatch[])
-{
- android::String8 match;
- match.append(PASS_MAGIC_WORD);
- match.append(reMatch);
- LOGV("re match %s", match.string());
- regex_t re;
- int cflags = REG_EXTENDED;
- if (nmatch == 0) {
- cflags |= REG_NOSUB;
- }
- if (regcomp(&re, match.string(), cflags) != 0) {
- LOGE("regcomp failed");
- return false;
- }
- bool result = false;
- if (regexec(&re, str.string(), nmatch, pmatch, 0) == 0) {
- // match found. passed
- result = true;
- }
- regfree(&re);
- return result;
-}
-
-bool SimpleScriptExec::runScript(const android::String8& script, const android::String8& param,
- android::String8& result)
-{
- FILE *fpipe;
- android::String8 command;
- command.appendFormat("%s %s %s", PYTHON_PATH, script.string(), param.string());
- const int READ_SIZE = 1024;
- char buffer[READ_SIZE];
- size_t len = 0;
-
- if ( !(fpipe = (FILE*)popen(command.string(),"r")) ) {
- LOGE("cannot execute python");
- return false;
- }
- result.clear();
- while((len = fread(buffer, 1, READ_SIZE, fpipe)) > 0) {
- result.append(buffer, len);
- }
- pclose(fpipe);
-
- return true;
-}
-
-
-
diff --git a/suite/audio_quality/lib/src/SimpleScriptExec.h b/suite/audio_quality/lib/src/SimpleScriptExec.h
deleted file mode 100644
index 28117c4..0000000
--- a/suite/audio_quality/lib/src/SimpleScriptExec.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_SIMPLESCRIPTEXEC_H
-#define CTSAUDIO_SIMPLESCRIPTEXEC_H
-
-#include <sys/types.h>
-#include <regex.h>
-
-#include <utils/String8.h>
-
-/**
- * Utility class for executing simple scripts
- * which prints ___CTS_AUDIO_PASS___ string in output
- */
-class SimpleScriptExec {
-public:
- static const char* PYTHON_PATH;
-
- static bool checkPythonEnv();
- /**
- * run given script
- * @param script full path of the script
- * @param param arguments to pass
- * @param result
- */
- static bool runScript(const android::String8& script, const android::String8& param,
- android::String8& result);
-
- /**
- * check if the given str include magic words for pass.
- * @param str
- * @param reMatch pattern to match in re besides the pass string
- * @param nmatch number of substring pattern match elements. It should be in POSIX
- * extended RE syntax, no \d nor [:digit:]
- * @param pmatch pattern match elements
- * @return true if passed
- */
- static bool checkIfPassed(const android::String8& str, const android::String8& reMatch,
- int nmatch = 0, regmatch_t pmatch[] = NULL);
-};
-
-
-#endif // CTSAUDIO_SIMPLESCRIPTEXEC_H
diff --git a/suite/audio_quality/lib/src/StringUtil.cpp b/suite/audio_quality/lib/src/StringUtil.cpp
deleted file mode 100644
index f23a29a..0000000
--- a/suite/audio_quality/lib/src/StringUtil.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-#include "Log.h"
-#include "StringUtil.h"
-
-std::vector<android::String8>* StringUtil::split(const android::String8& str, char delimiter)
-{
- std::vector<android::String8>* tokens = new std::vector<android::String8>();
- unsigned int lastTokenEnd = 0;
- for (unsigned int i = 0; i < str.length(); i++) {
- if (str[i] == delimiter) {
- if ((i - lastTokenEnd) > 0) {
- tokens->push_back(substr(str, lastTokenEnd, i - lastTokenEnd));
- }
- lastTokenEnd = i + 1; // 1 for skipping delimiter
- }
- }
- if (lastTokenEnd < str.length()) {
- tokens->push_back(substr(str, lastTokenEnd, str.length() - lastTokenEnd));
- }
- return tokens;
-}
-
-android::String8 StringUtil::substr(const android::String8& str, size_t pos, size_t n)
-{
- size_t l = str.length();
-
- if (pos >= l) {
- android::String8 resultDummy;
- return resultDummy;
- }
- if ((pos + n) > l) {
- n = l - pos;
- }
- android::String8 result(str.string() + pos, n);
- return result;
-}
-
-int StringUtil::compare(const android::String8& str, const char* other)
-{
- return strcmp(str.string(), other);
-}
-
-bool StringUtil::endsWith(const android::String8& str, const char* other)
-{
- size_t l1 = str.length();
- size_t l2 = strlen(other);
- const char* data = str.string();
- if (l2 > l1) {
- return false;
- }
- size_t iStr = l1 - l2;
- size_t iOther = 0;
- for(; iStr < l1; iStr++) {
- if (data[iStr] != other[iOther]) {
- return false;
- }
- iOther++;
- }
- return true;
-}
diff --git a/suite/audio_quality/lib/src/audio/AudioHardware.cpp b/suite/audio_quality/lib/src/audio/AudioHardware.cpp
deleted file mode 100644
index 0eebe0a..0000000
--- a/suite/audio_quality/lib/src/audio/AudioHardware.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <sys/types.h>
-#include <regex.h>
-#include <stdlib.h>
-
-#include <tinyalsa/asoundlib.h>
-
-#include "Log.h"
-#include "StringUtil.h"
-#include "SimpleScriptExec.h"
-#include "audio/AudioHardware.h"
-#include "audio/Buffer.h"
-#include "audio/AudioPlaybackLocal.h"
-#include "audio/AudioRecordingLocal.h"
-#include "audio/AudioRemote.h"
-#include "task/TaskCase.h"
-
-int AudioHardware::mHwId = -1;
-
-int AudioHardware::detectAudioHw()
-{
- android::String8 script("test_description/conf/detect_usb_audio.py");
- /* This is the list of supported devices.
- MobilePre: M-Audio MobilePre
- Track: M-Audio FastTrack
- */
- android::String8 param("MobilePre Track");
- android::String8 resultStr;
- if (!SimpleScriptExec::runScript(script, param, resultStr)) {
- LOGE("cannot run script");
- return -1;
- }
-
- android::String8 match("[ \t]+([A-Za-z0-9_]+)[ \t]+([0-9]+)");
- const int nmatch = 3;
- regmatch_t pmatch[nmatch];
- if (!SimpleScriptExec::checkIfPassed(resultStr, match, nmatch, pmatch)) {
- LOGE("result not correct %s", resultStr.string());
- return -1;
- }
- LOGV("pmatch 0: %d, %d 1:%d, %d 2:%d, %d",
- pmatch[0].rm_so, pmatch[0].rm_eo,
- pmatch[1].rm_so, pmatch[1].rm_eo,
- pmatch[2].rm_so, pmatch[2].rm_eo);
-
- if (pmatch[1].rm_so == -1) {
- return -1;
- }
- if (pmatch[2].rm_so == -1) {
- return -1;
- }
- android::String8 product = StringUtil::substr(resultStr, pmatch[1].rm_so,
- pmatch[1].rm_eo - pmatch[1].rm_so);
- LOGI("Audio device %s found", product.string());
- android::String8 cardNumber = StringUtil::substr(resultStr, pmatch[2].rm_so,
- pmatch[2].rm_eo - pmatch[2].rm_so);
- int cardN = atoi(cardNumber.string());
- LOGI("Card number : %d", cardN);
- return cardN;
-}
-
-android::sp<AudioHardware> AudioHardware::createAudioHw(bool local, bool playback,
- TaskCase* testCase)
-{
- android::sp<AudioHardware> hw;
- if (local) {
- if (mHwId < 0) {
- mHwId = detectAudioHw();
- }
- if (mHwId < 0) {
- return NULL;
- }
- if (playback) {
- hw = new AudioPlaybackLocal(mHwId);
- } else {
- hw = new AudioRecordingLocal(mHwId);
- }
- } else {
- if (testCase != NULL) {
- if (playback) {
- hw = new AudioRemotePlayback(testCase->getRemoteAudio());
- } else {
- hw = new AudioRemoteRecording(testCase->getRemoteAudio());
- }
- }
- }
- return hw;
-}
-
-AudioHardware::~AudioHardware()
-{
-
-}
-
-bool AudioHardware::startPlaybackOrRecordById(const android::String8& id, TaskCase* testCase)
-{
- if (testCase == NULL) { // default implementation only handles local buffer.
- return false;
- }
- android::sp<Buffer> buffer = testCase->findBuffer(id);
- if (buffer.get() == NULL) {
- return false;
- }
- return startPlaybackOrRecord(buffer);
-}
diff --git a/suite/audio_quality/lib/src/audio/AudioLocal.cpp b/suite/audio_quality/lib/src/audio/AudioLocal.cpp
deleted file mode 100644
index 2a65689..0000000
--- a/suite/audio_quality/lib/src/audio/AudioLocal.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <Log.h>
-#include "audio/Buffer.h"
-#include "audio/AudioLocal.h"
-
-bool AudioLocal::prepare(AudioHardware::SamplingRate samplingRate, int gain, int /*mode*/)
-{
- LOGV("prepare");
- // gain control not necessary in MobilePre as there is no control.
- // This means audio source itself should be adjusted to control volume
- if (mState == EStNone) {
- if (run("AudioLocal") != android::NO_ERROR) {
- LOGE("AudioLocal cannot run");
- // cannot run thread
- return false;
- }
- mState = EStCreated;
- } else if (mState == EStRunning) {
- // wrong usage. first stop!
- return false;
- }
- mClientCompletionWait.tryWait(); // this will reset semaphore to 0 if it is 1.
- mSamplingRate = samplingRate;
- return issueCommandAndWaitForCompletion(ECmInitialize);
-}
-
-bool AudioLocal::startPlaybackOrRecord(android::sp<Buffer>& buffer, int numberRepetition)
-{
- LOGV("startPlaybackOrRecord");
- if (mState != EStInitialized) {
- LOGE("startPlaybackOrRecord while not initialized");
- // wrong state
- return false;
- }
- mBuffer = buffer;
- mNumberRepetition = numberRepetition;
- mCurrentRepeat = 0;
- return issueCommandAndWaitForCompletion(ECmRun);
-}
-
-bool AudioLocal::waitForCompletion()
-{
- int waitTimeInMsec = mBuffer->getSamples() / (mSamplingRate/1000);
- waitTimeInMsec += COMMAND_WAIT_TIME_MSEC;
- LOGD("waitForCompletion will wait for %d", waitTimeInMsec);
- if (!mClientCompletionWait.timedWait(waitTimeInMsec)) {
- LOGE("waitForCompletion time-out");
- return false;
- }
- return mCompletionResult;
-}
-
-void AudioLocal::stopPlaybackOrRecord()
-{
- LOGV("stopPlaybackOrRecord");
- if (mState == EStRunning) {
- issueCommandAndWaitForCompletion(ECmStop);
- }
-
- if (mState != EStNone) { // thread alive
- requestExit();
- mCurrentCommand = ECmThreadStop;
- mAudioThreadWait.post();
- requestExitAndWait();
- mState = EStNone;
- }
-}
-
-bool AudioLocal::issueCommandAndWaitForCompletion(AudioCommand command)
-{
- mCurrentCommand = command;
- mAudioThreadWait.post();
- if (!mClientCommandWait.timedWait(COMMAND_WAIT_TIME_MSEC)) {
- LOGE("issueCommandAndWaitForCompletion timeout cmd %d", command);
- return false;
- }
- return mCommandResult;
-}
-
-AudioLocal::~AudioLocal()
-{
- LOGV("~AudioLocal");
-}
-
-AudioLocal::AudioLocal()
- : mState(EStNone),
- mCurrentCommand(ECmNone),
- mClientCommandWait(0),
- mClientCompletionWait(0),
- mAudioThreadWait(0),
- mCompletionResult(false)
-{
- LOGV("AudioLocal");
-}
-
-
-bool AudioLocal::threadLoop()
-{
- if (mCurrentCommand == ECmNone) {
- if (mState == EStRunning) {
- if (doPlaybackOrRecord(mBuffer)) {
- // check exit condition
- if (mBuffer->bufferHandled()) {
- mCurrentRepeat++;
- LOGV("repeat %d - %d", mCurrentRepeat, mNumberRepetition);
- if (mCurrentRepeat == mNumberRepetition) {
- LOGV("AudioLocal complete command");
- mState = EStInitialized;
- mCompletionResult = true;
- mClientCompletionWait.post();
- } else {
- mBuffer->restart();
- }
- }
- } else {
- mState = EStInitialized;
- //notify error
- mCompletionResult = false;
- mClientCompletionWait.post();
- }
- return true;
- }
- //LOGV("audio thread waiting");
- mAudioThreadWait.wait();
- //LOGV("audio thread waken up");
- if (mCurrentCommand == ECmNone) {
- return true; // continue to check exit condition
- }
- }
-
- int pendingCommand = mCurrentCommand;
- // now there is a command
- switch (pendingCommand) {
- case ECmInitialize:
- mCommandResult = doPrepare(mSamplingRate, AudioHardware::SAMPLES_PER_ONE_GO);
- if (mCommandResult) {
- mState = EStInitialized;
- }
- break;
- case ECmRun: {
- mCommandResult = doPlaybackOrRecord(mBuffer);
- if (mCommandResult) {
- mState = EStRunning;
- }
- }
- break;
- case ECmStop:
- doStop();
- mState = EStCreated;
- mCommandResult = true;
- break;
- case ECmThreadStop:
- return false;
- break;
- default:
- // this should not happen
- ASSERT(false);
- break;
- }
-
- mCurrentCommand = ECmNone;
- mClientCommandWait.post();
-
- return true;
-}
-
-
diff --git a/suite/audio_quality/lib/src/audio/AudioPlaybackLocal.cpp b/suite/audio_quality/lib/src/audio/AudioPlaybackLocal.cpp
deleted file mode 100644
index 06c92d6..0000000
--- a/suite/audio_quality/lib/src/audio/AudioPlaybackLocal.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-// TODO remove all the headers upto asound.h after removing pcm_drain hack
-#include <errno.h>
-#include <unistd.h>
-#include <poll.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-#include <limits.h>
-#include <linux/ioctl.h>
-#define __force
-#define __bitwise
-#define __user
-#include <sound/asound.h>
-
-#include <string.h>
-#include <tinyalsa/asoundlib.h>
-
-#include "audio/AudioHardware.h"
-#include "audio/Buffer.h"
-#include "Log.h"
-
-#include "audio/AudioPlaybackLocal.h"
-
-
-AudioPlaybackLocal::AudioPlaybackLocal(int hwId)
- : mHwId(hwId),
- mPcmHandle(NULL)
-{
- LOGV("AudioPlaybackLocal %x", (unsigned long)this);
-}
-
-AudioPlaybackLocal::~AudioPlaybackLocal()
-{
- LOGV("~AudioPlaybackLocal %x", (unsigned long)this);
- releaseHw();
-}
-
-bool AudioPlaybackLocal::doPrepare(AudioHardware::SamplingRate samplingRate, int samplesInOneGo)
-{
- releaseHw();
-
- struct pcm_config config;
-
- memset(&config, 0, sizeof(config));
- config.channels = 2;
- config.rate = samplingRate;
- config.period_size = 1024;
- config.period_count = 64;
- config.format = PCM_FORMAT_S16_LE;
- config.start_threshold = 0;
- config.stop_threshold = 0;
- config.silence_threshold = 0;
-
- mPcmHandle = pcm_open(mHwId, 0, PCM_OUT, &config);
- if (!mPcmHandle || !pcm_is_ready(mPcmHandle)) {
- LOGE("Unable to open PCM device(%d) (%s)\n", mHwId, pcm_get_error(mPcmHandle));
- return false;
- }
-
- mSamples = samplesInOneGo;
- mSizes = samplesInOneGo * 4; // stereo, 16bit
-
- return true;
-}
-
-bool AudioPlaybackLocal::doPlaybackOrRecord(android::sp<Buffer>& buffer)
-{
- if (buffer->amountToHandle() < (size_t)mSizes) {
- mSizes = buffer->amountToHandle();
- }
- if (pcm_write(mPcmHandle, buffer->getUnhanledData(), mSizes)) {
- LOGE("AudioPlaybackLocal error %s", pcm_get_error(mPcmHandle));
- return false;
- }
- buffer->increaseHandled(mSizes);
- LOGV("AudioPlaybackLocal::doPlaybackOrRecord %d", buffer->amountHandled());
- return true;
-}
-
-void AudioPlaybackLocal::doStop()
-{
- // TODO: remove when pcm_stop does pcm_drain
- // hack to have snd_pcm_drain equivalent
- struct pcm_ {
- int fd;
- };
- pcm_* pcm = (pcm_*)mPcmHandle;
- ioctl(pcm->fd, SNDRV_PCM_IOCTL_DRAIN);
- pcm_stop(mPcmHandle);
-}
-
-void AudioPlaybackLocal::releaseHw()
-{
- if (mPcmHandle != NULL) {
- LOGV("releaseHw %x", (unsigned long)this);
- doStop();
- pcm_close(mPcmHandle);
- mPcmHandle = NULL;
- }
-}
diff --git a/suite/audio_quality/lib/src/audio/AudioProtocol.cpp b/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
deleted file mode 100644
index 26ce5c5..0000000
--- a/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <stdint.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <memory>
-#include <utils/StrongPointer.h>
-
-#include "audio/Buffer.h"
-#include "Log.h"
-#include "audio/AudioProtocol.h"
-
-
-bool AudioProtocol::sendCommand(AudioParam& param)
-{
- mBuffer[0] = htonl(mCommand);
- mBuffer[1] = 0;
- return sendData((char*)mBuffer, 8);
-}
-
-bool AudioProtocol::handleReply(const uint32_t* data, AudioParam* param)
-{
- if (!checkHeaderId(data, mCommand)) {
- return false;
- }
- if (data[1] != 0) { // no endian change for 0
- LOGE("error in reply %d", ntohl(data[1]));
- return false;
- }
- if (data[2] != 0) {
- LOGE("payload length %d not zero", ntohl(data[2]));
- return false;
- }
- return true;
-}
-
-bool AudioProtocol::handleReplyHeader(ClientSocket& socket, uint32_t* data, CommandId& id)
-{
- if (!socket.readData((char*)data, REPLY_HEADER_SIZE)) {
- LOGE("handleReplyHeader cannot read");
- return false;
- }
- uint32_t command = ntohl(data[0]);
- if ((command & 0xffff0000) != 0x43210000) {
- LOGE("Wrong header %x %x", command, data[0]);
- return false;
- }
- command = (command & 0xffff) | 0x12340000; // convert to id
- if (command < ECmdStart) {
- LOGE("Wrong header %x %x", command, data[0]);
- return false;
- }
- if (command > (ECmdLast - 1)) {
- LOGE("Wrong header %x %x", command, data[0]);
- return false;
- }
- id = (CommandId)command;
- LOGD("received reply with command %x", command);
- return true;
-}
-
-bool AudioProtocol::checkHeaderId(const uint32_t* data, uint32_t command)
-{
- if (ntohl(data[0]) != ((command & 0xffff) | 0x43210000)) {
- LOGE("wrong reply ID 0x%x", ntohl(data[0]));
- return false;
- }
- return true;
-}
-
-
-/**
- * param0 u32 data id
- * param1 sp<Buffer>
- */
-bool CmdDownload::sendCommand(AudioParam& param)
-{
- mBuffer[0] = htonl(ECmdDownload);
- mBuffer[1] = htonl(4 + param.mBuffer->getSize());
- mBuffer[2] = htonl(param.mId);
- if(!sendData((char*)mBuffer, 12)) {
- return false;
- }
- return sendData(param.mBuffer->getData(), param.mBuffer->getSize());
-}
-
-/**
- * param0 u32 data id
- * param1 u32 sampling rate
- * param2 u32 mono / stereo(MSB) | mode
- * param3 u32 volume
- * param4 u32 repeat
- */
-bool CmdStartPlayback::sendCommand(AudioParam& param)
-{
- mBuffer[0] = htonl(ECmdStartPlayback);
- mBuffer[1] = htonl(20);
- mBuffer[2] = htonl(param.mId);
- mBuffer[3] = htonl(param.mSamplingF);
- uint32_t mode = param.mStereo ? 0x80000000 : 0;
- mode |= param.mMode;
- mBuffer[4] = htonl(mode);
- mBuffer[5] = htonl(param.mVolume);
- mBuffer[6] = htonl(param.mNumberRepetition);
-
- return sendData((char*)mBuffer, 28);
-}
-
-
-/**
- * param0 u32 sampling rate
- * param1 u32 mono / stereo(MSB) | mode
- * param2 u32 volume
- * param3 u32 samples
- */
-bool CmdStartRecording::sendCommand(AudioParam& param)
-{
- mBuffer[0] = htonl(ECmdStartRecording);
- mBuffer[1] = htonl(16);
- mBuffer[2] = htonl(param.mSamplingF);
- uint32_t mode = param.mStereo ? 0x80000000 : 0;
- mode |= param.mMode;
- mBuffer[3] = htonl(mode);
- mBuffer[4] = htonl(param.mVolume);
- uint32_t samples = param.mBuffer->getSize() / (param.mStereo ? 4 : 2);
- mBuffer[5] = htonl(samples);
-
- return sendData((char*)mBuffer, 24);
-}
-
-/**
- * param0 sp<Buffer>
- */
-bool CmdStartRecording::handleReply(const uint32_t* data, AudioParam* param)
-{
- if (!checkHeaderId(data, ECmdStartRecording)) {
- return false;
- }
- if (data[1] != 0) { // no endian change for 0
- LOGE("error in reply %d", ntohl(data[1]));
- return false;
- }
- int len = ntohl(data[2]);
- if (len > (int)param->mBuffer->getCapacity()) {
- LOGE("received data %d exceeding buffer capacity %d", len, param->mBuffer->getCapacity());
- // read and throw away
- //Buffer tempBuffer(len);
- //readData(tempBuffer.getData(), len);
- return false;
- }
- if (!readData(param->mBuffer->getData(), len)) {
- return false;
- }
- LOGI("received data %d from device", len);
- param->mBuffer->setHandled(len);
- param->mBuffer->setSize(len);
- return true;
-}
-
-bool CmdGetDeviceInfo::handleReply(const uint32_t* data, AudioParam* param)
-{
- if (!checkHeaderId(data, ECmdGetDeviceInfo)) {
- return false;
- }
- if (data[1] != 0) { // no endian change for 0
- LOGE("error in reply %d", ntohl(data[1]));
- return false;
- }
- int len = ntohl(data[2]);
-
- std::unique_ptr<char[]> infoString(new char[len + 1]);
- if (!readData(infoString.get(), len)) {
- return false;
- }
- (infoString.get())[len] = 0;
- LOGI("received data %s from device", infoString.get());
- android::String8* string = reinterpret_cast<android::String8*>(param->mExtra);
- string->setTo(infoString.get(), len);
- return true;
-}
-
-
diff --git a/suite/audio_quality/lib/src/audio/AudioRecordingLocal.cpp b/suite/audio_quality/lib/src/audio/AudioRecordingLocal.cpp
deleted file mode 100644
index eda705d..0000000
--- a/suite/audio_quality/lib/src/audio/AudioRecordingLocal.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <stdint.h>
-#include <string.h>
-#include <tinyalsa/asoundlib.h>
-
-#include "audio/AudioHardware.h"
-#include "audio/Buffer.h"
-#include "Log.h"
-
-#include "audio/AudioRecordingLocal.h"
-
-
-AudioRecordingLocal::AudioRecordingLocal(int hwId)
- : mHwId(hwId),
- mPcmHandle(NULL)
-{
- LOGV("AudioRecordingLocal %x", (unsigned long)this);
-}
-
-AudioRecordingLocal::~AudioRecordingLocal()
-{
- LOGV("~AudioRecordingLocal %x", (unsigned long)this);
- releaseHw();
-}
-
-bool AudioRecordingLocal::doPrepare(AudioHardware::SamplingRate samplingRate, int samplesInOneGo)
-{
- releaseHw();
-
- struct pcm_config config;
-
- memset(&config, 0, sizeof(config));
- config.channels = 2;
- config.rate = samplingRate;
- config.period_size = 1024;
- config.period_count = 32;
- config.format = PCM_FORMAT_S16_LE;
- config.start_threshold = 0;
- config.stop_threshold = 0;
- config.silence_threshold = 0;
-
- mPcmHandle = pcm_open(mHwId, 0, PCM_IN, &config);
- if (!mPcmHandle || !pcm_is_ready(mPcmHandle)) {
- LOGE("Unable to open PCM device(%d) (%s)\n", mHwId, pcm_get_error(mPcmHandle));
- return false;
- }
-
- mSamples = samplesInOneGo;
- mSizes = samplesInOneGo * 4; // stereo, 16bit
-
- mBufferSize = pcm_get_buffer_size(mPcmHandle);
- LOGD("buffer size %d, read size %d", mBufferSize, mSizes);
- return true;
-}
-
-bool AudioRecordingLocal::doPlaybackOrRecord(android::sp<Buffer>& buffer)
-{
- int toRead = mSizes;
- if (buffer->amountToHandle() < (size_t)mSizes) {
- toRead = buffer->amountToHandle();
- }
- LOGD("recording will read %d", toRead);
-
- while (toRead > 0) {
- int readSize = (toRead > mBufferSize) ? mBufferSize : toRead;
- if (pcm_read(mPcmHandle, buffer->getUnhanledData(), readSize)) {
- LOGE("AudioRecordingLocal error %s", pcm_get_error(mPcmHandle));
- return false;
- }
- buffer->increaseHandled(readSize);
- toRead -= readSize;
- }
- LOGV("AudioRecordingLocal::doPlaybackOrRecord %d", buffer->amountHandled());
- return true;
-}
-
-void AudioRecordingLocal::doStop()
-{
- pcm_stop(mPcmHandle);
-}
-
-void AudioRecordingLocal::releaseHw()
-{
- if (mPcmHandle != NULL) {
- LOGV("releaseHw %x", (unsigned long)this);
- doStop();
- pcm_close(mPcmHandle);
- mPcmHandle = NULL;
- }
-}
diff --git a/suite/audio_quality/lib/src/audio/AudioRemote.cpp b/suite/audio_quality/lib/src/audio/AudioRemote.cpp
deleted file mode 100644
index 444a33e..0000000
--- a/suite/audio_quality/lib/src/audio/AudioRemote.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "Log.h"
-#include "audio/AudioRemote.h"
-#include "audio/RemoteAudio.h"
-
-bool AudioRemote::prepare(AudioHardware::SamplingRate samplingRate, int volume, int mode)
-{
- if (mRemote == NULL) {
- LOGE("AudioRemote::prepare mRemote NULL");
- return false;
- }
- mSamplingRate = samplingRate;
- mVolume = volume;
- mMode = mode;
- return true;
-}
-
-AudioRemote::AudioRemote(android::sp<RemoteAudio>& remote)
- : mRemote(remote)
-{
-
-}
-
-AudioRemotePlayback::AudioRemotePlayback(android::sp<RemoteAudio>& remote)
- : AudioRemote(remote)
-{
-
-}
-
-bool AudioRemotePlayback::startPlaybackOrRecord(android::sp<Buffer>& buffer, int numberRepetition)
-{
- //TODO not supported for the moment
- return false;
-}
-
-bool AudioRemotePlayback::waitForCompletion()
-{
- return mRemote->waitForPlaybackCompletion();
-}
-
-void AudioRemotePlayback::stopPlaybackOrRecord()
-{
- mRemote->stopPlayback();
-}
-
-bool AudioRemotePlayback::startPlaybackForRemoteData(int id, bool stereo, int numberRepetition)
-{
- return mRemote->startPlayback(stereo, mSamplingRate, mMode, mVolume, id, numberRepetition);
-}
-
-AudioRemoteRecording::AudioRemoteRecording(android::sp<RemoteAudio>& remote)
- : AudioRemote(remote)
-{
-
-}
-
-bool AudioRemoteRecording::startPlaybackOrRecord(android::sp<Buffer>& buffer,
- int /*numberRepetition*/)
-{
- bool stereo = buffer->isStereo();
- return mRemote->startRecording(stereo, mSamplingRate, mMode, mVolume, buffer);
-}
-
-bool AudioRemoteRecording::waitForCompletion()
-{
- return mRemote->waitForRecordingCompletion();
-}
-
-void AudioRemoteRecording::stopPlaybackOrRecord()
-{
- mRemote->stopRecording();
-}
-
-
-
diff --git a/suite/audio_quality/lib/src/audio/AudioSignalFactory.cpp b/suite/audio_quality/lib/src/audio/AudioSignalFactory.cpp
deleted file mode 100644
index d2308a3..0000000
--- a/suite/audio_quality/lib/src/audio/AudioSignalFactory.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <math.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "Log.h"
-#include "audio/AudioSignalFactory.h"
-
-android::sp<Buffer> AudioSignalFactory::generateSineWave(AudioHardware::BytesPerSample BPS,
- int maxPositive, AudioHardware::SamplingRate samplingRate, int signalFreq,
- int samples, bool stereo)
-{
- int bufferSize = samples * (stereo? 2 : 1) * BPS;
- android::sp<Buffer> buffer(new Buffer(bufferSize));
- // only 16bit signed
- ASSERT(BPS == AudioHardware::E2BPS);
- int16_t* data = reinterpret_cast<int16_t*>(buffer->getData());
- double multiplier = 2.0 * M_PI * (double)signalFreq / samplingRate;
- for (int i = 0; i < samples; i++) {
- double val = sin(multiplier * i) * maxPositive;
- *data = (int16_t)val;
- data++;
- if(stereo) {
- *data = (int16_t)val;
- data++;
- }
- }
- buffer->setSize(buffer->getCapacity());
- return buffer;
-}
-android::sp<Buffer> AudioSignalFactory::generateWhiteNoise(AudioHardware::BytesPerSample BPS,
- int maxPositive, int samples, bool stereo)
-{
- int bufferSize = samples * (stereo? 2 : 1) * BPS;
- android::sp<Buffer> buffer(new Buffer(bufferSize, bufferSize));
- // only 16bit signed
- ASSERT(BPS == AudioHardware::E2BPS);
- srand(123456);
- int16_t* data = reinterpret_cast<int16_t*>(buffer->getData());
- int middle = RAND_MAX / 2;
- double multiplier = (double)maxPositive / middle;
- for (int i = 0; i < samples; i++) {
- int val = rand();
- val = (int16_t)((val - middle) * maxPositive / middle);
- *data = val;
- data++;
- if (stereo) {
- *data = val;
- data++;
- }
- }
- buffer->setSize(buffer->getCapacity());
- return buffer;
-}
-
-android::sp<Buffer> AudioSignalFactory::generateZeroSound(AudioHardware::BytesPerSample BPS,
- int samples, bool stereo)
-{
- int bufferSize = samples * (stereo? 2 : 1) * BPS;
- android::sp<Buffer> buffer(new Buffer(bufferSize, bufferSize));
- // only 16bit signed
- ASSERT(BPS == AudioHardware::E2BPS);
- int16_t* data = reinterpret_cast<int16_t*>(buffer->getData());
- for (int i = 0; i < samples; i++) {
- *data = 0;
- data++;
- if (stereo) {
- *data = 0;
- data++;
- }
- }
- buffer->setSize(buffer->getCapacity());
- return buffer;
-}
-
-
diff --git a/suite/audio_quality/lib/src/audio/Buffer.cpp b/suite/audio_quality/lib/src/audio/Buffer.cpp
deleted file mode 100644
index cd4406f..0000000
--- a/suite/audio_quality/lib/src/audio/Buffer.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <stdint.h>
-#include <iostream>
-#include <fstream>
-#include <utils/String8.h>
-#include "Log.h"
-#include "StringUtil.h"
-#include "audio/Buffer.h"
-
-Buffer::Buffer(size_t capacity, size_t size, bool stereo)
- : mCapacity(capacity),
- mSize(size),
- mHandled(0),
- mStereo(stereo)
-{
- mData = new char[capacity];
- //LOGV("Buffer %d data %x", capacity, (unsigned int)mData);
- // assume 4bytes alignment
- ASSERT(((long)mData & 0x3) == 0);
- // filling with zero just to make valgrind happy.
- // Otherwise, valgrind will complain about uninitialized data for all captured data
- memset(mData, 0, capacity);
-};
-
-Buffer::~Buffer()
-{
- delete[] mData;
- //LOGV("~Buffer %d", mCapacity);
-}
-
-void Buffer::changeToMono(ConvertOption option)
-{
- size_t newSize = mSize/2;
- int16_t* data = reinterpret_cast<int16_t*>(mData);
- if (option == EKeepCh0) {
- for (size_t i = 0; i < newSize/2; i++) { //16bpp only
- int16_t l = data[i * 2];
- data[i] = l;
- }
- } else if (option == EKeepCh1) {
- for (size_t i = 0; i < newSize/2; i++) { //16bpp only
- int16_t r = data[i * 2 + 1];
- data[i] = r;
- }
- } else { // average
- for (size_t i = 0; i < newSize/2; i++) { //16bpp only
- int16_t l = data[i * 2];
- int16_t r = data[i * 2 + 1];
- int16_t avr = (int16_t)(((int32_t)l + (int32_t)r)/2);
- data[i] = avr;
- }
- }
- mSize = newSize;
- mHandled /= 2;
- mStereo = false;
-}
-
-bool Buffer::changeToStereo()
-{
- //TODO ChangeToStereo
- return false;
-}
-
-const char* EXTENSION_S16_STEREO = ".r2s";
-const char* EXTENSION_S16_MONO = ".r2m";
-Buffer* Buffer::loadFromFile(const android::String8& filename)
-{
- bool stereo;
- if (StringUtil::endsWith(filename, EXTENSION_S16_STEREO)) {
- stereo = true;
- } else if (StringUtil::endsWith(filename, EXTENSION_S16_MONO)) {
- stereo = false;
- } else {
- LOGE("Buffer::loadFromFile specified file %s has unknown extension.", filename.string());
- return NULL;
- }
- std::ifstream file(filename.string(), std::ios::in | std::ios::binary |
- std::ios::ate);
- if (!file.is_open()) {
- LOGE("Buffer::loadFromFile cannot open file %s.", filename.string());
- return NULL;
- }
- size_t size = file.tellg();
- Buffer* buffer = new Buffer(size, size, stereo);
- if (buffer == NULL) {
- return NULL;
- }
- file.seekg(0, std::ios::beg);
- file.read(buffer->mData, size); //TODO handle read error
- file.close();
- return buffer;
-}
-
-bool Buffer::saveToFile(const android::String8& filename)
-{
- android::String8 filenameWithExtension(filename);
- if (isStereo()) {
- filenameWithExtension.append(EXTENSION_S16_STEREO);
- } else {
- filenameWithExtension.append(EXTENSION_S16_MONO);
- }
- std::ofstream file(filenameWithExtension.string(), std::ios::out | std::ios::binary |
- std::ios::trunc);
- if (!file.is_open()) {
- LOGE("Buffer::saveToFile cannot create file %s.",
- filenameWithExtension.string());
- return false;
- }
- file.write(mData, mSize);
- bool writeOK = true;
- if (file.rdstate() != std::ios_base::goodbit) {
- LOGE("Got error while writing file %s %x", filenameWithExtension.string(), file.rdstate());
- writeOK = false;
- }
- file.close();
- return writeOK;
-}
-
-bool Buffer::operator == (const Buffer& b) const
-{
- if (mStereo != b.mStereo) {
- LOGD("stereo mismatch %d %d", mStereo, b.mStereo);
- return false;
- }
- if (mSize != b.mSize) {
- LOGD("size mismatch %d %d", mSize, b.mSize);
- return false;
- }
- for (size_t i = 0; i < mSize; i++) {
- if (mData[i] != b.mData[i]) {
- LOGD("%d %x vs %x", i, mData[i], b.mData[i]);
- return false;
- }
- }
- return true;
-}
diff --git a/suite/audio_quality/lib/src/audio/RemoteAudio.cpp b/suite/audio_quality/lib/src/audio/RemoteAudio.cpp
deleted file mode 100644
index 56758fb..0000000
--- a/suite/audio_quality/lib/src/audio/RemoteAudio.cpp
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <arpa/inet.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <utils/Looper.h>
-
-#include "Log.h"
-#include "audio/AudioProtocol.h"
-#include "audio/RemoteAudio.h"
-
-
-RemoteAudio::RemoteAudio(ClientSocket& socket)
- : mExitRequested(false),
- mSocket(socket),
- mDownloadHandler(new CommandHandler(*this, (int)AudioProtocol::ECmdDownload)),
- mPlaybackHandler(new CommandHandler(*this, (int)AudioProtocol::ECmdStartPlayback)),
- mRecordingHandler(new CommandHandler(*this, (int)AudioProtocol::ECmdStartRecording)),
- mDeviceInfoHandler(new CommandHandler(*this, (int)AudioProtocol::ECmdGetDeviceInfo)),
- mDownloadId(0)
-{
- mCmds[AudioProtocol::ECmdDownload - AudioProtocol::ECmdStart] = new CmdDownload(socket);
- mCmds[AudioProtocol::ECmdStartPlayback - AudioProtocol::ECmdStart] =
- new CmdStartPlayback(socket);
- mCmds[AudioProtocol::ECmdStopPlayback - AudioProtocol::ECmdStart] =
- new CmdStopPlayback(socket);
- mCmds[AudioProtocol::ECmdStartRecording - AudioProtocol::ECmdStart] =
- new CmdStartRecording(socket);
- mCmds[AudioProtocol::ECmdStopRecording - AudioProtocol::ECmdStart] =
- new CmdStopRecording(socket);
- mCmds[AudioProtocol::ECmdGetDeviceInfo - AudioProtocol::ECmdStart] =
- new CmdGetDeviceInfo(socket);
-}
-
-RemoteAudio::~RemoteAudio()
-{
- for (int i = 0; i < (AudioProtocol::ECmdLast - AudioProtocol::ECmdStart); i++) {
- delete mCmds[i];
- }
- //mBufferList.clear();
-}
-
-bool RemoteAudio::init(int port)
-{
- mPort = port;
- if (run("RemoteAudio") != android::NO_ERROR) {
- LOGE("RemoteAudio cannot run");
- // cannot run thread
- return false;
- }
-
- if (!mInitWait.timedWait(CLIENT_WAIT_TIMEOUT_MSEC)) {
- return false;
- }
- return mInitResult;
-}
-
-bool RemoteAudio::threadLoop()
-{
- // initial action until socket connection done by init
- mLooper = new android::Looper(false);
- if (mLooper.get() == NULL) {
- wakeClient(false);
- return false;
- }
- android::Looper::setForThread(mLooper);
-
- if (!mSocket.init("127.0.0.1", mPort)) {
- wakeClient(false);
- return false;
- }
- LOGD("adding fd %d to polling", mSocket.getFD());
- mLooper->addFd(mSocket.getFD(), EIdSocket, android::Looper::EVENT_INPUT, socketRxCallback, this);
- wakeClient(true);
- while(!mExitRequested) {
- mLooper->pollOnce(10000);
- }
- return false; // exit without requestExit()
-}
-
-void RemoteAudio::wakeClient(bool result)
-{
- mInitResult = result;
- mInitWait.post();
-}
-
-bool RemoteAudio::handlePacket()
-{
- uint32_t data[AudioProtocol::REPLY_HEADER_SIZE/sizeof(uint32_t)];
- AudioProtocol::CommandId id;
- if (!AudioProtocol::handleReplyHeader(mSocket, data, id)) {
- return false;
- }
- CommandHandler* handler = NULL;
- if (id == AudioProtocol::ECmdDownload) {
- handler = reinterpret_cast<CommandHandler*>(mDownloadHandler.get());
- } else if (id == AudioProtocol::ECmdStartPlayback) {
- handler = reinterpret_cast<CommandHandler*>(mPlaybackHandler.get());
- } else if (id == AudioProtocol::ECmdStartRecording) {
- handler = reinterpret_cast<CommandHandler*>(mRecordingHandler.get());
- } else if (id == AudioProtocol::ECmdGetDeviceInfo) {
- handler = reinterpret_cast<CommandHandler*>(mDeviceInfoHandler.get());
- }
- AudioParam* param = NULL;
- if (handler != NULL) {
- param = &(handler->getParam());
- }
- bool result = mCmds[id - AudioProtocol::ECmdStart]->handleReply(data, param);
- if (handler != NULL) {
- LOGD("handler present. Notify client");
- android::Mutex::Autolock lock(handler->mStateLock);
- if (handler->mNotifyOnReply) {
- handler->mNotifyOnReply = false;
- handler->mResult = result;
- handler->mClientWait.post();
- }
- handler->mActive = false;
- }
- return result;
-}
-
-int RemoteAudio::socketRxCallback(int fd, int events, void* data)
-{
- RemoteAudio* self = reinterpret_cast<RemoteAudio*>(data);
- if (events & android::Looper::EVENT_INPUT) {
- //LOGD("socketRxCallback input");
- if (!self->handlePacket()) { //error, stop polling
- LOGE("socketRxCallback, error in packet, stopping polling");
- return 0;
- }
- }
- return 1;
-}
-
-void RemoteAudio::sendCommand(android::sp<android::MessageHandler>& command)
-{
- mLooper->sendMessage(command, toCommandHandler(command)->getMessage());
-}
-
-bool RemoteAudio::waitForCompletion(android::sp<android::MessageHandler>& command, int timeInMSec)
-{
- LOGV("waitForCompletion %d", timeInMSec);
- return toCommandHandler(command)->timedWait(timeInMSec);
-}
-
-bool RemoteAudio::waitForPlaybackOrRecordingCompletion(
- android::sp<android::MessageHandler>& commandHandler)
-{
- CommandHandler* handler = reinterpret_cast<CommandHandler*>(commandHandler.get());
- handler->mStateLock.lock();
- if(!handler->mActive) {
- handler->mStateLock.unlock();
- return true;
- }
- int runTime = handler->getParam().mBuffer->getSize() /
- (handler->getParam().mStereo ? 4 : 2) * 1000 / handler->getParam().mSamplingF;
- handler->mNotifyOnReply = true;
- handler->mStateLock.unlock();
- return waitForCompletion(commandHandler, runTime + CLIENT_WAIT_TIMEOUT_MSEC);
-}
-
-void RemoteAudio::doStop(android::sp<android::MessageHandler>& commandHandler,
- AudioProtocol::CommandId id)
-{
- CommandHandler* handler = reinterpret_cast<CommandHandler*>(commandHandler.get());
- handler->mStateLock.lock();
- if (!handler->mActive) {
- handler->mStateLock.unlock();
- return;
- }
- handler->mActive = false;
- handler->mNotifyOnReply = false;
- handler->mStateLock.unlock();
- android::sp<android::MessageHandler> command(new CommandHandler(*this, (int)id));
- sendCommand(command);
- waitForCompletion(command, CLIENT_WAIT_TIMEOUT_MSEC);
-}
-
-
-bool RemoteAudio::downloadData(const android::String8& name, android::sp<Buffer>& buffer, int& id)
-{
- CommandHandler* handler = reinterpret_cast<CommandHandler*>(mDownloadHandler.get());
- id = mDownloadId;
- mDownloadId++;
- handler->mStateLock.lock();
- handler->getParam().mId = id;
- handler->getParam().mBuffer = buffer;
- handler->mNotifyOnReply = true;
- handler->mStateLock.unlock();
- sendCommand(mDownloadHandler);
-
- // assume 1Mbps ==> 1000 bits per msec ==> 125 bytes per msec
- int maxWaitTime = CLIENT_WAIT_TIMEOUT_MSEC + buffer->getSize() / 125;
- // client blocked until reply comes from DUT
- if (!waitForCompletion(mDownloadHandler, maxWaitTime)) {
- LOGE("timeout");
- return false;
- }
- mBufferList[id] = buffer;
- mIdMap[name] = id;
- return handler->mResult;
-}
-
-int RemoteAudio::getDataId(const android::String8& name)
-{
- std::map<android::String8, int>::iterator it;
- it = mIdMap.find(name);
- if (it == mIdMap.end()) {
- LOGE("Buffer name %s not registered", name.string());
- return -1;
- }
- return it->second;
-}
-
-bool RemoteAudio::startPlayback(bool stereo, int samplingF, int mode, int volume,
- int id, int numberRepetition)
-{
- CommandHandler* handler = reinterpret_cast<CommandHandler*>(mPlaybackHandler.get());
- handler->mStateLock.lock();
- if (handler->mActive) {
- LOGE("busy");
- handler->mStateLock.unlock();
- return false;
- }
- std::map<int, android::sp<Buffer> >::iterator it;
- it = mBufferList.find(id);
- if (it == mBufferList.end()) {
- LOGE("Buffer id %d not registered", id);
- return false;
- }
- LOGD("RemoteAudio::startPlayback stereo %d mode %d", stereo, mode);
- handler->mActive = true;
- handler->getParam().mStereo = stereo;
- handler->getParam().mSamplingF = samplingF;
- handler->getParam().mMode = mode;
- handler->getParam().mVolume = volume;
- handler->getParam().mId = id;
- // for internal tracking
- handler->getParam().mBuffer = it->second;
- handler->getParam().mNumberRepetition = numberRepetition;
- handler->mStateLock.unlock();
- sendCommand(mPlaybackHandler);
- if (!waitForCompletion(mPlaybackHandler, CLIENT_WAIT_TIMEOUT_MSEC)) {
- LOGE("timeout");
- return false;
- }
- return handler->mResult;
-}
-
-void RemoteAudio::stopPlayback()
-{
- doStop(mPlaybackHandler, AudioProtocol::ECmdStopPlayback);
-}
-
-bool RemoteAudio::waitForPlaybackCompletion()
-{
- return waitForPlaybackOrRecordingCompletion(mPlaybackHandler);
-}
-
-bool RemoteAudio::startRecording(bool stereo, int samplingF, int mode, int volume,
- android::sp<Buffer>& buffer)
-{
- CommandHandler* handler = reinterpret_cast<CommandHandler*>(mRecordingHandler.get());
- handler->mStateLock.lock();
- if (handler->mActive) {
- LOGE("busy");
- handler->mStateLock.unlock();
- return false;
- }
- handler->mActive = true;
- handler->getParam().mStereo = stereo;
- handler->getParam().mSamplingF = samplingF;
- handler->getParam().mMode = mode;
- handler->getParam().mVolume = volume;
- handler->getParam().mBuffer = buffer;
- handler->mStateLock.unlock();
- sendCommand(mRecordingHandler);
- if (!waitForCompletion(mRecordingHandler, CLIENT_WAIT_TIMEOUT_MSEC)) {
- LOGE("timeout");
- return false;
- }
- return handler->mResult;
-}
-
-bool RemoteAudio::waitForRecordingCompletion()
-{
- return waitForPlaybackOrRecordingCompletion(mRecordingHandler);
-}
-
-void RemoteAudio::stopRecording()
-{
- doStop(mRecordingHandler, AudioProtocol::ECmdStopRecording);
-}
-
-bool RemoteAudio::getDeviceInfo(android::String8& data)
-{
- CommandHandler* handler = reinterpret_cast<CommandHandler*>(mDeviceInfoHandler.get());
- handler->mStateLock.lock();
- handler->mNotifyOnReply = true;
- handler->getParam().mExtra = &data;
- handler->mStateLock.unlock();
- sendCommand(mDeviceInfoHandler);
-
- // client blocked until reply comes from DUT
- if (!waitForCompletion(mDeviceInfoHandler, CLIENT_WAIT_TIMEOUT_MSEC)) {
- LOGE("timeout");
- return false;
- }
- return handler->mResult;
-}
-
-/** should be called before RemoteAudio is destroyed */
-void RemoteAudio::release()
-{
- android::sp<android::MessageHandler> command(new CommandHandler(*this, CommandHandler::EExit));
- sendCommand(command);
- join(); // wait for exit
- mSocket.release();
-}
-
-void RemoteAudio::CommandHandler::handleMessage(const android::Message& message)
-{
- switch(message.what) {
- case EExit:
- LOGD("thread exit requested, will exit ");
- mResult = true;
- mThread.mExitRequested = true;
- mClientWait.post(); // client will not wait, but just do it.
- break;
- case AudioProtocol::ECmdDownload:
- case AudioProtocol::ECmdStartPlayback:
- case AudioProtocol::ECmdStopPlayback:
- case AudioProtocol::ECmdStartRecording:
- case AudioProtocol::ECmdStopRecording:
- case AudioProtocol::ECmdGetDeviceInfo:
- {
- mResult = (mThread.mCmds[message.what - AudioProtocol::ECmdStart]) \
- ->sendCommand(mParam);
- // no post for download and getdeviceinfo. Client blocked until reply comes with time-out
- if ((message.what != AudioProtocol::ECmdDownload) &&
- (message.what != AudioProtocol::ECmdGetDeviceInfo) ) {
- mClientWait.post();
- }
-
- }
- break;
-
- }
-}
diff --git a/suite/audio_quality/lib/src/task/ModelBuilder.cpp b/suite/audio_quality/lib/src/task/ModelBuilder.cpp
deleted file mode 100644
index f1a506b..0000000
--- a/suite/audio_quality/lib/src/task/ModelBuilder.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <tinyxml2.h>
-
-#include <memory>
-
-#include "Log.h"
-#include "GenericFactory.h"
-#include "task/ModelBuilder.h"
-
-using namespace tinyxml2;
-
-static const int MAX_NO_CHILDREN = 8;
-static const ModelBuilder::ChildInfo CASE_TABLE[] = {
- { TaskGeneric::ETaskSetup, true },
- { TaskGeneric::ETaskAction, true },
- { TaskGeneric::ETaskSave, false }
-};
-static const ModelBuilder::ChildInfo SETUP_TABLE[] = {
- { TaskGeneric::ETaskSound, false },
- { TaskGeneric::ETaskProcess, false },
- { TaskGeneric::ETaskDownload, false }
-};
-static const ModelBuilder::ChildInfo ACTION_TABLE[] = {
- { TaskGeneric::ETaskSequential, true }
-};
-static const ModelBuilder::ChildInfo SEQUENTIAL_TABLE[] = {
- { TaskGeneric::ETaskSequential, false },
- { TaskGeneric::ETaskInput, false },
- { TaskGeneric::ETaskOutput, false },
- { TaskGeneric::ETaskProcess, false },
- { TaskGeneric::ETaskMessage, false }
-};
-
-
-ModelBuilder::ParsingInfo ModelBuilder::mParsingTable[ModelBuilder::PARSING_TABLE_SIZE] = {
- { "case", TaskGeneric::ETaskCase, CASE_TABLE,
- sizeof(CASE_TABLE)/sizeof(ModelBuilder::ChildInfo) },
- { "setup", TaskGeneric::ETaskSetup, SETUP_TABLE,
- sizeof(SETUP_TABLE)/sizeof(ModelBuilder::ChildInfo) },
- { "action", TaskGeneric::ETaskAction, ACTION_TABLE,
- sizeof(ACTION_TABLE)/sizeof(ModelBuilder::ChildInfo) },
- { "sequential", TaskGeneric::ETaskSequential, SEQUENTIAL_TABLE,
- sizeof(SEQUENTIAL_TABLE)/sizeof(ModelBuilder::ChildInfo) },
- { "process", TaskGeneric::ETaskProcess, NULL, 0 },
- { "input", TaskGeneric::ETaskInput, NULL, 0 },
- { "output", TaskGeneric::ETaskOutput, NULL, 0 },
- { "sound", TaskGeneric::ETaskSound, NULL, 0 },
- { "save", TaskGeneric::ETaskSave, NULL, 0 },
- { "message", TaskGeneric::ETaskMessage, NULL, 0 },
- { "download", TaskGeneric::ETaskDownload, NULL, 0 }
-};
-
-
-ModelBuilder::ModelBuilder()
- : mFactory(new GenericFactory())
-{
-
-}
-
-ModelBuilder::ModelBuilder(GenericFactory* factory)
- : mFactory(factory)
-{
-
-}
-ModelBuilder::~ModelBuilder()
-{
- delete mFactory;
-}
-
-TaskGeneric* ModelBuilder::parseTestDescriptionXml(const android::String8& xmlFileName,
- bool caseOnly)
-{
- XMLDocument doc;
- int error = doc.LoadFile(xmlFileName.string());
- if (error != XML_SUCCESS) {
- LOGE("ModelBuilder::parseTestDescriptionXml cannot load file %s: %d", xmlFileName.string(), error);
- return NULL;
- }
- const XMLElement* root;
- if ((root = doc.FirstChildElement("case")) != NULL) {
- return parseCase(*root);
- } else if (!caseOnly && ((root = doc.FirstChildElement("batch")) != NULL)) {
- return parseBatch(*root, xmlFileName);
- } else {
- LOGE("ModelBuilder::parseTestDescriptionXml wrong root element");
- return NULL;
- }
-}
-
-TaskGeneric* ModelBuilder::parseGeneric(const XMLElement& self, int tableIndex)
-{
- TaskGeneric::TaskType typeSelf(mParsingTable[tableIndex].type);
- int Nchildren = mParsingTable[tableIndex].Nchildren;
- std::unique_ptr<TaskGeneric> taskSelf(mFactory->createTask(typeSelf));
- if (taskSelf.get() == NULL) {
- return NULL;
- }
- if (!parseAttributes(self, *taskSelf.get())) {
- return NULL;
- }
- // copy mandatory flags, and will be cleared once the item is found
- bool mandatoryAbsence[MAX_NO_CHILDREN];
- const ModelBuilder::ChildInfo* childTable = mParsingTable[tableIndex].allowedChildren;
- for (int i = 0; i < Nchildren; i++) {
- mandatoryAbsence[i] = childTable[i].mandatory;
- }
-
- // handle children
- const XMLElement* child = self.FirstChildElement();
- while (child != NULL) {
- TaskGeneric::TaskType childType(TaskGeneric::ETaskInvalid);
- int i;
- // check if type is valid
- for (i = 0; i < PARSING_TABLE_SIZE; i++) {
- if (strcmp(child->Value(), mParsingTable[i].name) == 0) {
- break;
- }
- }
- if (i == PARSING_TABLE_SIZE) {
- LOGE("ModelBuilder::parseGeneric unknown element %s", child->Value());
- return NULL;
- }
- childType = mParsingTable[i].type;
- int j;
- // check if the type is allowed as child
- for (j = 0; j < Nchildren; j++) {
- if (childTable[j].type == childType) {
- if (childTable[j].mandatory) {
- mandatoryAbsence[j] = false;
- }
- break;
- }
- }
- if (j == Nchildren) {
- LOGE("ModelBuilder::parseGeneric unsupported child type %d for type %d", childType,
- typeSelf);
- return NULL;
- }
- std::unique_ptr<TaskGeneric> taskChild(parseGeneric(*child, i));
- if (taskChild.get() == NULL) {
- LOGE("ModelBuilder::parseGeneric failed in parsing child type %d for type %d",
- childType, typeSelf);
- return NULL;
- }
- if (!taskSelf.get()->addChild(taskChild.get())) {
- LOGE("ModelBuilder::parseGeneric cannot add child type %d to type %d", childType,
- typeSelf);
- return NULL;
- }
- TaskGeneric* donotuse = taskChild.release();
-
- child = child->NextSiblingElement();
- }
- for (int i = 0; i < Nchildren; i++) {
- if (mandatoryAbsence[i]) {
- LOGE("ModelBuilder::parseGeneric mandatory child type %d not present in type %d",
- childTable[i].type, typeSelf);
- return NULL;
- }
- }
-
- return taskSelf.release();
-}
-
-
-TaskCase* ModelBuilder::parseCase(const XMLElement& root)
-{
- // position 0 of mParsingTable should be "case"
- return reinterpret_cast<TaskCase*>(parseGeneric(root, 0));
-}
-
-
-TaskBatch* ModelBuilder::parseBatch(const XMLElement& root, const android::String8& xmlFileName)
-{
- std::unique_ptr<TaskBatch> batch(
- reinterpret_cast<TaskBatch*>(mFactory->createTask(TaskGeneric::ETaskBatch)));
- if (batch.get() == NULL) {
- LOGE("ModelBuilder::handleBatch cannot create TaskBatch");
- return NULL;
- }
- if (!parseAttributes(root, *batch.get())) {
- return NULL;
- }
-
- const XMLElement* inc = root.FirstChildElement("include");
- if (inc == NULL) {
- LOGE("ModelBuilder::handleBatch no include inside batch");
- return NULL;
- }
- android::String8 path = xmlFileName.getPathDir();
-
- std::unique_ptr<TaskCase> testCase;
- int i = 0;
- while (1) {
- if (inc == NULL) {
- break;
- }
- if (strcmp(inc->Value(),"include") != 0) {
- LOGE("ModelBuilder::handleBatch invalid element %s", inc->Value());
- }
- testCase.reset(parseInclude(*inc, path));
- if (testCase.get() == NULL) {
- LOGE("ModelBuilder::handleBatch cannot create test case from include");
- return NULL;
- }
- if (!batch.get()->addChild(testCase.get())) {
- return NULL;
- }
- TaskGeneric* donotuse = testCase.release(); // parent will take care of destruction.
- inc = inc->NextSiblingElement();
- i++;
- }
- if (i == 0) {
- // at least one include should exist.
- LOGE("ModelBuilder::handleBatch no include elements");
- return NULL;
- }
-
- return batch.release();
-}
-
-TaskCase* ModelBuilder::parseInclude(const XMLElement& elem, const android::String8& path)
-{
- const char* fileName = elem.Attribute("file");
- if (fileName == NULL) {
- LOGE("ModelBuilder::handleBatch no include elements");
- return NULL;
- }
- android::String8 incFile = path;
- incFile.appendPath(fileName);
-
- // again no dynamic_cast intentionally
- return reinterpret_cast<TaskCase*>(parseTestDescriptionXml(incFile, true));
-}
-
-bool ModelBuilder::parseAttributes(const XMLElement& elem, TaskGeneric& task)
-{
- const XMLAttribute* attr = elem.FirstAttribute();
- while (1) {
- if (attr == NULL) {
- break;
- }
- android::String8 name(attr->Name());
- android::String8 value(attr->Value());
- if (!task.parseAttribute(name, value)) {
- LOGE("ModelBuilder::parseAttributes cannot parse attribute %s:%s for task type %d",
- attr->Name(), attr->Value(), task.getType());
- return false;
- }
- attr = attr->Next();
- }
- return true;
-}
diff --git a/suite/audio_quality/lib/src/task/TaskAsync.cpp b/suite/audio_quality/lib/src/task/TaskAsync.cpp
deleted file mode 100644
index 4121a5e..0000000
--- a/suite/audio_quality/lib/src/task/TaskAsync.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <stdlib.h>
-#include "Log.h"
-#include "StringUtil.h"
-#include "task/TaskAll.h"
-
-TaskAsync::TaskAsync(TaskType type)
- : TaskGeneric(type),
- mVolume(-1),
- mDeviceType(EDeviceHost),
- mMode(AudioHardware::EModeVoice),
- mAsynchronous(false)
-{
- // nothing to do
-}
-
-TaskAsync::~TaskAsync()
-{
-
-}
-
-TaskGeneric::ExecutionResult TaskAsync::run()
-{
- // id is mandatory
- if (mId.length() == 0) {
- LOGE(" TaskAsync::run no id attribute");
- return TaskGeneric::EResultError;
- }
- TaskGeneric::ExecutionResult result = start();
- if (result == TaskGeneric::EResultOK) {
- if (!isAsynchronous()) {
- return complete();
- } else {
- if (!getParentSequential()->queueAsyncTask(const_cast<TaskAsync*>(this))) {
- LOGE("TaskAsync::run queueAsyncTask failed");
- return TaskGeneric::EResultError;
- }
- }
- }
- return result;
-}
-
-bool TaskAsync::parseAttribute(const android::String8& name, const android::String8& value)
-{
- bool result = true;
- if (StringUtil::compare(name, "id") == 0) {
- mId.append(value);
- } else if (StringUtil::compare(name, "gain") == 0) {
- mVolume = atoi(value.string());
- if ((mVolume < 1) || (mVolume > 100)) {
- LOGE("TaskGeneric::parseAttribute gain out of range %d", mVolume);
- return false;
- }
- } else if (StringUtil::compare(name, "sync") == 0) {
- if (StringUtil::compare(value, "start") == 0) { // async
- makeAsynchronous();
- }
- } else if (StringUtil::compare(name, "device") == 0) {
- if (StringUtil::compare(value, "host") == 0) {
- mDeviceType = EDeviceHost;
- } else if (StringUtil::compare(value, "DUT") == 0) {
- mDeviceType = EDeviceDUT;
- } else {
- return false;
- }
- } else if (StringUtil::compare(name, "mode") == 0) {
- if (StringUtil::compare(value, "voice") == 0) {
- mMode = AudioHardware::EModeVoice;
- } else if (StringUtil::compare(value, "music") == 0) {
- mMode = AudioHardware::EModeMusic;
- } else {
- return false;
- }
- } else {
- result = TaskGeneric::parseAttribute(name, value);
- }
- return result;
-}
-
-TaskSequential* TaskAsync::getParentSequential()
-{
- ASSERT(getParent()->getType() == TaskGeneric::ETaskSequential);
- return reinterpret_cast<TaskSequential*>(getParent());
-}
-
diff --git a/suite/audio_quality/lib/src/task/TaskBatch.cpp b/suite/audio_quality/lib/src/task/TaskBatch.cpp
deleted file mode 100644
index 70499fc..0000000
--- a/suite/audio_quality/lib/src/task/TaskBatch.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "Log.h"
-#include "Report.h"
-
-#include "task/TaskBatch.h"
-
-static const android::String8 STR_NAME("name");
-static const android::String8 STR_VERSION("version");
-static const android::String8 STR_DESCRIPTION("description");
-
-TaskBatch::TaskBatch()
- :TaskGeneric(TaskGeneric::ETaskBatch)
-{
- const android::String8* list[] = {&STR_NAME, &STR_VERSION, &STR_DESCRIPTION, NULL};
- registerSupportedStringAttributes(list);
-}
-
-TaskBatch::~TaskBatch()
-{
-
-}
-
-bool TaskBatch::addChild(TaskGeneric* child)
-{
- if (child->getType() != TaskGeneric::ETaskCase) {
- LOGE("TaskBatch::addChild wrong child type %d", child->getType());
- return false;
- }
- return TaskGeneric::addChild(child);
-}
-
-bool runAlways(TaskGeneric* child, void* data)
-{
- child->run();
- return true;
-}
-
-TaskGeneric::ExecutionResult TaskBatch::run()
-{
- android::String8 name;
- android::String8 version;
-
- if (!findStringAttribute(STR_NAME, name) || !findStringAttribute(STR_VERSION, version)) {
- LOGW("TaskBatch::run no name or version information");
- }
- MSG("= Test batch %s version %s started. =", name.string(),
- version.string());
- bool result = TaskGeneric::forEachChild(runAlways, NULL);
- MSG("= Finished Test batch =");
- return TaskGeneric::EResultOK;
-}
-
-
diff --git a/suite/audio_quality/lib/src/task/TaskCase.cpp b/suite/audio_quality/lib/src/task/TaskCase.cpp
deleted file mode 100644
index 861802d..0000000
--- a/suite/audio_quality/lib/src/task/TaskCase.cpp
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <sys/types.h>
-#include <regex.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "Log.h"
-#include "audio/RemoteAudio.h"
-#include "ClientImpl.h"
-#include "Report.h"
-#include "Settings.h"
-#include "StringUtil.h"
-#include "task/TaskCase.h"
-
-static const android::String8 STR_NAME("name");
-static const android::String8 STR_VERSION("version");
-static const android::String8 STR_DESCRIPTION("description");
-
-TaskCase::TaskCase()
- : TaskGeneric(TaskGeneric::ETaskCase),
- mClient(NULL)
-{
- const android::String8* list[] = {&STR_NAME, &STR_VERSION, &STR_DESCRIPTION, NULL};
- registerSupportedStringAttributes(list);
-}
-
-TaskCase::~TaskCase()
-{
- delete mClient;
-}
-
-bool TaskCase::getCaseName(android::String8& name) const
-{
- if (!findStringAttribute(STR_NAME, name)) {
- LOGW("TaskCase no name");
- return false;
- }
- return true;
-}
-
-bool TaskCase::addChild(TaskGeneric* child)
-{
- if ((child->getType() != TaskGeneric::ETaskSetup)
- && (child->getType() != TaskGeneric::ETaskAction)
- && (child->getType() != TaskGeneric::ETaskSave)) {
- LOGE("TestCase::addChild wrong child type %d", child->getType());
- return false;
- }
- return TaskGeneric::addChild(child);
-}
-
-template <typename T> bool registerGeneric(
- typename std::map<android::String8, T>& map,
- const android::String8& name, T& data)
-{
- typename std::map<android::String8, T>::iterator it;
- it = map.find(name);
- if (it != map.end()) {
- LOGV("registerGeneric key %s already registered", name.string());
- return false;
- }
- LOGD("registerGeneric registered key %s", name.string());
- map[name] = data;
- return true;
-}
-
-template <typename T> bool findGeneric(typename std::map<android::String8, T>& map,
- const android::String8& name, T& data)
-{
- LOGD("findGeneric key %s", name.string());
- typename std::map<android::String8, T>::iterator it;
- it = map.find(name);
- if (it == map.end()) {
- return false;
- }
- data = it->second;
- return true;
-}
-
-template <typename T> bool updateGeneric(typename std::map<android::String8, T>& map,
- const android::String8& name, T& data)
-{
- LOGD("updateGeneric key %s", name.string());
- typename std::map<android::String8, T>::iterator it;
- it = map.find(name);
- if (it == map.end()) {
- return false;
- }
- it->second = data;
- return true;
-}
-
-// return all the matches for the given regular expression.
-// name string and the data itself is copied.
-template <typename T> typename std::list<std::pair<android::String8, T> >* findAllGeneric(
- typename std::map<android::String8, T>& map, const char* re)
-{
- regex_t regex;
- if (regcomp(®ex, re, REG_EXTENDED | REG_NOSUB) != 0) {
- LOGE("regcomp failed");
- return NULL;
- }
- typename std::map<android::String8, T>::iterator it;
- typename std::list<std::pair<android::String8, T> >* list = NULL;
- for (it = map.begin(); it != map.end(); it++) {
- if (regexec(®ex, it->first, 0, NULL, 0) == 0) {
- if (list == NULL) { // create only when found
- list = new std::list<std::pair<android::String8, T> >();
- if (list == NULL) {
- regfree(®ex);
- return NULL;
- }
- }
- typename std::pair<android::String8, T> match(it->first, it->second);
- list->push_back(match);
- }
- }
- regfree(®ex);
- return list;
-}
-
-
-bool TaskCase::registerBuffer(const android::String8& orig, android::sp<Buffer>& buffer)
-{
- android::String8 translated;
- if (!translateVarName(orig, translated)) {
- return false;
- }
- return registerGeneric<android::sp<Buffer> >(mBufferList, translated, buffer);
-}
-
-bool TaskCase::updateBuffer(const android::String8& orig, android::sp<Buffer>& buffer)
-{
- android::String8 translated;
- if (!translateVarName(orig, translated)) {
- return false;
- }
- return updateGeneric<android::sp<Buffer> >(mBufferList, translated, buffer);
-}
-
-android::sp<Buffer> TaskCase::findBuffer(const android::String8& orig)
-{
- android::String8 translated;
- android::sp<Buffer> result;
- if (!translateVarName(orig, translated)) {
- return result;
- }
- findGeneric<android::sp<Buffer> >(mBufferList, translated, result);
- return result;
-}
-
-std::list<TaskCase::BufferPair>* TaskCase::findAllBuffers(const android::String8& re)
-{
- android::String8 translated;
- if (!translateVarName(re, translated)) {
- return NULL;
- }
- return findAllGeneric<android::sp<Buffer> >(mBufferList, translated.string());
-}
-
-
-bool TaskCase::registerValue(const android::String8& orig, Value& val)
-{
- android::String8 translated;
- if (!translateVarName(orig, translated)) {
- return false;
- }
- LOGD("str %x", translated.string());
- return registerGeneric<Value>(mValueList, translated, val);
-}
-
-bool TaskCase::updateValue(const android::String8& orig, Value& val)
-{
- android::String8 translated;
- if (!translateVarName(orig, translated)) {
- return false;
- }
- return updateGeneric<Value>(mValueList, translated, val);
-}
-
-bool TaskCase::findValue(const android::String8& orig, Value& val)
-{
- android::String8 translated;
- if (!translateVarName(orig, translated)) {
- return false;
- }
- return findGeneric<Value>(mValueList, translated, val);
-}
-
-std::list<TaskCase::ValuePair>* TaskCase::findAllValues(const android::String8& re)
-{
- android::String8 translated;
- if (!translateVarName(re, translated)) {
- return NULL;
- }
- return findAllGeneric<Value>(mValueList, translated.string());
-}
-
-bool TaskCase::registerIndex(const android::String8& name, int value)
-{
- return registerGeneric<int>(mIndexList, name, value);
-}
-
-bool TaskCase::updateIndex(const android::String8& name, int value)
-{
- return updateGeneric<int>(mIndexList, name, value);
-}
-
-bool TaskCase::findIndex(const android::String8& name, int& val)
-{
- return findGeneric<int>(mIndexList, name, val);
-}
-
-std::list<TaskCase::IndexPair>* TaskCase::findAllIndices(const android::String8& re)
-{
- android::String8 translated;
- if (!translateVarName(re, translated)) {
- return NULL;
- }
- return findAllGeneric<int>(mIndexList, translated.string());
-}
-
-bool TaskCase::translateVarName(const android::String8& orig, android::String8& translated)
-{
- const char* src = orig.string();
- const int nmatch = 2;
- regmatch_t pmatch[nmatch];
- regex_t re;
- size_t strStart = 0;
-
- if (regcomp(&re, "[a-z0-9_]*[$]([a-z0-9]+)[_]*", REG_EXTENDED) != 0) {
- LOGE("regcomp failed");
- return false;
- }
- bool result = false;
- size_t matchStart = 0;
- size_t matchEnd = 0;
- while (regexec(&re, src, nmatch, pmatch, 0) == 0) {
- matchStart = strStart + pmatch[1].rm_so;
- matchEnd = strStart + pmatch[1].rm_eo;
- translated.append(StringUtil::substr(orig, strStart, pmatch[1].rm_so - 1)); //-1 for $
- android::String8 indexName;
- indexName.append(StringUtil::substr(orig, matchStart, matchEnd - matchStart));
- int val;
- if (!findIndex(indexName, val)) {
- LOGE("TaskCase::translateVarName no index with name %s", indexName.string());
- regfree(&re);
- return false;
- }
- translated.appendFormat("%d", val);
- LOGD("match found strStart %d, matchStart %d, matchEnd %d, converted str %s",
- strStart, matchStart, matchEnd, translated.string());
- src += pmatch[1].rm_eo;
- strStart += pmatch[1].rm_eo;
- }
- if (matchEnd < orig.length()) {
- //LOGD("%d %d", matchEnd, orig.length());
- translated.append(StringUtil::substr(orig, matchEnd, orig.length() - matchEnd));
- }
- LOGD("translated str %s to %s", orig.string(), translated.string());
- regfree(&re);
- return true;
-}
-
-android::sp<RemoteAudio>& TaskCase::getRemoteAudio()
-{
- if (mClient == NULL) {
- mClient = new ClientImpl();
- ASSERT(mClient->init(Settings::Instance()->getSetting(Settings::EADB)));
- }
- return mClient->getAudio();
-}
-
-void TaskCase::releaseRemoteAudio()
-{
- delete mClient;
- mClient = NULL;
-}
-
-void TaskCase::setDetails(const android::String8& details)
-{
- mDetails = details;
-}
-
-const android::String8& TaskCase::getDetails() const
-{
- return mDetails;
-}
-
-
-TaskGeneric::ExecutionResult TaskCase::run()
-{
- android::String8 name;
- android::String8 version;
- //LOGI("str %d, %d", strlen(STR_NAME), strlen(STR_VERSION));
- if (!findStringAttribute(STR_NAME, name) || !findStringAttribute(STR_VERSION, version)) {
- LOGW("TaskCase::run no name or version information");
- }
- MSG("== Test case %s version %s started ==", name.string(), version.string());
- std::list<TaskGeneric*>::iterator i = getChildren().begin();
- std::list<TaskGeneric*>::iterator end = getChildren().end();
- TaskGeneric* setup = *i;
- i++;
- TaskGeneric* action = *i;
- i++;
- TaskGeneric* save = (i == end)? NULL : *i;
- if (save == NULL) {
- LOGW("No save stage in test case");
- }
- bool testPassed = true;
- TaskGeneric::ExecutionResult result = setup->run();
- TaskGeneric::ExecutionResult resultAction(TaskGeneric::EResultOK);
- if (result != TaskGeneric::EResultOK) {
- MSG("== setup stage failed %d ==", result);
- testPassed = false;
- } else {
- resultAction = action->run();
- if (resultAction != TaskGeneric::EResultPass) {
- MSG("== action stage failed %d ==", resultAction);
- testPassed = false;
- }
- // save done even for failure if possible
- if (save != NULL) {
- result = save->run();
- }
- if (result != TaskGeneric::EResultOK) {
- MSG("== save stage failed %d ==", result);
- testPassed = false;
- }
- }
- if (testPassed) {
- result = TaskGeneric::EResultPass;
- MSG("== Case %s Passed ==", name.string());
- Report::Instance()->addCasePassed(this);
- } else {
- if (resultAction != TaskGeneric::EResultOK) {
- result = resultAction;
- }
- MSG("== Case %s Failed ==", name.string());
- Report::Instance()->addCaseFailed(this);
- }
- // release remote audio for other cases to use
- releaseRemoteAudio();
- return result;
-}
-
diff --git a/suite/audio_quality/lib/src/task/TaskDownload.cpp b/suite/audio_quality/lib/src/task/TaskDownload.cpp
deleted file mode 100644
index 2973f17..0000000
--- a/suite/audio_quality/lib/src/task/TaskDownload.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "Log.h"
-#include "audio/AudioSignalFactory.h"
-#include "audio/RemoteAudio.h"
-#include "StringUtil.h"
-#include "task/TaskCase.h"
-#include "task/TaskDownload.h"
-
-static const android::String8 STR_ID("id");
-
-TaskDownload::TaskDownload()
- : TaskGeneric(TaskGeneric::ETaskDownload)
-{
- const android::String8* list[] = {&STR_ID, NULL};
- registerSupportedStringAttributes(list);
-}
-
-TaskDownload::~TaskDownload()
-{
-
-}
-
-TaskGeneric::ExecutionResult TaskDownload::run()
-{
- android::String8 id;
- if (!findStringAttribute(STR_ID, id)) {
- LOGE("TaskDownload::run %s string not found", STR_ID.string());
- return TaskGeneric::EResultError;
- }
-
- android::sp<Buffer> buffer = getTestCase()->findBuffer(id);
- if (buffer.get() == NULL) {
- LOGE("TaskDownload::run cannot find buffer %s", id.string());
- return TaskGeneric::EResultError;
- }
- int downloadId;
- if (!getTestCase()->getRemoteAudio()->downloadData(id, buffer, downloadId)) {
- return TaskGeneric::EResultError;
- }
- LOGI("Downloaded buffer %s to DUT with id %d", id.string(), downloadId);
- return TaskGeneric::EResultOK;
-}
-
-
-
diff --git a/suite/audio_quality/lib/src/task/TaskGeneric.cpp b/suite/audio_quality/lib/src/task/TaskGeneric.cpp
deleted file mode 100644
index 4a394e2..0000000
--- a/suite/audio_quality/lib/src/task/TaskGeneric.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "Log.h"
-
-#include "task/TaskAll.h"
-
-
-TaskGeneric::TaskGeneric(TaskType type):
- mType(type),
- mParent(NULL)
-{
-
-}
-
-bool deleteChildInstance(TaskGeneric* child, void* /*data*/)
-{
- delete child;
- return true;
-}
-
-TaskGeneric::~TaskGeneric()
-{
- forEachChild(deleteChildInstance, NULL);
- //mChildren.clear();
-}
-
-bool TaskGeneric::addChild(TaskGeneric* child)
-{
- mChildren.push_back(child);
- child->setParent(this);
- return true;
-}
-
-bool TaskGeneric::forEachChild(bool (*runForEachChild)(TaskGeneric* child, void* data), void* data)
-{
- std::list<TaskGeneric*>::iterator i = mChildren.begin();
- std::list<TaskGeneric*>::iterator end = mChildren.end();
- for (; i != end; i++) {
- if (!(*runForEachChild)(*i, data)) {
- return false;
- }
- }
- return true;
-}
-
-TaskGeneric* TaskGeneric::getParent()
-{
- return mParent;
-}
-
-TaskCase* TaskGeneric::getTestCase()
-{
- TaskGeneric* task = this;
-
- while (task != NULL) {
- if (task->getType() == ETaskCase) {
- // do not use dynamic_cast intentionally
- return reinterpret_cast<TaskCase*>(task);
- }
- task = task->getParent();
- }
- LOGE("TaskGeneric::getTestCase no TaskCase found!");
- return NULL;
-}
-
-void TaskGeneric::setParent(TaskGeneric* parent)
-{
- LOGD("TaskGeneric::setParent self %x, parent %x", this, parent);
- mParent = parent;
-}
-
-bool runChild(TaskGeneric* child, void* data)
-{
- TaskGeneric::ExecutionResult* result = reinterpret_cast<TaskGeneric::ExecutionResult*>(data);
- *result = child->run();
- if (*result != TaskGeneric::EResultOK) {
- LOGE("child type %d returned %d", child->getType(), *result);
- return false;
- }
- return true;
-}
-
-TaskGeneric::ExecutionResult TaskGeneric::run()
-{
- ExecutionResult result = EResultOK;
- forEachChild(runChild, &result);
- return result;
-}
-
-bool TaskGeneric::parseAttribute(const android::String8& name, const android::String8& value)
-{
- // default implementation only handles registered string attributes
- if (!addStringAttribute(name, value)) {
- LOGE("parseAttribute unknown attribute %s %s for type %d",
- name.string(), value.string(), getType());
- return false;
- }
- return true;
-}
-
-
-void TaskGeneric::registerSupportedStringAttributes(const android::String8* keys[])
-{
- int i = 0;
- while (keys[i] != NULL) {
- mAllowedStringAttributes.insert(*keys[i]);
- i++;
- }
-}
-
-bool TaskGeneric::addStringAttribute(const android::String8& key, const android::String8& value)
-{
- auto it = mAllowedStringAttributes.find(key);
- if (it == mAllowedStringAttributes.end()) {
- return false; // not allowed
- }
- mStringAttributes[key] = value;
- return true;
-}
-
-bool TaskGeneric::findStringAttribute(const android::String8& key, android::String8& value) const
-{
- auto it = mStringAttributes.find(key);
- if (it == mStringAttributes.end()) {
- return false; // not found
- }
- value = it->second;
- return true;
-}
-
diff --git a/suite/audio_quality/lib/src/task/TaskInput.cpp b/suite/audio_quality/lib/src/task/TaskInput.cpp
deleted file mode 100644
index e5b4b06..0000000
--- a/suite/audio_quality/lib/src/task/TaskInput.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <stdlib.h>
-
-#include "Log.h"
-#include "audio/AudioHardware.h"
-#include "task/TaskCase.h"
-#include "task/TaskInput.h"
-
-TaskInput::TaskInput()
- : TaskAsync(TaskGeneric::ETaskInput),
- mRecordingTimeInMs(0)
-{
-
-}
-
-TaskInput::~TaskInput()
-{
-
-}
-
-bool TaskInput::parseAttribute(const android::String8& name, const android::String8& value)
-{
- if (strcmp(name, "time") == 0) {
- mRecordingTimeInMs = atoi(value);
- if (mRecordingTimeInMs < 0) {
- LOGE("TaskInput::parseAttribute invalid recording time %d", mRecordingTimeInMs);
- return false;
- }
- return true;
- }
- return TaskAsync::parseAttribute(name, value);
-}
-
-TaskGeneric::ExecutionResult TaskInput::start()
-{
- bool localDevice = (mDeviceType == TaskAsync::EDeviceHost);
- android::sp<AudioHardware> hw = AudioHardware::createAudioHw(localDevice, false,
- getTestCase());
- if (hw.get() == NULL) {
- LOGE("createAudioHw failed");
- return TaskGeneric::EResultError;
- }
- // TODO support stereo mode in local later
- // for now, local is captured in stereo, and it is stored to mono
- // by keeping only channel 1.
- // local : stereo only, remote : mono only
- size_t bufferSize = mRecordingTimeInMs * AudioHardware::ESampleRate_44100 / 1000 *
- (localDevice ? 4 : 2);
- android::sp<Buffer> buffer(new Buffer(bufferSize, bufferSize, localDevice));
- if (buffer.get() == NULL) {
- LOGE("buffer alloc failed");
- return TaskGeneric::EResultError;
- }
- if (!hw->prepare(AudioHardware::ESampleRate_44100, mVolume, mMode)) {
- LOGE("prepare failed");
- return TaskGeneric::EResultError;
- }
- if (!hw->startPlaybackOrRecord(buffer)) {
- LOGE("record failed");
- return TaskGeneric::EResultError;
- }
- // now store sp
- mHw = hw;
- mBuffer = buffer;
- return TaskGeneric::EResultOK;
-}
-
-TaskGeneric::ExecutionResult TaskInput::complete()
-{
- bool result = mHw->waitForCompletion();
- mHw->stopPlaybackOrRecord();
- mHw.clear();
- if (!result) {
- LOGE("waitForComletion failed");
- return TaskGeneric::EResultError;
- }
- // TODO: need to keep stereo for local if in stereo mode
- // For now, convert to mono if it is stereo
- if (mBuffer->isStereo()) {
- mBuffer->changeToMono(Buffer::EKeepCh0);
- }
- if (!getTestCase()->registerBuffer(mId, mBuffer)) {
- if (!getTestCase()->updateBuffer(mId, mBuffer)) {
- LOGE("cannot register/update buffer %s", mId.string());
- return TaskGeneric::EResultError;
- }
- }
- return TaskGeneric::EResultOK;
-}
-
-
diff --git a/suite/audio_quality/lib/src/task/TaskMessage.cpp b/suite/audio_quality/lib/src/task/TaskMessage.cpp
deleted file mode 100644
index 4241d2e..0000000
--- a/suite/audio_quality/lib/src/task/TaskMessage.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "task/TaskMessage.h"
-
-
-TaskMessage::TaskMessage()
- : TaskGeneric(TaskGeneric::ETaskMessage)
-{}
-TaskMessage::~TaskMessage()
-{
-
-}
-TaskGeneric::ExecutionResult TaskMessage::run()
-{
- //TODO
- return TaskGeneric::EResultError;
-}
-bool TaskMessage::parseAttribute(const android::String8& name, const android::String8& value)
-{
- //TODO
- return false;
-}
diff --git a/suite/audio_quality/lib/src/task/TaskOutput.cpp b/suite/audio_quality/lib/src/task/TaskOutput.cpp
deleted file mode 100644
index be6f4fd..0000000
--- a/suite/audio_quality/lib/src/task/TaskOutput.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "task/TaskCase.h"
-#include "StringUtil.h"
-#include "task/TaskOutput.h"
-#include "audio/AudioRemote.h"
-#include "audio/RemoteAudio.h"
-
-
-TaskOutput::TaskOutput()
- : TaskAsync(TaskGeneric::ETaskOutput),
- mWaitForCompletion(false)
-{
-
-}
-
-TaskOutput::~TaskOutput()
-{
-
-}
-bool TaskOutput::parseAttribute(const android::String8& name, const android::String8& value)
-{
- if (StringUtil::compare(name, "waitforcompletion") == 0) {
- if (StringUtil::compare(value, "1") == 0) {
- mWaitForCompletion = true;
- }
- return true;
- }
- return TaskAsync::parseAttribute(name, value);
-}
-TaskGeneric::ExecutionResult TaskOutput::start()
-{
- bool localDevice = (mDeviceType == TaskAsync::EDeviceHost);
- android::sp<AudioHardware> hw = AudioHardware::createAudioHw(localDevice, true, getTestCase());
- if (hw.get() == NULL) {
- LOGE("cannot create Audio HW");
- return TaskGeneric::EResultError;
- }
- if (!hw->prepare(AudioHardware::ESampleRate_44100, mVolume, mMode)) {
- LOGE("prepare failed");
- return TaskGeneric::EResultError;
- }
- android::sp<Buffer> buffer = getTestCase()->findBuffer(mId);
- if (buffer.get() == NULL) {
- LOGE("cannot find buffer %s", mId.string());
- return TaskGeneric::EResultError;
- }
- buffer->restart(); // reset to play from beginning
- if (localDevice) {
- if (!hw->startPlaybackOrRecord(buffer)) {
- LOGE("play failed");
- return TaskGeneric::EResultError;
- }
- } else {
- int id = getTestCase()->getRemoteAudio()->getDataId(mId);
- if (id < 0) {
- return TaskGeneric::EResultError;
- }
- AudioRemotePlayback* remote = reinterpret_cast<AudioRemotePlayback*>(hw.get());
- if (!remote->startPlaybackForRemoteData(id, buffer->isStereo())) {
- return TaskGeneric::EResultError;
- }
- }
- // now store sp
- mHw = hw;
-
- return TaskGeneric::EResultOK;
-}
-
-TaskGeneric::ExecutionResult TaskOutput::complete()
-{
- bool result = true;
- if (mWaitForCompletion) {
- result = mHw->waitForCompletion();
- }
- mHw->stopPlaybackOrRecord();
- mHw.clear();
- if (!result) {
- LOGE("waitForCompletion failed");
- return TaskGeneric::EResultError;
- }
- return TaskGeneric::EResultOK;
-}
-
-
diff --git a/suite/audio_quality/lib/src/task/TaskProcess.cpp b/suite/audio_quality/lib/src/task/TaskProcess.cpp
deleted file mode 100644
index 816e920..0000000
--- a/suite/audio_quality/lib/src/task/TaskProcess.cpp
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include <memory>
-#include <vector>
-
-#include "Log.h"
-#include "StringUtil.h"
-#include "task/TaskProcess.h"
-#include "SignalProcessingImpl.h"
-
-TaskProcess::TaskProcess()
- : TaskGeneric(TaskGeneric::ETaskProcess)
-{
-
-}
-
-TaskProcess::~TaskProcess()
-{
-}
-
-TaskGeneric::ExecutionResult TaskProcess::run()
-{
- if (mType == EBuiltin) {
- return doRun(true);
- } else {
- if (mSp.get() == NULL) {
- mSp.reset(new SignalProcessingImpl());
- if (!mSp->init(SignalProcessingImpl::MAIN_PROCESSING_SCRIPT)) {
- mSp.reset(NULL);
- return TaskGeneric::EResultError;
- }
- }
- return doRun(false);
- }
-}
-
-// Allocate Buffers and Values to pass to builtin functions
-bool TaskProcess::prepareParams(std::vector<TaskProcess::Param>& list,
- const bool* paramTypes,
- std::unique_ptr<void_ptr[]>& ptrs,
- std::unique_ptr<UniqueValue[]>& values,
- std::unique_ptr<UniqueBuffer[]>& buffers,
- bool isInput)
-{
- size_t N = list.size();
-
- LOGD("TaskProcess::prepareParams N = %d", N);
- ptrs.reset(new void_ptr[N]);
- if (ptrs.get() == NULL) {
- LOGE("alloc failed");
- return false;
- }
- // set to NULL to detect illegal access
- bzero(ptrs.get(), N * sizeof(void_ptr));
- values.reset(new UniqueValue[N]);
- if (values.get() == NULL) {
- LOGE("alloc failed");
- return false;
- }
- buffers.reset(new UniqueBuffer[N]);
- if (buffers.get() == NULL) {
- LOGE("alloc failed");
- return false;
- }
-
- void_ptr* voidPtrs = ptrs.get();
- UniqueValue* valuesPtr = values.get();
- UniqueBuffer* buffersPtr = buffers.get();
- for (size_t i = 0; i < N; i++) {
- if ((paramTypes != NULL) && paramTypes[i] && (list[i].getType() != EId)) {
- LOGE("mismatching types %d %d", paramTypes[i], list[i].getType());
- return false;
- }
- if ((paramTypes != NULL) && !paramTypes[i] && (list[i].getType() == EId)) {
- LOGE("mismatching types %d %d", paramTypes[i], list[i].getType());
- return false;
- }
- switch(list[i].getType()) {
- case EId: {
- std::unique_ptr<android::sp<Buffer> > buffer(new android::sp<Buffer>());
- if (buffer.get() == NULL) {
- LOGE("alloc failed");
- return false;
- }
- if (isInput) {
- *(buffer.get()) = getTestCase()->findBuffer(list[i].getParamString());
- if (buffer.get()->get() == NULL) {
- LOGE("find failed");
- return false;
- }
- LOGD("input buffer len %d stereo %d", (*buffer.get())->getSize(),
- (*buffer.get())->isStereo());
- }
- buffersPtr[i].reset(buffer.release());
- voidPtrs[i] = buffersPtr[i].get();
- }
- break;
- case EVal: {
- valuesPtr[i].reset(new TaskCase::Value());
- if (isInput) {
- if (!getTestCase()->findValue(list[i].getParamString(), *(valuesPtr[i].get()))) {
- LOGE("find %s failed", list[i].getParamString().string());
- return false;
- }
- }
- voidPtrs[i] = valuesPtr[i].get();
- }
- break;
- case EConst: {
- if (!isInput) {
- LOGE("const for output");
- return false;
- }
- voidPtrs[i] = list[i].getValuePtr();
-
- if (list[i].getValue().getType() == TaskCase::Value::ETypeDouble) {
- LOGD(" %f", list[i].getValue().getDouble());
- } else {
- LOGD(" %lld", list[i].getValue().getInt64());
- }
- }
- break;
- }
- LOGD("TaskProcess::prepareParams %d-th, const 0x%x", i, voidPtrs[i]);
- }
- return true;
-}
-
-// run builtin function by searching BuiltinProcessing::BUINTIN_FN_TABLE
-TaskGeneric::ExecutionResult TaskProcess::doRun(bool builtIn)
-{
- BuiltinProcessing::BuiltinInfo* info = NULL;
- if (builtIn) {
- for (int i = 0; i < BuiltinProcessing::N_BUILTIN_FNS; i++) {
- if (StringUtil::compare(mName, BuiltinProcessing::BUINTIN_FN_TABLE[i].mName) == 0) {
- info = &BuiltinProcessing::BUINTIN_FN_TABLE[i];
- break;
- }
- }
- if (info == NULL) {
- LOGE("TaskProcess::runBuiltin no match for %s", mName.string());
- return TaskGeneric::EResultError;
- }
- if (mInput.size() != info->mNInput) {
- LOGE("TaskProcess::runBuiltin size mismatch %d vs %d", mInput.size(), info->mNInput);
- return TaskGeneric::EResultError;
- }
- if (mOutput.size() != info->mNOutput) {
- LOGE("TaskProcess::runBuiltin size mismatch %d vs %d", mOutput.size(), info->mNOutput);
- return TaskGeneric::EResultError;
- }
- }
- // This is for passing to builtin fns. Just void pts will be cleared in exit
- std::unique_ptr<void_ptr[]> inputs;
- // This is for holding Value instances. Will be destroyed in exit
- std::unique_ptr<UniqueValue[]> inputValues;
- // This is for holding android::sp<Buffer>. Buffer itself is from the global map.
- std::unique_ptr<UniqueBuffer[]> inputBuffers;
-
- std::unique_ptr<void_ptr[]> outputs;
- // Value is created here. Builtin function just need to set it.
- std::unique_ptr<UniqueValue[]> outputValues;
- // Buffer itself should be allocated by the builtin function itself.
- std::unique_ptr<UniqueBuffer[]> outputBuffers;
-
- if (!prepareParams(mInput, builtIn ? info->mInputTypes : NULL, inputs, inputValues,
- inputBuffers, true)) {
- return TaskGeneric::EResultError;
- }
-
- if (!prepareParams(mOutput, builtIn ? info->mOutputTypes : NULL, outputs, outputValues,
- outputBuffers, false)) {
- return TaskGeneric::EResultError;
- }
-
- TaskGeneric::ExecutionResult result;
- if (builtIn) {
- result = (mBuiltin.*(info->mFunction))(inputs.get(), outputs.get());
- } else {
- std::unique_ptr<bool[]> inputTypes(new bool[mInput.size()]);
- for (size_t i = 0; i < mInput.size(); i++) {
- (inputTypes.get())[i] = mInput[i].isIdType();
- }
- std::unique_ptr<bool[]> outputTypes(new bool[mOutput.size()]);
- for (size_t i = 0; i < mOutput.size(); i++) {
- (outputTypes.get())[i] = mOutput[i].isIdType();
- }
- result = mSp->run( mName,
- mInput.size(), inputTypes.get(), inputs.get(),
- mOutput.size(), outputTypes.get(), outputs.get());
- }
- if ((result == TaskGeneric::EResultOK) || (result == TaskGeneric::EResultFail)
- || (result == TaskGeneric::EResultPass)) {
- // try to save result
- bool saveResultFailed = false;
- for (size_t i = 0; i < mOutput.size(); i++) {
- if (mOutput[i].isIdType()) { // Buffer
- android::sp<Buffer>* bufferp =
- reinterpret_cast<android::sp<Buffer>*>((outputs.get())[i]);
- if (!getTestCase()->registerBuffer(mOutput[i].getParamString(), *bufferp)) {
- // maybe already there, try update
- if (!getTestCase()->updateBuffer(mOutput[i].getParamString(), *bufferp)) {
- LOGE("cannot register / update %d-th output Buffer for builtin fn %s",
- i, mName.string());
- saveResultFailed = true; // mark failure, but continue
- }
- }
- } else { // Value
- TaskCase::Value* valuep =
- reinterpret_cast<TaskCase::Value*>((outputs.get())[i]);
- if (!getTestCase()->registerValue(mOutput[i].getParamString(), *valuep)) {
- if (!getTestCase()->updateValue(mOutput[i].getParamString(), *valuep)) {
- LOGE("cannot register / update %d-th output Value for builtin fn %s",
- i, mName.string());
- saveResultFailed = true; // mark failure, but continue
- }
- }
- }
- }
- if (saveResultFailed) {
- LOGE("TaskProcess::runBuiltin cannot save result");
- return TaskGeneric::EResultError;
- }
- }
- LOGV("TaskProcess::runBuiltin return %d", result);
- return result;
-}
-
-bool TaskProcess::parseParams(std::vector<TaskProcess::Param>& list, const char* str, bool isInput)
-{
- LOGV("TaskProcess::parseParams will parse %s", str);
- android::String8 paramStr(str);
- std::unique_ptr<std::vector<android::String8>> paramTokens(StringUtil::split(paramStr, ','));
- if (paramTokens.get() == NULL) {
- LOGE("split failed");
- return false;
- }
- std::vector<android::String8>& tokens = *(paramTokens.get());
- for (size_t i = 0; i < tokens.size(); i++) {
- std::unique_ptr<std::vector<android::String8>> itemTokens(StringUtil::split(tokens[i],
- ':'));
- if (itemTokens.get() == NULL) {
- LOGE("split failed");
- return false;
- }
- if (itemTokens->size() != 2) {
- LOGE("size mismatch %d", itemTokens->size());
- return false;
- }
- std::vector<android::String8>& item = *(itemTokens.get());
- if (StringUtil::compare(item[0], "id") == 0) {
- Param param(EId, item[1]);
- list.push_back(param);
- LOGD(" id %s", param.getParamString().string());
- } else if (StringUtil::compare(item[0], "val") == 0) {
- Param param(EVal, item[1]);
- list.push_back(param);
- LOGD(" val %s", param.getParamString().string());
- } else if (isInput && (StringUtil::compare(item[0], "consti") == 0)) {
- int64_t value = atoll(item[1].string());
- TaskCase::Value v(value);
- Param param(v);
- list.push_back(param);
- LOGD("consti %lld", value);
- } else if (isInput && (StringUtil::compare(item[0], "constf") == 0)) {
- double value = atof(item[1].string());
- TaskCase::Value v(value);
- Param param(v);
- list.push_back(param);
- LOGD("constf %f", value);
- } else {
- LOGE("unrecognized word %s", item[0].string());
- return false;
- }
- LOGV("TaskProcess::parseParams %d-th type %d", i, list[i].getType());
- }
- return true;
-}
-
-bool TaskProcess::parseAttribute(const android::String8& name, const android::String8& value)
-{
- if (StringUtil::compare(name, "method") == 0) {
- std::unique_ptr<std::vector<android::String8> > tokenPtr(StringUtil::split(value, ':'));
- std::vector<android::String8>* tokens = tokenPtr.get();
- if (tokens == NULL) {
- LOGE("split failed");
- return false;
- }
- if (tokens->size() != 2) {
- LOGE("cannot parse attr %s %s", name.string(), value.string());
- return false;
- }
- if (StringUtil::compare(tokens->at(0), "builtin") == 0) {
- mType = EBuiltin;
- } else if (StringUtil::compare(tokens->at(0), "script") == 0) {
- mType = EScript;
- } else {
- LOGE("cannot parse attr %s %s", name.string(), value.string());
- return false;
- }
- mName.append(tokens->at(1));
- return true;
- } else if (StringUtil::compare(name, "input") == 0) {
- return parseParams(mInput, value, true);
- } else if (StringUtil::compare(name, "output") == 0) {
- return parseParams(mOutput, value, false);
- } else {
- LOGE("cannot parse attr %s %s", name.string(), value.string());
- return false;
- }
-}
-
-TaskProcess::Param::Param(TaskProcess::ParamType type, android::String8& string)
- : mType(type),
- mString(string)
-{
- ASSERT((type == TaskProcess::EId) || (type == TaskProcess::EVal));
-
-}
-
-TaskProcess::Param::Param(TaskCase::Value& val)
- : mType(TaskProcess::EConst),
- mValue(val)
-{
-
-}
-
-TaskProcess::ParamType TaskProcess::Param::getType()
-{
- return mType;
-}
-
-android::String8& TaskProcess::Param::getParamString()
-{
- ASSERT((mType == TaskProcess::EId) || (mType == TaskProcess::EVal));
- return mString;
-}
-
-TaskCase::Value& TaskProcess::Param::getValue()
-{
- ASSERT(mType == TaskProcess::EConst);
- return mValue;
-}
-
-TaskCase::Value* TaskProcess::Param::getValuePtr()
-{
- ASSERT(mType == TaskProcess::EConst);
- return &mValue;
-}
diff --git a/suite/audio_quality/lib/src/task/TaskSave.cpp b/suite/audio_quality/lib/src/task/TaskSave.cpp
deleted file mode 100644
index 64a1928..0000000
--- a/suite/audio_quality/lib/src/task/TaskSave.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <inttypes.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-
-#include <memory>
-
-#include "Log.h"
-#include "FileUtil.h"
-#include "Report.h"
-#include "StringUtil.h"
-#include "task/TaskCase.h"
-#include "task/TaskGeneric.h"
-#include "task/TaskSave.h"
-
-static const android::String8 STR_FILE("file");
-static const android::String8 STR_REPORT("report");
-
-TaskSave::TaskSave()
- : TaskGeneric(TaskGeneric::ETaskSave)
-{
- const android::String8* list[] = {&STR_FILE, &STR_REPORT, NULL};
- registerSupportedStringAttributes(list);
-}
-
-TaskSave::~TaskSave()
-{
-
-}
-
-bool TaskSave::handleFile()
-{
- android::String8 fileValue;
- if (!findStringAttribute(STR_FILE, fileValue)) {
- LOGI("no saving to file");
- return true; // true as there is no need to save
- }
-
- std::unique_ptr<std::vector<android::String8> > list(StringUtil::split(fileValue, ','));
- std::vector<android::String8>* listp = list.get();
- if (listp == NULL) {
- LOGE("alloc failed");
- return false;
- }
-
- android::String8 dirName;
- if (!FileUtil::prepare(dirName)) {
- LOGE("cannot prepare report dir");
- return false;
- }
- android::String8 caseName;
- if (!getTestCase()->getCaseName(caseName)) {
- return false;
- }
- dirName.appendPath(caseName);
- int result = mkdir(dirName.string(), S_IRWXU);
- if ((result == -1) && (errno != EEXIST)) {
- LOGE("mkdir of save dir %s failed, error %d", dirName.string(), errno);
- return false;
- }
-
- for (size_t i = 0; i < listp->size(); i++) {
- std::unique_ptr<std::list<TaskCase::BufferPair> > buffers(
- getTestCase()->findAllBuffers((*listp)[i]));
- std::list<TaskCase::BufferPair>* buffersp = buffers.get();
- if (buffersp == NULL) {
- LOGE("no buffer for given pattern %s", ((*listp)[i]).string());
- return false;
- }
- std::list<TaskCase::BufferPair>::iterator it = buffersp->begin();
- std::list<TaskCase::BufferPair>::iterator end = buffersp->end();
- for (; it != end; it++) {
- android::String8 fileName(dirName);
- fileName.appendPath(it->first);
- if (!it->second->saveToFile(fileName)) {
- LOGE("save failed");
- return false;
- }
- }
- }
- return true;
-}
-
-bool TaskSave::handleReport()
-{
- android::String8 reportValue;
- if (!findStringAttribute(STR_REPORT, reportValue)) {
- LOGI("no saving to report");
- return true; // true as there is no need to save
- }
-
- std::unique_ptr<std::vector<android::String8> > list(StringUtil::split(reportValue, ','));
- std::vector<android::String8>* listp = list.get();
- if (listp == NULL) {
- LOGE("alloc failed");
- return false;
- }
- MSG("=== Values stored ===");
- android::String8 details;
- for (size_t i = 0; i < listp->size(); i++) {
- std::unique_ptr<std::list<TaskCase::ValuePair> > values(
- getTestCase()->findAllValues((*listp)[i]));
- std::list<TaskCase::ValuePair>* valuesp = values.get();
- if (valuesp == NULL) {
- LOGE("no value for given pattern %s", ((*listp)[i]).string());
- return false;
- }
- std::list<TaskCase::ValuePair>::iterator it = values->begin();
- std::list<TaskCase::ValuePair>::iterator end = values->end();
-
- for (; it != end; it++) {
- if (it->second.getType() == TaskCase::Value::ETypeDouble) {
- details.appendFormat(" %s: %f\n", it->first.string(), it->second.getDouble());
- } else { //64bit int
- details.appendFormat(" %s: %" PRId64 "\n", it->first.string(),
- it->second.getInt64());
- }
- }
- MSG("%s", details.string());
- }
- getTestCase()->setDetails(details);
- return true;
-}
-
-TaskGeneric::ExecutionResult TaskSave::run()
-{
- bool failed = false;
- if (!handleFile()) {
- failed = true;
- }
- if (!handleReport()) {
- failed = true;
- }
- if (failed) {
- return TaskGeneric::EResultError;
- } else {
- return TaskGeneric::EResultOK;
- }
-}
-
-
diff --git a/suite/audio_quality/lib/src/task/TaskSequential.cpp b/suite/audio_quality/lib/src/task/TaskSequential.cpp
deleted file mode 100644
index 8c60cb7f..0000000
--- a/suite/audio_quality/lib/src/task/TaskSequential.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <stdlib.h>
-#include <algorithm>
-#include "Log.h"
-#include "StringUtil.h"
-#include "task/TaskSequential.h"
-#include "task/TaskCase.h"
-#include "task/TaskAsync.h"
-
-TaskSequential::TaskSequential()
- : TaskGeneric(TaskGeneric::ETaskSequential),
- mRepeatCount(1),
- mRepeatIndex(-1)
-{
-
-}
-
-TaskSequential::~TaskSequential()
-{
-
-}
-
-
-TaskGeneric::ExecutionResult TaskSequential::run()
-{
- mRepeatIndex = -1;
- bool storeIndex = (mIndexName.length() == 0 ? false: true);
- if (storeIndex && !getTestCase()->registerIndex(mIndexName, mRepeatIndex)) {
- if (!getTestCase()->updateIndex(mIndexName, mRepeatIndex)) {
- LOGE("register/update of index %s failed", mIndexName.string());
- return TaskGeneric::EResultError;
- }
- }
-
- TaskGeneric::ExecutionResult firstError(TaskGeneric::EResultOK);
-
- for (mRepeatIndex = 0; mRepeatIndex < mRepeatCount; mRepeatIndex++) {
- LOGI(" TaskSequential index %s loop %d-th", mIndexName.string(), mRepeatIndex);
- if (storeIndex && !getTestCase()->updateIndex(mIndexName, mRepeatIndex)) {
- return TaskGeneric::EResultError;
- }
- std::list<TaskGeneric*>::iterator i = getChildren().begin();
- std::list<TaskGeneric*>::iterator end = getChildren().end();
- for (; i != end; i++) {
- TaskGeneric* child = *i;
- TaskGeneric::ExecutionResult result = child->run();
- if ((result != TaskGeneric::EResultOK) && (firstError == TaskGeneric::EResultOK)) {
- firstError = result;
- break;
- }
- }
- TaskGeneric::ExecutionResult result = runAsyncTasksQueued();
- if ((result != TaskGeneric::EResultOK) && (firstError == TaskGeneric::EResultOK)) {
- firstError = result;
- }
- switch (firstError) {
- case TaskGeneric::EResultOK:
- case TaskGeneric::EResultContinue:
- // continue at the last index should be treated as OK
- firstError = TaskGeneric::EResultOK;
- break; // continue for loop
- case TaskGeneric:: EResultBreakOneLoop:
- return TaskGeneric::EResultOK;
- case TaskGeneric::EResultError:
- case TaskGeneric::EResultFail:
- case TaskGeneric::EResultPass:
- mRepeatIndex = mRepeatCount; //exit for loop
- break;
- }
- }
- // update to the loop exit value
- if (storeIndex && !getTestCase()->updateIndex(mIndexName, mRepeatIndex)) {
- return TaskGeneric::EResultError;
- }
- return firstError;
-}
-
-bool TaskSequential::queueAsyncTask(TaskAsync* task)
-{
- std::list<TaskAsync*>::iterator it;
- it = std::find(mAsyncTasks.begin(), mAsyncTasks.end(), task);
- if (it != mAsyncTasks.end()) { // already queued
- return true;
- }
- mAsyncTasks.push_back(task);
- return true;
-}
-
-TaskGeneric::ExecutionResult TaskSequential::runAsyncTasksQueued()
-{
- std::list<TaskAsync*>::iterator i = mAsyncTasks.begin();
- std::list<TaskAsync*>::iterator end = mAsyncTasks.end();
- TaskGeneric::ExecutionResult firstError(TaskGeneric::EResultOK);
-
- for (; i != end; i++) {
- TaskAsync* child = *i;
- TaskGeneric::ExecutionResult result = child->complete();
- if ((result != TaskGeneric::EResultOK) && (firstError == TaskGeneric::EResultOK)) {
- firstError = result;
- }
- }
- mAsyncTasks.clear();
- return firstError;
-}
-
-
-bool TaskSequential::parseAttribute(const android::String8& name, const android::String8& value)
-{
- if (StringUtil::compare(name, "repeat") == 0) {
- mRepeatCount = atoi(value.string());
- if (mRepeatCount <= 0) {
- LOGE("TaskSequential::parseAttribute invalid value %s for key %s",
- value.string(), name.string());
- return false;
- }
- return true;
- } else if (StringUtil::compare(name, "index") == 0) {
- mIndexName.append(value);
- LOGD("TaskSequential::parseAttribute index %s", mIndexName.string());
- return true;
- } else {
- return false;
- }
-}
diff --git a/suite/audio_quality/lib/src/task/TaskSound.cpp b/suite/audio_quality/lib/src/task/TaskSound.cpp
deleted file mode 100644
index 58b0364..0000000
--- a/suite/audio_quality/lib/src/task/TaskSound.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <memory>
-#include "Log.h"
-#include "audio/AudioSignalFactory.h"
-#include "audio/RemoteAudio.h"
-#include "StringUtil.h"
-#include "task/TaskCase.h"
-#include "task/TaskSound.h"
-
-static const android::String8 STR_ID("id");
-static const android::String8 STR_TYPE("type");
-
-TaskSound::TaskSound()
- : TaskGeneric(TaskGeneric::ETaskSound),
- mPreload(false)
-{
- const android::String8* list[] = {&STR_ID, &STR_TYPE, NULL};
- registerSupportedStringAttributes(list);
-}
-
-TaskSound::~TaskSound()
-{
-
-}
-
-bool TaskSound::parseAttribute(const android::String8& name, const android::String8& value)
-{
- if (StringUtil::compare(name, "preload") == 0) {
- if (StringUtil::compare(value, "1") == 0) {
- mPreload = true;
- }
- return true;
- }
- return TaskGeneric::parseAttribute(name, value);
-}
-
-TaskGeneric::ExecutionResult TaskSound::run()
-{
- android::String8 id;
- if (!findStringAttribute(STR_ID, id)) {
- LOGE("TaskSound::run %s string not found", STR_ID.string());
- return TaskGeneric::EResultError;
- }
- android::String8 type;
- if (!findStringAttribute(STR_TYPE, type)) {
- LOGE("TaskSound::run %s string not found", STR_TYPE.string());
- return TaskGeneric::EResultError;
- }
- std::unique_ptr<std::vector<android::String8> > tokens(StringUtil::split(type, ':'));
- if (tokens.get() == NULL) {
- LOGE("alloc failed");
- return TaskGeneric::EResultError;
- }
- android::sp<Buffer> buffer;
- if (StringUtil::compare(tokens->at(0), "file") == 0) {
- if (tokens->size() != 2) {
- LOGE("Wrong number of parameters %d", tokens->size());
- }
- buffer = Buffer::loadFromFile(tokens->at(1));
- } else if (StringUtil::compare(tokens->at(0), "sin") == 0) {
- if (tokens->size() != 4) {
- LOGE("Wrong number of parameters %d", tokens->size());
- }
- int amplitude = atoi(tokens->at(1).string());
- int freq = atoi(tokens->at(2).string());
- int time = atoi(tokens->at(3).string());
- int samples = time * AudioHardware::ESampleRate_44100 / 1000;
- buffer = AudioSignalFactory::generateSineWave(AudioHardware::E2BPS, amplitude,
- AudioHardware::ESampleRate_44100, freq, samples, true);
- } else if (StringUtil::compare(tokens->at(0), "random") == 0) {
- // TODO FIXME it does not seem to work well.
- if (tokens->size() != 3) {
- LOGE("Wrong number of parameters %d", tokens->size());
- }
- int amplitude = atoi(tokens->at(1).string());
- int time = atoi(tokens->at(2).string());
- int samples = time * AudioHardware::ESampleRate_44100 / 1000;
- buffer = AudioSignalFactory::generateWhiteNoise(AudioHardware::E2BPS, amplitude,
- samples, true);
- } else { // unknown word
- LOGE("TaskSound::run unknown word in type %s", type.string());
- // next buffer check will return
- }
-
- if (buffer.get() == NULL) {
- return TaskGeneric::EResultError;
- }
- if (!getTestCase()->registerBuffer(id, buffer)) {
- LOGE("TaskSound::run registering buffer %s failed", id.string());
- return TaskGeneric::EResultError;
- }
- if (mPreload) {
- int downloadId;
- if (!getTestCase()->getRemoteAudio()->downloadData(id, buffer, downloadId)) {
- return TaskGeneric::EResultError;
- }
- LOGI("Downloaded buffer %s to DUT with id %d", id.string(), downloadId);
- }
- return TaskGeneric::EResultOK;
-}
-
-
-
diff --git a/suite/audio_quality/test/Android.bp b/suite/audio_quality/test/Android.bp
deleted file mode 100644
index 443e995..0000000
--- a/suite/audio_quality/test/Android.bp
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// Copyright (C) 2012 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_test_host {
- name: "cts_audio_quality_test",
- srcs: ["*.cpp"],
- test_options: {
- unit_test: false,
- },
- static_libs: [
- "libbase",
- "libutils",
- "liblog",
- "libcutils",
- "libtinyalsa",
- "libtinyxml2",
- ],
-
- // need to keep everything in libcts_.. Otherwise, linker will drop some
- // functions and linker error happens
- whole_static_libs: ["libcts_audio_quality"],
-
- cflags: [
- "-g",
- "-fno-exceptions",
- "-Wall",
- "-Werror",
- "-Wno-unused-parameter",
- "-Wno-unused-variable",
- ],
- ldflags: [
- "-g",
- "-fno-exceptions",
- ],
- stl: "libc++_static",
- target: {
- darwin: {
- enabled: false,
- },
- },
- compile_multilib: "first",
-}
diff --git a/suite/audio_quality/test/AudioHardwareTest.cpp b/suite/audio_quality/test/AudioHardwareTest.cpp
deleted file mode 100644
index 35d750b..0000000
--- a/suite/audio_quality/test/AudioHardwareTest.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gtest/gtest.h>
-#include <audio/AudioHardware.h>
-#include <task/TaskAll.h>
-
-
-class AudioHardwareTest : public testing::Test {
-
-};
-
-TEST_F(AudioHardwareTest, DetectTest) {
- int hwId = AudioHardware::detectAudioHw();
- ASSERT_TRUE(hwId >= 0);
-}
-
-TEST_F(AudioHardwareTest, LocalFactoryTest) {
- android::sp<AudioHardware> playback = AudioHardware::createAudioHw(true, true);
- ASSERT_TRUE(playback.get() != NULL);
- android::sp<AudioHardware> recording = AudioHardware::createAudioHw(true, false);
- ASSERT_TRUE(recording.get() != NULL);
-}
-
-TEST_F(AudioHardwareTest, RemoteFactoryTest) {
- TaskCase* testCase = new TaskCase();
- ASSERT_TRUE(testCase != NULL);
- android::sp<AudioHardware> playback = AudioHardware::createAudioHw(false, true, testCase);
- ASSERT_TRUE(playback.get() != NULL);
- android::sp<AudioHardware> recording = AudioHardware::createAudioHw(false, false, testCase);
- ASSERT_TRUE(recording.get() != NULL);
- delete testCase;
-}
diff --git a/suite/audio_quality/test/AudioLocalTest.cpp b/suite/audio_quality/test/AudioLocalTest.cpp
deleted file mode 100644
index b38c44d..0000000
--- a/suite/audio_quality/test/AudioLocalTest.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <unistd.h>
-
-#include <gtest/gtest.h>
-#include <utils/threads.h>
-#include <utils/StrongPointer.h>
-
-#include <audio/AudioLocal.h>
-#include <audio/Buffer.h>
-#include <Log.h>
-
-#include "AudioPlayTestCommon.h"
-
-class AudioPlayerDummy: public AudioLocal {
-public:
- AudioHardware::SamplingRate mSamplingRate;
- android::sp<Buffer> mBufferPassed;
- bool mPrepareCalled;
- bool mdoStartPlaybackOrRecordCalled;
- bool mdoContinuePlaybackOrRecordCalled;
- bool mdoStopCalled;
- int mPlaybackUnit;
-
- AudioPlayerDummy()
- : mSamplingRate(AudioHardware::ESamplingRateInvald),
- mPrepareCalled(false),
- mdoStartPlaybackOrRecordCalled(false),
- mdoContinuePlaybackOrRecordCalled(false),
- mdoStopCalled(false)
- {
-
- }
-
- virtual bool doPrepare(AudioHardware::SamplingRate samplingRate, int samplesInOneGo) {
- mPlaybackUnit = samplesInOneGo * 4;
- LOGV("doPrepare");
- return true;
- };
-
- virtual bool doPlaybackOrRecord(android::sp<Buffer>& buffer) {
- buffer->increaseHandled(mPlaybackUnit);
- return true;
- };
-
- virtual void doStop() {
- LOGV("doStop");
- };
-
-
-};
-
-class AudioLocalTest : public AudioPlayTestCommon {
-public:
- virtual ~AudioLocalTest() {};
-
-protected:
- android::sp<AudioHardware> createAudioHw() {
- android::sp<AudioHardware> hw(new AudioPlayerDummy());
- return hw;
- }
-};
-
-TEST_F(AudioLocalTest, PlayAllTest) {
- playAll(1);
-}
-
-TEST_F(AudioLocalTest, PlayAllRepeatTest) {
- playAll(4);
-}
-
-TEST_F(AudioLocalTest, StartStopTest) {
- repeatPlayStop();
-}
-
-TEST_F(AudioLocalTest, WrongUsageTest) {
- playWrongUsage();
-}
-
diff --git a/suite/audio_quality/test/AudioPlayTestCommon.h b/suite/audio_quality/test/AudioPlayTestCommon.h
deleted file mode 100644
index 96f129c..0000000
--- a/suite/audio_quality/test/AudioPlayTestCommon.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef CTSAUDIO_AUDIOPLAYTESTCOMMON_H
-#define CTSAUDIO_AUDIOPLAYTESTCOMMON_H
-
-#include <gtest/gtest.h>
-#include <utils/threads.h>
-#include <utils/StrongPointer.h>
-
-#include <audio/AudioHardware.h>
-#include <audio/AudioPlaybackLocal.h>
-#include <audio/AudioRecordingLocal.h>
-#include <audio/AudioSignalFactory.h>
-#include <audio/AudioLocal.h>
-#include <audio/Buffer.h>
-
-
-#include <Log.h>
-
-
-class AudioPlayTestCommon : public testing::Test {
-protected:
- android::sp<Buffer> mBuffer;
- android::sp<AudioHardware> mAudioHw;
-
- static const int MAX_POSITIVE_AMPLITUDE = 1000;
- static const int SIGNAL_FREQ = 1000;
- static const int SIGNAL_LENGTH = AudioHardware::SAMPLES_PER_ONE_GO * 2;
- static const int DEFAULT_VOLUME = 10;
-
-protected:
- virtual ~AudioPlayTestCommon() {
- LOGV("~AudioPlayTestCommon");
- }
- virtual void SetUp() {
- mAudioHw = createAudioHw();
- ASSERT_TRUE(mAudioHw.get() != NULL);
- mBuffer = AudioSignalFactory::generateSineWave(AudioHardware::E2BPS,
- MAX_POSITIVE_AMPLITUDE, AudioHardware::ESampleRate_44100,
- SIGNAL_FREQ, SIGNAL_LENGTH);
- ASSERT_TRUE(mBuffer.get() != NULL);
- }
-
- virtual void TearDown() {
- LOGV("AudioPlayTestCommon::TearDown");
- mAudioHw->stopPlaybackOrRecord(); // this stops the thread
- mAudioHw.clear();
- }
-
- void playAll(int numberRepetition) {
- ASSERT_TRUE(mAudioHw->prepare(AudioHardware::ESampleRate_44100, DEFAULT_VOLUME));
- ASSERT_TRUE(mAudioHw->startPlaybackOrRecord(mBuffer, numberRepetition));
- ASSERT_TRUE(mAudioHw->waitForCompletion());
- mAudioHw->stopPlaybackOrRecord();
- LOGV("size %d, handled %d", mBuffer->getSize(), mBuffer->amountHandled());
- ASSERT_TRUE(mBuffer->amountHandled() == mBuffer->getSize());
- }
-
- void repeatPlayStop() {
- for (int i = 0; i < 2; i++) {
- ASSERT_TRUE(mAudioHw->prepare(AudioHardware::ESampleRate_44100, DEFAULT_VOLUME));
- mBuffer->restart();
- ASSERT_TRUE(mAudioHw->startPlaybackOrRecord(mBuffer, 10));
- mAudioHw->stopPlaybackOrRecord();
- }
- }
-
- void playWrongUsage() {
- ASSERT_FALSE(mAudioHw->startPlaybackOrRecord(mBuffer));
- ASSERT_TRUE(mAudioHw->prepare(AudioHardware::ESampleRate_44100, DEFAULT_VOLUME));
- playAll(1);
- }
-
- virtual android::sp<AudioHardware> createAudioHw() = 0;
-};
-
-#endif // CTSAUDIO_AUDIOPLAYTESTCOMMON_H
diff --git a/suite/audio_quality/test/AudioPlaybackLocalTest.cpp b/suite/audio_quality/test/AudioPlaybackLocalTest.cpp
deleted file mode 100644
index 896d01c..0000000
--- a/suite/audio_quality/test/AudioPlaybackLocalTest.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <unistd.h>
-
-#include <gtest/gtest.h>
-#include <utils/threads.h>
-#include <utils/StrongPointer.h>
-
-#include <audio/AudioHardware.h>
-#include <GenericFactory.h>
-#include <audio/AudioPlaybackLocal.h>
-
-#include <Log.h>
-
-#include "AudioPlayTestCommon.h"
-
-class AudioPlaybackLocalTest : public AudioPlayTestCommon {
-public:
- virtual ~AudioPlaybackLocalTest() {};
-protected:
-
- android::sp<AudioHardware> createAudioHw() {
- return AudioHardware::createAudioHw(true, true);
- }
-};
-
-
-TEST_F(AudioPlaybackLocalTest, PlayAllTest) {
- playAll(1);
-}
-
-TEST_F(AudioPlaybackLocalTest, PlayAllRepeatTest) {
- playAll(4);
-}
-
-TEST_F(AudioPlaybackLocalTest, StartStopTest) {
- repeatPlayStop();
-}
-
-TEST_F(AudioPlaybackLocalTest, WrongUsageTest) {
- playWrongUsage();
-}
-
-
diff --git a/suite/audio_quality/test/AudioRecordPlayLocalTest.cpp b/suite/audio_quality/test/AudioRecordPlayLocalTest.cpp
deleted file mode 100644
index 3a94d06..0000000
--- a/suite/audio_quality/test/AudioRecordPlayLocalTest.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "AudioRecordPlayTestCommon.h"
-
-#include <Log.h>
-
-class AudioRecordPlayLocalTest: public AudioRecordPlayTestCommon {
-public:
- virtual ~AudioRecordPlayLocalTest() {};
-protected:
- android::sp<AudioHardware> createRecordingHw() {
- return AudioHardware::createAudioHw(true, false);
- };
-
- android::sp<AudioHardware> createPlaybackHw() {
- return AudioHardware::createAudioHw(true, true);
- }
-};
-
-
-
-TEST_F(AudioRecordPlayLocalTest, PlayAndRecordTest) {
- PlayAndRecord(4);
-}
-
-
diff --git a/suite/audio_quality/test/AudioRecordPlayTestCommon.h b/suite/audio_quality/test/AudioRecordPlayTestCommon.h
deleted file mode 100644
index 28bc0a6..0000000
--- a/suite/audio_quality/test/AudioRecordPlayTestCommon.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_AUDIORECORDPLAYTESTCOMMON_H
-#define CTSAUDIO_AUDIORECORDPLAYTESTCOMMON_H
-
-#include <gtest/gtest.h>
-#include <utils/threads.h>
-#include <utils/StrongPointer.h>
-
-#include <audio/AudioHardware.h>
-#include <audio/AudioPlaybackLocal.h>
-#include <audio/AudioRecordingLocal.h>
-#include <audio/AudioSignalFactory.h>
-#include <audio/AudioLocal.h>
-#include <audio/Buffer.h>
-#include <Log.h>
-
-class AudioRecordPlayTestCommon : public testing::Test {
-protected:
- android::sp<Buffer> mBufferRecording;
- android::sp<Buffer> mBufferPlayback;
- android::sp<AudioHardware> mAudioRecordingHw;
- android::sp<AudioHardware> mAudioPlaybackHw;
-
- static const int MAX_POSITIVE_AMPLITUDE = 10000;
- static const int SIGNAL_FREQ = 1000;
- static const int NUMBER_SAMPLES = AudioHardware::SAMPLES_PER_ONE_GO * 4;
- static const int DEFAULT_VOLUME = 10;
-protected:
- virtual void SetUp() {
- mAudioPlaybackHw = createPlaybackHw();
- ASSERT_TRUE(mAudioPlaybackHw.get() != NULL);
- mAudioRecordingHw = createRecordingHw();
- ASSERT_TRUE(mAudioRecordingHw.get() != NULL);
- mBufferPlayback = AudioSignalFactory::generateSineWave(AudioHardware::E2BPS,
- MAX_POSITIVE_AMPLITUDE, AudioHardware::ESampleRate_44100,
- SIGNAL_FREQ, NUMBER_SAMPLES);
- ASSERT_TRUE(mBufferPlayback.get() != NULL);
- mBufferRecording = new Buffer(NUMBER_SAMPLES * 4, NUMBER_SAMPLES * 4);
- ASSERT_TRUE(mBufferRecording.get() != NULL);
- }
-
- virtual void TearDown() {
- mAudioRecordingHw->stopPlaybackOrRecord();
- mAudioPlaybackHw->stopPlaybackOrRecord();
- mAudioRecordingHw.clear();
- mAudioPlaybackHw.clear();
- }
-
- void PlayAndRecord(int numberRepetition) {
- ASSERT_TRUE(mAudioPlaybackHw->prepare(AudioHardware::ESampleRate_44100, DEFAULT_VOLUME));
- ASSERT_TRUE(mAudioRecordingHw->prepare(AudioHardware::ESampleRate_44100, DEFAULT_VOLUME));
- ASSERT_TRUE(mAudioRecordingHw->startPlaybackOrRecord(mBufferRecording,
- numberRepetition));
- ASSERT_TRUE(mAudioPlaybackHw->startPlaybackOrRecord(mBufferPlayback,
- numberRepetition));
-
- ASSERT_TRUE(mAudioRecordingHw->waitForCompletion());
- ASSERT_TRUE(mAudioPlaybackHw->waitForCompletion());
- mAudioPlaybackHw->stopPlaybackOrRecord();
- mAudioRecordingHw->stopPlaybackOrRecord();
- LOGV("Audio playback buffer size %d, handled %d", mBufferPlayback->getSize(),
- mBufferPlayback->amountHandled());
- ASSERT_TRUE(mBufferPlayback->amountHandled() == mBufferPlayback->getSize());
- LOGV("Audio recording buffer size %d, handled %d", mBufferRecording->getSize(),
- mBufferRecording->amountHandled());
- ASSERT_TRUE(mBufferRecording->amountHandled() == mBufferRecording->getSize());
- }
-
- virtual android::sp<AudioHardware> createRecordingHw() = 0;
- virtual android::sp<AudioHardware> createPlaybackHw() = 0;
-};
-
-
-
-
-#endif // CTSAUDIO_AUDIORECORDPLAYTESTCOMMON_H
diff --git a/suite/audio_quality/test/AudioRecordingLocalTest.cpp b/suite/audio_quality/test/AudioRecordingLocalTest.cpp
deleted file mode 100644
index bb9f8ba..0000000
--- a/suite/audio_quality/test/AudioRecordingLocalTest.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <unistd.h>
-
-#include <gtest/gtest.h>
-#include <utils/threads.h>
-#include <utils/StrongPointer.h>
-
-#include <audio/AudioHardware.h>
-#include <GenericFactory.h>
-#include <audio/AudioRecordingLocal.h>
-
-#include <Log.h>
-
-#include "AudioPlayTestCommon.h"
-
-class AudioRecordingLocalTest : public AudioPlayTestCommon {
-public:
- virtual ~AudioRecordingLocalTest() {};
-protected:
-
- android::sp<AudioHardware> createAudioHw() {
- return AudioHardware::createAudioHw(true, false);
- }
-};
-
-
-TEST_F(AudioRecordingLocalTest, PlayAllTest) {
- playAll(1);
-}
-
-TEST_F(AudioRecordingLocalTest, PlayAllRepeatTest) {
- playAll(4);
-}
-
-TEST_F(AudioRecordingLocalTest, StartStopTest) {
- repeatPlayStop();
-}
-
-TEST_F(AudioRecordingLocalTest, WrongUsageTest) {
- playWrongUsage();
-}
-
diff --git a/suite/audio_quality/test/AudioSignalFactoryTest.cpp b/suite/audio_quality/test/AudioSignalFactoryTest.cpp
deleted file mode 100644
index 62ff900..0000000
--- a/suite/audio_quality/test/AudioSignalFactoryTest.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <stdint.h>
-
-#include <gtest/gtest.h>
-
-#include <audio/AudioSignalFactory.h>
-
-class AudioSignalFactoryTest: public testing::Test {
-protected:
-
- void testSignalBasic(android::sp<Buffer>& buffer, int maxPositive,
- AudioHardware::SamplingRate samplingRate, int signalFreq, int samples) {
- ASSERT_TRUE(buffer->getSize() == (unsigned int)(AudioHardware::E2BPS * 2 * samples));
- int16_t* data = reinterpret_cast<int16_t*>(buffer->getData());
- for(int i = 0; i < samples; i++) {
- ASSERT_TRUE(*data <= maxPositive);
- ASSERT_TRUE(*data >= -maxPositive);
- data++;
- ASSERT_TRUE(*data <= maxPositive);
- ASSERT_TRUE(*data >= -maxPositive);
- data++;
- }
- }
-};
-
-TEST_F(AudioSignalFactoryTest, SineTest) {
- const int maxPositive = 1000;
- const int signalFreq = AudioHardware::ESampleRate_44100/100;
- const int samples = 8192 * 10;
- android::sp<Buffer> buffer = AudioSignalFactory::generateSineWave(AudioHardware::E2BPS,
- maxPositive, AudioHardware::ESampleRate_44100, signalFreq, samples);
- testSignalBasic(buffer, maxPositive, AudioHardware::ESampleRate_44100, signalFreq, samples);
-}
-
-TEST_F(AudioSignalFactoryTest, WhiteNoiseTest) {
- const int maxPositive = 1000;
- const int signalFreq = AudioHardware::ESampleRate_44100/100;
- const int samples = 8192 * 10;
- android::sp<Buffer> buffer = AudioSignalFactory::generateWhiteNoise(AudioHardware::E2BPS,
- maxPositive, samples);
- testSignalBasic(buffer, maxPositive, AudioHardware::ESampleRate_44100, signalFreq, samples);
-}
-
diff --git a/suite/audio_quality/test/BufferTest.cpp b/suite/audio_quality/test/BufferTest.cpp
deleted file mode 100644
index 5e315977..0000000
--- a/suite/audio_quality/test/BufferTest.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <stdint.h>
-#include <gtest/gtest.h>
-
-#include <memory>
-
-#include "audio/Buffer.h"
-
-
-class BufferTest : public testing::Test {
-public:
-
- virtual void SetUp() {
-
- }
-
- virtual void TearDown() {
-
- }
-};
-
-
-TEST_F(BufferTest, saveLoadStereoTest) {
- const int BUFFER_SIZE = 32;
-
- std::unique_ptr<Buffer> buffer(new Buffer(BUFFER_SIZE, BUFFER_SIZE, true));
- ASSERT_TRUE(buffer.get() != NULL);
- int16_t* data = (int16_t*)buffer->getData();
- ASSERT_TRUE(data != NULL);
- for (int i = 0; i < BUFFER_SIZE/4; i++) {
- data[2*i] = i;
- data[2*i+1] = i;
- }
- android::String8 file("/tmp/cts_audio_temp");
- ASSERT_TRUE(buffer->saveToFile(file));
- file.append(".r2s");
- std::unique_ptr<Buffer> bufferRead(Buffer::loadFromFile(file));
- ASSERT_TRUE(bufferRead.get() != NULL);
- ASSERT_TRUE(bufferRead->getSize() == (size_t)BUFFER_SIZE);
- ASSERT_TRUE(bufferRead->isStereo());
- int16_t* dataRead = (int16_t*)bufferRead->getData();
- for (int i = 0; i < BUFFER_SIZE/4; i++) {
- ASSERT_TRUE(data[2*i] == dataRead[2*i]);
- ASSERT_TRUE(data[2*i+1] == dataRead[2*i+1]);
- }
-}
-
-TEST_F(BufferTest, monoLTest) {
- const int BUFFER_SIZE = 8;
-
- std::unique_ptr<Buffer> buffer(new Buffer(BUFFER_SIZE, BUFFER_SIZE, true));
- ASSERT_TRUE(buffer.get() != NULL);
- int16_t* data = (int16_t*)buffer->getData();
- ASSERT_TRUE(data != NULL);
- for (int i = 0; i < BUFFER_SIZE/2; i++) {
- data[i] = i;
- }
- std::unique_ptr<Buffer> bufferl(new Buffer(BUFFER_SIZE/2, BUFFER_SIZE/2, false));
- ASSERT_TRUE(bufferl.get() != NULL);
- data = (int16_t*)bufferl->getData();
- ASSERT_TRUE(data != NULL);
- for (int i = 0; i < BUFFER_SIZE/4; i++) {
- data[i] = 2 * i;
- }
- buffer->changeToMono(Buffer::EKeepCh0);
- ASSERT_TRUE((*buffer) == (*bufferl));
-}
diff --git a/suite/audio_quality/test/ClientInterfaceTest.cpp b/suite/audio_quality/test/ClientInterfaceTest.cpp
deleted file mode 100644
index 88e502b..0000000
--- a/suite/audio_quality/test/ClientInterfaceTest.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <utils/String8.h>
-
-#include <gtest/gtest.h>
-
-#include <audio/AudioSignalFactory.h>
-#include <ClientInterface.h>
-#include <ClientImpl.h>
-#include <GenericFactory.h>
-#include <audio/RemoteAudio.h>
-
-
-
-class ClientInterfaceTest : public testing::Test {
-protected:
- ClientInterface* mClient;
-
-protected:
- virtual void SetUp() {
- GenericFactory factory;
- mClient = factory.createClientInterface();
- ASSERT_TRUE(mClient != NULL);
- android::String8 dummyParam;
- ASSERT_TRUE(mClient->init(dummyParam));
- }
-
- virtual void TearDown() {
- delete mClient;
- mClient = NULL;
- }
-};
-
-TEST_F(ClientInterfaceTest, InitTest) {
- // all done in SetUp
-}
-
-TEST_F(ClientInterfaceTest, getDeviceInfoTest) {
- ClientImpl* client = reinterpret_cast<ClientImpl*>(mClient);
- android::sp<RemoteAudio>& audio(client->getAudio());
- android::String8 info;
-
- ASSERT_TRUE(audio->getDeviceInfo(info));
- LOGD("device info %s", info.string());
-}
-
-TEST_F(ClientInterfaceTest, PlayTest) {
- ClientImpl* client = reinterpret_cast<ClientImpl*>(mClient);
- android::sp<RemoteAudio>& audio(client->getAudio());
- const int maxPositive = 10000;
- const int signalFreq = AudioHardware::ESampleRate_44100/100;
- const int samples = 8192*2;
- android::sp<Buffer> buffer = AudioSignalFactory::generateSineWave(AudioHardware::E2BPS,
- maxPositive, AudioHardware::ESampleRate_44100, signalFreq, samples);
- int id;
- android::String8 name("1");
- ASSERT_TRUE(audio->downloadData(name, buffer, id));
- ASSERT_TRUE(audio->startPlayback(true, AudioHardware::ESampleRate_44100,
- AudioHardware::EModeVoice, 100, id, 1));
- ASSERT_TRUE(audio->waitForPlaybackCompletion());
- ASSERT_TRUE(id == audio->getDataId(name));
- android::String8 name2("2");
- ASSERT_TRUE(audio->getDataId(name2) < 0);
-}
-
-TEST_F(ClientInterfaceTest, RecordTest) {
- ClientImpl* client = reinterpret_cast<ClientImpl*>(mClient);
- android::sp<RemoteAudio>& audio(client->getAudio());
- const int maxPositive = 10000;
- const int signalFreq = AudioHardware::ESampleRate_44100 / 100;
- const int samples = 44100 * 4;
- android::sp<Buffer> buffer(new Buffer(samples * 2, samples * 2, false));
-
- ASSERT_TRUE(audio->startRecording(false, AudioHardware::ESampleRate_44100,
- AudioHardware::EModeVoice, 100, buffer));
- ASSERT_TRUE(audio->waitForRecordingCompletion());
- ASSERT_TRUE(buffer->amountHandled() == (samples * 2));
-}
diff --git a/suite/audio_quality/test/FileUtilTest.cpp b/suite/audio_quality/test/FileUtilTest.cpp
deleted file mode 100644
index 990d7b9..0000000
--- a/suite/audio_quality/test/FileUtilTest.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <stdint.h>
-#include <gtest/gtest.h>
-
-#include "Log.h"
-#include "FileUtil.h"
-
-
-class FileUtilTest : public testing::Test {
-public:
-
-};
-
-
-TEST_F(FileUtilTest, initTest) {
- android::String8 dirPath;
- ASSERT_TRUE(FileUtil::prepare(dirPath));
- ASSERT_TRUE(dirPath.find("reports/") == 0);
- LOGI("returned %s %d", dirPath.string(), dirPath.find("reports/"));
- android::String8 dirPath2;
- ASSERT_TRUE(FileUtil::prepare(dirPath2));
- ASSERT_TRUE(dirPath == dirPath2);
-}
-
-
diff --git a/suite/audio_quality/test/LogTest.cpp b/suite/audio_quality/test/LogTest.cpp
deleted file mode 100644
index 51cde10..0000000
--- a/suite/audio_quality/test/LogTest.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <inttypes.h>
-#include <stdint.h>
-#include <gtest/gtest.h>
-
-#include "Log.h"
-
-
-
-class LogTest : public testing::Test {
-public:
-
-};
-
-
-TEST_F(LogTest, logTest) {
- Log::LogLevel level = Log::Instance()->getLogLevel();
-
- // following lines should match. no automatic test yet..
- // TODO make it automatic?
- Log::Instance()->setLogLevel(Log::ELogV);
- printf("printf %d %d %d %d %d %d\n", 0, 1, 2, 3, 4, 5);
- LOGD( "logd %d %d %d %d %d %d", 0, 1, 2, 3, 4, 5);
- LOGV( "logv %d %d %d %d %d %d", 0, 1, 2, 3, 4, 5);
- LOGI( "logi %d %d %d %d %d %d", 0, 1, 2, 3, 4, 5);
- LOGW( "logw %d %d %d %d %d %d", 0, 1, 2, 3, 4, 5);
- LOGE( "loge %d %d %d %d %d %d", 0, 1, 2, 3, 4, 5);
-
- int64_t a = 0;
- int64_t b = 1;
- int64_t c = 2;
- int64_t d = 3;
- int64_t e = 4;
- int64_t f = 5;
-#define PrintABCDEF "%" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 \
- " %" PRId64
- printf("printf " PrintABCDEF "\n", a, b, c, d, e, f);
- LOGD( "logd " PrintABCDEF, a, b, c, d, e, f);
- LOGV( "logv " PrintABCDEF, a, b, c, d, e, f);
- LOGI( "logi " PrintABCDEF, a, b, c, d, e, f);
- LOGW( "logw " PrintABCDEF, a, b, c, d, e, f);
- LOGE( "loge " PrintABCDEF, a, b, c, d, e, f);
-
- Log::Instance()->setLogLevel(level);
-}
-
-
-
diff --git a/suite/audio_quality/test/MixerTest.cpp b/suite/audio_quality/test/MixerTest.cpp
deleted file mode 100644
index 413c3ce..0000000
--- a/suite/audio_quality/test/MixerTest.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-#include <stdint.h>
-#include <gtest/gtest.h>
-
-#include <tinyalsa/asoundlib.h>
-#include <Log.h>
-#include <audio/AudioHardware.h>
-
-class MixerTest : public testing::Test {
-public:
-
- virtual void SetUp() {
-
- }
-
- virtual void TearDown() {
-
- }
-};
-
-
-TEST_F(MixerTest, tryTinyAlsaTest) {
- int hwId = AudioHardware::detectAudioHw();
- ASSERT_TRUE(hwId >= 0);
- struct mixer* mixerp = mixer_open(hwId);
- ASSERT_TRUE(mixerp != NULL);
- int num_ctls = mixer_get_num_ctls(mixerp);
- LOGI("Number of mixel control %d", num_ctls);
- for (int i = 0; i < num_ctls; i++) {
- struct mixer_ctl* control = mixer_get_ctl(mixerp, i);
- ASSERT_TRUE(control != NULL);
- LOGI("Mixer control %s type %s value %d", mixer_ctl_get_name(control),
- mixer_ctl_get_type_string(control), mixer_ctl_get_num_values(control));
- free(control);
- }
- // no mixer control for MobilePre. If this assumption fails,
- // mixer control should be added.
- ASSERT_TRUE(num_ctls == 0);
- mixer_close(mixerp);
-}
-
diff --git a/suite/audio_quality/test/ModelBuilderTest.cpp b/suite/audio_quality/test/ModelBuilderTest.cpp
deleted file mode 100644
index c9ba154..0000000
--- a/suite/audio_quality/test/ModelBuilderTest.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#include <gtest/gtest.h>
-#include <task/ModelBuilder.h>
-
-
-class ModelBuilderTest : public testing::Test {
-public:
- ModelBuilder mModelBuilder;
-};
-
-TEST_F(ModelBuilderTest, ParsingCaseNoAttribTest) {
- android::String8 xmlFile("test_description/test/no_attrib.xml");
- TaskGeneric* testCase = mModelBuilder.parseTestDescriptionXml(xmlFile);
- ASSERT_TRUE(testCase != NULL);
- //TODO verify TestCase
- delete testCase;
-}
-
-TEST_F(ModelBuilderTest, ParsingCaseTest) {
- android::String8 xmlFile("test_description/host_speaker_calibration.xml");
- TaskGeneric* testCase = mModelBuilder.parseTestDescriptionXml(xmlFile);
- ASSERT_TRUE(testCase != NULL);
- //TODO verify TestCase
- delete testCase;
-}
-
-TEST_F(ModelBuilderTest, ParsingBatchTest) {
- android::String8 xmlFile("test_description/all_playback.xml");
- TaskGeneric* testBatch = mModelBuilder.parseTestDescriptionXml(xmlFile);
- ASSERT_TRUE(testBatch != NULL);
- //TODO verify TestCase
- delete testBatch;
-}
-
-TEST_F(ModelBuilderTest, CaseOnlyTest) {
- android::String8 xmlFile("test_description/all_playback.xml");
- TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile, true);
- ASSERT_TRUE(task == NULL);
-
- delete task;
-}
-
-TEST_F(ModelBuilderTest, MissingMandatoryTest) {
- android::String8 xmlFile("test_description/test/missing_mandatory.xml");
- TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile);
- ASSERT_TRUE(task == NULL);
- delete task;
-}
-
-TEST_F(ModelBuilderTest, UnknownElementTest) {
- android::String8 xmlFile("test_description/test/unknown_element.xml");
- TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile);
- ASSERT_TRUE(task == NULL);
- delete task;
-}
-
-TEST_F(ModelBuilderTest, WrongAttributeTest) {
- android::String8 xmlFile("test_description/test/wrong_attrib.xml");
- TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile);
- ASSERT_TRUE(task == NULL);
- delete task;
-}
-
-TEST_F(ModelBuilderTest, BuiltinRMSTest) {
- android::String8 xmlFile("test_description/test/test_rms_vma.xml");
- TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile);
- ASSERT_TRUE(task != NULL);
- TaskGeneric::ExecutionResult result = task->run();
- ASSERT_TRUE((result == TaskGeneric::EResultOK) || (result == TaskGeneric::EResultPass));
- delete task;
-}
-
diff --git a/suite/audio_quality/test/RemoteAudioFakeTcpTest.cpp b/suite/audio_quality/test/RemoteAudioFakeTcpTest.cpp
deleted file mode 100644
index d428c17..0000000
--- a/suite/audio_quality/test/RemoteAudioFakeTcpTest.cpp
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-// test RemoteAudio with fake TCP
-
-#include <unistd.h>
-
-#include <utils/String8.h>
-
-#include <gtest/gtest.h>
-
-#include <utils/StrongPointer.h>
-
-#include <Log.h>
-#include <audio/AudioHardware.h>
-#include <audio/AudioProtocol.h>
-#include <audio/AudioSignalFactory.h>
-#include <ClientSocket.h>
-#include <audio/RemoteAudio.h>
-
-
-
-void assertTrue(bool cond) {
- ASSERT_TRUE(cond);
-}
-void assertData(const char* data1, const char* data2, int len) {
- for (int i = 0; i < len; i++) {
- //LOGD("0x%x vs 0x%x", data1[i], data2[i]);
- ASSERT_TRUE(data1[i] == data2[i]);
- }
-}
-
-class ClientSocketForTest: public ClientSocket {
-public:
- ClientSocketForTest()
- : mToRead(NULL),
- mReadLength(0) {};
-
- virtual ~ClientSocketForTest() {
- close(mSocket);
- close(mPipeWrFd);
- }
- virtual bool init(const char* hostIp, int port, bool enableTimeout = false) {
- LOGD("ClientSocketForTest::init");
- // use this fd to work with poll
- int pipefd[2];
- if (pipe(pipefd) == -1) {
- LOGE("cannot create pipe");
- return false;
- }
- LOGD("pipe %d %d", pipefd[0], pipefd[1]);
- mSocket = pipefd[0];
- mPipeWrFd = pipefd[1];
- const char ipExpectation[] = "127.0.0.1";
- assertTrue(memcmp(ipExpectation, hostIp, sizeof(ipExpectation)) == 0);
- return true;
- }
- virtual bool readData(char* data, int len, int timeoutInMs = 0) {
- read(mSocket, data, len);
- return true;
- }
- virtual bool sendData(const char* data, int len) {
- assertTrue((len + mSendPointer) <= mSendLength);
- assertData(data, mToSend + mSendPointer, len);
- mSendPointer += len;
- if ((mToRead != NULL) && (mReadLength != 0)) {
- LOGD("fake TCP copy reply %d", mReadLength);
- write(mPipeWrFd, mToRead, mReadLength);
- mToRead = NULL; // prevent writing the same data again
- }
- return true;
- }
-
- void setSendExpectation(const char* data, int len) {
- mToSend = data;
- mSendLength = len;
- mSendPointer = 0;
- }
- void setReadExpectation(char* data, int len) {
- mToRead = data;
- mReadLength = len;
- }
-public:
- int mPipeWrFd; // for writing
- const char* mToRead;
- int mReadLength;
- const char* mToSend;
- int mSendLength;
- int mSendPointer;
-};
-
-class RemoteAudioFakeTcpTest : public testing::Test {
-protected:
- android::sp<RemoteAudio> mRemoteAudio;
- ClientSocketForTest mTestSocket;
-
-protected:
- virtual void SetUp() {
- ASSERT_TRUE(U32_ENDIAN_SWAP(0x12345678) == 0x78563412);
- mRemoteAudio = new RemoteAudio(mTestSocket);
- ASSERT_TRUE(mRemoteAudio != NULL);
- ASSERT_TRUE(mRemoteAudio->init(1234));
- }
-
- virtual void TearDown() {
- mRemoteAudio->release();
- mRemoteAudio.clear();
- }
-
- void doDownload() {
- android::sp<Buffer> buffer = AudioSignalFactory::generateZeroSound(AudioHardware::E2BPS, 2,
- false);
- uint32_t prepareSend[] = {
- U32_ENDIAN_SWAP(AudioProtocol::ECmdDownload),
- U32_ENDIAN_SWAP(8),
- U32_ENDIAN_SWAP(0), //id
- U32_ENDIAN_SWAP(0)
- };
- uint32_t prepareReply[] = {
- U32_ENDIAN_SWAP((AudioProtocol::ECmdDownload & 0xffff) | 0x43210000),
- 0,
- 0
- };
- LOGD("reply 0x%x", prepareReply[0]);
-
- mTestSocket.setSendExpectation((char*)prepareSend, sizeof(prepareSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)prepareReply, sizeof(prepareReply));
-
- int id = -1;
- android::String8 name("1");
- ASSERT_TRUE(mRemoteAudio->downloadData(name, buffer, id));
- ASSERT_TRUE(id >= 0);
- }
-};
-
-TEST_F(RemoteAudioFakeTcpTest, InitTest) {
- // all done in SetUp
-}
-
-TEST_F(RemoteAudioFakeTcpTest, DownloadTest) {
- doDownload();
-}
-
-TEST_F(RemoteAudioFakeTcpTest, PlayTest) {
- doDownload();
-
- bool stereo = false;
- int id = 0;
- int samplingF = 44100;
- int mode = AudioHardware::EModeVoice | (stereo ? 0x80000000 : 0);
- int volume = 0;
- int repeat = 1;
-
- uint32_t prepareSend[] = {
- U32_ENDIAN_SWAP(AudioProtocol::ECmdStartPlayback),
- U32_ENDIAN_SWAP(20),
- U32_ENDIAN_SWAP(id), //id
- U32_ENDIAN_SWAP(samplingF),
- U32_ENDIAN_SWAP(mode),
- U32_ENDIAN_SWAP(volume),
- U32_ENDIAN_SWAP(repeat)
- };
- uint32_t prepareReply[] = {
- U32_ENDIAN_SWAP((AudioProtocol::ECmdStartPlayback & 0xffff) | 0x43210000),
- 0,
- 0
- };
-
- mTestSocket.setSendExpectation((char*)prepareSend, sizeof(prepareSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)prepareReply, sizeof(prepareReply));
-
- ASSERT_TRUE(mRemoteAudio->startPlayback(stereo, samplingF, mode, volume, id, repeat));
- ASSERT_TRUE(mRemoteAudio->waitForPlaybackCompletion());
-}
-
-TEST_F(RemoteAudioFakeTcpTest, PlayStopTest) {
- doDownload();
-
- bool stereo = false;
- int id = 0;
- int samplingF = 44100;
- int mode = AudioHardware::EModeVoice | (stereo ? 0x80000000 : 0);
- int volume = 0;
- int repeat = 1;
-
- uint32_t startPlaybackSend[] = {
- U32_ENDIAN_SWAP(AudioProtocol::ECmdStartPlayback),
- U32_ENDIAN_SWAP(20),
- U32_ENDIAN_SWAP(id),
- U32_ENDIAN_SWAP(samplingF),
- U32_ENDIAN_SWAP(mode),
- U32_ENDIAN_SWAP(volume),
- U32_ENDIAN_SWAP(repeat)
- };
- uint32_t startReply[] = {
- U32_ENDIAN_SWAP((AudioProtocol::ECmdStartPlayback & 0xffff) | 0x43210000),
- 0,
- 0
- };
-
- uint32_t stopPlaybackSend[] = {
- U32_ENDIAN_SWAP(AudioProtocol::ECmdStopPlayback),
- U32_ENDIAN_SWAP(0)
- };
-
- uint32_t stopReply[] = {
- U32_ENDIAN_SWAP((AudioProtocol::ECmdStopPlayback & 0xffff) | 0x43210000),
- 0,
- 0
- };
-
- mTestSocket.setSendExpectation((char*)startPlaybackSend, sizeof(startPlaybackSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)startReply, sizeof(startReply));
-
- ASSERT_TRUE(mRemoteAudio->startPlayback(stereo, samplingF, mode, volume, id, repeat));
- sleep(1);
- mTestSocket.setSendExpectation((char*)stopPlaybackSend, sizeof(stopPlaybackSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)stopReply, sizeof(stopReply));
- mRemoteAudio->stopPlayback();
-
- mTestSocket.setSendExpectation((char*)startPlaybackSend, sizeof(startPlaybackSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)startReply, sizeof(startReply));
- ASSERT_TRUE(mRemoteAudio->startPlayback(stereo, samplingF, mode, volume, id, repeat));
- sleep(1);
- mTestSocket.setSendExpectation((char*)stopPlaybackSend, sizeof(stopPlaybackSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)stopReply, sizeof(stopReply));
- mRemoteAudio->stopPlayback();
-
- mTestSocket.setSendExpectation((char*)startPlaybackSend, sizeof(startPlaybackSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)startReply, sizeof(startReply));
- ASSERT_TRUE(mRemoteAudio->startPlayback(stereo, samplingF, mode, volume, id, repeat));
- ASSERT_TRUE(mRemoteAudio->waitForPlaybackCompletion());
-}
-
-TEST_F(RemoteAudioFakeTcpTest, RecordingTest) {
- bool stereo = false;
- int id = 0;
- int samplingF = 44100;
- int mode = AudioHardware::EModeVoice | (stereo ? 0x80000000 : 0);
- int volume = 0;
- int noSamples = 44; // 1ms worth
-
- android::sp<Buffer> buffer(new Buffer(100, noSamples*2, false));
-
- uint32_t startSend[] = {
- U32_ENDIAN_SWAP(AudioProtocol::ECmdStartRecording),
- U32_ENDIAN_SWAP(16),
- U32_ENDIAN_SWAP(samplingF),
- U32_ENDIAN_SWAP(mode),
- U32_ENDIAN_SWAP(volume),
- U32_ENDIAN_SWAP(noSamples)
- };
-
- // 2bytes per sample, +2 for last samples rounded off
- uint32_t startReply[noSamples/2 + 2 + 3];
- memset(startReply, 0, sizeof(startReply));
- startReply[0] = U32_ENDIAN_SWAP((AudioProtocol::ECmdStartRecording & 0xffff) | 0x43210000);
- startReply[1] = 0;
- startReply[2] = U32_ENDIAN_SWAP(noSamples * 2);
-
- uint32_t stopSend[] = {
- U32_ENDIAN_SWAP(AudioProtocol::ECmdStopRecording),
- U32_ENDIAN_SWAP(0)
- };
-
- uint32_t stopReply[] = {
- U32_ENDIAN_SWAP((AudioProtocol::ECmdStopRecording & 0xffff) | 0x43210000),
- 0,
- 0
- };
-
-
- mTestSocket.setSendExpectation((char*)startSend, sizeof(startSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)startReply, 12 + noSamples*2);
-
- ASSERT_TRUE(mRemoteAudio->startRecording(stereo, samplingF, mode, volume, buffer));
- ASSERT_TRUE(mRemoteAudio->waitForRecordingCompletion());
- ASSERT_TRUE(buffer->amountHandled() == (size_t)(noSamples * 2));
- mTestSocket.setSendExpectation((char*)startSend, sizeof(startSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)startReply, 12 + noSamples*2);
- ASSERT_TRUE(mRemoteAudio->startRecording(stereo, samplingF, mode, volume, buffer));
- sleep(1);
- mTestSocket.setSendExpectation((char*)stopSend, sizeof(stopSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)stopReply, sizeof(stopReply));
- mRemoteAudio->stopRecording();
-}
-
-TEST_F(RemoteAudioFakeTcpTest, getDeviceInfoTest) {
- uint32_t prepareSend[] = {
- U32_ENDIAN_SWAP(AudioProtocol::ECmdGetDeviceInfo),
- U32_ENDIAN_SWAP(0)
- };
- uint32_t prepareReply[] = {
- U32_ENDIAN_SWAP((AudioProtocol::ECmdGetDeviceInfo & 0xffff) | 0x43210000),
- 0,
- U32_ENDIAN_SWAP(4),
- U32_ENDIAN_SWAP(0x30313233)
- };
-
- mTestSocket.setSendExpectation((char*)prepareSend, sizeof(prepareSend));
- // this is reply, but set expectation for reply first as it is sent after send
- mTestSocket.setReadExpectation((char*)prepareReply, sizeof(prepareReply));
-
- android::String8 info;
- ASSERT_TRUE(mRemoteAudio->getDeviceInfo(info));
- ASSERT_TRUE(info == "0123");
-}
diff --git a/suite/audio_quality/test/SignalProcessingInterfaceTest.cpp b/suite/audio_quality/test/SignalProcessingInterfaceTest.cpp
deleted file mode 100644
index cdffeb9..0000000
--- a/suite/audio_quality/test/SignalProcessingInterfaceTest.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gtest/gtest.h>
-#include <utils/String8.h>
-
-#include <audio/AudioSignalFactory.h>
-#include <SignalProcessingInterface.h>
-#include <SignalProcessingImpl.h>
-#include <task/TaskAll.h>
-
-class SignalProcessingInterfaceTest : public testing::Test {
-protected:
- SignalProcessingImpl* mSp;
-
-protected:
- virtual void SetUp() {
- mSp = new SignalProcessingImpl();
- ASSERT_TRUE(mSp != NULL);
- ASSERT_TRUE(mSp->init(SignalProcessingImpl::MAIN_PROCESSING_SCRIPT));
- }
-
- virtual void TearDown() {
- delete mSp;
- mSp = NULL;
- }
-};
-
-TEST_F(SignalProcessingInterfaceTest, InitTest) {
- // SetUp do all the work, nothing to do
-}
-
-TEST_F(SignalProcessingInterfaceTest, EchoTest) {
- android::String8 functionName("echo");
- int nInputs = 4;
- int nOutputs = 4;
- bool inputTypes[4] = { true, true, false, false };
- bool outputTypes[4] = { true, true, false, false };
-
- android::sp<Buffer> in0(new Buffer(160000, 160000, true));
- char* data0 = in0->getData();
- for (size_t i = 0; i < in0->getSize(); i++) {
- data0[i] = i;
- }
- android::sp<Buffer> in1(new Buffer(8, 8, false));
- char* data1 = in1->getData();
- for (size_t i = 0; i < in1->getSize(); i++) {
- data1[i] = i;
- }
- TaskCase::Value in2(1.0f);
- TaskCase::Value in3((int64_t)100);
- void* inputs[4] = { &in0, &in1, &in2, &in3 };
-
- android::sp<Buffer> out0(new Buffer(160000, 160000, true));
- char* outdata0 = out0->getData();
- for (size_t i = 0; i < out0->getSize(); i++) {
- outdata0[i] = 0xaa;
- }
- android::sp<Buffer> out1(new Buffer(8, 8, false));
- char* outdata1 = out1->getData();
- for (size_t i = 0; i < out1->getSize(); i++) {
- outdata1[i] = 0xbb;
- }
- TaskCase::Value out2(-1.0f);
- TaskCase::Value out3((int64_t)1000);
- void *outputs[4] = { &out0, &out1, &out2, &out3 };
-
- ASSERT_TRUE(mSp->run( functionName,
- nInputs, inputTypes, inputs,
- nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK);
- ASSERT_TRUE(*(in0.get()) == *(out0.get()));
- ASSERT_TRUE(*(in1.get()) == *(out1.get()));
- ASSERT_TRUE(in2 == out2);
- ASSERT_TRUE(in3 == out3);
-}
-
-TEST_F(SignalProcessingInterfaceTest, intsumTest) {
- android::String8 functionName("intsum");
- int nInputs = 2;
- int nOutputs = 1;
- bool inputTypes[2] = { false, false };
- bool outputTypes[1] = { false };
-
- TaskCase::Value in0((int64_t)10);
- TaskCase::Value in1((int64_t)100);
- void* inputs[2] = { &in0, &in1 };
-
- TaskCase::Value out0((int64_t)0);
- void *outputs[1] = { &out0 };
-
- ASSERT_TRUE(mSp->run( functionName,
- nInputs, inputTypes, inputs,
- nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK);
- ASSERT_TRUE(out0.getInt64() == (in0.getInt64() + in1.getInt64()));
-}
-
-// two instances of python processing processes should work
-TEST_F(SignalProcessingInterfaceTest, TwoInstanceTest) {
- SignalProcessingImpl* sp2 = new SignalProcessingImpl();
- ASSERT_TRUE(sp2 != NULL);
- ASSERT_TRUE(sp2->init(SignalProcessingImpl::MAIN_PROCESSING_SCRIPT));
-
- android::String8 functionName("intsum");
- int nInputs = 2;
- int nOutputs = 1;
- bool inputTypes[2] = { false, false };
- bool outputTypes[1] = { false };
-
- TaskCase::Value in0((int64_t)10);
- TaskCase::Value in1((int64_t)100);
- void* inputs[2] = { &in0, &in1 };
-
- TaskCase::Value out0((int64_t)0);
- void *outputs[1] = { &out0 };
-
- ASSERT_TRUE(mSp->run( functionName,
- nInputs, inputTypes, inputs,
- nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK);
- ASSERT_TRUE(out0.getInt64() == (in0.getInt64() + in1.getInt64()));
- out0.setInt64(0);
- ASSERT_TRUE(sp2->run( functionName,
- nInputs, inputTypes, inputs,
- nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK);
- ASSERT_TRUE(out0.getInt64() == (in0.getInt64() + in1.getInt64()));
- delete sp2;
-}
-
-// test to run processing/example.py
-TEST_F(SignalProcessingInterfaceTest, exampleTest) {
- android::String8 functionName("example");
- int nInputs = 8;
- int nOutputs = 4;
- bool inputTypes[8] = { true, true, true, true, false, false, false, false };
- bool outputTypes[4] = { true, true, false, false };
-
- android::sp<Buffer> in0(new Buffer(16, 16, true));
- char* data0 = in0->getData();
- for (size_t i = 0; i < in0->getSize(); i++) {
- data0[i] = i;
- }
- android::sp<Buffer> in1(new Buffer(16, 16, true));
- char* data1 = in1->getData();
- for (size_t i = 0; i < in1->getSize(); i++) {
- data1[i] = i;
- }
- android::sp<Buffer> in2(new Buffer(8, 8, false));
- char* data2 = in2->getData();
- for (size_t i = 0; i < in2->getSize(); i++) {
- data2[i] = i;
- }
- android::sp<Buffer> in3(new Buffer(8, 8, false));
- char* data3 = in3->getData();
- for (size_t i = 0; i < in3->getSize(); i++) {
- data3[i] = i;
- }
- TaskCase::Value in4((int64_t)100);
- TaskCase::Value in5((int64_t)100);
- TaskCase::Value in6(1.0f);
- TaskCase::Value in7(1.0f);
- void* inputs[8] = { &in0, &in1, &in2, &in3, &in4, &in5, &in6, &in7 };
-
- android::sp<Buffer> out0(new Buffer(16, 16, true));
- char* outdata0 = out0->getData();
- for (size_t i = 0; i < out0->getSize(); i++) {
- outdata0[i] = 0xaa;
- }
- android::sp<Buffer> out1(new Buffer(8, 8, false));
- char* outdata1 = out1->getData();
- for (size_t i = 0; i < out1->getSize(); i++) {
- outdata1[i] = 0xbb;
- }
- TaskCase::Value out2((int64_t)1000);
- TaskCase::Value out3(-1.0f);
- void *outputs[4] = { &out0, &out1, &out2, &out3 };
-
- ASSERT_TRUE(mSp->run( functionName,
- nInputs, inputTypes, inputs,
- nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK);
- ASSERT_TRUE(*(in0.get()) == *(out0.get()));
- ASSERT_TRUE(*(in2.get()) == *(out1.get()));
- ASSERT_TRUE(in4 == out2);
- ASSERT_TRUE(in6 == out3);
-}
diff --git a/suite/audio_quality/test/SimpleScriptExecTest.cpp b/suite/audio_quality/test/SimpleScriptExecTest.cpp
deleted file mode 100644
index 7016ef9..0000000
--- a/suite/audio_quality/test/SimpleScriptExecTest.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#include <gtest/gtest.h>
-#include <SimpleScriptExec.h>
-
-
-class ScriptExecTest : public testing::Test {
-
-};
-
-TEST_F(ScriptExecTest, PythonVersionTest) {
- ASSERT_TRUE(SimpleScriptExec::checkPythonEnv());
-}
-
-
-TEST_F(ScriptExecTest, checkIfPassedTest) {
- android::String8 pass1("___CTS_AUDIO_PASS___");
- android::String8 match1;
- ASSERT_TRUE(SimpleScriptExec::checkIfPassed(pass1, match1));
-
- android::String8 fail1;
- ASSERT_TRUE(!SimpleScriptExec::checkIfPassed(fail1, match1));
-}
-
diff --git a/suite/audio_quality/test/StringUtilTest.cpp b/suite/audio_quality/test/StringUtilTest.cpp
deleted file mode 100644
index 1dbcea0..0000000
--- a/suite/audio_quality/test/StringUtilTest.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <gtest/gtest.h>
-#include <StringUtil.h>
-
-
-class StringUtilTest : public testing::Test {
-
-};
-
-TEST_F(StringUtilTest, compareTest) {
- android::String8 str("hello");
- ASSERT_TRUE(StringUtil::compare(str, "hello") == 0);
- ASSERT_TRUE(StringUtil::compare(str, "hi") != 0);
-}
-
-TEST_F(StringUtilTest, substrTest) {
- android::String8 str("hello there");
-
- android::String8 sub1 = StringUtil::substr(str, 0, 5);
- ASSERT_TRUE(StringUtil::compare(sub1, "hello") == 0);
-
- android::String8 sub2 = StringUtil::substr(str, 10, 5);
- ASSERT_TRUE(StringUtil::compare(sub2, "e") == 0);
-
- android::String8 sub3 = StringUtil::substr(str, 6, 5);
- ASSERT_TRUE(StringUtil::compare(sub3, "there") == 0);
-
- android::String8 sub4 = StringUtil::substr(str, 100, 5);
- ASSERT_TRUE(sub4.length() == 0);
-}
-
-TEST_F(StringUtilTest, endsWithTest) {
- android::String8 str("hello there");
- ASSERT_TRUE(StringUtil::endsWith(str, "there"));
- ASSERT_TRUE(StringUtil::endsWith(str, "hello there"));
- ASSERT_TRUE(!StringUtil::endsWith(str, "not there"));
-}
-
-TEST_F(StringUtilTest, splitTest) {
- android::String8 str("hello:there:break:this:");
- std::vector<android::String8>* tokens = StringUtil::split(str, ':');
- ASSERT_TRUE(tokens != NULL);
- ASSERT_TRUE(tokens->size() == 4);
- ASSERT_TRUE(StringUtil::compare(tokens->at(0), "hello") == 0);
- ASSERT_TRUE(StringUtil::compare(tokens->at(1), "there") == 0);
- ASSERT_TRUE(StringUtil::compare(tokens->at(2), "break") == 0);
- ASSERT_TRUE(StringUtil::compare(tokens->at(3), "this") == 0);
- delete tokens;
-
- android::String8 str2("::::");
- std::vector<android::String8>* tokens2 = StringUtil::split(str2, ':');
- ASSERT_TRUE(tokens2 != NULL);
- ASSERT_TRUE(tokens2->size() == 0);
- delete tokens2;
-}
-
-
-
diff --git a/suite/audio_quality/test/TaskCaseCommon.h b/suite/audio_quality/test/TaskCaseCommon.h
deleted file mode 100644
index cf8d272..0000000
--- a/suite/audio_quality/test/TaskCaseCommon.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#ifndef CTSAUDIO_TASKCASECOMMON_H
-#define CTSAUDIO_TASKCASECOMMON_H
-
-#include <gtest/gtest.h>
-
-#include <Log.h>
-#include <GenericFactory.h>
-#include <task/TaskAll.h>
-
-/**
- * Create TaskCase with setup and action as children
- * No need to destroy setup and action
- */
-inline TaskCase* getTaskCase(TaskGeneric*& setup, TaskGeneric*& action)
-{
- GenericFactory factory;
- TaskCase* taskCase = new TaskCase();
- setup = factory.createTask(TaskGeneric::ETaskSetup);
- taskCase->addChild(setup);
- action = factory.createTask(TaskGeneric::ETaskAction);
- taskCase->addChild(action);
- return taskCase;
-}
-
-
-#endif // CTSAUDIO_TASKCASECOMMON_H
diff --git a/suite/audio_quality/test/TaskCaseTest.cpp b/suite/audio_quality/test/TaskCaseTest.cpp
deleted file mode 100644
index 9cf74a7..0000000
--- a/suite/audio_quality/test/TaskCaseTest.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <stdint.h>
-#include <gtest/gtest.h>
-
-#include "Log.h"
-#include "StringUtil.h"
-#include "task/TaskAll.h"
-
-
-class TaskCaseTest : public testing::Test {
-public:
- TaskCase* mTaskCase;
- virtual void SetUp() {
- mTaskCase = new TaskCase();
- ASSERT_TRUE(mTaskCase != NULL);
- }
-
- virtual void TearDown() {
- delete mTaskCase;
- }
-};
-
-
-TEST_F(TaskCaseTest, DataMapTest) {
- android::sp<Buffer> buffer1(new Buffer(4, 4, true));
- android::sp<Buffer> buffer2(new Buffer(4, 4, true));
- android::sp<Buffer> buffer3(new Buffer(4, 4, true));
- android::sp<Buffer> buffer4(new Buffer(4, 4, true));
-
- const android::String8 BUFFER1("buffer1");
- const android::String8 BUFFER2("buffer2");
- const android::String8 BUFFER3("buffer3");
- const android::String8 BUFFER4("buffer4");
- ASSERT_TRUE(mTaskCase->registerBuffer(BUFFER1, buffer1));
- ASSERT_TRUE(mTaskCase->registerBuffer(BUFFER2, buffer2));
- ASSERT_TRUE(mTaskCase->registerBuffer(BUFFER3, buffer3));
- ASSERT_TRUE(mTaskCase->registerBuffer(BUFFER4, buffer4));
-
- android::sp<Buffer> buffer1f = mTaskCase->findBuffer(BUFFER1);
- //LOGI("buffer1 %x, buffer1f %x", &buffer1, buffer1f);
- ASSERT_TRUE(buffer1.get() == buffer1f.get());
- const android::String8 NO_SUCH_BUFFER("no_such_buffer");
- buffer1f = mTaskCase->findBuffer(NO_SUCH_BUFFER);
- ASSERT_TRUE(buffer1f.get() == NULL);
- const android::String8 RE("buffer[1-2]");
- std::list<TaskCase::BufferPair>* list = mTaskCase->findAllBuffers(RE);
- ASSERT_TRUE(list != NULL);
- ASSERT_TRUE(((list->front().second.get() == buffer1.get()) &&
- (list->back().second.get() == buffer2.get())) ||
- ((list->front().second.get() == buffer2.get()) &&
- (list->back().second.get() == buffer1.get())));
- delete list;
-}
-
-TEST_F(TaskCaseTest, ValueMapTest) {
- TaskCase::Value val1(1.0f);
- TaskCase::Value val2(2.0f);
- TaskCase::Value val3((int64_t)1);
- TaskCase::Value val4((int64_t)2);
- TaskCase::Value val2_copy(2.0f);
- ASSERT_TRUE(!(val1 == val2));
- ASSERT_TRUE(!(val2 == val3));
- ASSERT_TRUE(val2 == val2_copy);
- ASSERT_TRUE(val1.getDouble() == 1.0f);
- ASSERT_TRUE(val3.getInt64() == 1);
- const android::String8 V1("v1");
- const android::String8 V2("v2");
- const android::String8 V3("v3");
- const android::String8 V4("v4");
- const android::String8 V5("v5");
- ASSERT_TRUE(mTaskCase->registerValue(V1, val1));
- ASSERT_TRUE(mTaskCase->registerValue(V2, val2));
- ASSERT_TRUE(mTaskCase->registerValue(V3, val3));
- ASSERT_TRUE(mTaskCase->registerValue(V4, val4));
-
- TaskCase::Value valRead;
- ASSERT_TRUE(mTaskCase->findValue(V4, valRead));
- ASSERT_TRUE(valRead.getInt64() == 2);
- TaskCase::Value val4_2((int64_t)3);
- ASSERT_TRUE(mTaskCase->updateValue(V4, val4_2));
- ASSERT_TRUE(mTaskCase->findValue(V4, valRead));
- ASSERT_TRUE(valRead.getInt64() == 3);
- ASSERT_TRUE(!mTaskCase->updateValue(V5, val4));
- ASSERT_TRUE(!mTaskCase->findValue(V5, valRead));
-
- const android::String8 RE("v[2-3]");
- std::list<TaskCase::ValuePair>* list = mTaskCase->findAllValues(RE);
- ASSERT_TRUE(list != NULL);
- ASSERT_TRUE(((list->front().second == val2) && (list->back().second == val3)) ||
- ((list->front().second == val3) && (list->back().second == val4)));
- delete list;
-}
-
-TEST_F(TaskCaseTest, IndexMapTest) {
- Buffer buffer1(4, 4, true);
- Buffer buffer2(4, 4, true);
- Buffer buffer3(4, 4, true);
- Buffer buffer4(4, 4, true);
-
- int i = 0;
- int j = 1;
- const android::String8 I("i");
- const android::String8 J("j");
- const android::String8 K("k");
- ASSERT_TRUE(mTaskCase->registerIndex(I));
- ASSERT_TRUE(mTaskCase->registerIndex(J));
- ASSERT_TRUE(mTaskCase->updateIndex(I, i));
- ASSERT_TRUE(mTaskCase->updateIndex(J, j));
- int i_read, j_read, k_read;
- ASSERT_TRUE(mTaskCase->findIndex(I, i_read));
- ASSERT_TRUE(mTaskCase->findIndex(J, j_read));
- ASSERT_TRUE(!mTaskCase->findIndex(K, k_read));
- ASSERT_TRUE(i == i_read);
- ASSERT_TRUE(j == j_read);
- //TODO add findAll test
-}
-
-TEST_F(TaskCaseTest, VarTranslateTest) {
- const android::String8 I("i");
- const android::String8 J("j");
- const android::String8 K("k");
- ASSERT_TRUE(mTaskCase->registerIndex(I, 1));
- ASSERT_TRUE(mTaskCase->registerIndex(J, 2));
- ASSERT_TRUE(mTaskCase->registerIndex(K, 3));
-
- android::String8 orig1("hello_$i_$j");
- android::String8 result1;
- ASSERT_TRUE(mTaskCase->translateVarName(orig1, result1));
- ASSERT_TRUE(StringUtil::compare(result1, "hello_1_2") == 0);
-
- android::String8 orig2("hello_$i_$j_$k_there");
- android::String8 result2;
- ASSERT_TRUE(mTaskCase->translateVarName(orig2, result2));
- ASSERT_TRUE(StringUtil::compare(result2, "hello_1_2_3_there") == 0);
-
- // should fail as there is no such var
- android::String8 orig3("$n");
- android::String8 result3;
- ASSERT_TRUE(!mTaskCase->translateVarName(orig3, result3));
-
- android::String8 orig4("hello_there");
- android::String8 result4;
- ASSERT_TRUE(mTaskCase->translateVarName(orig4, result4));
- ASSERT_TRUE(StringUtil::compare(result4, "hello_there") == 0);
-}
diff --git a/suite/audio_quality/test/TaskProcessTest.cpp b/suite/audio_quality/test/TaskProcessTest.cpp
deleted file mode 100644
index 05c7f1d..0000000
--- a/suite/audio_quality/test/TaskProcessTest.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-
-#include "TaskCaseCommon.h"
-
-class TaskProcessTest : public testing::Test {
-public:
- TaskCase* mTestCase;
- TaskSequential* mSequential;
- TaskProcess* mProcess;
-
-
- virtual void SetUp() {
- TaskGeneric* setup = NULL;
- TaskGeneric* action = NULL;
- mTestCase = getTaskCase(setup, action);
- ASSERT_TRUE(mTestCase != NULL);
- ASSERT_TRUE(setup != NULL);
- ASSERT_TRUE(action != NULL);
- mSequential = new TaskSequential();
- const android::String8 REPEAT("repeat");
- const android::String8 N_10("10");
- const android::String8 INDEX("index");
- const android::String8 I("i");
- ASSERT_TRUE(mSequential->parseAttribute(REPEAT, N_10));
- ASSERT_TRUE(mSequential->parseAttribute(INDEX, I));
- ASSERT_TRUE(action->addChild(mSequential));
- mProcess = new TaskProcess();
- ASSERT_TRUE(mSequential->addChild(mProcess));
-
- }
-
- virtual void TearDown() {
- delete mTestCase;
- }
-};
-
-
-TEST_F(TaskProcessTest, AttributeTest) {
-
-}
-
-
diff --git a/suite/audio_quality/test/TaskSequentialTest.cpp b/suite/audio_quality/test/TaskSequentialTest.cpp
deleted file mode 100644
index 289dafe..0000000
--- a/suite/audio_quality/test/TaskSequentialTest.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include "TaskCaseCommon.h"
-class TaskSequentialTest : public testing::Test {
-public:
- TaskCase* mTestCase;
- TaskSequential* mSequential;
-
-
- virtual void SetUp() {
- TaskGeneric* setup = NULL;
- TaskGeneric* action = NULL;
- mTestCase = getTaskCase(setup, action);
- ASSERT_TRUE(mTestCase != NULL);
- ASSERT_TRUE(setup != NULL);
- ASSERT_TRUE(action != NULL);
- mSequential = new TaskSequential();
- action->addChild(mSequential);
- }
-
- virtual void TearDown() {
- delete mTestCase;
- }
-};
-
-
-TEST_F(TaskSequentialTest, AttributeTest) {
- const android::String8 REPEAT("repeat");
- const android::String8 N_10("10");
- const android::String8 INDEX("index");
- const android::String8 I("i");
- const android::String8 NO_SUCH_THING("no_such_thing");
- const android::String8 SHOULD_FAIL("should_fail");
- ASSERT_TRUE(mSequential->parseAttribute(REPEAT, N_10));
- ASSERT_TRUE(mSequential->parseAttribute(INDEX, I));
- ASSERT_TRUE(!mSequential->parseAttribute(NO_SUCH_THING, SHOULD_FAIL));
- mSequential->run();
- const android::String8 RE(".*");
- std::list<TaskCase::IndexPair>* indices = mTestCase->findAllIndices(RE);
- ASSERT_TRUE(indices != NULL);
- ASSERT_TRUE(indices->size() == 1);
- int index = -10;
-
- ASSERT_TRUE(mTestCase->findIndex(I, index));
- ASSERT_TRUE(index == 10);
- delete indices;
-}
-
-
-
-
diff --git a/suite/audio_quality/test/TaskTest.cpp b/suite/audio_quality/test/TaskTest.cpp
deleted file mode 100644
index 3636f82..0000000
--- a/suite/audio_quality/test/TaskTest.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#include <gtest/gtest.h>
-#include "task/TaskAll.h"
-
-static const android::String8 AAA("aaa");
-static const android::String8 BBB("bbb");
-
-class TaskTest : public testing::Test {
-public:
- TaskCase* mTestCase;
- // should not delete
- TaskGeneric* mTaskSetup;
- TaskGeneric* mTaskAction;
- TaskGeneric* mTaskSequential;
- TaskGeneric* mTaskProcess;
- TaskGeneric* mTaskInput;
- TaskGeneric* mTaskOutput;
- TaskGeneric* mTaskSound;
-
- class TestTaskDummy: public TaskGeneric {
- public:
- static int mRunCounter;
- static int mLiveInstanceCounter;
-
- explicit TestTaskDummy(TaskGeneric::TaskType type)
- : TaskGeneric(type) {
- mLiveInstanceCounter++;
-
-
- const android::String8* list[] = {&AAA, &BBB, NULL};
- registerSupportedStringAttributes(list);
- };
- virtual ~TestTaskDummy(){
- mLiveInstanceCounter--;
- };
-
- virtual TaskGeneric::ExecutionResult run()
- {
- mRunCounter++;
- return TaskGeneric::run();
- };
- bool addStringAttributePublic(const android::String8& key, android::String8& value){
- return addStringAttribute(key, value);
- }
- bool findStringAttributePublic(const android::String8& key, android::String8& value){
- return findStringAttribute(key, value);
- }
- };
-
- virtual void SetUp() {
- TestTaskDummy::mRunCounter = 0;
- TestTaskDummy::mLiveInstanceCounter = 0;
- mTestCase = new TaskCase();
- mTaskSetup = new TestTaskDummy(TaskGeneric::ETaskSetup);
- mTaskAction = new TestTaskDummy(TaskGeneric::ETaskAction);
- ASSERT_TRUE(mTestCase->addChild(mTaskSetup));
- ASSERT_TRUE(mTestCase->addChild(mTaskAction));
- mTaskSequential = new TestTaskDummy(TaskGeneric::ETaskSequential);
- ASSERT_TRUE(mTaskAction->addChild(mTaskSequential));
- mTaskProcess = new TestTaskDummy(TaskGeneric::ETaskProcess);
- mTaskInput = new TestTaskDummy(TaskGeneric::ETaskInput);
- mTaskOutput = new TestTaskDummy(TaskGeneric::ETaskOutput);
- ASSERT_TRUE(mTaskSequential->addChild(mTaskOutput));
- ASSERT_TRUE(mTaskSequential->addChild(mTaskInput));
- ASSERT_TRUE(mTaskSequential->addChild(mTaskProcess));
- mTaskSound = new TestTaskDummy(TaskGeneric::ETaskSound);
- ASSERT_TRUE(mTaskSetup->addChild(mTaskSound));
- ASSERT_TRUE(TestTaskDummy::mLiveInstanceCounter == 7);
- }
-
- virtual void TearDown() {
- if(mTestCase != NULL) {
- delete mTestCase;
- }
- ASSERT_TRUE(TestTaskDummy::mLiveInstanceCounter == 0);
- }
-};
-
-int TaskTest::TestTaskDummy::mRunCounter = 0;
-int TaskTest::TestTaskDummy::mLiveInstanceCounter = 0;
-
-TEST_F(TaskTest, HierarchyTest) {
- // verify hierarchy
- ASSERT_TRUE(mTaskSetup->getTestCase() == mTestCase);
- ASSERT_TRUE(mTaskAction->getTestCase() == mTestCase);
- ASSERT_TRUE(mTaskSequential->getTestCase() == mTestCase);
- ASSERT_TRUE(mTaskProcess->getTestCase() == mTestCase);
- ASSERT_TRUE(mTaskInput->getTestCase() == mTestCase);
- ASSERT_TRUE(mTaskOutput->getTestCase() == mTestCase);
- ASSERT_TRUE(mTaskSound->getTestCase() == mTestCase);
-}
-
-TEST_F(TaskTest, RunTest) {
- ASSERT_TRUE(mTestCase->run() == TaskGeneric::EResultOK);
- ASSERT_TRUE(TestTaskDummy::mRunCounter == 7);
-}
-
-TEST_F(TaskTest, StringAttributeTest) {
- android::String8 aaaVal("aaa_val");
- android::String8 bbbVal("bbb_val");
- android::String8 read;
- TestTaskDummy* task = reinterpret_cast<TestTaskDummy*>(mTaskSetup);
- ASSERT_TRUE(task->addStringAttributePublic(AAA, aaaVal));
- ASSERT_TRUE(task->addStringAttributePublic(BBB, bbbVal));
- const android::String8 CCC("ccc");
- ASSERT_TRUE(!task->addStringAttributePublic(CCC, bbbVal));
- ASSERT_TRUE(task->findStringAttributePublic(AAA, read));
- ASSERT_TRUE(read == aaaVal);
- ASSERT_TRUE(task->findStringAttributePublic(BBB, read));
- ASSERT_TRUE(read == bbbVal);
- const android::String8 VERSION("version");
- const android::String8 NAME("name");
- ASSERT_TRUE(!task->findStringAttributePublic(VERSION, read));
- ASSERT_TRUE(!task->findStringAttributePublic(NAME, read));
-}
-
-
diff --git a/suite/audio_quality/test_description/all_playback.xml b/suite/audio_quality/test_description/all_playback.xml
deleted file mode 100644
index cf5af6f..0000000
--- a/suite/audio_quality/test_description/all_playback.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<batch name="cts_audio_all_playback" version="1.0" description="All playback tests">
- <include file="dut_speaker_calibration.xml" />
- <include file="dut_playback_thd.xml" />
- <include file="dut_playback_spectrum.xml" />
-</batch>
diff --git a/suite/audio_quality/test_description/all_recording.xml b/suite/audio_quality/test_description/all_recording.xml
deleted file mode 100644
index f1e78b9..0000000
--- a/suite/audio_quality/test_description/all_recording.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<batch name="cts_audio_all_recording" version="1.0" description="All recording tests">
- <include file="host_speaker_calibration.xml" />
- <include file="dut_recording_thd.xml" />
- <include file="dut_recording_spectrum.xml" />
-</batch>
diff --git a/suite/audio_quality/test_description/conf/check_conf.py b/suite/audio_quality/test_description/conf/check_conf.py
deleted file mode 100644
index d7775af..0000000
--- a/suite/audio_quality/test_description/conf/check_conf.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import sys
-import numpy as np
-import scipy as sp
-from numpy import *
-if __name__=="__main__":
- if(sys.version_info < (2,6,0)):
- print "Wrong Python version ", sys.version_info
- sys.exit(1)
- a = np.array([1,2,3])
- print "___CTS_AUDIO_PASS___"
diff --git a/suite/audio_quality/test_description/conf/detect_usb_audio.py b/suite/audio_quality/test_description/conf/detect_usb_audio.py
deleted file mode 100644
index 259f7e1..0000000
--- a/suite/audio_quality/test_description/conf/detect_usb_audio.py
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#detect USB sound card from sound card lists under sys/class/sound/soundX
-
-import os, re, sys
-
-AUDIO_CLASS_DIR = "/sys/class/sound"
-
-def main(argv):
- if len(argv) < 2:
- print "Usage: detect_usb_audio.py (product)+"
- print " ex: detect_usb_audio.py MobilePre"
- sys.exit(1)
- current_argv = 1
- product_list = []
- while current_argv < len(argv):
- product_list.append(argv[current_argv])
- current_argv = current_argv + 1
- #print product_list
- sound_dev_list = os.listdir(AUDIO_CLASS_DIR)
- for sound_dev in sound_dev_list:
- m = re.search("card(\d+)$", sound_dev)
- if m != None:
- card_full_path = os.path.realpath(AUDIO_CLASS_DIR + "/" + sound_dev)
- if "usb" in card_full_path:
- f = open(card_full_path + "/id")
- line = f.readline().strip()
- if line in product_list:
- print "___CTS_AUDIO_PASS___ " + line + " " + m.group(1)
- sys.exit(0)
- f.close()
- # card not found
- sys.exit(1)
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/suite/audio_quality/test_description/dut_playback_sample.xml b/suite/audio_quality/test_description/dut_playback_sample.xml
deleted file mode 100644
index f78209e..0000000
--- a/suite/audio_quality/test_description/dut_playback_sample.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="dut_playback_sample" version="1.0" description="Sample test which check frequency of DUT's playback">
- <setup>
- <!-- prepare sound source id: to be used in output, sine 1000Hz, 4000ms long -->
- <sound id="sound1" type="sin:32000:1000:4000" preload="1" />
- </setup>
- <action>
- <sequential repeat="1" index="i">
- <output device="DUT" id="sound1" gain="100" sync="start" waitforcompletion="0" />
- <sequential repeat="1" index="j">
- <!-- dummy recording to compensate for possible playback latency -->
- <input device="host" id="dummy" gain="100" time="1000" sync="complete" />
- <input device="host" id="host_in_$j" gain="100" time="2000" sync="complete" />
- </sequential>
- </sequential>
- <sequential repeat="1" index="k">
- <!-- input: host record, signal frequency in Hz, threshold, output: frequency calculated -->
- <process method="script:playback_sample" input="id:host_in_$k,consti:1000,constf:5.0" output="val:freq_device_$k" />
- </sequential>
- </action>
- <save file="host_in_.*" report="freq_device_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/dut_playback_spectrum.xml b/suite/audio_quality/test_description/dut_playback_spectrum.xml
deleted file mode 100644
index 90a5a3d..0000000
--- a/suite/audio_quality/test_description/dut_playback_spectrum.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="dut_playback_spectrum" version="1.0" description="Check frequency spectrum for playback">
- <setup>
- <!-- input: peak amplitude, duration in msec, sampling rate, high frequency, output: generated sound-->
- <process method="script:gen_random" input="consti:10000,consti:4000,consti:44100,consti:20000" output="id:sound1" />
- <download id="sound1" />
- </setup>
- <action>
- <sequential repeat="1" index="i">
- <input device="host" id="host_in_$i" gain="100" time="5000" sync="start" />
- <output device="DUT" id="sound1" gain="100" mode="voice" sync="start" waitforcompletion="1" />
- </sequential>
- <sequential repeat="1" index="k">
- <!-- input: host record, device record, samping rate, low frequency in Hz, high frequency in Hz, allowed error for pass in smaller side, allowed error in bigger side%, output: min value in lower side calculated normalized to 1.0, max value in higher side, calculated amplitude ratio in mannitude only between low f to high f -->
- <process method="script:check_spectrum" input="id:sound1,id:host_in_$k,consti:44100,consti:500,consti:8000,constf:97.0,constf:200.0" output="val:min_val_$k,val:max_val_$k,id:spectrum_$k" />
- </sequential>
- </action>
- <save file="sound1,host_in_.*,spectrum_.*" report="min_val_.*,max_val_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/dut_playback_thd.xml b/suite/audio_quality/test_description/dut_playback_thd.xml
deleted file mode 100644
index 9e32756..0000000
--- a/suite/audio_quality/test_description/dut_playback_thd.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="dut_playback_thd" version="1.0" description="Check THD in DUT's playback side">
- <setup>
- <!-- prepare sound source id: to be used in output, sine 1000Hz, 4000ms long -->
- <sound id="sound1" type="sin:32000:1000:4000" preload="1" />
- </setup>
- <action>
- <sequential repeat="1" index="i">
- <output device="DUT" id="sound1" gain="100" sync="start" waitforcompletion="0" />
- <sequential repeat="1" index="j">
- <!-- dummy recording to compensate for possible playback latency -->
- <input device="host" id="dummy" gain="100" time="1000" sync="complete" />
- <input device="host" id="host_in_$j" gain="100" time="2000" sync="complete" />
- </sequential>
- </sequential>
- <sequential repeat="1" index="k">
- <!-- input: host record, signal frequency in Hz, THD for pass in percentile, output: THD calculated -->
- <process method="script:playback_thd" input="id:host_in_$k,consti:1000,constf:5.0" output="val:thd_device_$k" />
- </sequential>
- </action>
- <save file="host_in_.*" report="thd_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/dut_recording_spectrum.xml b/suite/audio_quality/test_description/dut_recording_spectrum.xml
deleted file mode 100644
index a7373d2..0000000
--- a/suite/audio_quality/test_description/dut_recording_spectrum.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="dut_recording_spectrum" version="1.0" description="Check frequency spectrum for recording">
- <setup>
- <!-- input: peak amplitude, duration in msec, sampling rate, high frequency, output: generated sound-->
- <process method="script:gen_random" input="consti:10000,consti:30000,consti:44100,consti:6000" output="id:sound1" />
- <!-- Only for starting client app early. The data is not used -->
- <sound id="sound2" type="sin:1:1000:2" preload="1"/>
- </setup>
- <action>
- <sequential repeat="1" index="i">
- <output device="host" id="sound1" gain="100" sync="start" waitforcompletion="0" />
- <sequential repeat="5" index="j">
- <input device="host" id="host_in_$j" gain="100" time="6000" sync="start" />
- <input device="DUT" id="dut_in_$j" gain="100" time="4000" sync="start" />
- </sequential>
- </sequential>
- <sequential repeat="5" index="k">
- <!-- input: host record, device record, samping rate, low frequency in Hz, high frequency in Hz, allowed error for pass in smaller side, allowed error in bigger side%, output: min value in lower side calculated normalized to 1.0, max value in higher side, calculated amplitude ratio in mannitude only between low f to high f -->
- <process method="script:check_spectrum" input="id:host_in_$k,id:dut_in_$k,consti:44100,consti:200,consti:4000,constf:95.0,constf:200.0" output="val:min_val_$k,val:max_val_$k,id:tf_$k" />
- </sequential>
- </action>
- <save file="sound1,host_in_.*,dut_in_.*,tf_.*" report="min_val_.*,max_val_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/dut_recording_thd.xml b/suite/audio_quality/test_description/dut_recording_thd.xml
deleted file mode 100644
index 4567ee2..0000000
--- a/suite/audio_quality/test_description/dut_recording_thd.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="dut_recording_thd" version="1.0" description="Check THD in DUT's recording side">
- <setup>
- <!-- prepare sound source id: to be used in output, sine 1000Hz, 40000ms long -->
- <sound id="sound1" type="sin:32000:1000:40000" />
- <!-- Only for starting client app early. The data is not used -->
- <sound id="sound2" type="sin:1:1000:2" preload="1"/>
- </setup>
- <action>
- <sequential repeat="1" index="i">
- <output device="host" id="sound1" gain="100" sync="start" waitforcompletion="0" />
- <sequential repeat="2" index="j">
- <input device="host" id="host_in_$j" gain="100" time="4000" sync="start" />
- <input device="DUT" id="dut_in_$j" gain="100" time="2000" sync="start" />
- </sequential>
- </sequential>
- <sequential repeat="2" index="k">
- <!-- input: host record, device record, signal frequency in Hz, THD for pass in percentile, output: THD calculated -->
- <process method="script:recording_thd" input="id:host_in_$k,id:dut_in_$k,consti:1000,constf:1.0" output="val:thd_host_$k,val:thd_device_$k" />
- </sequential>
- </action>
- <save file="host_in_.*,dut_in_.*" report="thd_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/dut_speaker_calibration.xml b/suite/audio_quality/test_description/dut_speaker_calibration.xml
deleted file mode 100644
index a70442c..0000000
--- a/suite/audio_quality/test_description/dut_speaker_calibration.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="dut_speaker_calibration" version="1.0" description="Calibrate host recording gain">
- <setup> <!-- 1 setup -->
- <!-- prepare sound source id: to be used in output, sine 1000Hz, 20000ms long -->
- <sound id="sound1" type="sin:32000:1000:20000" preload="1" />
- </setup>
-
- <action> <!-- 1 action -->
- <!-- equivalent of for loop. all children will be completed before moving to the next
- stage.repeat up to 100 times unless stopped by some condition -->
- <sequential repeat="20" index="i">
- <!-- sync start : execute only sync complete : execute + complete
- For sync start, complete will be called when the parent completes -->
- <output device="DUT" id="sound1" gain="100" sync="start"/>
- <sequential repeat="50" index="j">
- <input device="host" id="host_in" gain="100" time="250" sync="complete" />
- <!-- ------------moving average RMS min for pass, max for pass result calculated -->
- <process method="builtin:rms_mva" input="id:host_in,consti:1000,consti:8000" output="val:rms_$i_$j" />
- <!-- <message input="val:passfail" output_low="Volume Low" output_ok="Volume OK" output_high="Volume High" /> -->
- </sequential>
- </sequential>
- </action>
- <save file="host_in" report="rms_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/dut_speaker_calibration_no_pass.xml b/suite/audio_quality/test_description/dut_speaker_calibration_no_pass.xml
deleted file mode 100644
index 5ebdf8b..0000000
--- a/suite/audio_quality/test_description/dut_speaker_calibration_no_pass.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="dut_speaker_calibration" version="1.0" description="Calibrate host recording gain">
- <setup> <!-- 1 setup -->
- <!-- prepare sound source id: to be used in output, sine 1000Hz, 20000ms long -->
- <sound id="sound1" type="sin:32000:1000:20000" preload="1" />
- </setup>
-
- <action> <!-- 1 action -->
- <!-- equivalent of for loop. all children will be completed before moving to the next
- stage.repeat up to 100 times unless stopped by some condition -->
- <sequential repeat="20" index="i">
- <!-- sync start : execute only sync complete : execute + complete
- For sync start, complete will be called when the parent completes -->
- <output device="DUT" id="sound1" gain="100" sync="start" waitforcompletion="1" />
- <sequential repeat="50" index="j">
- <input device="host" id="host_in" gain="100" time="250" sync="complete" />
- <!-- ------------moving average RMS min for pass, max for pass result calculated -->
- <process method="builtin:rms_mva" input="id:host_in,consti:2,consti:1" output="val:rms_$i_$j" />
- <!-- <message input="val:passfail" output_low="Volume Low" output_ok="Volume OK" output_high="Volume High" /> -->
- </sequential>
- </sequential>
- </action>
- <save file="host_in" report="rms_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/experimental/chirp_400_20000.r2s b/suite/audio_quality/test_description/experimental/chirp_400_20000.r2s
deleted file mode 100644
index 46ba654..0000000
--- a/suite/audio_quality/test_description/experimental/chirp_400_20000.r2s
+++ /dev/null
Binary files differ
diff --git a/suite/audio_quality/test_description/experimental/dut_playback_spectrum_chirp.xml b/suite/audio_quality/test_description/experimental/dut_playback_spectrum_chirp.xml
deleted file mode 100644
index 63374eb..0000000
--- a/suite/audio_quality/test_description/experimental/dut_playback_spectrum_chirp.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="dut_playback_spectrum_chirp" version="1.0" description="Check frequency spectrum for playback">
- <setup>
- <!-- input: peak amplitude, duration in msec, sampling rate, high frequency, output: generated sound-->
- <sound id="chirp" type="file:test_description/experimental/chirp_400_20000.r2s" preload="1" />
- </setup>
- <action>
- <sequential repeat="1" index="i">
- <input device="host" id="host_in_$i" gain="100" time="5000" sync="start" />
- <output device="DUT" id="chirp" gain="100" mode="voice" sync="start" waitforcompletion="0" />
- </sequential>
- <sequential repeat="1" index="k">
- <!-- input: host record, device record, samping rate, low frequency in Hz, high frequency in Hz, allowed error for pass in smaller side, allowed error in bigger side%, output: min value in lower side calculated normalized to 1.0, max value in higher side, calculated amplitude ratio in mannitude only between low f to high f -->
- <process method="script:check_spectrum" input="id:chirp,id:host_in_$k,consti:44100,consti:500,consti:8000,constf:50.0,constf:100.0" output="val:min_val_$k,val:max_val_$k,id:spectrum_$k" />
- </sequential>
- </action>
- <save file="chirp,host_in_.*,spectrum_.*" report="min_val_.*,max_val_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/experimental/ref_playback_spectrum.xml b/suite/audio_quality/test_description/experimental/ref_playback_spectrum.xml
deleted file mode 100644
index 7653208..0000000
--- a/suite/audio_quality/test_description/experimental/ref_playback_spectrum.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="dut_playback_spectrum" version="1.0" description="Check frequency spectrum for playback">
- <setup>
- <!-- input: peak amplitude, duration in msec, sampling rate, high frequency, output: generated sound-->
- <process method="script:gen_random" input="consti:10000,consti:5000,consti:44100,consti:20000" output="id:sound1" />
- </setup>
- <action>
- <sequential repeat="1" index="i">
- <input device="host" id="host_in_$i" gain="100" time="4000" sync="start" />
- <output device="host" id="sound1" gain="100" sync="start" waitforcompletion="1" />
- </sequential>
- <sequential repeat="1" index="k">
- <!-- input: host record, device record, samping rate, low frequency in Hz, high frequency in Hz, allowed error for pass in smaller side, allowed error in bigger side%, output: min value in lower side calculated normalized to 1.0, max value in higher side, calculated amplitude ratio in mannitude only between low f to high f -->
- <process method="script:check_spectrum" input="id:sound1,id:host_in_$k,consti:44100,consti:500,consti:8000,constf:50.0,constf:100.0" output="val:min_val_$k,val:max_val_$k,id:spectrum_$k" />
- </sequential>
- </action>
- <save file="sound1,host_in_.*,spectrum_.*" report="min_val_.*,max_val_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/experimental/ref_playback_spectrum_chirp.xml b/suite/audio_quality/test_description/experimental/ref_playback_spectrum_chirp.xml
deleted file mode 100644
index 9e689f2..0000000
--- a/suite/audio_quality/test_description/experimental/ref_playback_spectrum_chirp.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="ref_playback_spectrum_chirp" version="1.0" description="Check frequency spectrum of reference speaker for playback">
- <setup>
- <!-- input: peak amplitude, duration in msec, sampling rate, high frequency, output: generated sound-->
- <sound id="chirp" type="file:test_description/experimental/chirp_400_20000.r2s" />
- </setup>
- <action>
- <sequential repeat="1" index="i">
- <input device="host" id="host_in_$i" gain="100" time="5000" sync="start" />
- <output device="host" id="chirp" gain="100" sync="start" waitforcompletion="0" />
- </sequential>
- <sequential repeat="1" index="k">
- <!-- input: host record, device record, samping rate, low frequency in Hz, high frequency in Hz, allowed error for pass in smaller side, allowed error in bigger side%, output: min value in lower side calculated normalized to 1.0, max value in higher side, calculated amplitude ratio in mannitude only between low f to high f -->
- <process method="script:check_spectrum" input="id:chirp,id:host_in_$k,consti:44100,consti:500,consti:8000,constf:50.0,constf:100.0" output="val:min_val_$k,val:max_val_$k,id:spectrum_$k" />
- </sequential>
- </action>
- <save file="chirp,host_in_.*,spectrum_.*" report="min_val_.*,max_val_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/host_speaker_calibration.xml b/suite/audio_quality/test_description/host_speaker_calibration.xml
deleted file mode 100644
index 7ec3b77..0000000
--- a/suite/audio_quality/test_description/host_speaker_calibration.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="host_speaker_calibration" version="1.0" description="Calibrate host speaker's volume.">
- <setup> <!-- 1 setup -->
- <!-- prepare sound source id: to be used in output, sine 1000Hz, 30000ms long -->
- <sound id="sound1" type="sin:32000:1000:30000" />
- </setup>
-
- <action> <!-- 1 action -->
- <!-- equivalent of for loop. all children will be completed before moving to the next
- stage.repeat up to 100 times unless stopped by some condition -->
- <sequential repeat="20" index="i">
- <!-- sync start : execute only sync complete : execute + complete
- For sync start, complete will be called when the parent completes -->
- <output device="host" id="sound1" gain="70" sync="start"/>
- <sequential repeat="80" index="j">
- <input device="host" id="host_in" gain="70" time="250" sync="complete" />
- <!-- ------------moving average RMS min for pass, max for pass result calculated -->
- <process method="builtin:rms_mva" input="id:host_in,consti:2000,consti:6000" output="val:rms_$i_$j" />
- <!-- <message input="val:passfail" output_low="Volume Low" output_ok="Volume OK" output_high="Volume High" /> -->
- </sequential>
- </sequential>
- </action>
- <save file="host_in" report="rms_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/host_speaker_calibration_no_pass.xml b/suite/audio_quality/test_description/host_speaker_calibration_no_pass.xml
deleted file mode 100644
index a1d5afb..0000000
--- a/suite/audio_quality/test_description/host_speaker_calibration_no_pass.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="host_speaker_calibration" version="1.0" description="Calibrate host speaker's volume.">
- <setup> <!-- 1 setup -->
- <!-- prepare sound source id: to be used in output, sine 1000Hz, 30000ms long -->
- <sound id="sound1" type="sin:32000:1000:30000" />
- </setup>
-
- <action> <!-- 1 action -->
- <!-- equivalent of for loop. all children will be completed before moving to the next
- stage.repeat up to 100 times unless stopped by some condition -->
- <sequential repeat="20" index="i">
- <!-- sync start : execute only sync complete : execute + complete
- For sync start, complete will be called when the parent completes -->
- <output device="host" id="sound1" gain="70" sync="start"/>
- <sequential repeat="80" index="j">
- <input device="host" id="host_in" gain="70" time="250" sync="complete" />
- <!-- ------------moving average RMS min for pass, max for pass result calculated -->
- <process method="builtin:rms_mva" input="id:host_in,consti:2,consti:1" output="val:rms_$i_$j" />
- <!-- <message input="val:passfail" output_low="Volume Low" output_ok="Volume OK" output_high="Volume High" /> -->
- </sequential>
- </sequential>
- </action>
- <save file="host_in" report="rms_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/processing/calc_delay.py b/suite/audio_quality/test_description/processing/calc_delay.py
deleted file mode 100644
index 6e63d28..0000000
--- a/suite/audio_quality/test_description/processing/calc_delay.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import numpy as np
-import numpy.linalg
-import scipy as sp
-import scipy.fftpack
-import scipy.signal
-import math
-import sys
-from multiprocessing import Pool
-
-def convolution(data0, data1reversed, n):
- """calculate convolution part of data0 with data1 from pos n"""
- N = len(data1reversed)
- return np.dot(data0[n:N+n], data1reversed)
-
-
-def convolutionstar(args):
- return convolution(*args)
-
-def calc_delay(data0, data1):
- """Calcuate delay between two data. data0 is assumed to be recorded first,
- and will have longer length than data1
- returns delay between data0 and data1 in number of samples in data0's point of view"""
-
- len0 = len(data0)
- len1 = len(data1)
- if len1 > len0:
- print "data1 longer than data0"
- return -1
- searchLen = len0 - len1
- data1reverse = data1[::-1]
-
- # This is faster than signal.correlate as there is no need to process
- # full data, but still it is slow. about 18 secs for data0 of 4 secs with data1 of 1 secs
- print "***Caluclating delay, may take some time***"
- gData0 = data0
- gData1 = data1reverse
- pool = Pool(processes = 4)
- TASK = [(data0, data1reverse, i) for i in range(searchLen)]
- result = pool.map(convolutionstar, TASK)
-
- return np.argmax(result)
-
-
-# test code
-if __name__=="__main__":
- samplingRate = 44100
- durationInSec = 0.001
- if len(sys.argv) > 1:
- durationInSec = float(sys.argv[1])
- signalFrequency = 1000
- samples = float(samplingRate) * float(durationInSec)
- index = np.linspace(0.0, samples, num=samples, endpoint=False)
- time = index / samplingRate
- multiplier = 2.0 * np.pi * signalFrequency / float(samplingRate)
- data0 = np.sin(index * multiplier)
- DELAY = durationInSec / 2.0 * samplingRate
- data1 = data0[DELAY:]
- delay = calc_delay(data0, data1)
- print "calc_delay returned", delay, " while expecting ", DELAY
-
-
diff --git a/suite/audio_quality/test_description/processing/calc_thd.py b/suite/audio_quality/test_description/processing/calc_thd.py
deleted file mode 100644
index 7c96c77..0000000
--- a/suite/audio_quality/test_description/processing/calc_thd.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import numpy as np
-import scipy as sp
-import scipy.fftpack as fft
-import scipy.linalg as la
-import math
-
-def calc_thd(data, signalFrequency, samplingRate, frequencyMargin):
- # only care about magnitude
- fftData = abs(fft.fft(data * np.hanning(len(data))))
- fftData[0] = 0 # ignore DC
- fftLen = len(fftData)/2
- baseI = fftLen * signalFrequency * 2 / samplingRate
- iMargain = baseI * frequencyMargin
- baseSignalLoc = baseI - iMargain / 2 + \
- np.argmax(fftData[baseI - iMargain /2: baseI + iMargain/2])
- peakLoc = np.argmax(fftData[:fftLen])
- if peakLoc != baseSignalLoc:
- print "**ERROR Wrong peak signal", peakLoc, baseSignalLoc
- return 1.0
- print baseI, baseSignalLoc
- P0 = math.pow(la.norm(fftData[baseSignalLoc - iMargain/2: baseSignalLoc + iMargain/2]), 2)
- i = baseSignalLoc * 2
- Pothers = 0.0
- while i < fftLen:
- Pothers += math.pow(la.norm(fftData[i - iMargain/2: i + iMargain/2]), 2)
- i += baseSignalLoc
- print "P0", P0, "Pothers", Pothers
-
- return Pothers / P0
-
-# test code
-if __name__=="__main__":
- samplingRate = 44100
- durationInSec = 10
- signalFrequency = 1000
- samples = float(samplingRate) * float(durationInSec)
- index = np.linspace(0.0, samples, num=samples, endpoint=False)
- time = index / samplingRate
- multiplier = 2.0 * np.pi * signalFrequency / float(samplingRate)
- data = np.sin(index * multiplier)
- thd = calc_thd(data, signalFrequency, samplingRate, 0.02)
- print "THD", thd
-
diff --git a/suite/audio_quality/test_description/processing/check_spectrum.py b/suite/audio_quality/test_description/processing/check_spectrum.py
deleted file mode 100644
index 3d10e34..0000000
--- a/suite/audio_quality/test_description/processing/check_spectrum.py
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from consts import *
-import numpy as np
-import scipy as sp
-import scipy.fftpack as fft
-import matplotlib.pyplot as plt
-import sys
-sys.path.append(sys.path[0])
-import calc_delay
-
-# check if amplitude ratio of DUT / Host signal
-# lies in the given error boundary
-# input: host record
-# device record,
-# sampling rate
-# low frequency in Hz,
-# high frequency in Hz,
-# allowed error in negative side for pass in %,
-# allowed error ih positive side for pass
-# output: min value in negative side, normalized to 1.0
-# max value in positive side
-# calculated amplittude ratio in magnitude (DUT / Host)
-
-def do_check_spectrum(hostData, DUTData, samplingRate, fLow, fHigh, margainLow, margainHigh):
- # reduce FFT resolution to have averaging effects
- N = 512 if (len(hostData) > 512) else len(hostData)
- iLow = N * fLow / samplingRate + 1 # 1 for DC
- if iLow > (N / 2 - 1):
- iLow = (N / 2 - 1)
- iHigh = N * fHigh / samplingRate + 1 # 1 for DC
- if iHigh > (N / 2 + 1):
- iHigh = N / 2 + 1
- print fLow, iLow, fHigh, iHigh, samplingRate
-
- Phh, freqs = plt.psd(hostData, NFFT=N, Fs=samplingRate, Fc=0, detrend=plt.mlab.detrend_none,\
- window=plt.mlab.window_hanning, noverlap=0, pad_to=None, sides='onesided',\
- scale_by_freq=False)
- Pdd, freqs = plt.psd(DUTData, NFFT=N, Fs=samplingRate, Fc=0, detrend=plt.mlab.detrend_none,\
- window=plt.mlab.window_hanning, noverlap=0, pad_to=None, sides='onesided',\
- scale_by_freq=False)
- print len(Phh), len(Pdd)
- print "Phh", abs(Phh[iLow:iHigh])
- print "Pdd", abs(Pdd[iLow:iHigh])
- amplitudeRatio = np.sqrt(abs(Pdd[iLow:iHigh]/Phh[iLow:iHigh]))
- ratioMean = np.mean(amplitudeRatio)
- amplitudeRatio = amplitudeRatio / ratioMean
- print "Normialized ratio", amplitudeRatio
- print "ratio mean for normalization", ratioMean
- positiveMax = abs(max(amplitudeRatio))
- negativeMin = abs(min(amplitudeRatio))
- passFail = True if (positiveMax < (margainHigh / 100.0 + 1.0)) and\
- ((1.0 - negativeMin) < margainLow / 100.0) else False
- RatioResult = np.zeros(len(amplitudeRatio), dtype=np.int16)
- for i in range(len(amplitudeRatio)):
- RatioResult[i] = amplitudeRatio[i] * 1024 # make fixed point
- print "positiveMax", positiveMax, "negativeMin", negativeMin
- return (passFail, negativeMin, positiveMax, RatioResult)
-
-def toMono(stereoData):
- n = len(stereoData)/2
- monoData = np.zeros(n)
- for i in range(n):
- monoData[i] = stereoData[2 * i]
- return monoData
-
-def check_spectrum(inputData, inputTypes):
- output = []
- outputData = []
- outputTypes = []
- # basic validate
- inputError = False
- if (inputTypes[0] != TYPE_MONO) and (inputTypes[0] != TYPE_STEREO):
- inputError = True
- if (inputTypes[1] != TYPE_MONO) and (inputTypes[1] != TYPE_STEREO):
- inputError = True
- if (inputTypes[2] != TYPE_I64):
- inputError = True
- if (inputTypes[3] != TYPE_I64):
- inputError = True
- if (inputTypes[4] != TYPE_I64):
- inputError = True
- if (inputTypes[5] != TYPE_DOUBLE):
- inputError = True
- if (inputTypes[6] != TYPE_DOUBLE):
- inputError = True
- if inputError:
- print "input error"
- output.append(RESULT_ERROR)
- output.append(outputData)
- output.append(outputTypes)
- return output
- hostData = inputData[0]
- if inputTypes[0] == TYPE_STEREO:
- hostData = toMono(hostData)
- dutData = inputData[1]
- if inputTypes[1] == TYPE_STEREO:
- dutData = toMono(dutData)
- samplingRate = inputData[2]
- fLow = inputData[3]
- fHigh = inputData[4]
- margainLow = inputData[5]
- margainHigh = inputData[6]
- delay = 0
- N = 0
- hostData_ = hostData
- dutData_ = dutData
- if len(hostData) > len(dutData):
- delay = calc_delay.calc_delay(hostData, dutData)
- N = len(dutData)
- hostData_ = hostData[delay:delay+N]
- if len(hostData) < len(dutData):
- delay = calc_delay.calc_delay(dutData, hostData)
- N = len(hostData)
- dutData_ = dutData[delay:delay+N]
-
- print "delay ", delay, "deviceRecording samples ", N
- (passFail, minError, maxError, TF) = do_check_spectrum(hostData_, dutData_,\
- samplingRate, fLow, fHigh, margainLow, margainHigh)
-
- if passFail:
- output.append(RESULT_PASS)
- else:
- output.append(RESULT_OK)
- outputData.append(minError)
- outputTypes.append(TYPE_DOUBLE)
- outputData.append(maxError)
- outputTypes.append(TYPE_DOUBLE)
- outputData.append(TF)
- outputTypes.append(TYPE_MONO)
- output.append(outputData)
- output.append(outputTypes)
- return output
-
-# test code
-if __name__=="__main__":
- sys.path.append(sys.path[0])
- mod = __import__("gen_random")
- peakAmpl = 10000
- durationInMSec = 1000
- samplingRate = 44100
- fLow = 500
- fHigh = 15000
- data = getattr(mod, "do_gen_random")(peakAmpl, durationInMSec, samplingRate, fHigh,\
- stereo=False)
- print len(data)
- (passFail, minVal, maxVal, ampRatio) = do_check_spectrum(data, data, samplingRate, fLow, fHigh,\
- 1.0, 1.0)
- plt.plot(ampRatio)
- plt.show()
diff --git a/suite/audio_quality/test_description/processing/check_spectrum_playback.py b/suite/audio_quality/test_description/processing/check_spectrum_playback.py
deleted file mode 100644
index caef332..0000000
--- a/suite/audio_quality/test_description/processing/check_spectrum_playback.py
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from consts import *
-import numpy as np
-import scipy as sp
-import scipy.fftpack as fft
-import matplotlib.pyplot as plt
-import sys
-sys.path.append(sys.path[0])
-import calc_delay
-
-# check if amplitude of DUT's playback
-# lies in the given error boundary
-# input: host record
-# sampling rate
-# low frequency in Hz,
-# high frequency in Hz,
-# allowed error in negative side for pass in %,
-# allowed error ih positive side for pass
-# output: min value in negative side, normalized to 1.0
-# max value in positive side
-# calculated freq spectrum in amplittude
-
-def do_check_spectrum_playback(hostData, samplingRate, fLow, fHigh, margainLow, margainHigh):
- # reduce FFT resolution to have averaging effects
- N = 512 if (len(hostData) > 512) else len(hostData)
- iLow = N * fLow / samplingRate + 1 # 1 for DC
- if iLow > (N / 2 - 1):
- iLow = (N / 2 - 1)
- iHigh = N * fHigh / samplingRate + 1 # 1 for DC
- if iHigh > (N / 2 + 1):
- iHigh = N / 2 + 1
- print fLow, iLow, fHigh, iHigh, samplingRate
-
- Phh, freqs = plt.psd(hostData, NFFT=N, Fs=samplingRate, Fc=0, detrend=plt.mlab.detrend_none,\
- window=plt.mlab.window_hanning, noverlap=0, pad_to=None, sides='onesided',\
- scale_by_freq=False)
- print len(Phh)
- print "Phh", abs(Phh[iLow:iHigh])
- spectrum = np.sqrt(abs(Phh[iLow:iHigh]))
- spectrumMean = np.mean(spectrum)
- spectrum = spectrum / spectrumMean
- print "Mean ", spectrumMean
- print "Normalized spectrum", spectrum
- positiveMax = abs(max(spectrum))
- negativeMin = abs(min(spectrum))
- passFail = True if (positiveMax < (margainHigh / 100.0 + 1.0)) and\
- ((1.0 - negativeMin) < margainLow / 100.0) else False
- spectrumResult = np.zeros(len(spectrum), dtype=np.int16)
- for i in range(len(spectrum)):
- spectrumResult[i] = spectrum[i] * 1024 # make fixed point
- print "positiveMax", positiveMax, "negativeMin", negativeMin
- return (passFail, negativeMin, positiveMax, spectrumResult)
-
-def check_spectrum_playback(inputData, inputTypes):
- output = []
- outputData = []
- outputTypes = []
- # basic validate
- inputError = False
- if (inputTypes[0] != TYPE_MONO):
- inputError = True
- if (inputTypes[1] != TYPE_I64):
- inputError = True
- if (inputTypes[2] != TYPE_I64):
- inputError = True
- if (inputTypes[3] != TYPE_I64):
- inputError = True
- if (inputTypes[4] != TYPE_DOUBLE):
- inputError = True
- if (inputTypes[5] != TYPE_DOUBLE):
- inputError = True
- if inputError:
- output.append(RESULT_ERROR)
- output.append(outputData)
- output.append(outputTypes)
- return output
- hostData = inputData[0]
- samplingRate = inputData[1]
- fLow = inputData[2]
- fHigh = inputData[3]
- margainLow = inputData[4]
- margainHigh = inputData[5]
- (passFail, minError, maxError, Spectrum) = do_check_spectrum_playback(hostData, \
- samplingRate, fLow, fHigh, margainLow, margainHigh)
-
- if passFail:
- output.append(RESULT_PASS)
- else:
- output.append(RESULT_OK)
- outputData.append(minError)
- outputTypes.append(TYPE_DOUBLE)
- outputData.append(maxError)
- outputTypes.append(TYPE_DOUBLE)
- outputData.append(Spectrum)
- outputTypes.append(TYPE_MONO)
- output.append(outputData)
- output.append(outputTypes)
- return output
-
-# test code
-if __name__=="__main__":
- sys.path.append(sys.path[0])
- mod = __import__("gen_random")
- peakAmpl = 10000
- durationInMSec = 1000
- samplingRate = 44100
- fLow = 500
- fHigh = 15000
- data = getattr(mod, "do_gen_random")(peakAmpl, durationInMSec, samplingRate, fHigh,\
- stereo=False)
- print len(data)
- (passFail, minVal, maxVal, amp) = do_check_spectrum_playback(data, samplingRate, fLow,\
- fHigh, 1.0, 1.0)
- plt.plot(amp)
- plt.show()
diff --git a/suite/audio_quality/test_description/processing/consts.py b/suite/audio_quality/test_description/processing/consts.py
deleted file mode 100644
index 3b643a9..0000000
--- a/suite/audio_quality/test_description/processing/consts.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# consts to be used in signal processing functions
-
-# types of data for input / output
-TYPE_I64 = 0
-TYPE_DOUBLE = 1
-TYPE_MONO = 2
-TYPE_STEREO = 3
-
-# result for the processing
-RESULT_OK = 0
-RESULT_CONTINUE = 1
-RESULT_BREAKONELOOP = 2
-RESULT_ERROR = 3
-RESULT_FAIL = 4
-RESULT_PASS = 5
diff --git a/suite/audio_quality/test_description/processing/example.py b/suite/audio_quality/test_description/processing/example.py
deleted file mode 100644
index cce697d..0000000
--- a/suite/audio_quality/test_description/processing/example.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from consts import *
-import numpy as np
-import scipy as sp
-
-# Example python script for signal processing in CTS audio
-# There should be a function with the same name as the script
-# Here, function example in example.py
-
-# inputData : list of inputs with different types like int64, double,
-# mono or stereo audio data
-# inputTypes: list of types for each input. Types are defined as TYPE_XXX
-# consts from consts.py
-# return value: 3 elements list
-# element 0 : execution result value as defined as RESULT_XXX in consts.py
-# element 1 : outputData
-# element 2 : outputTypes
-#
-# This example takes 2 stereo data, 2 mono data, 2 i64, and 2 doubles
-# and returns average as 1 stereo data, 1 mono data, 1 i64, and 1 double
-# inputTypes for this function is expected to be
-# [ TYPE_STEREO, TYPE_STEREO, TYPE_MONO, TYPE_MONO, TYPE_I64, TYPE_I64,
-# TYPE_DOUBLE, TYPE_DOUBLE ]
-# outputTypes will be [ TYPE_STEREO, TYPE_MONO, TYPE_I64, TYPE_DOUBLE ]
-def example(inputData, inputTypes):
- output = []
- outputData = []
- outputTypes = []
- stereoInt = (inputData[0].astype(int) + inputData[1].astype(int))/2
- stereo = stereoInt.astype(np.int16)
- #print len(inputData[0]), len(inputData[1]), len(stereoInt), len(stereo)
- monoInt = (inputData[2].astype(int) + inputData[3].astype(int))/2
- mono = monoInt.astype(np.int16)
- #print len(inputData[2]), len(inputData[3]), len(monoInt), len(mono)
- i64Val = (inputData[4] + inputData[5])/2
- doubleVal = (inputData[6] + inputData[7])/2
- outputData.append(stereo)
- outputTypes.append(TYPE_STEREO)
- outputData.append(mono)
- outputTypes.append(TYPE_MONO)
- outputData.append(i64Val)
- outputTypes.append(TYPE_I64)
- outputData.append(doubleVal)
- outputTypes.append(TYPE_DOUBLE)
- output.append(RESULT_OK)
- output.append(outputData)
- output.append(outputTypes)
-
- return output
diff --git a/suite/audio_quality/test_description/processing/gen_random.py b/suite/audio_quality/test_description/processing/gen_random.py
deleted file mode 100644
index 5548242..0000000
--- a/suite/audio_quality/test_description/processing/gen_random.py
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from consts import *
-import numpy as np
-import scipy as sp
-import scipy.fftpack as fft
-import matplotlib.pyplot as plt
-
-# generate random signal with max freq
-# Input: peak amplitude,
-# duration in msec,
-# sampling rate HZ
-# high frequency,
-# Output: generated sound (stereo)
-
-def do_gen_random(peakAmpl, durationInMSec, samplingRate, fHigh, stereo=True):
- samples = durationInMSec * samplingRate / 1000
- result = np.zeros(samples * 2 if stereo else samples, dtype=np.int16)
- randomSignal = np.random.normal(scale = peakAmpl * 2 / 3, size=samples)
- fftData = fft.rfft(randomSignal)
- freqSamples = samples/2
- iHigh = freqSamples * fHigh * 2 / samplingRate + 1
- #print len(randomSignal), len(fftData), fLow, fHigh, iHigh
- if iHigh > freqSamples - 1:
- iHigh = freqSamples - 1
- fftData[0] = 0 # DC
- for i in range(iHigh, freqSamples - 1):
- fftData[ 2 * i + 1 ] = 0
- fftData[ 2 * i + 2 ] = 0
- if (samples - 2 *freqSamples) != 0:
- fftData[samples - 1] = 0
-
- filteredData = fft.irfft(fftData)
- #freq = np.linspace(0.0, samplingRate, num=len(fftData), endpoint=False)
- #plt.plot(freq, abs(fft.fft(filteredData)))
- #plt.plot(filteredData)
- #plt.show()
- if stereo:
- for i in range(len(filteredData)):
- result[2 * i] = filteredData[i]
- result[2 * i + 1] = filteredData[i]
- else:
- for i in range(len(filteredData)):
- result[i] = filteredData[i]
- return result
-
-
-def gen_random(inputData, inputTypes):
- output = []
- outputData = []
- outputTypes = []
- # basic validate
- inputError = False
- if (inputTypes[0] != TYPE_I64):
- inputError = True
- if (inputTypes[1] != TYPE_I64):
- inputError = True
- if (inputTypes[2] != TYPE_I64):
- inputError = True
- if (inputTypes[3] != TYPE_I64):
- inputError = True
- if inputError:
- output.append(RESULT_ERROR)
- output.append(outputData)
- output.append(outputTypes)
- return output
-
- result = do_gen_random(inputData[0], inputData[1], inputData[2], inputData[3])
-
- output.append(RESULT_OK)
- outputData.append(result)
- outputTypes.append(TYPE_STEREO)
- output.append(outputData)
- output.append(outputTypes)
- return output
-
-# test code
-if __name__=="__main__":
- peakAmplitude = 10000
- samplingRate = 44100
- durationInMSec = 10000
- #fLow = 500
- fHigh = 15000
- result = do_gen_random(peakAmplitude, durationInMSec, samplingRate, fHigh)
- plt.plot(result)
- plt.show()
diff --git a/suite/audio_quality/test_description/processing/playback_sample.py b/suite/audio_quality/test_description/processing/playback_sample.py
deleted file mode 100644
index d9c462a..0000000
--- a/suite/audio_quality/test_description/processing/playback_sample.py
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from consts import *
-
-# Sample test for dut_playback_sample case
-# Input: host recording (mono),
-# frequency of sine in Hz (i64)
-# pass level threshold (double)
-# Output: device (double) frequency
-
-def playback_sample(inputData, inputTypes):
- output = []
- outputData = []
- outputTypes = []
- # basic validate
- inputError = False
- if (inputTypes[0] != TYPE_MONO):
- inputError = True
- if (inputTypes[1] != TYPE_I64):
- inputError = True
- if (inputTypes[2] != TYPE_DOUBLE):
- inputError = True
- if inputError:
- output.append(RESULT_ERROR)
- output.append(outputData)
- output.append(outputTypes)
- return output
-
- hostRecording = inputData[0]
- signalFrequency = inputData[1]
- threshold = inputData[2]
- samplingRate = 44100
-
- freq = calc_freq(hostRecording, samplingRate)
- print "Expected Freq ", signalFrequency, "Actual Freq ", freq, "Threshold % ", threshold
- diff = abs(freq - signalFrequency)
- if (diff < threshold):
- output.append(RESULT_PASS)
- else:
- output.append(RESULT_OK)
- outputData.append(freq)
- outputTypes.append(TYPE_DOUBLE)
- output.append(outputData)
- output.append(outputTypes)
- return output
-
-def calc_freq(recording, samplingRate):
- #This would calculate the frequency of recording, but is skipped in this sample test for brevity
- return 32000
\ No newline at end of file
diff --git a/suite/audio_quality/test_description/processing/playback_thd.py b/suite/audio_quality/test_description/processing/playback_thd.py
deleted file mode 100644
index af490bc..0000000
--- a/suite/audio_quality/test_description/processing/playback_thd.py
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from consts import *
-import numpy as np
-import scipy as sp
-from calc_thd import *
-import calc_delay
-
-# calculate THD for dut_playback_thd case
-# Input: host recording (mono),
-# frequency of sine in Hz (i64)
-# THD pass level in percentile (double)
-# Output: THD device (double) in percentile
-
-def playback_thd(inputData, inputTypes):
- output = []
- outputData = []
- outputTypes = []
- # basic validate
- inputError = False
- if (inputTypes[0] != TYPE_MONO):
- inputError = True
- if (inputTypes[1] != TYPE_I64):
- inputError = True
- if (inputTypes[2] != TYPE_DOUBLE):
- inputError = True
- if inputError:
- output.append(RESULT_ERROR)
- output.append(outputData)
- output.append(outputTypes)
- return output
-
- hostRecording = inputData[0]
- signalFrequency = inputData[1]
- thdPassPercentile = inputData[2]
- samplingRate = 44100
-
- thd = calc_thd(hostRecording, signalFrequency, samplingRate, 0.02) * 100
- print "THD %", thd, "Margain % ", thdPassPercentile
- if (thd < thdPassPercentile):
- output.append(RESULT_PASS)
- else:
- output.append(RESULT_OK)
- outputData.append(thd)
- outputTypes.append(TYPE_DOUBLE)
- output.append(outputData)
- output.append(outputTypes)
- return output
diff --git a/suite/audio_quality/test_description/processing/recording_thd.py b/suite/audio_quality/test_description/processing/recording_thd.py
deleted file mode 100644
index c0251b5..0000000
--- a/suite/audio_quality/test_description/processing/recording_thd.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from consts import *
-import numpy as np
-import scipy as sp
-from calc_thd import *
-import calc_delay
-
-# calculate THD for dut_recording_thd case
-# Input: host recording (mono), device recording (mono),
-# frequency of sine in Hz (i64)
-# THD pass level in percentile (double)
-# Output:THD host (double), THD device (double) in percentile
-# host recording will be longer than device recording
-# the function works in following steps:
-# 1. match the start of device recording with host recording
-# As the host recording starts eariler and longer than device recording,
-# matching process is required.
-# 2. calculate THD of host recording and client recording
-# 3. check pass/fail
-
-def recording_thd(inputData, inputTypes):
- output = []
- outputData = []
- outputTypes = []
- # basic validate
- inputError = False
- if (inputTypes[0] != TYPE_MONO):
- inputError = True
- if (inputTypes[1] != TYPE_MONO):
- inputError = True
- if (inputTypes[2] != TYPE_I64):
- inputError = True
- if (inputTypes[3] != TYPE_DOUBLE):
- inputError = True
- if inputError:
- output.append(RESULT_ERROR)
- output.append(outputData)
- output.append(outputTypes)
- return output
-
- hostRecording = inputData[0]
- deviceRecording = inputData[1]
- signalFrequency = inputData[2]
- thdPassPercentile = inputData[3]
- samplingRate = 44100
-
- delay = calc_delay.calc_delay(hostRecording, deviceRecording)
- N = len(deviceRecording)
- print "delay ", delay, "deviceRecording samples ", N
- thdHost = calc_thd(hostRecording[delay:delay+N], signalFrequency, samplingRate, 0.02) * 100
- thdDevice = calc_thd(deviceRecording, signalFrequency, samplingRate, 0.02) * 100
- print "THD Host %", thdHost, "THD device %", thdDevice, "Margain % ", thdPassPercentile
- if (thdDevice < (thdHost + thdPassPercentile)) and (thdHost < thdPassPercentile):
- output.append(RESULT_PASS)
- else:
- output.append(RESULT_OK)
- outputData.append(thdHost)
- outputTypes.append(TYPE_DOUBLE)
- outputData.append(thdDevice)
- outputTypes.append(TYPE_DOUBLE)
- output.append(outputData)
- output.append(outputTypes)
- return output
diff --git a/suite/audio_quality/test_description/processing_main.py b/suite/audio_quality/test_description/processing_main.py
deleted file mode 100644
index b5075fd..0000000
--- a/suite/audio_quality/test_description/processing_main.py
+++ /dev/null
@@ -1,219 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import sys
-import numpy as np
-import scipy as sp
-import socket
-import struct
-sys.path.append(sys.path[0] + "/processing")
-from consts import *
-
-builtinFunctions = [
- "echo", # send back whatever is received
- "intsum", # returns int64 + int64
-]
-
-CMD_HEADER = 0x0
-CMD_TERMINATE = 0x1
-CMD_FUNCTION = 0x2
-CMD_AUDIO_MONO = 0x4
-CMD_AUDIO_STEREO = 0x5
-CMD_INT64 = 0x8
-CMD_DOUBLE = 0x9
-CMD_RESULT = 0x10
-
-def echo(inputData, inputTypes):
- output = []
- print "echo received ", inputData
- output.append(RESULT_OK)
- output.append(inputData)
- output.append(inputTypes)
- return output
-
-def intsum(inputData, inputTypes):
- output = []
- output.append(RESULT_OK)
- sum = inputData[0] + inputData[1]
- print "intsum sum is ", sum
- outputData = []
- outputData.append(sum)
- outputTypes = []
- outputTypes.append(TYPE_I64)
- output.append(outputData)
- output.append(outputTypes)
- return output
-
-
-class CommandHandler(object):
-
- def __init__(self, conn):
- self.conn = conn
- def __del__(self):
- self.conn.close()
- def run(self):
- header = self.readI32()
- if header == CMD_TERMINATE:
- print "terminate cmd, will exit"
- sys.exit(0)
- nParam = 0
- if header == CMD_HEADER:
- nParam = self.readI32()
- if nParam < 1:
- protocolError("wrong number of params")
- cmdFunction = self.readI32()
- if cmdFunction != CMD_FUNCTION:
- protocolError("not function")
- nameLen = self.readI32()
- self.functionName = self.readRaw(nameLen)
- print "Processing function:", self.functionName
- inputData = []
- inputTypes = []
- for i in range(nParam - 1):
- cmd = self.readI32()
- if (cmd == CMD_AUDIO_STEREO) or (cmd == CMD_AUDIO_MONO):
- dataLen = self.readI32()
- data = self.readI16Array(dataLen / 2)
- inputData.append(data)
- if (cmd == CMD_AUDIO_STEREO):
- inputTypes.append(TYPE_STEREO)
- else:
- inputTypes.append(TYPE_MONO)
- print i, "-th input received audio data ", dataLen, cmd
- elif cmd == CMD_INT64:
- i64 = self.readI64()
- inputData.append(i64)
- inputTypes.append(TYPE_I64)
- elif cmd == CMD_DOUBLE:
- val = self.readDouble()
- inputData.append(val)
- inputTypes.append(TYPE_DOUBLE)
- else:
- self.protocolError("unknown command " + str(cmd))
- print "inputTypes ", inputTypes
- # length 3 list
- # output[0]: int, execution result, RESULT_XXX values
- # output[1]: output data list
- # output[2]: output type list
- output = []
- if not self.functionName in builtinFunctions:
- mod = __import__(self.functionName)
- output = getattr(mod, self.functionName)(inputData, inputTypes)
- else:
- output = globals()[self.functionName](inputData, inputTypes)
- nOutputParams = len(output[1])
- self.sendI32(CMD_HEADER)
- self.sendI32(nOutputParams + 1) # 1 for result
- self.sendI32(CMD_RESULT)
- self.sendI32(output[0])
- outputData = output[1]
- outputTypes = output[2]
- print "outputTypes ", outputTypes
- for i in range(nOutputParams):
- if (outputTypes[i] == TYPE_I64):
- self.sendI32(CMD_INT64)
- self.sendI64(outputData[i])
- elif (outputTypes[i] == TYPE_DOUBLE):
- self.sendI32(CMD_DOUBLE)
- self.sendDouble(outputData[i])
- elif (outputTypes[i] == TYPE_STEREO):
- self.sendI32(CMD_AUDIO_STEREO)
- self.sendI32(len(outputData[i]) * 2)
- self.sendI16Array(outputData[i])
- elif (outputTypes[i] == TYPE_MONO):
- self.sendI32(CMD_AUDIO_MONO)
- self.sendI32(len(outputData[i]) * 2)
- self.sendI16Array(outputData[i])
- else:
- print "unknown type ", outputTypes[i], \
- " returned from funcion ", self.functionName
- sys.exit(1)
-
- def readRaw(self, length):
- result = []
- totalRead = 0
- while totalRead < length:
- raw = self.conn.recv(length - totalRead)
- justRead = len(raw)
- if justRead == 0: # socket closed
- sys.exit(1)
- totalRead += justRead
- result.append(raw)
- return ''.join(result)
-
- def readI32(self):
- raw = self.readRaw(4)
- i32 = struct.unpack("<i", raw)
- return i32[0]
-
- def readI64(self):
- raw = self.readRaw(8)
- i64 = struct.unpack("<q", raw)
- return i64[0]
-
- def readDouble(self):
- raw = self.readRaw(8)
- val = struct.unpack("<d", raw)
- return val[0]
-
- def readI16Array(self, length):
- raw = self.readRaw(length * 2)
- data = np.fromstring(raw, dtype=np.int16)
- return data
-
- def sendI32(self, i32):
- raw = struct.pack("<i", i32)
- self.sendRaw(raw)
-
- def sendI64(self, i64):
- raw = struct.pack("<q", i64)
- self.sendRaw(raw)
-
- def sendDouble(self, val):
- raw = struct.pack("<d", val)
- self.sendRaw(raw)
-
- def sendI16Array(self, arry):
- raw = arry.tostring()
- self.sendRaw(raw)
-
- def sendRaw(self, rawString):
- totalSent = 0
- stringLen = len(rawString)
- while totalSent < stringLen:
- sent = self.conn.send(rawString[totalSent:])
- totalSent += sent
-
- def protocolError(self, message):
- print message
- sys.exit(1)
-
-
-if __name__=="__main__":
- HOST = "localhost"
- PORT = 15010
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- s.bind((HOST, PORT))
- s.listen(1)
-
- conn, addr = s.accept()
- print "client connected"
- # close the server socket to allow other instance to run
- s.close()
- handler = CommandHandler(conn)
- while 1:
- handler.run()
diff --git a/suite/audio_quality/test_description/review/review_dut_recording_spectrum.xml b/suite/audio_quality/test_description/review/review_dut_recording_spectrum.xml
deleted file mode 100644
index b8157be..0000000
--- a/suite/audio_quality/test_description/review/review_dut_recording_spectrum.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="review_dut_recording_spectrum" version="1.0" description="Review">
- <setup>
- <sound id="sound_host_0" type="file:reports/2012_05_14_09_27_40/dut_recording_spectrum/host_in_0.r2m" />
- <sound id="sound_dut_0" type="file:reports/2012_05_14_09_27_40/dut_recording_spectrum/dut_in_0.r2m" />
- <sound id="sound_host_1" type="file:reports/2012_05_14_09_27_40/dut_recording_spectrum/host_in_1.r2m" />
- <sound id="sound_dut_1" type="file:reports/2012_05_14_09_27_40/dut_recording_spectrum/dut_in_1.r2m" />
- <sound id="sound_host_2" type="file:reports/2012_05_14_09_27_40/dut_recording_spectrum/host_in_2.r2m" />
- <sound id="sound_dut_2" type="file:reports/2012_05_14_09_27_40/dut_recording_spectrum/dut_in_2.r2m" />
- <sound id="sound_host_3" type="file:reports/2012_05_14_09_27_40/dut_recording_spectrum/host_in_3.r2m" />
- <sound id="sound_dut_3" type="file:reports/2012_05_14_09_27_40/dut_recording_spectrum/dut_in_3.r2m" />
- <sound id="sound_host_4" type="file:reports/2012_05_14_09_27_40/dut_recording_spectrum/host_in_4.r2m" />
- <sound id="sound_dut_4" type="file:reports/2012_05_14_09_27_40/dut_recording_spectrum/dut_in_4.r2m" />
- </setup>
- <action>
- <sequential repeat="5" index="k">
- <!-- input: host record, device record, samping rate, low frequency in Hz, high frequency in Hz, allowed error for pass in smaller side, allowed error in bigger side%, output: min value in lower side calculated normalized to 1.0, max value in higher side, calculated TF in mannitude only between low f to high f -->
- <process method="script:check_spectrum" input="id:sound_host_$k,id:sound_dut_$k,consti:44100,consti:200,consti:4000,constf:50.0,constf:100.0" output="val:min_val_$k,val:max_val_$k,id:tf_$k" />
- </sequential>
- </action>
- <save report="min_val_.*,max_val_.*" />
-</case>
diff --git a/suite/audio_quality/test_description/test/dut_speaker_play.xml b/suite/audio_quality/test_description/test/dut_speaker_play.xml
deleted file mode 100644
index d2e35e8..0000000
--- a/suite/audio_quality/test_description/test/dut_speaker_play.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="dut_speaker_play" version="1.0" description="Play DUT speaker for some time">
- <setup> <!-- 1 setup -->
- <!-- prepare sound source id: to be used in output, sine 1000Hz, 20000ms long -->
- <sound id="sound1" type="sin:32000:100:5000" preload="1" />
- </setup>
-
-
- <action> <!-- 1 action -->
- <!-- equivalent of for loop. all children will be completed before moving to the next
- stage.repeat up to 100 times unless stopped by some condition -->
- <sequential repeat="20" index="i">
- <!-- sync start : execute only sync complete : execute + complete
- For sync start, complete will be called when the parent completes -->
- <output device="DUT" id="sound1" gain="100" sync="start" waitforcompletion="1" />
- </sequential>
- </action>
-</case>
diff --git a/suite/audio_quality/test_description/test/missing_mandatory.xml b/suite/audio_quality/test_description/test/missing_mandatory.xml
deleted file mode 100644
index d245a2f..0000000
--- a/suite/audio_quality/test_description/test/missing_mandatory.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="host_speaker_calibration" version="1.0" description="Calibrate host speaker's volume.">
- <action>
- <sequential repeat="100" index="i">
- <output device="host" id="sound1" gain="70" sync="start"/>
- <sequential repeat="20" index=j>
- <input device="host" id="host_in" gain="70" time="1000" sync="complete" />
- <process method="builtin:rms_passfail" input="id:host_in" output="val:rms_$i_$j,val:passfail" />
- <message input="val:passfail" output_low="Volume Low" output_ok="Volume OK" output_high="Volume High" />
- </sequential>
- </sequential>
- </action>
- <save file="host_in" report="rms_.*" />
-</case>
\ No newline at end of file
diff --git a/suite/audio_quality/test_description/test/no_attrib.xml b/suite/audio_quality/test_description/test/no_attrib.xml
deleted file mode 100644
index a5aba05..0000000
--- a/suite/audio_quality/test_description/test/no_attrib.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case>
- <setup>
- <sound />
- </setup>
-
- <action>
- <sequential>
- <output />
- <sequential >
- <input />
- <process />
- <message />
- </sequential>
- </sequential>
- </action>
- <save />
-</case>
\ No newline at end of file
diff --git a/suite/audio_quality/test_description/test/short1.r2s b/suite/audio_quality/test_description/test/short1.r2s
deleted file mode 100644
index 78a68a8..0000000
--- a/suite/audio_quality/test_description/test/short1.r2s
+++ /dev/null
Binary files differ
diff --git a/suite/audio_quality/test_description/test/test_io.xml b/suite/audio_quality/test_description/test/test_io.xml
deleted file mode 100644
index 60aac3f..0000000
--- a/suite/audio_quality/test_description/test/test_io.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="test_io" version="1.0" description="Test Input / Output">
- <setup> <!-- 1 setup -->
- <!-- prepare sound source id: to be used in output, sine 1000Hz, 1000ms long -->
- <sound id="sound1" type="sin:10000:1000:1000" preload="1" />
- </setup>
-
- <action> <!-- 1 action -->
- <!-- equivalent of for loop. all children will be completed before moving to the next
- stage.repeat up to 100 times unless stopped by some condition -->
- <sequential repeat="1" index="i">
- <output device="host" id="sound1" gain="100" sync="start"/>
- <output device="DUT" id="sound1" gain="100" sync="start"/>
- <input device="host" id="host1" gain="100" time="500" sync="start"/>
- <input device="DUT" id="device1" gain="100" time="500" sync="start"/>
- </sequential>
- <sequential repeat="1" index="i2">
- <process method="builtin:rms_mva" input="id:host1,consti:0,consti:0" output="val:rms_host" />
- <process method="builtin:rms_mva" input="id:device1,consti:0,consti:20000" output="val:rms_device" />
- </sequential>
- </action>
- <save file="host1,device1" report="rms_.*"/>
-</case>
diff --git a/suite/audio_quality/test_description/test/test_rms_vma.xml b/suite/audio_quality/test_description/test/test_rms_vma.xml
deleted file mode 100644
index 163ddad..0000000
--- a/suite/audio_quality/test_description/test/test_rms_vma.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="test_rms_vma" version="1.0" description="Test built-in rms_vma">
- <setup> <!-- 1 setup -->
- <!-- prepare sound source id: to be used in output, sine 1000Hz, 20000ms long -->
- <sound id="sound1" type="sin:100:1000:20000" />
- </setup>
-
- <action> <!-- 1 action -->
- <!-- equivalent of for loop. all children will be completed before moving to the next
- stage.repeat up to 100 times unless stopped by some condition -->
- <sequential repeat="10" index="i">
- <sequential repeat="10" index="j">
- <process method="builtin:rms_mva" input="id:sound1,consti:1000,consti:2000" output="val:rms_$i_$j" />
- </sequential>
- </sequential>
- </action>
- <save file="sound1" report="rms_.*"/>
-</case>
\ No newline at end of file
diff --git a/suite/audio_quality/test_description/test/unknown_element.xml b/suite/audio_quality/test_description/test/unknown_element.xml
deleted file mode 100644
index ae5eaa1..0000000
--- a/suite/audio_quality/test_description/test/unknown_element.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="host_speaker_calibration" version="1.0" description="Calibrate host speaker's volume.">
- <setup>
- <sound id="sound1" type="sin:100:1000:20000" unsupprotedattrib="should fail" />
- </setup>
-
- <action>
- <sequential repeat="100" index="i">
- </sequential>
- </action>
- <nosuchelement />
-</case>
\ No newline at end of file
diff --git a/suite/audio_quality/test_description/test/wrong_attrib.xml b/suite/audio_quality/test_description/test/wrong_attrib.xml
deleted file mode 100644
index 0c7c95c..0000000
--- a/suite/audio_quality/test_description/test/wrong_attrib.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<case name="host_speaker_calibration" version="1.0" description="Calibrate host speaker's volume." unsupprotedattrib="should fail">
- <setup unsupprotedattrib="should fail">
- <sound id="sound1" type="sin:100:1000:20000" unsupprotedattrib="should fail" />
- </setup>
-
- <action unsupprotedattrib="should fail">
- <sequential repeat="100" index="i" unsupprotedattrib="should fail">
- </sequential>
- </action>
- <save file="host_in" report="rms_.*" unsupprotedattrib="should fail"/>
-</case>
\ No newline at end of file
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-h360dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-h360dp/strings.xml
index b17566c..e37a5d6 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-h360dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">h360dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-h400dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-h400dp/strings.xml
index b17566c..329841e 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-h400dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">h400dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-h480dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-h480dp/strings.xml
index b17566c..77a1a6e 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-h480dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">h480dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-h540dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-h540dp/strings.xml
index b17566c..7bf32c5 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-h540dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">h540dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-h600dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-h600dp/strings.xml
index b17566c..21504a1 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-h600dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">h600dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-h720dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-h720dp/strings.xml
index b17566c..2c01735 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-h720dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">h720dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-sw1024dp/strings.xml
similarity index 76%
rename from suite/audio_quality/client/res/values/strings.xml
rename to tests/framework/base/windowmanager/res/values-sw1024dp/strings.xml
index b17566c..21916b7 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-sw1024dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">sw1024dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-sw360dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-sw360dp/strings.xml
index b17566c..1d97d27 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-sw360dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">sw360dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-sw400dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-sw400dp/strings.xml
index b17566c..42b5c49 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-sw400dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">sw400dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-sw480dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-sw480dp/strings.xml
index b17566c..239f423 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-sw480dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">sw480dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-sw540dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-sw540dp/strings.xml
index b17566c..f770b4b 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-sw540dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">sw540dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-sw600dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-sw600dp/strings.xml
index b17566c..4349549 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-sw600dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">sw600dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-sw720dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-sw720dp/strings.xml
index b17566c..3071d5d 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-sw720dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">sw720dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-sw800dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-sw800dp/strings.xml
index b17566c..0baa47e 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-sw800dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">sw800dp</string>
+</resources>
diff --git a/suite/audio_quality/client/res/values/strings.xml b/tests/framework/base/windowmanager/res/values-sw900dp/strings.xml
similarity index 76%
copy from suite/audio_quality/client/res/values/strings.xml
copy to tests/framework/base/windowmanager/res/values-sw900dp/strings.xml
index b17566c..69dd2e5 100644
--- a/suite/audio_quality/client/res/values/strings.xml
+++ b/tests/framework/base/windowmanager/res/values-sw900dp/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,6 +14,6 @@
limitations under the License.
-->
-<resources>
- <string name="app_name">CtsAudioClient</string>
-</resources>
\ No newline at end of file
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="for_generate_size_configuration">sw900dp</string>
+</resources>
diff --git a/tests/tests/bionic_app/Android.bp b/tests/tests/bionic_app/Android.bp
index bde208e..78d7343 100644
--- a/tests/tests/bionic_app/Android.bp
+++ b/tests/tests/bionic_app/Android.bp
@@ -5,7 +5,10 @@
cc_test_library {
name: "libbionic_app_jni",
sdk_version: "current",
- srcs: ["bionic_app_jni.cpp"],
+ srcs: [
+ "bionic_app_jni.cpp",
+ "main.cpp",
+ ],
cflags: [
"-Wall",
"-Werror",
diff --git a/tests/tests/bionic_app/bionic_app_jni.cpp b/tests/tests/bionic_app/bionic_app_jni.cpp
index 1cda5d7..e9f7cf6 100644
--- a/tests/tests/bionic_app/bionic_app_jni.cpp
+++ b/tests/tests/bionic_app/bionic_app_jni.cpp
@@ -14,10 +14,33 @@
* limitations under the License.
*/
+#include <android/set_abort_message.h>
+#include <dlfcn.h>
#include <jni.h>
+#include <stdio.h>
+#include <stdlib.h>
extern "C" const char* __progname;
extern "C" jstring Java_com_android_bionic_1app_BionicAppTest_progname(JNIEnv* env) {
return env->NewStringUTF(__progname);
}
+
+extern "C" int main(int argc, char* argv[]);
+
+extern "C" jint Java_com_android_bionic_1app_BionicAppTest_callMainDirect(JNIEnv* env __unused) {
+ return main(0, nullptr);
+}
+
+// Having a variant of the test that uses dlsym is helpful to ensure that main isn't accidentally
+// hidden in the app's DSO.
+extern "C" jint Java_com_android_bionic_1app_BionicAppTest_callMainDlsym(JNIEnv* env __unused) {
+ auto pmain = reinterpret_cast<int(*)(int, char**)>(dlsym(RTLD_DEFAULT, "main"));
+ if (pmain == nullptr) {
+ char msg[256];
+ snprintf(msg, sizeof(msg), "dlsym(RTLD_DEFAULT, \"main\") was nullptr: %s", dlerror());
+ android_set_abort_message(msg);
+ abort();
+ }
+ return pmain(0, nullptr);
+}
diff --git a/tests/tests/bionic_app/com/android/bionic_app/BionicAppTest.java b/tests/tests/bionic_app/com/android/bionic_app/BionicAppTest.java
index 97a1f50..bf1be29 100644
--- a/tests/tests/bionic_app/com/android/bionic_app/BionicAppTest.java
+++ b/tests/tests/bionic_app/com/android/bionic_app/BionicAppTest.java
@@ -24,9 +24,17 @@
}
private native String progname();
+ private native int callMainDirect();
+ private native int callMainDlsym();
public void test__progname() {
// https://issuetracker.google.com/152893281
assertEquals("com.android.bionic_app", progname());
}
+
+ public void test__main() {
+ // http://b/190100879 - an app DSO can have a main function
+ assertEquals(42, callMainDirect());
+ assertEquals(42, callMainDlsym());
+ }
}
diff --git a/tests/tests/bionic_app/main.cpp b/tests/tests/bionic_app/main.cpp
new file mode 100644
index 0000000..d7d7040
--- /dev/null
+++ b/tests/tests/bionic_app/main.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sys/cdefs.h>
+
+// Some apps ship DSOs with a main function, and it works because the main function in app_process
+// isn't exported. Ensure that this keeps working. (http://b/190100879).
+//
+// This function is in a separate C++ file to try to guard against the -fno-semantic-interposition
+// optimization that Clang enables by default.
+extern "C" int main(int argc __unused, char* argv[] __unused) {
+ return 42;
+}
diff --git a/tests/tests/nativemidi/jni/Android.bp b/tests/tests/nativemidi/jni/Android.bp
new file mode 100644
index 0000000..34cdc3e
--- /dev/null
+++ b/tests/tests/nativemidi/jni/Android.bp
@@ -0,0 +1,42 @@
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+ // See: http://go/android-license-faq
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_test_library {
+ name: "libnativemidi_jni",
+ compile_multilib: "both",
+ srcs: ["native-lib.cpp"],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ "-O0",
+ ],
+ sdk_version: "current",
+ stl: "c++_static",
+ shared_libs: [
+ "libamidi",
+ "liblog",
+ "libnativehelper_compat_libc++",
+ "libmediandk",
+ ],
+ whole_static_libs: ["libnativetesthelper_jni"],
+ static: {
+ enabled: false,
+ },
+}
diff --git a/tests/tests/nativemidi/jni/Android.mk b/tests/tests/nativemidi/jni/Android.mk
deleted file mode 100644
index 52f889b..0000000
--- a/tests/tests/nativemidi/jni/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_MODULE := libnativemidi_jni
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_MULTILIB := both
-
-LOCAL_SRC_FILES := native-lib.cpp
-
-LOCAL_CFLAGS += -Wall -Wextra -Werror -O0
-
-LOCAL_SDK_VERSION := current
-LOCAL_NDK_STL_VARIANT := c++_static
-
-LOCAL_SHARED_LIBRARIES := libamidi liblog
-LOCAL_WHOLE_STATIC_LIBRARIES := libnativetesthelper_jni
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/neuralnetworks/Android.mk b/tests/tests/neuralnetworks/Android.mk
index d25d1c4..c55746f 100644
--- a/tests/tests/neuralnetworks/Android.mk
+++ b/tests/tests/neuralnetworks/Android.mk
@@ -43,4 +43,3 @@
include $(BUILD_CTS_EXECUTABLE)
include $(nnapi_cts_dir)/benchmark/Android.mk
-include $(nnapi_cts_dir)/tflite_delegate/Android.mk
diff --git a/tests/tests/neuralnetworks/tflite_delegate/Android.bp b/tests/tests/neuralnetworks/tflite_delegate/Android.bp
new file mode 100644
index 0000000..ec2e23c
--- /dev/null
+++ b/tests/tests/neuralnetworks/tflite_delegate/Android.bp
@@ -0,0 +1,56 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+ // See: http://go/android-license-faq
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+// The "CtsTfliteNnapiDelegateTests_static" has been moved to
+// external/tensorflow/Android.bp, due to the fact that the srcs files
+// are not in the current directory.
+
+// Build the actual CTS module with the static lib above.
+// This is necessary for the build system to pickup the AndroidTest.xml.
+
+cc_test {
+ name: "CtsTfliteNnapiDelegateTestCases",
+ compile_multilib: "both",
+ multilib: {
+ lib32: {
+ suffix: "32",
+ },
+ lib64: {
+ suffix: "64",
+ },
+ },
+ whole_static_libs: ["TfliteNnapiDelegateTests_static"],
+ shared_libs: [
+ "libandroid",
+ "liblog",
+ "libneuralnetworks",
+ ],
+ static_libs: [
+ "libgtest_ndk_c++",
+ "libtflite_static",
+ ],
+ // Tag this module as a cts test artifact
+ test_suites: [
+ "cts",
+ "mts",
+ "general-tests",
+ ],
+ sdk_version: "current",
+ stl: "c++_static",
+}
diff --git a/tests/tests/neuralnetworks/tflite_delegate/Android.mk b/tests/tests/neuralnetworks/tflite_delegate/Android.mk
deleted file mode 100644
index eb6f2c8..0000000
--- a/tests/tests/neuralnetworks/tflite_delegate/Android.mk
+++ /dev/null
@@ -1,80 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-my_dir := $(call my-dir)
-
-LOCAL_PATH:= external/tensorflow/
-include $(CLEAR_VARS)
-LOCAL_MODULE := CtsTfliteNnapiDelegateTests_static
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := \
- tensorflow/lite/delegates/nnapi/nnapi_delegate_test.cc \
- tensorflow/lite/kernels/test_util.cc \
- tensorflow/core/platform/default/logging.cc \
- tensorflow/core/platform/default/env_time.cc \
- tensorflow/lite/kernels/acceleration_test_util.cc \
- tensorflow/lite/kernels/acceleration_test_util_internal.cc \
- tensorflow/lite/delegates/nnapi/acceleration_test_list.cc \
- tensorflow/lite/delegates/nnapi/acceleration_test_util.cc
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_C_INCLUDES += external/flatbuffers/include
-LOCAL_C_INCLUDES += external/tensorflow
-LOCAL_C_INCLUDES += external/ruy
-
-LOCAL_CFLAGS := \
- -DPLATFORM_POSIX_ANDROID \
- -Wall \
- -Werror \
- -Wextra \
- -Wno-extern-c-compat \
- -Wno-sign-compare \
- -Wno-unused-parameter \
- -Wno-unused-private-field \
-
-LOCAL_SHARED_LIBRARIES := libandroid liblog libneuralnetworks
-LOCAL_STATIC_LIBRARIES := libgtest_ndk_c++ libgmock_ndk libtflite_static
-LOCAL_HEADER_LIBRARIES := libeigen gemmlowp_headers libtflite_schema_headers
-LOCAL_SDK_VERSION := current
-LOCAL_NDK_STL_VARIANT := c++_static
-include $(BUILD_STATIC_LIBRARY)
-
-
-# Build the actual CTS module with the static lib above.
-# This is necessary for the build system to pickup the AndroidTest.xml.
-LOCAL_PATH:= $(my_dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CtsTfliteNnapiDelegateTestCases
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_WHOLE_STATIC_LIBRARIES := CtsTfliteNnapiDelegateTests_static
-
-LOCAL_SHARED_LIBRARIES := libandroid liblog libneuralnetworks
-LOCAL_STATIC_LIBRARIES := libgtest_ndk_c++ libtflite_static
-LOCAL_CTS_TEST_PACKAGE := android.neuralnetworks
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts mts general-tests
-
-LOCAL_SDK_VERSION := current
-LOCAL_NDK_STL_VARIANT := c++_static
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/tests/tests/selinux/selinuxEphemeral/src/android/security/SELinuxTargetSdkTest.java b/tests/tests/selinux/selinuxEphemeral/src/android/security/SELinuxTargetSdkTest.java
index d642e45..9153b8a 100644
--- a/tests/tests/selinux/selinuxEphemeral/src/android/security/SELinuxTargetSdkTest.java
+++ b/tests/tests/selinux/selinuxEphemeral/src/android/security/SELinuxTargetSdkTest.java
@@ -85,8 +85,4 @@
public void testNoNetlinkRouteBind() throws IOException {
noNetlinkRouteBind();
}
-
- public void testNetworkInterface() throws Exception {
- checkNetworkInterfaceHardwareAddress_returnsNull();
- }
}
diff --git a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceConnector.java b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceConnector.java
index e2764f0..933d958 100644
--- a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceConnector.java
+++ b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceConnector.java
@@ -339,6 +339,10 @@
if (ImsUtils.VDBG) {
Log.d(TAG, "getDefaultSmsApp result: " + result);
}
+ if (result.isEmpty()) {
+ // No default SMS app.
+ return null;
+ }
// There should only be one default sms app
return result.get(0);
}
diff --git a/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/DefaultSmsAppHelper.java b/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/DefaultSmsAppHelper.java
index 8e9ecd4..0a433b0 100644
--- a/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/DefaultSmsAppHelper.java
+++ b/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/DefaultSmsAppHelper.java
@@ -25,6 +25,7 @@
import android.content.pm.PackageManager;
import android.os.Process;
import android.os.UserHandle;
+import android.telephony.TelephonyManager;
import androidx.test.core.app.ApplicationProvider;
@@ -35,7 +36,7 @@
class DefaultSmsAppHelper {
static void ensureDefaultSmsApp() {
- if (!hasTelephony()) {
+ if (!hasTelephony() || !hasSms()) {
return;
}
@@ -71,6 +72,9 @@
}
static void stopBeingDefaultSmsApp() {
+ if (!hasSms()) {
+ return;
+ }
Context context = ApplicationProvider.getApplicationContext();
String packageName = context.getPackageName();
@@ -110,4 +114,9 @@
Context context = ApplicationProvider.getApplicationContext();
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
}
+
+ static boolean hasSms() {
+ TelephonyManager telephonyManager = (TelephonyManager) ApplicationProvider.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
+ return telephonyManager.isSmsCapable();
+ }
}
diff --git a/tools/cts-tradefed/res/config/cts-on-gsi-exclude-non-hal.xml b/tools/cts-tradefed/res/config/cts-on-gsi-exclude-non-hal.xml
index 9f56bb8..0dd958f 100644
--- a/tools/cts-tradefed/res/config/cts-on-gsi-exclude-non-hal.xml
+++ b/tools/cts-tradefed/res/config/cts-on-gsi-exclude-non-hal.xml
@@ -53,6 +53,12 @@
<option name="compatibility:exclude-filter" value="CtsBackupTestCases" />
<option name="compatibility:exclude-filter" value="CtsBionicAppTestCases" />
<option name="compatibility:exclude-filter" value="CtsBionicTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsBlobStoreHostTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsBlobStoreHostTestHelper" />
+ <option name="compatibility:exclude-filter" value="CtsBlobStoreTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsBlobStoreTestHelper" />
+ <option name="compatibility:exclude-filter" value="CtsBlobStoreTestHelperDiffSig" />
+ <option name="compatibility:exclude-filter" value="CtsBlobStoreTestHelperDiffSig2" />
<option name="compatibility:exclude-filter" value="CtsBootStatsTestCases" />
<option name="compatibility:exclude-filter" value="CtsCalendarcommon2TestCases" />
<option name="compatibility:exclude-filter" value="CtsCalendarProviderTestCases" />
@@ -206,6 +212,8 @@
<option name="compatibility:exclude-filter" value="CtsLegacyNotification29TestCases" />
<option name="compatibility:exclude-filter" value="CtsLocationNoneTestCases" />
<option name="compatibility:exclude-filter" value="CtsNetTestCasesInternetPermission" />
+ <option name="compatibility:exclude-filter" value="CtsNoPermissionTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsNoPermissionTestCases25" />
<option name="compatibility:exclude-filter" value="CtsOsTestCases android.os.cts.StrictModeTest" />
<option name="compatibility:exclude-filter" value="CtsPackageInstallAppOpDefaultTestCases" />
<option name="compatibility:exclude-filter" value="CtsPackageInstallAppOpDeniedTestCases" />
@@ -214,10 +222,27 @@
<option name="compatibility:exclude-filter" value="CtsPackageUninstallTestCases" />
<option name="compatibility:exclude-filter" value="CtsPackageWatchdogTestCases" />
<option name="compatibility:exclude-filter" value="CtsProtoTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsRsBlasTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsRsCppTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSelinuxEphemeralTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSelinuxTargetSdk25TestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSelinuxTargetSdk27TestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSelinuxTargetSdk28TestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSelinuxTargetSdk29TestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSelinuxTargetSdkCurrentTestCases" />
<option name="compatibility:exclude-filter" value="CtsSimpleCpuTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSimpleperfTestCases" />
<option name="compatibility:exclude-filter" value="CtsSoundTriggerTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsStagedInstallHostTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsStrictJavaPackagesTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSuspendAppsPermissionTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSuspendAppsTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSustainedPerformanceHostTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsSyncAccountAccessOtherCertTestCases" />
<option name="compatibility:exclude-filter" value="CtsSystemIntentTestCases" />
<option name="compatibility:exclude-filter" value="CtsTelephony3TestCases" />
<option name="compatibility:exclude-filter" value="CtsThemeDeviceTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsToastLegacyTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsToastTestCases" />
</configuration>