[Motorola Atrix 2] nma83:
Thread title was: Debugging in-call volume adjustment issue

I have made an app to adjust the in-call voice volume when running kexec based ROMs in edison (works in non-kexec ROMs too). This app uses the binary published previously. It needs root privileges to create the socket that will talk to the modem. Source posted on github and the compiled apk (ATCmd.apk) is attached to this post.

Testers welcome! Seems to work well on my phone. I'd also like some peer review since the app needs root privileges.

The app has been modified by [MENTION=2372465]ShurikKb[/MENTION] to change volume via volume keys.

How to use the new app (thanks to [MENTION=5363366]sameerm02[/MENTION])

:

1. Uninstall the old call volume app (if you have it).

2. Install the apk named ATCmd_ShurikKb_26032014.apk, allow SU permissions

3. Restart your phone (only if making a call immediately after installing)

4. Don’t call immediately as your phone turns ON, wait until you get the message that super user has given the permission to call volume.

5. After this message, call anyone and check the in-call volume

6. Just take care not to press volume up or down button repeatedly, wait for some moment after the press then press the required volume buttons.

7. It is recommended to go to SuperUser right after granting the permission and switch off journaling and notifications for this programm, it will improve performance.

Change-log

:

26-12-2013: Added service to restore stored volume on boot.

27-12-2013: Minor UI updates.

30-12-2013: Added an 'Auto apply' option that changes volume as soon as bar is adjusted. Works best when the app is granted root permission always.

26-03-2014: [MENTION=2372465]ShurikKb[/MENTION] updated the app to change volume via volume keys instead of needing to open the app.

TODO

:

Store volume setting and restore on boot.

Integrate the solution into phone dialer app.

Any bugs - report here.

Thanks,

NMA

Hi devs,

The bunch of kexec kernel based ROMs for the A2 are terrific to use across android versions 4.2.x, 4.3.x and now 4.4.x. One issue that bothers me a lot is the inability to adjust the in-call volume when using kexec kernels. The volume seems to be pegged at close to maximum and can be ear-splitting sometimes! Over the last week, I set out to dig deep into this, though I am handicapped w.r.t knowledge about Android internals and the Linux kernel, being just a hobby programmer.

I am nowhere close to a solution, but would like to lay out the steps I took and what I could find for the benefit of the great devs here.

Tried to control voice audio path via ALSA as described in http://omappedia.org/wiki/File:ASoC_ABE_controls.jpg.

Found that ALSA does not control the voice path at all in both stock and kexec. Dead-end...

Looked at strings in audio.primary.omap4.so for any reference to volume.

Found an error string "Cannot open volume key sys file".

On tracing disassembly of the library, found it to be used in a wakeup related function and not for volume.

Compare logcats taken during a call and volume buttons toggled from both stock kernel and kexec based setups.

Observed that AT commands are sent during volume adjustment in stock, specifically AT*EADVOL.

In kexec, no AT command activity observed (in logcat atleast).

Searched for AT strings in kexec audio.primary.omap4.so.

Found strings with AT*EADVOL in them, and formatted similarly as seen in stock logcat.

Parsed audio.primary.omap4.so disassembly for all references to the AT string assuming the pointer is passed as an argument to some function (looked at r1 and r2 registers for a start).

Found calls to at_send_command() with the above AT strings passed as part of am_aipcm_codec* functions.

Checked /proc/tty/drivers for getting the modem device so that I could send the AT command manually, but no success.

I stopped here and thought I could ask the community. It is possible that once we figure out how to send the AT commands to the modem (what command is already known), the problem could be solved? Or am I missing something here....

EDIT: Solution!

I was able to build a binary which would send the proper AT commands to control voice volume. Attached is the compiled executable named at-cmd (meant for expert users only as of now). Code and instructions available at github. I have only made a native executable as of now. The proper solution would be to integrate this method into the framework to act on volume button input in-call.

Devs, I would love some feedback!

Thanks to altered for pointing me to the modem daemon source which donated most of the code in this binary.