Applying cleanup to default AIDL AudioControl

Updating default AudioControl HAL with cleanup steps
applied based on feedback to emulator specific version
of HAL.

Bug: 183601304
Test: adb shell dumpsys
android.hardware.automotive.audiocontrol.IAudioControl/default --request
AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE 0 3

Change-Id: Ic8068b66d7f99a4bfaed025f13303f33d3f3a5bc
This commit is contained in:
Hayden Gomes
2021-03-25 11:27:59 -07:00
parent 0b4586e19f
commit 6333eedc9e
3 changed files with 17 additions and 16 deletions

View File

@@ -27,10 +27,8 @@ cc_binary {
init_rc: ["audiocontrol-default.rc"],
vintf_fragments: ["audiocontrol-default.xml"],
vendor: true,
generated_headers: ["audio_policy_configuration_V7_0"],
generated_sources: ["audio_policy_configuration_V7_0"],
header_libs: ["libxsdc-utils"],
shared_libs: [
"android.hardware.audio.common@7.0-enums",
"android.frameworks.automotive.powerpolicy-V1-ndk_platform",
"android.hardware.automotive.audiocontrol-V1-ndk_platform",
"libbase",
@@ -38,7 +36,6 @@ cc_binary {
"libcutils",
"liblog",
"libpowerpolicyclient",
"libxml2",
],
srcs: [
"AudioControl.cpp",

View File

@@ -14,6 +14,9 @@
* limitations under the License.
*/
#define LOG_TAG "AudioControl"
// #define LOG_NDEBUG 0
#include "AudioControl.h"
#include <aidl/android/hardware/automotive/audiocontrol/AudioFocusChange.h>
@@ -24,7 +27,7 @@
#include <android-base/parseint.h>
#include <android-base/strings.h>
#include <android_audio_policy_configuration_V7_0.h>
#include <android_audio_policy_configuration_V7_0-enums.h>
#include <private/android_filesystem_config.h>
#include <stdio.h>
@@ -33,6 +36,7 @@ namespace aidl::android::hardware::automotive::audiocontrol {
using ::android::base::EqualsIgnoreCase;
using ::android::base::ParseInt;
using ::std::shared_ptr;
using ::std::string;
namespace xsd {
@@ -68,7 +72,7 @@ ndk::ScopedAStatus AudioControl::registerFocusListener(
const shared_ptr<IFocusListener>& in_listener) {
LOG(DEBUG) << "registering focus listener";
if (in_listener.get()) {
if (in_listener) {
std::atomic_store(&mFocusListener, in_listener);
} else {
LOG(ERROR) << "Unexpected nullptr for listener resulting in no-op.";
@@ -80,9 +84,10 @@ ndk::ScopedAStatus AudioControl::setBalanceTowardRight(float value) {
if (isValidValue(value)) {
// Just log in this default mock implementation
LOG(INFO) << "Balance set to " << value;
} else {
LOG(ERROR) << "Balance value out of range -1 to 1 at " << value;
return ndk::ScopedAStatus::ok();
}
LOG(ERROR) << "Balance value out of range -1 to 1 at " << value;
return ndk::ScopedAStatus::ok();
}
@@ -90,9 +95,10 @@ ndk::ScopedAStatus AudioControl::setFadeTowardFront(float value) {
if (isValidValue(value)) {
// Just log in this default mock implementation
LOG(INFO) << "Fader set to " << value;
} else {
LOG(ERROR) << "Fader value out of range -1 to 1 at " << value;
return ndk::ScopedAStatus::ok();
}
LOG(ERROR) << "Fader value out of range -1 to 1 at " << value;
return ndk::ScopedAStatus::ok();
}
@@ -194,7 +200,7 @@ binder_status_t AudioControl::cmdRequestFocus(int fd, const char** args, uint32_
}
string usage = string(args[1]);
if (xsd::stringToAudioUsage(usage) == xsd::AudioUsage::UNKNOWN) {
if (xsd::isUnknownAudioUsage(usage)) {
dprintf(fd,
"Unknown usage provided: %s. Please see audio_policy_configuration.xsd V7_0 "
"for supported values\n",
@@ -236,7 +242,7 @@ binder_status_t AudioControl::cmdAbandonFocus(int fd, const char** args, uint32_
}
string usage = string(args[1]);
if (xsd::stringToAudioUsage(usage) == xsd::AudioUsage::UNKNOWN) {
if (xsd::isUnknownAudioUsage(usage)) {
dprintf(fd,
"Unknown usage provided: %s. Please see audio_policy_configuration.xsd V7_0 "
"for supported values\n",

View File

@@ -23,8 +23,6 @@
namespace aidl::android::hardware::automotive::audiocontrol {
using ::std::shared_ptr;
class AudioControl : public BnAudioControl {
public:
ndk::ScopedAStatus onAudioFocusChange(const std::string& in_usage, int32_t in_zoneId,
@@ -34,7 +32,7 @@ class AudioControl : public BnAudioControl {
ndk::ScopedAStatus onDevicesToMuteChange(
const std::vector<MutingInfo>& in_mutingInfos) override;
ndk::ScopedAStatus registerFocusListener(
const shared_ptr<IFocusListener>& in_listener) override;
const std::shared_ptr<IFocusListener>& in_listener) override;
ndk::ScopedAStatus setBalanceTowardRight(float in_value) override;
ndk::ScopedAStatus setFadeTowardFront(float in_value) override;
binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
@@ -44,7 +42,7 @@ class AudioControl : public BnAudioControl {
// a single instance of CarAudioService. As such, it doesn't have explicit serialization.
// If a different AudioControl implementation were to have multiple threads leveraging this
// listener, then it should also include mutexes or make the listener atomic.
shared_ptr<IFocusListener> mFocusListener;
std::shared_ptr<IFocusListener> mFocusListener;
binder_status_t cmdHelp(int fd) const;
binder_status_t cmdRequestFocus(int fd, const char** args, uint32_t numArgs);