From ecac1123237c610a1166b1e07b678d259e4d4e71 Mon Sep 17 00:00:00 2001 From: Michael Dooley Date: Fri, 28 Sep 2018 07:25:12 +0000 Subject: [PATCH] Revert "Adding getModelState to soundtrigger with build fix." This reverts commit 0320d560eaaaaf88ca84dfd6b22b1792904d986c. Reason for revert: broke build Change-Id: I69cda44f90985b57e69455a8d04cec71f2675831 --- .../2.0/default/SoundTriggerHalImpl.cpp | 2 +- .../2.0/default/SoundTriggerHalImpl.h | 5 +- soundtrigger/2.2/Android.bp | 20 --- soundtrigger/2.2/ISoundTriggerHw.hal | 40 ------ soundtrigger/2.2/default/Android.mk | 50 -------- soundtrigger/2.2/default/SoundTriggerHw.cpp | 110 ----------------- soundtrigger/2.2/default/SoundTriggerHw.h | 114 ------------------ soundtrigger/2.2/vts/functional/Android.bp | 29 ----- .../VtsHalSoundtriggerV2_2TargetTest.cpp | 101 ---------------- 9 files changed, 2 insertions(+), 469 deletions(-) delete mode 100644 soundtrigger/2.2/Android.bp delete mode 100644 soundtrigger/2.2/ISoundTriggerHw.hal delete mode 100644 soundtrigger/2.2/default/Android.mk delete mode 100644 soundtrigger/2.2/default/SoundTriggerHw.cpp delete mode 100644 soundtrigger/2.2/default/SoundTriggerHw.h delete mode 100644 soundtrigger/2.2/vts/functional/Android.bp delete mode 100644 soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp diff --git a/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp b/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp index 2de35e8a0d..612772cc63 100644 --- a/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp +++ b/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp @@ -247,7 +247,7 @@ exit: } SoundTriggerHalImpl::SoundTriggerHalImpl() - : mModuleName("primary"), mNextModelId(1), mHwDevice(NULL) {} + : mModuleName("primary"), mHwDevice(NULL), mNextModelId(1) {} void SoundTriggerHalImpl::onFirstRef() { const hw_module_t* mod; diff --git a/soundtrigger/2.0/default/SoundTriggerHalImpl.h b/soundtrigger/2.0/default/SoundTriggerHalImpl.h index fbe24c15d9..5a9f0e19af 100644 --- a/soundtrigger/2.0/default/SoundTriggerHalImpl.h +++ b/soundtrigger/2.0/default/SoundTriggerHalImpl.h @@ -167,11 +167,8 @@ class SoundTriggerHalImpl : public RefBase { static void recognitionCallback(struct sound_trigger_recognition_event* halEvent, void* cookie); const char* mModuleName; - - volatile atomic_uint_fast32_t mNextModelId; - - protected: struct sound_trigger_hw_device* mHwDevice; + volatile atomic_uint_fast32_t mNextModelId; DefaultKeyedVector > mClients; Mutex mLock; }; diff --git a/soundtrigger/2.2/Android.bp b/soundtrigger/2.2/Android.bp deleted file mode 100644 index 0a7c2d80ba..0000000000 --- a/soundtrigger/2.2/Android.bp +++ /dev/null @@ -1,20 +0,0 @@ -// This file is autogenerated by hidl-gen -Landroidbp. - -hidl_interface { - name: "android.hardware.soundtrigger@2.2", - root: "android.hardware", - vndk: { - enabled: true, - }, - srcs: [ - "ISoundTriggerHw.hal", - ], - interfaces: [ - "android.hardware.audio.common@2.0", - "android.hardware.soundtrigger@2.0", - "android.hardware.soundtrigger@2.1", - "android.hidl.base@1.0", - ], - gen_java: false, -} - diff --git a/soundtrigger/2.2/ISoundTriggerHw.hal b/soundtrigger/2.2/ISoundTriggerHw.hal deleted file mode 100644 index c5033588de..0000000000 --- a/soundtrigger/2.2/ISoundTriggerHw.hal +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 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 android.hardware.soundtrigger@2.2; - -import @2.1::ISoundTriggerHw; -import @2.0::SoundModelHandle; -import @2.0::ISoundTriggerHwCallback.RecognitionEvent; - -/** - * SoundTrigger HAL interface. Used for hardware recognition of hotwords. - */ -interface ISoundTriggerHw extends @2.1::ISoundTriggerHw { - - /** - * Get the state of a given model. - * The model state is returned as a RecognitionEvent. - * @param modelHandle The handle of the sound model to use for recognition - * @return retval Operation completion status: 0 in case of success, - * -ENOSYS in case of invalid model handle, - * -ENOMEM in case of memory allocation failure, - * -ENODEV in case of initialization error. - * @return state RecognitionEvent in case of success - */ - getModelState(SoundModelHandle modelHandle) - generates (int32_t retval, RecognitionEvent state); -}; diff --git a/soundtrigger/2.2/default/Android.mk b/soundtrigger/2.2/default/Android.mk deleted file mode 100644 index 8c0f653d8d..0000000000 --- a/soundtrigger/2.2/default/Android.mk +++ /dev/null @@ -1,50 +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 := android.hardware.soundtrigger@2.2-impl -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_SRC_FILES := \ - SoundTriggerHw.cpp - -LOCAL_CFLAGS := -Wall -Werror - -LOCAL_SHARED_LIBRARIES := \ - libhardware \ - libhidlbase \ - libhidlmemory \ - libhidltransport \ - liblog \ - libutils \ - android.hardware.soundtrigger@2.2 \ - android.hardware.soundtrigger@2.1 \ - android.hardware.soundtrigger@2.0 \ - android.hardware.soundtrigger@2.0-core \ - android.hidl.allocator@1.0 \ - android.hidl.memory@1.0 - -LOCAL_C_INCLUDE_DIRS := $(LOCAL_PATH) - -ifeq ($(strip $(AUDIOSERVER_MULTILIB)),) -LOCAL_MULTILIB := 32 -else -LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB) -endif - -include $(BUILD_SHARED_LIBRARY) diff --git a/soundtrigger/2.2/default/SoundTriggerHw.cpp b/soundtrigger/2.2/default/SoundTriggerHw.cpp deleted file mode 100644 index 90faf33598..0000000000 --- a/soundtrigger/2.2/default/SoundTriggerHw.cpp +++ /dev/null @@ -1,110 +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. - */ - -#define LOG_TAG "SoundTriggerHw" - -#include "SoundTriggerHw.h" - -#include -#include - -namespace android { -namespace hardware { -namespace soundtrigger { -namespace V2_2 { -namespace implementation { - -Return SoundTriggerHw::getModelState_2_2(int32_t modelHandle, getModelState_cb hidl_cb) { - sp client; - if (mHwDevice == NULL) { - hidl_cb(-ENODEV, NULL); - return Void(); - } - - { - AutoMutex lock(mLock); - client = mClients.valueFor(modelHandle); - if (client == 0) { - hidl_cb(-ENOSYS, NULL); - return Void(); - } - } - - if (mHwDevice->get_model_state == NULL) { - ALOGE("Failed to get model state from device, no such method"); - hidl_cb(-ENODEV, NULL); - return Void(); - } - - // Get the state from the device (as a recognition event) - struct sound_trigger_recognition_event* event = - mHwDevice->get_model_state(mHwDevice, client->getHalHandle()); - if (event == NULL) { - ALOGE("Failed to get model state from device"); - hidl_cb(-ENODEV, NULL); - return Void(); - } - - // Allocate shared memory to return to the client - sp alloc = IAllocator::getService("ashmem"); - if (alloc == 0) { - ALOGE("Failed to retrieve ashmem allocator service"); - free(event); - hidl_cb(-ENOMEM, NULL); - return Void(); - } - // Note: Only generic recognition events are currently supported - int n_bytes = sizeof(struct sound_trigger_generic_recognition_event); - bool success = false; - const hidl_memory& mem; - Return r = ashmem->allocate(n_bytes, [&](bool s, const hidl_memory& m) { - success = s; - if (success) mem = m; - }); - if (r.isOk() && success) { - // Copy the event data to the shared memory - sp memory = mapMemory(mem); - if (memory != 0) { - struct sound_trigger_generic_recognition_event* data = - (struct sound_trigger_generic_recognition_event*)memory->getPointer(); - memory->update(); - *data = *event; - memory->commit(); - - // Return the event memory via this callback - hidl_cb(0, memory); - } else { - ALOGE("Failed to map memory for recognition event"); - hidl_cb(-ENOMEM, NULL); - } - } else { - ALOGE("Failed to allocate %d bytes from ashmem allocator service", n_bytes); - hidl_cb(-ENOMEM, NULL); - } - - free(event); - return Void(); -} - -ISoundTriggerHw* HIDL_FETCH_ISoundTriggerHw(const char* /* name */) { - return (new SoundTriggerHw())->getInterface(); -} - -} // namespace implementation -} // namespace V2_2 -} // namespace soundtrigger -} // namespace hardware -} // namespace android diff --git a/soundtrigger/2.2/default/SoundTriggerHw.h b/soundtrigger/2.2/default/SoundTriggerHw.h deleted file mode 100644 index 7db54db941..0000000000 --- a/soundtrigger/2.2/default/SoundTriggerHw.h +++ /dev/null @@ -1,114 +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. - */ - -#ifndef ANDROID_HARDWARE_SOUNDTRIGGER_V2_2_SOUNDTRIGGERHW_H -#define ANDROID_HARDWARE_SOUNDTRIGGER_V2_2_SOUNDTRIGGERHW_H - -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace soundtrigger { -namespace V2_2 { -namespace implementation { - -using ::android::sp; -using ::android::hardware::Return; - -struct SoundTriggerHw : public V2_1::implementation::SoundTriggerHw { - SoundTriggerHw() = default; - ISoundTriggerHw* getInterface() { return new TrampolineSoundTriggerHw_2_2(this); } - - protected: - virtual ~SoundTriggerHw() = default; - - Return> getModelState_2_2( - V2_0::SoundModelHandle modelHandle modelHandle); - - private: - struct TrampolineSoundTriggerHw_2_2 : public ISoundTriggerHw { - explicit TrampolineSoundTriggerHw_2_2(sp impl) : mImpl(impl) {} - - // Methods from ::android::hardware::soundtrigger::V2_0::ISoundTriggerHw follow. - Return getProperties(getProperties_cb _hidl_cb) override { - return mImpl->getProperties(_hidl_cb); - } - Return loadSoundModel(const V2_0::ISoundTriggerHw::SoundModel& soundModel, - const sp& callback, - int32_t cookie, loadSoundModel_cb _hidl_cb) override { - return mImpl->loadSoundModel(soundModel, callback, cookie, _hidl_cb); - } - Return loadPhraseSoundModel(const V2_0::ISoundTriggerHw::PhraseSoundModel& soundModel, - const sp& callback, - int32_t cookie, - loadPhraseSoundModel_cb _hidl_cb) override { - return mImpl->loadPhraseSoundModel(soundModel, callback, cookie, _hidl_cb); - } - Return unloadSoundModel(V2_0::SoundModelHandle modelHandle) override { - return mImpl->unloadSoundModel(modelHandle); - } - Return startRecognition(int32_t modelHandle, - const V2_0::ISoundTriggerHw::RecognitionConfig& config, - const sp& /*callback*/, - int32_t /*cookie*/) override { - return mImpl->startRecognition(modelHandle, config); - } - Return stopRecognition(V2_0::SoundModelHandle modelHandle) override { - return mImpl->stopRecognition(modelHandle); - } - Return stopAllRecognitions() override { return mImpl->stopAllRecognitions(); } - - // Methods from V2_1::ISoundTriggerHw follow. - Return loadSoundModel_2_1(const V2_1::ISoundTriggerHw::SoundModel& soundModel, - const sp& callback, - int32_t cookie, loadSoundModel_2_1_cb _hidl_cb) override { - return mImpl->loadSoundModel_2_1(soundModel, callback, cookie, _hidl_cb); - } - Return loadPhraseSoundModel_2_1( - const V2_1::ISoundTriggerHw::PhraseSoundModel& soundModel, - const sp& callback, int32_t cookie, - loadPhraseSoundModel_2_1_cb _hidl_cb) override { - return mImpl->loadPhraseSoundModel_2_1(soundModel, callback, cookie, _hidl_cb); - } - Return startRecognition_2_1(int32_t modelHandle, - const V2_1::ISoundTriggerHw::RecognitionConfig& config, - const sp& /*callback*/, - int32_t /*cookie*/) override { - return mImpl->startRecognition_2_1(modelHandle, config); - } - - // Methods from V2_2::ISoundTriggerHw follow. - Return getModelState(int32_t modelHandle, getModelState_cb hidl_cb) override { - return mImpl->getModelState_2_2(modelHandle, hidl_cb); - } - - private: - sp mImpl; - }; -}; - -extern "C" ISoundTriggerHw* HIDL_FETCH_ISoundTriggerHw(const char* name); - -} // namespace implementation -} // namespace V2_2 -} // namespace soundtrigger -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_SOUNDTRIGGER_V2_2_SOUNDTRIGGERHW_H diff --git a/soundtrigger/2.2/vts/functional/Android.bp b/soundtrigger/2.2/vts/functional/Android.bp deleted file mode 100644 index adbd0188b4..0000000000 --- a/soundtrigger/2.2/vts/functional/Android.bp +++ /dev/null @@ -1,29 +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. -// - -cc_test { - name: "VtsHalSoundtriggerV2_2TargetTest", - defaults: ["VtsHalTargetTestDefaults"], - srcs: ["VtsHalSoundtriggerV2_2TargetTest.cpp"], - static_libs: [ - "android.hidl.allocator@1.0", - "android.hidl.memory@1.0", - "android.hardware.soundtrigger@2.0", - "android.hardware.soundtrigger@2.1", - "android.hardware.soundtrigger@2.2", - "libhidlmemory" - ], -} diff --git a/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp b/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp deleted file mode 100644 index ed5149fe7d..0000000000 --- a/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp +++ /dev/null @@ -1,101 +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. - */ - -#define LOG_TAG "SoundTriggerHidlHalTest" -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -using ::android::sp; -using ::android::hardware::Return; -using ::android::hardware::soundtrigger::V2_0::ISoundTriggerHwCallback; -using ::android::hardware::soundtrigger::V2_0::SoundModelHandle; -using ::android::hardware::soundtrigger::V2_2::ISoundTriggerHw; - -// Test environment for SoundTrigger HIDL HAL. -class SoundTriggerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { - public: - // get the test environment singleton - static SoundTriggerHidlEnvironment* Instance() { - static SoundTriggerHidlEnvironment* instance = new SoundTriggerHidlEnvironment; - return instance; - } - - void registerTestServices() override { registerTestService(); } - - private: - SoundTriggerHidlEnvironment() {} -}; - -// The main test class for Sound Trigger HIDL HAL. -class SoundTriggerHidlTest : public ::testing::VtsHalHidlTargetTestBase { - public: - void SetUp() override { - mSoundTriggerHal = ::testing::VtsHalHidlTargetTestBase::getService( - SoundTriggerHidlEnvironment::Instance()->getServiceName()); - ASSERT_NE(nullptr, mSoundTriggerHal.get()); - } - - static void SetUpTestCase() { srand(1234); } - - void TearDown() override {} - - protected: - sp mSoundTriggerHal; -}; - -/** - * Test ISoundTriggerHw::getModelState() method - * - * Verifies that: - * - the implementation returns -EINVAL with invalid model handle - * - */ -TEST_F(SoundTriggerHidlTest, GetModelStateInvalidModel) { - int ret = android::OK; - ISoundTriggerHwCallback::RecognitionEvent event; - SoundModelHandle handle = 0; - Return hidlReturn = - mSoundTriggerHal->getModelState(handle, [&](int32_t retval, auto res) { - ret = retval; - event = res; - }); - - EXPECT_TRUE(hidlReturn.isOk()); - EXPECT_EQ(-ENOSYS, ret); -} - -int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(SoundTriggerHidlEnvironment::Instance()); - ::testing::InitGoogleTest(&argc, argv); - SoundTriggerHidlEnvironment::Instance()->init(&argc, argv); - int status = RUN_ALL_TESTS(); - ALOGI("Test result = %d", status); - return status; -}