mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-23 12:35: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",
|
"libfileio",
|
||||||
"libutils",
|
"libutils",
|
||||||
"audioflinger-aidl-cpp",
|
"audioflinger-aidl-cpp",
|
||||||
"audiopolicy-aidl-cpp",
|
|
||||||
"audiopolicy-types-aidl-cpp",
|
|
||||||
"libaudiofoundation",
|
"libaudiofoundation",
|
||||||
"libaudioutils",
|
"libaudioutils",
|
||||||
"libaudioclient",
|
"libaudioclient",
|
||||||
"libaudiopolicy",
|
|
||||||
"libaudiomanager",
|
"libaudiomanager",
|
||||||
"vendor.eureka.hardware.fmradio-V1-ndk",
|
"vendor.eureka.hardware.fmradio-V1-ndk",
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,15 @@
|
||||||
#include <media/AudioSystem.h>
|
#include <media/AudioSystem.h>
|
||||||
#include <media/IAudioFlinger.h>
|
#include <media/IAudioFlinger.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define FM_FAILURE (-1)
|
#define FM_FAILURE (-1)
|
||||||
#define FM_SUCCESS 0
|
#define FM_SUCCESS 0
|
||||||
#define IOHANDLE 13
|
#define IOHANDLE 13
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
|
||||||
int audioflinger_exynos7885_forceroute (bool speaker) {
|
static int audioflinger_exynos7885_forceroute(bool speaker) {
|
||||||
const sp<IAudioFlinger> &af = AudioSystem::get_audio_flinger();
|
const sp<IAudioFlinger> &af = AudioSystem::get_audio_flinger();
|
||||||
if (af == 0)
|
if (af == 0)
|
||||||
return PERMISSION_DENIED;
|
return PERMISSION_DENIED;
|
||||||
|
|
@ -34,3 +36,15 @@ int audioflinger_exynos7885_forceroute (bool speaker) {
|
||||||
}
|
}
|
||||||
return FM_SUCCESS;
|
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 <fm_slsi-impl.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
// FMAudioRouteControl.cpp
|
// FMAudioRouteControl.cpp
|
||||||
extern int audioflinger_exynos7885_forceroute(bool speaker);
|
extern void setAudioFlingerSpeaker(bool enable);
|
||||||
|
|
||||||
namespace aidl::vendor::eureka::hardware::fmradio {
|
namespace aidl::vendor::eureka::hardware::fmradio {
|
||||||
|
|
||||||
|
|
@ -86,9 +85,7 @@ static int fd = -1;
|
||||||
fm_radio_slsi::stop_search(fd);
|
fm_radio_slsi::stop_search(fd);
|
||||||
break;
|
break;
|
||||||
case SetType::SET_TYPE_FM_SPEAKER_ROUTE:
|
case SetType::SET_TYPE_FM_SPEAKER_ROUTE:
|
||||||
seteuid(1041 /* AudioServer UID */);
|
setAudioFlingerSpeaker(value);
|
||||||
audioflinger_exynos7885_forceroute(value);
|
|
||||||
seteuid(0);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
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 fm_radio_device:chr_file { read write open ioctl };
|
||||||
|
|
||||||
allow hal_fmradio_default self:capability setuid;
|
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