Skip to content

Commit

Permalink
chiron: Switch to OSS libnotifyaudiohal
Browse files Browse the repository at this point in the history
Change-Id: Id392223e539716522d1c54efecae38ef72e38a1d
  • Loading branch information
mikeNG authored and BYZYB committed Jan 7, 2023
1 parent 05b4ff4 commit 2fdc111
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 6 deletions.
3 changes: 2 additions & 1 deletion device.mk
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ PRODUCT_COPY_FILES += \
# Sensors
PRODUCT_PACKAGES += \
[email protected]:64 \
[email protected]
[email protected] \
libnotifyaudiohal:64

# Sdcard support
PRODUCT_CHARACTERISTICS := nosdcard
Expand Down
1 change: 0 additions & 1 deletion sepolicy/vendor/audioserver.te

This file was deleted.

4 changes: 1 addition & 3 deletions sepolicy/vendor/hal_sensors_default.te
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
allow hal_sensors_default audioserver_service:service_manager find;
allow hal_sensors_default audioserver:binder { call transfer };
allow hal_sensors_default sound_device:chr_file { ioctl read open };
binder_use(hal_sensors_default)
hal_client_domain(hal_sensors_default, hal_audio)
set_prop(hal_sensors_default, vendor_sensors_prop);
1 change: 0 additions & 1 deletion sepolicy/vendor/system_server.te
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
allow system_server fingerprint_sysfs:file rw_file_perms;
allow system_server sound_device:chr_file rw_file_perms;
get_prop(system_server, vendor_fp_prop)
13 changes: 13 additions & 0 deletions ultrasound/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cc_library_shared {
name: "libnotifyaudiohal",
srcs: [
"libnotifyaudiohal.cpp",
],
shared_libs: [
"[email protected]",
"libhidlbase",
"liblog",
"libutils",
],
vendor: true,
}
42 changes: 42 additions & 0 deletions ultrasound/libnotifyaudiohal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2023 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/

#define LOG_TAG "libnotifyaudiohal"

#include <android/hardware/audio/6.0/IDevicesFactory.h>
#include <log/log.h>
#include <string.h>

using android::sp;
using android::hardware::audio::V6_0::IDevicesFactory;
using android::hardware::audio::V6_0::IPrimaryDevice;
using android::hardware::audio::V6_0::Result;

void ultrasound_enable(int enable) {
ALOGD("ultrasound_enable: %d", enable);
auto factory = IDevicesFactory::getService();
factory->openPrimaryDevice([&](Result retval, const sp<IPrimaryDevice>& result) {
if (retval == Result::OK) {
result->setParameters({} /* context */,
{
{"ultrasound-sensor", std::to_string(enable)},
});
}
});
}

extern "C" void elliptic_notify_audio_hal(char* param) {
ALOGD("elliptic_notify_audio_hal: %s", param);
if (!strcmp(param, "ultrasound_enable=1")) {
ultrasound_enable(1);
} else if (!strcmp(param, "ultrasound_enable=0")) {
ultrasound_enable(0);
}
}

extern "C" void elliptic_ultrasound_supported() {
return;
}

0 comments on commit 2fdc111

Please sign in to comment.