mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 19:55:33 -04:00
universal7885: aidl-support: Fork subprocess to setuid
This commit is contained in:
parent
50f3bfa31a
commit
b226436fc7
4 changed files with 20 additions and 9 deletions
|
|
@ -23,12 +23,9 @@ cc_binary {
|
|||
"libfileio",
|
||||
"libutils",
|
||||
"audioflinger-aidl-cpp",
|
||||
"audiopolicy-aidl-cpp",
|
||||
"audiopolicy-types-aidl-cpp",
|
||||
"libaudiofoundation",
|
||||
"libaudioutils",
|
||||
"libaudioclient",
|
||||
"libaudiopolicy",
|
||||
"libaudiomanager",
|
||||
"vendor.eureka.hardware.fmradio-V1-ndk",
|
||||
],
|
||||
|
|
|
|||
|
|
@ -17,13 +17,15 @@
|
|||
#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;
|
||||
|
||||
int audioflinger_exynos7885_forceroute (bool speaker) {
|
||||
static int audioflinger_exynos7885_forceroute(bool speaker) {
|
||||
const sp<IAudioFlinger> &af = AudioSystem::get_audio_flinger();
|
||||
if (af == 0)
|
||||
return PERMISSION_DENIED;
|
||||
|
|
@ -34,3 +36,15 @@ int audioflinger_exynos7885_forceroute (bool speaker) {
|
|||
}
|
||||
return FM_SUCCESS;
|
||||
}
|
||||
|
||||
void setAudioFlingerSpeaker(bool enable) {
|
||||
pid_t pid;
|
||||
|
||||
if ((pid = fork()) < 0) {
|
||||
return;
|
||||
}
|
||||
if (pid == 0) {
|
||||
setuid(1041);
|
||||
audioflinger_exynos7885_forceroute(enable);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,11 @@
|
|||
|
||||
#include <fm_slsi-impl.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cassert>
|
||||
#include <fcntl.h>
|
||||
|
||||
// FMAudioRouteControl.cpp
|
||||
extern int audioflinger_exynos7885_forceroute(bool speaker);
|
||||
extern void setAudioFlingerSpeaker(bool enable);
|
||||
|
||||
namespace aidl::vendor::eureka::hardware::fmradio {
|
||||
|
||||
|
|
@ -86,9 +85,7 @@ static int fd = -1;
|
|||
fm_radio_slsi::stop_search(fd);
|
||||
break;
|
||||
case SetType::SET_TYPE_FM_SPEAKER_ROUTE:
|
||||
seteuid(1041 /* AudioServer UID */);
|
||||
audioflinger_exynos7885_forceroute(value);
|
||||
seteuid(0);
|
||||
setAudioFlingerSpeaker(value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -13,3 +13,6 @@ 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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue