mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-23 12:35:33 -04:00
universal7885: aidl-support: Add audio route hal to fake audioserver uid
This commit is contained in:
parent
0834ccd364
commit
4ef818a802
17 changed files with 231 additions and 37 deletions
|
|
@ -8,7 +8,6 @@ cc_binary {
|
|||
srcs: [
|
||||
"FMSupport.cpp",
|
||||
"FMDevControl.cpp",
|
||||
"FMAudioRouteControl.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
defaults: [
|
||||
|
|
@ -21,15 +20,13 @@ cc_binary {
|
|||
"libbinder_ndk",
|
||||
"liblog",
|
||||
"libfileio",
|
||||
"libutils",
|
||||
"audioflinger-aidl-cpp",
|
||||
"libaudiofoundation",
|
||||
"libaudioutils",
|
||||
"libaudioclient",
|
||||
"libaudiomanager",
|
||||
"vendor.eureka.hardware.fmradio-V1-ndk",
|
||||
"vendor.eureka.hardware.audio_route-V1-ndk",
|
||||
],
|
||||
header_libs: ["libaudioclient_headers"],
|
||||
init_rc: ["vendor.eureka.hardware.fmradio-service.rc"],
|
||||
vintf_fragments: ["vendor.eureka.hardware.fmradio.xml"],
|
||||
required: [
|
||||
"vendor.eureka.hardware.audio_route-service",
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Copyright 2021 Soo Hwan Na "Royna"
|
||||
*
|
||||
* 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 <media/AudioSystem.h>
|
||||
#include <media/IAudioFlinger.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#define FM_FAILURE (-1)
|
||||
#define FM_SUCCESS 0
|
||||
#define IOHANDLE 13
|
||||
|
||||
using namespace android;
|
||||
|
||||
static int audioflinger_exynos7885_forceroute(bool speaker) {
|
||||
const sp<IAudioFlinger> &af = AudioSystem::get_audio_flinger();
|
||||
if (af == 0)
|
||||
return PERMISSION_DENIED;
|
||||
if (speaker) {
|
||||
af->setParameters(IOHANDLE, String8("routing=2"));
|
||||
} else {
|
||||
af->setParameters(IOHANDLE, String8("routing=8"));
|
||||
}
|
||||
return FM_SUCCESS;
|
||||
}
|
||||
|
||||
void setAudioFlingerSpeaker(bool enable) {
|
||||
pid_t pid;
|
||||
|
||||
if ((pid = fork()) < 0) {
|
||||
return;
|
||||
}
|
||||
if (pid == 0) {
|
||||
setuid(1041);
|
||||
audioflinger_exynos7885_forceroute(enable);
|
||||
}
|
||||
}
|
||||
|
|
@ -19,8 +19,7 @@
|
|||
#include <cassert>
|
||||
#include <fcntl.h>
|
||||
|
||||
// FMAudioRouteControl.cpp
|
||||
extern void setAudioFlingerSpeaker(bool enable);
|
||||
#include <vendor/eureka/hardware/audio_route/BnAudioRoute.h>
|
||||
|
||||
namespace aidl::vendor::eureka::hardware::fmradio {
|
||||
|
||||
|
|
@ -85,7 +84,8 @@ static int fd = -1;
|
|||
fm_radio_slsi::stop_search(fd);
|
||||
break;
|
||||
case SetType::SET_TYPE_FM_SPEAKER_ROUTE:
|
||||
setAudioFlingerSpeaker(value);
|
||||
auto svc = IAudioRoute::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService("vendor.eureka.hardware.audio_route.IAudioRoute/default")));
|
||||
svc->setParam(value ? "routing=2": "routing=8");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue