mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-23 04:25:33 -04:00
universal7885: FMRadio: Remove source edit
If the AIDL hal which can be allowed to change uid calls audioflinger API to change route, we don't need to change source for it. seteuid(audioserver_uid) will work fine
This commit is contained in:
parent
4296d27bea
commit
946f4768e9
11 changed files with 27 additions and 39 deletions
|
|
@ -8,6 +8,7 @@ cc_binary {
|
|||
srcs: [
|
||||
"FMSupport.cpp",
|
||||
"FMDevControl.cpp",
|
||||
"FMAudioRouteControl.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
defaults: [
|
||||
|
|
@ -20,8 +21,18 @@ cc_binary {
|
|||
"libbinder_ndk",
|
||||
"liblog",
|
||||
"libfileio",
|
||||
"libutils",
|
||||
"audioflinger-aidl-cpp",
|
||||
"audiopolicy-aidl-cpp",
|
||||
"audiopolicy-types-aidl-cpp",
|
||||
"libaudiofoundation",
|
||||
"libaudioutils",
|
||||
"libaudioclient",
|
||||
"libaudiopolicy",
|
||||
"libaudiomanager",
|
||||
"vendor.eureka.hardware.fmradio-ndk",
|
||||
],
|
||||
header_libs: ["libaudioclient_headers"],
|
||||
init_rc: ["vendor.eureka.hardware.fmradio-service.rc"],
|
||||
vintf_fragments: ["vendor.eureka.hardware.fmradio.xml"],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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>
|
||||
|
||||
#define FM_FAILURE (-1)
|
||||
#define FM_SUCCESS 0
|
||||
#define IOHANDLE 13
|
||||
|
||||
using namespace android;
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -16,9 +16,13 @@
|
|||
|
||||
#include <fm_slsi-impl.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cassert>
|
||||
#include <fcntl.h>
|
||||
|
||||
// FMAudioRouteControl.cpp
|
||||
extern int audioflinger_exynos7885_forceroute(bool speaker);
|
||||
|
||||
namespace aidl::vendor::eureka::hardware::fmradio {
|
||||
|
||||
static int fd = -1;
|
||||
|
|
@ -81,6 +85,11 @@ static int fd = -1;
|
|||
case SetType::SET_TYPE_FM_SEARCH_CANCEL:
|
||||
fm_radio_slsi::stop_search(fd);
|
||||
break;
|
||||
case SetType::SET_TYPE_FM_SPEAKER_ROUTE:
|
||||
seteuid(1041 /* AudioServer UID */);
|
||||
audioflinger_exynos7885_forceroute(value);
|
||||
seteuid(0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ constexpr const char *FM_FREQ_SEEK =
|
|||
case SetType::SET_TYPE_FM_THREAD:
|
||||
case SetType::SET_TYPE_FM_RMSSI:
|
||||
case SetType::SET_TYPE_FM_SEARCH_CANCEL:
|
||||
case SetType::SET_TYPE_FM_SPEAKER_ROUTE:
|
||||
NOT_SUPPORTED;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -22,4 +22,5 @@ enum SetType {
|
|||
SET_TYPE_FM_THREAD,
|
||||
SET_TYPE_FM_RMSSI,
|
||||
SET_TYPE_FM_SEARCH_CANCEL,
|
||||
SET_TYPE_FM_SPEAKER_ROUTE,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue