I was trying to do the following:-
I was trying to find which application of my phone is using my phone microphone,i made lot of try and research and found the following:-
When app want to use microphone, it must use "android.media.MediaRecorder" class,
then the request will be delivered to /system/bin/mediaserver which is a system service,
this service will open device and record voice,if you try to find app, it is very hard to do,
because the request is delivered by Binder, we should monitor "/system/bin/mediaserver",
if the service is using the "/dev/msm_pcm_in" device, it means it is recording,
then we could list all running apps and find the app which have "RECORD_AUDIO" permission and also consumes CPU,
I know it is a dirty way, but it maybe works.
You could detect if microphone is working, you just need to su as root, then run "lsof | grep msm_pcm_in",
ABOVE SOLUTION CANNOT BE USED BECAUSE I CANT USE THE ROOT PERMISSION
then I FOUND
dumpsys doesn't need root permission,
although dumpsys can't give any mic information, but it could dump the service information,
it also could help you find the app is using mic, we can combine two ways into one.
1. all apps use microphone via "/system/mediaserver", it is a service whose name is "media.player".
2. dumpsys can get information from specific service.
Finally, we get the answer, "dumpsys media.player",
if we are running any recording app,
you will see a "MediaRecorderClient" which includes pid and more information,
it means the app is using mic and recording voice ,now I can find the correct app which is using mic.
BUT I WAS NOT ABLE TO USE DUMPSYS THROUGH C
THEN I SWITCHED FINALLY TO lsof COMMAND AND RUN THE lsof CODE THROUGH MY NDK CODE AND I FOUND IN THE DUMP OF lsof THAT THERE IS SERVICE NAMED MEDIA SERVER AND FINALLY
As per Android Multimedia framework the MediaServer is responsible for opening the device and the Java based audio applications connect it as a client. The data transfer happens on the Binder. May because of this there is only one process seen which opens the audio device.
HOWEVER I REACHED HERE NOW I WANT TO KNOW HOW TO READ FROM THE INFO FROM MEDIA SERVER.
OR
ANYOTHER WAY TO DETECT WHICH APPLICATION IS USING MY PHONE MICROPHONE?
I was trying to find which application of my phone is using my phone microphone,i made lot of try and research and found the following:-
When app want to use microphone, it must use "android.media.MediaRecorder" class,
then the request will be delivered to /system/bin/mediaserver which is a system service,
this service will open device and record voice,if you try to find app, it is very hard to do,
because the request is delivered by Binder, we should monitor "/system/bin/mediaserver",
if the service is using the "/dev/msm_pcm_in" device, it means it is recording,
then we could list all running apps and find the app which have "RECORD_AUDIO" permission and also consumes CPU,
I know it is a dirty way, but it maybe works.
You could detect if microphone is working, you just need to su as root, then run "lsof | grep msm_pcm_in",
ABOVE SOLUTION CANNOT BE USED BECAUSE I CANT USE THE ROOT PERMISSION
then I FOUND
dumpsys doesn't need root permission,
although dumpsys can't give any mic information, but it could dump the service information,
it also could help you find the app is using mic, we can combine two ways into one.
1. all apps use microphone via "/system/mediaserver", it is a service whose name is "media.player".
2. dumpsys can get information from specific service.
Finally, we get the answer, "dumpsys media.player",
if we are running any recording app,
you will see a "MediaRecorderClient" which includes pid and more information,
it means the app is using mic and recording voice ,now I can find the correct app which is using mic.
BUT I WAS NOT ABLE TO USE DUMPSYS THROUGH C
THEN I SWITCHED FINALLY TO lsof COMMAND AND RUN THE lsof CODE THROUGH MY NDK CODE AND I FOUND IN THE DUMP OF lsof THAT THERE IS SERVICE NAMED MEDIA SERVER AND FINALLY
As per Android Multimedia framework the MediaServer is responsible for opening the device and the Java based audio applications connect it as a client. The data transfer happens on the Binder. May because of this there is only one process seen which opens the audio device.
HOWEVER I REACHED HERE NOW I WANT TO KNOW HOW TO READ FROM THE INFO FROM MEDIA SERVER.
OR
ANYOTHER WAY TO DETECT WHICH APPLICATION IS USING MY PHONE MICROPHONE?