mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -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
|
|
@ -4,7 +4,6 @@ android_app {
|
|||
"src/**/*.kt",
|
||||
],
|
||||
platform_apis: true,
|
||||
jni_libs: ["libaudiohack"],
|
||||
certificate: "platform",
|
||||
static_libs: [
|
||||
"androidx.core_core",
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
cc_library_shared {
|
||||
name: "libaudiohack",
|
||||
cflags: [
|
||||
"-Wno-unused-parameter",
|
||||
],
|
||||
srcs: [
|
||||
"FM_AudioRoute_ctl.cpp",
|
||||
],
|
||||
defaults: ["eureka_defaults"],
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libutils",
|
||||
"audioflinger-aidl-cpp",
|
||||
"audiopolicy-aidl-cpp",
|
||||
"audiopolicy-types-aidl-cpp",
|
||||
"libaudiofoundation",
|
||||
"libaudioutils",
|
||||
"libaudioclient",
|
||||
"libutils",
|
||||
"libaudiopolicy",
|
||||
"libaudiomanager",
|
||||
],
|
||||
header_libs: [
|
||||
"libaudioclient_headers",
|
||||
"jni_headers",
|
||||
],
|
||||
}
|
||||
|
|
@ -47,7 +47,6 @@ class MainActivity : AppCompatActivity() {
|
|||
private lateinit var mAlertImage: AppCompatImageView
|
||||
private lateinit var mAudioManager: AudioManager
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
System.loadLibrary("audiohack")
|
||||
MainFragment.fd = mFMInterface.openFMDevice()
|
||||
mAlertView = (getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater)
|
||||
.inflate(R.layout.alertdialog, null)
|
||||
|
|
|
|||
|
|
@ -37,5 +37,5 @@ class NativeFMInterface {
|
|||
fun setFMRSSI(a: Int, rssi: Long) = mDevCtl.setValue(SetType.SET_TYPE_FM_RMSSI, rssi.toInt())
|
||||
fun closeFMDevice(fd: Int) = mDevCtl.close()
|
||||
fun getSysfsSupport(): Boolean = mSysfsCtl.getValue(GetType.GET_TYPE_FM_SYSFS_IF) == 0
|
||||
external fun setAudioRoute(speaker: Boolean): Int
|
||||
fun setAudioRoute(speaker: Boolean) = mDevCtl.setValue(SetType.SET_TYPE_FM_SPEAKER_ROUTE, if (speaker) 1 else 0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <jni.h>
|
||||
|
||||
#include <media/AudioSystem.h>
|
||||
#include <media/IAudioFlinger.h>
|
||||
|
||||
|
|
@ -23,9 +23,7 @@
|
|||
|
||||
using namespace android;
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_eurekateam_fmradio_NativeFMInterface_setAudioRoute(
|
||||
__unused JNIEnv *env, __unused jobject thiz, jboolean speaker) {
|
||||
int audioflinger_exynos7885_forceroute (bool speaker) {
|
||||
const sp<IAudioFlinger> &af = AudioSystem::get_audio_flinger();
|
||||
if (af == 0)
|
||||
return PERMISSION_DENIED;
|
||||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,3 +11,5 @@ 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;
|
||||
|
|
|
|||
|
|
@ -24,11 +24,6 @@ for dev in a10dd a10 a20 a20e a30 a30s a40; do
|
|||
bash ${UNIVERSAL}/setup.sh "$dev"
|
||||
done
|
||||
|
||||
# For FM Radio
|
||||
if grep -q isAudioServerUid\(callingUid\) frameworks/av/services/audioflinger/AudioFlinger.cpp; then
|
||||
echo "Applying FM routing patch"
|
||||
sed -i 's/isAudioServerUid(callingUid)/isAudioServerOrSystemServerUid(callingUid)/g' frameworks/av/services/audioflinger/AudioFlinger.cpp
|
||||
fi
|
||||
# Remove multiple declared FMRadio path (we have our own FMRadio and this cause build error)
|
||||
if [ -d "$FM_PATH" ]; then
|
||||
echo "Remove FMRadio from ROM Source"
|
||||
|
|
|
|||
Loading…
Reference in a new issue