mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -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
|
|
@ -0,0 +1,17 @@
|
|||
aidl_interface {
|
||||
name: "vendor.eureka.hardware.audio_route",
|
||||
srcs: ["vendor/eureka/hardware/audio_route/*.aidl"],
|
||||
stability: "vintf",
|
||||
backend: {
|
||||
ndk: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
versions_with_info: [
|
||||
{
|
||||
version: "1",
|
||||
imports: [],
|
||||
},
|
||||
],
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
e5802a2cbeff18d06e61d70381d5f1b65f2448ca
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2022 Eureka Team
|
||||
//
|
||||
// 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.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package vendor.eureka.hardware.audio_route;
|
||||
@VintfStability
|
||||
interface IAudioRoute {
|
||||
oneway void setParam(String param);
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2022 Eureka Team
|
||||
//
|
||||
// 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.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package vendor.eureka.hardware.audio_route;
|
||||
@VintfStability
|
||||
interface IAudioRoute {
|
||||
oneway void setParam(String param);
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
cc_binary {
|
||||
name: "vendor.eureka.hardware.audio_route-service",
|
||||
srcs: [
|
||||
"AudioRoute.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
defaults: [
|
||||
"eureka_defaults",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"audioflinger-aidl-cpp",
|
||||
"libaudiofoundation",
|
||||
"libaudioutils",
|
||||
"libaudioclient",
|
||||
"libaudiomanager",
|
||||
"vendor.eureka.hardware.audio_route-V1-ndk",
|
||||
],
|
||||
header_libs: ["libaudioclient_headers"],
|
||||
init_rc: ["vendor.eureka.hardware.audio_route-service.rc"],
|
||||
vintf_fragments: ["vendor.eureka.hardware.audio_route.xml"],
|
||||
}
|
||||
|
|
@ -17,34 +17,16 @@
|
|||
#include <media/AudioSystem.h>
|
||||
#include <media/IAudioFlinger.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include "AudioRoute.h"
|
||||
|
||||
#define FM_FAILURE (-1)
|
||||
#define FM_SUCCESS 0
|
||||
#define IOHANDLE 13
|
||||
|
||||
using namespace android;
|
||||
|
||||
static int audioflinger_exynos7885_forceroute(bool speaker) {
|
||||
ndk::ScopedAStatus AudioRoute::setParam(std::string param) {
|
||||
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);
|
||||
}
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_SECURITY);
|
||||
af->setParameters(IOHANDLE, String8(param.c_str()));
|
||||
return ndk::ScopedAStatus::ok();;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/vendor/eureka/hardware/audio_route/BnAudioRoute.h>
|
||||
|
||||
namespace aidl::vendor::eureka::hardware::audio_route {
|
||||
|
||||
struct AudioRoute : public BnAudioRoute {
|
||||
public:
|
||||
AudioRoute() = default;
|
||||
// Methods from aidl::vendor::eureka::hardware::fmradio::IFMRadio follow.
|
||||
::ndk::ScopedAStatus setParam(std::string param) override;
|
||||
};
|
||||
} // namespace aidl::vendor::eureka::hardware::fmradio
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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 <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
#include "AudioRoute.h"
|
||||
|
||||
using ::aidl::vendor::eureka::hardware::audio_route::AudioRoute;
|
||||
|
||||
int main() {
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(3);
|
||||
|
||||
auto service = ndk::SharedRefBase::make<AudioRoute>();
|
||||
const std::string instance = std::string() + C::descriptor + "/default";
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(service->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
LOG(INFO) << "Register done";
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return -1; // should never get here
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
service audioroute-hal-aidl /system/bin/vendor.eureka.hardware.audio_route-service
|
||||
class hal
|
||||
user audioserver
|
||||
group audio
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<manifest version="1.0" type="framework">
|
||||
<hal format="aidl">
|
||||
<name>vendor.eureka.hardware.audio_route</name>
|
||||
<fqname>IAudioRoute/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2022 Eureka Team
|
||||
//
|
||||
// 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 vendor.eureka.hardware.audio_route;
|
||||
|
||||
@VintfStability
|
||||
interface IAudioRoute {
|
||||
oneway void setParam(String param);
|
||||
}
|
||||
|
|
@ -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",
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -13,5 +13,6 @@
|
|||
|
||||
# FMRadio
|
||||
/system/bin/vendor\.eureka\.hardware\.fmradio-service u:object_r:hal_fmradio_default_exec:s0
|
||||
/system/bin/vendor\.eureka\.hardware\.audio_route-service u:object_r:hal_audio_route_default_exec:s0
|
||||
|
||||
/dev/radio0 u:object_r:fm_radio_device:s0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
type hal_audio_route_default, domain, coredomain;
|
||||
type hal_audio_route_default_exec, exec_type, file_type, system_file_type;
|
||||
|
||||
add_service(hal_audio_route_default, hal_fmradio_service);
|
||||
init_daemon_domain(hal_audio_route_default);
|
||||
|
||||
binder_use(hal_audio_route_default);
|
||||
|
||||
binder_call(hal_audio_route_default, audioserver)
|
||||
binder_call(audioserver, hal_audio_route_default)
|
||||
|
|
@ -12,7 +12,3 @@ allow hal_fmradio_default sysfs_fmradio_tune:dir search;
|
|||
allow hal_fmradio_default sysfs_virtual:dir search;
|
||||
allow hal_fmradio_default fm_radio_device:chr_file { read write open ioctl };
|
||||
|
||||
allow hal_fmradio_default self:capability setuid;
|
||||
|
||||
binder_call(hal_fmradio_default, audioserver)
|
||||
binder_call(audioserver, hal_fmradio_default)
|
||||
|
|
|
|||
|
|
@ -8,3 +8,4 @@ vendor.eureka.hardware.parts.ISmartCharge/default u:object_r:hal_parts_service:s
|
|||
# FMRadio
|
||||
vendor.eureka.hardware.fmradio.IFMDevControl/default u:object_r:hal_fmradio_service:s0
|
||||
vendor.eureka.hardware.fmradio.IFMDevControl/support u:object_r:hal_fmradio_service:s0
|
||||
vendor.eureka.hardware.audio_route.IAudioRoute/default u:object_r:hal_audio_route_service:s0
|
||||
|
|
|
|||
Loading…
Reference in a new issue