Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Android Emulator microphone's default settings

When I'm starting my Android Emulator, I click on the three dots at right. Then, in "Extended controls" window, I set the Microphone options all active.

I must do it every time I start it, and it's very annoying. It is possible to make these settings active by default? And how?

like image 383
Lore Avatar asked Sep 18 '19 13:09

Lore


People also ask

How do I increase my mic sensitivity on my Android?

Go to Settings > System > Sound. Under Input, make sure your mic is selected, then click Device Properties. Select Additional device properties. In the Levels tab, increase or decrease the Microphone (sensitivity).

Why is Android studio using my mic?

It's the Android emulator. The emulated phone has a microphone, so the emulator uses your computer's microphone to emulate it. Feel free to deny access to your microphone; the emulator will work fine—except for its microphone, of course.


1 Answers

Edit: I was wrong saying there is no other way to allow microphone input. Looked again and found another commit later that introduced allow-host-audio option. So this is the way to start the emulator with host audio enabled:

emulator -avd YourAvdName -qemu -allow-host-audio
adb emu avd hostmicon

It seems like it's not enabling the switch in the settings, but that's a pure UI issue, the mic works fine.

Previous answer:

I don't believe there is currently a way for this particular setting. Normally emulator setting are saved into AVD.conf. Here are all the constants for the persistent settings and microphone settings are not among them. Looking further at the Virtual microphone uses host audio input setting I found the commit which introduced this setting and as you can see when you toggle this setting it sets allow_real_audio in audio subsystem and that's it. No other code is setting this flag. As you can see here this option is being reset on restart intentionally and hopefully it will be fixed when the described bug is fixed.

Edit: here is a bit more on how exactly the flag is set: UI switch toggle is handled in this line. It calls this function, which in its turn calls qemu_allow_real_audio, which sets allow_real_audio flag. This flag is used in the AUD_read function

    if (!allow_real_audio) {
        // TODO: Also a potential way to pipe fake audio input
        // that is not just all zeroes.
        memset(buf, 0x0, size);
    }
like image 126
esentsov Avatar answered Oct 27 '22 11:10

esentsov