Recording sound from various internal devices in Android (through an illegal API)

I was wondering if it is possible to record audio data from other sources such as system, FM radio, Bluetooth headset, etc. I am particularly interested in capturing sound from an FM radio and have already explored all the possibilities, including trying to smell the raw bluetooth connection between the phone and the radio without any luck. This is too bad. Android only allows you to record audio from MIC.

I looked at the Android source code and could not find the back door to let me do this without rooting the device. At least do you know how to use other devices (maybe access / somehow / dev / audio ) through the NDK or even better - Java (maybe Reflection?), To trick the system into capturing an audio stream, say FM radio. (in my case, I'm trying to develop an application for HTC Desire)

PS. And for those of you who are against the use of undocumented APIs, please do not post here - I am writing an application that will be for my personal use, or even when I publish it, I have warned the user against possible incompatibilities.

+4
source share
1 answer

I spent quite a bit of time decrypting the audio packet, and I think you can try to capture libaudio. You will have problems accessing the hardware directly (/ dev / *), as many devices use proprietary audio drivers. There is no rule in this regard.

However, the Audio Abstraction Layer (HAL) provided by /system/lib/libaudio.so should disclose the API described at http://source.android.com/porting/audio.html

The Android system, and especially the audioflinger, uses this libaudio HAL to search for available devices, handle routing, and, of course, to read / write PCM data.

That way, you could capture the interaction between the audio framer and libaudio by renaming it later and providing your own libaudio that will beautify the real one. Therefore, you should be able to record what is happening, and possibly intercept the FM radio output, provided that the hardware is not directly processed.

Of course, all this requires rooting. Please comment if you manage to do this, which interests me.

+5
source

Source: https://habr.com/ru/post/1334573/


All Articles