What does Intent.ACTION_HEADSET_PLUG: state: 2 means? - Java for Android App Development

Dear developers,
I absolutely couldn't find my answer on google, so I hope you can help me out.
Problem
I'm using the Intent.ACTION_HEADSET_PLUG to detect the state of the jack-plug (plugged-in or not). But when I connect my HTC Desire with Android-2.2.2 to my Eclipse and plug-in my jackplug, I get "Intent.ACTION_HEADSET_PLUG: state: 2". But according to the android API, the state 2 doesn't even exist. What does this "state: 2" mean and how to solve this?
Android API
The intent will have the following extra values:
state - 0 for unplugged, 1 for plugged.
name - Headset type, human readable string
microphone - 1 if headset has a microphone, 0 otherwise
Click to expand...
Click to collapse
Logcat output
Code:
//When I plug IN my headset
HeadsetObserver Headset UEVENT: {SUBSYSTEM=switch, SWITCH_STATE=130, DEVPATH=/devices/virtual/switch/h2w, SEQNUM=1506, ACTION=change, SWITCH_NAME=Headset}
HeadsetObserver Intent.ACTION_HEADSET_PLUG: state: 2 name: Headset mic: 0
//When i plug OUT my headset
HeadsetObserver Headset UEVENT: {SUBSYSTEM=switch, SWITCH_STATE=0, DEVPATH=/devices/virtual/switch/h2w, SEQNUM=1505, ACTION=change, SWITCH_NAME=Headset}
HeadsetObserver Intent.ACTION_HEADSET_PLUG: state: 0 name: Headset mic: 0
Hope you can give me some more information! Looking forward to hear from you. Thanks in advance!!

Have you beat audio enabled? HTC has done a deep refactoring on audio management, for test try with another device too
Sent from my Nexus 4 using XDA Premium 4 mobile app

taomorpheus said:
Have you beat audio enabled? HTC has done a deep refactoring on audio management, for test try with another device too
Sent from my Nexus 4 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
I don't have Beats audio, but maybe it is a code change by HTC anyway. Does anyone knows where I can find the API/HeadsetObserver source by HTC? Thanks.

Related

Microphone Gain Control and Current Audio Path

Hello, all
Hopefully there're some real developers here who can help me
Recently developing VoIP App for HTC devices I've found that none of them support 'Hardware Mixer' functionality. This means that mixerGetNumDevs() had returned 0 for all 4 different devices I had.
My App should at least control Microphone Input Gain to prevent signal distortion with echo from loudspeaker. In addition I'd like to control current audio path, because all HTC devices use rear loudspeaker indstead of the front one when you try to use waveOutOpen() with the single supported device ID (0).
Did anyone here develop audio recording/playing solution???
Are there any hints on this problem???
Please, help me, if you can
P.S. For now it looks like HTC produces the worst devices in the World from developers' point of view

Bet You Xda Experts Can't Solve This One...

I bet you XDA experts can't solve this one:
I used to be able to connect my Mogul to my car stereo, via the analog headphone jack, and then take/make calls using my bluetooth headset all at the same time.
But after updating the firmware in my Mogul (I think it was the upgrade to WM 6) I was no longer able to do this. And now, while playing music with the Mogul, when a call comes in I first have to physically unplug the phone from the car to be able to hear the caller on my bluetooth headset.
Is there a registry fix for this problem?
**UPDATE**UPDATE**UPDATE**
Good news!
This one was solved by ATOMCLOCK!
The link to the thread containing the fix is HERE.
Here is the fix as quoted from his thread:
"I found the fix!!!
This is the registry key
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\HTC\AudioPath]
"AudioPathSwitchToWired"=dword:00000000
If AudioPathSwitchToWired = 0 then bluetooth will be the primary output
If AudioPathSwitchToWired = 1 then usb audio will be the primary output (Default setting)"
Thanks ATOMCLOCK for your persistence in solving this issue.
ozone777 said:
I bet you XDA experts can't solve this one:
I used to be able to connect my Mogul to my car stereo, via the analog headphone jack, and then take/make calls using my bluetooth headset all at the same time.
But after updating the firmware in my Mogul (I think it was the upgrade to WM 6) I was no longer able to do this. And now, while playing music with the Mogul, when a call comes in I first have to physically unplug the phone from the car to be able to hear the caller on my bluetooth headset.
Is there a registry fix for this problem?
Click to expand...
Click to collapse
Not enough information here to help you (need ROM / Radio versions, etc).
Reflash the phone with no other programs installed and try to see if program still exists.
I do this all the time with no issues on 3.39 and 3.1.6, must be your configuration.
serfboreds said:
Not enough information here to help you (need ROM / Radio versions, etc).
Reflash the phone with no other programs installed and try to see if program still exists.
I do this all the time with no issues on 3.39 and 3.1.6, must be your configuration.
Click to expand...
Click to collapse
Here is my info:
Phone: Mogul on Sprint network
ROM: DCD 3.1.2
Radio: 3.39.10
I'm using a Y-cable that separates power (female USB) and headphone (female 3.5mm stereo) connections.
I then have a USB cigarette lighter adapter for power and a standard 3.5mm male/male stereo cable going to my radio's aux input.
This all worked flawlessly before upgrading the ROM to the first one that included Windows Mobile 6.
And yes I have tried re-flashing several times and with different ROMs.
Could it be a hardware problem?
Good news!
This one was solved by ATOMCLOCK!
The link to the thread containing the fix is HERE.
Here is the fix as quoted from his thread:
"I found the fix!!!
This is the registry key
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\HTC\AudioPath]
"AudioPathSwitchToWired"=dword:00000000
If AudioPathSwitchToWired = 0 then bluetooth will be the primary output
If AudioPathSwitchToWired = 1 then usb audio will be the primary output (Default setting)"
Thanks ATOMCLOCK for your persistence in solving this issue.

[Q] ask for bluetooth App

Hey,
I'm searching for an App to redirect FM_Radio to Bluetooth.
There are many requests about this feature for nearly all kind of mobiles. But I never found a solution.
Most mobiles have a FM_Radio just as an on top, meaning it's not really integrated and connected to the processor. (Saving an A/D converter)
But here, at the Wave FM_Radio recording is available. So the FM-Chip is fully integrated and a redirection to Bluetooth should be possible. I'm sure they only forgot it to implement or were thinking it makes no sense even you need the wired Headphone as antenna.
Antenna is not a problem, it can be done by a piece of wire.
So don't mind to possible problems with incoming calls etc.
Is it possible for someone to write a simple small app just to redirect the FM_Radio output to Bluetooth?
Regards
juppkk
Hey,
give me a chance.
is it the wrong forum?
is the requirement insoluble?
have I formulated it so incomprehensible?
or really no one here is interested in listening via Bluetooth FM_Radio
Regards
juppkk
juppk said:
Hey,
give me a chance.
is it the wrong forum?
is the requirement insoluble?
have I formulated it so incomprehensible?
or really no one here is interested in listening via Bluetooth FM_Radio
Regards
juppkk
Click to expand...
Click to collapse
Dunno if A2DP is, programmatically, supported at all. SPP, OBEX are surely accessible programmatically. As I'm just discovering the BT programming capabilities of Bada, I'll surely come back if I have some good news for you.

[DEV] Galaxy S Dual Mic Recording

Hi, I'm almost new here
Since this is my first post, I cannot post in the development section, I hope this do not cause problems.
A few days ago I got my first android phone and started to do some low-level development and I needed to record both the input from the headset mic and the internal mic at the same time. I searched a lot on the net and did not find anything useful for the Galaxy S (Vodafone european I9000), so I decided to add this feature to the wm8994 driver included in the samsung kernel source for the Galaxy S.
Since I've never worked with this kind of device, I do not know if this is the correct way to do it, but it seems to work great.
Basicly I've enabled both input at the same time and routed left adc channel output to left audio interface channel and right adc channe output to right audio interface channel. Everything else is on default settings (as configured by MAIN and SUB path, in fact I've just used the same code).
The code also adds a new enum entry for the capture path, called "DUAL", which now is after "MIC OFF", but its just an hack, I'll clean it up later. Using the command "amix" will dump all the mixer channel:
Code:
...
7 MIXER 0 0 0 1 rw ENUM Capture MIC Path { Main Mic=0, Hands Free Mic=1, BT Sco Mic=2, MIC OFF=3, Dual=4 }
...
It can be tested using the pcm_* and mixer_* routines taken from samsung's libaudio, you just need to call pcm_open without specifying PCM_MONO but just PCM_IN, since now both left and right channels will be populated. If you have access to Cyanogen Mod repository, just grab the arec.c source from there and remove the PCM_MONO flag. Beside this I suggest you to dump raw pcm audio and load it into something like Audacity, arec.c seems to produce a wrong riff header.
Now for the questions...
Any ideas on how to correctly setup the gain on both channels? Currently the gain of the headset mic is set to +15 dB on the input PGA and +0 dB on the adc channel while the gain of the internal mic is set to +10.5 dB on the input PGA and +0 dB on the adc channel. I also tried to use the same settings from Voodoo Sound high sensitivity path (with drc enabled), but no results so far... The default gain is far too low, I must talk very near to the headset mic.
Beside this, I've also noticed a strange behavior when recording from both mic. If they're very near, the audio recorded from the headset mic channel will be highly suppressed, if they're far apart, no suppression occurs. As far as I know, wm8994 do not perform noise cancellation on device, any clues on this? Anyway this is not a big deal, since the two microphones will be quite far during normal usage. By far the biggest problem is on the gain for the headset mic.
I hope someone might be interested on this extension to wm8994, this device is really powerful, it's a shame that samsung is using 1/10 of its power...
Attached to this post is the patch file, I've worked on the 2.6.35-12 (recently switched to -13) kernel from teamhacksung, you can get it on github (cannot post the link for the 8 post limit...), just apply the patch from the root kernel directory and rebuild the kernel image as usual.
Any help is highly appreciated
Thanks.
Bye!
EDIT: OPS I'm sorry but I forgot to mention that to enable dual mic recording, you have to activate its path of course through alsa_mixer, like this:
ctl = mixer_get_control(mixer, "Capture MIC Path", 0);
printf("ctl: %x\n", ctl);
if(ctl)
{
int r;
r = mixer_ctl_select(ctl, "Dual");
printf("res: %d\n", r);
}
Click to expand...
Click to collapse
forgive me
i think you should contact supercurio ( https://twitter.com/#!/supercurio )
he's a real badass when it comes to tweaking WM8994 driver
also you might want to check out his app called "voodoo control (plus)"
Welcome to xda! .... That's a great first post!
Sorry to not have any info to help you, but I hope you find what you are looking for and get this working how you want.
I agree that Supercurio is probably the most clued up on audio for these phones. But you probably already knew that since you mention Voodoo Sound (which is his work).
Good luck
Mike
Quake2 said:
Hi, I'm almost new here
Since this is my first post, I cannot post in the development section, I hope this do not cause problems.
A few days ago I got my first android phone and started to do some low-level development and I needed to record both the input from the headset mic and the internal mic at the same time. I searched a lot on the net and did not find anything useful for the Galaxy S (Vodafone european I9000), so I decided to add this feature to the wm8994 driver included in the samsung kernel source for the Galaxy S.
Since I've never worked with this kind of device, I do not know if this is the correct way to do it, but it seems to work great.
Basicly I've enabled both input at the same time and routed left adc channel output to left audio interface channel and right adc channe output to right audio interface channel. Everything else is on default settings (as configured by MAIN and SUB path, in fact I've just used the same code).
The code also adds a new enum entry for the capture path, called "DUAL", which now is after "MIC OFF", but its just an hack, I'll clean it up later. Using the command "amix" will dump all the mixer channel:
Code:
...
7 MIXER 0 0 0 1 rw ENUM Capture MIC Path { Main Mic=0, Hands Free Mic=1, BT Sco Mic=2, MIC OFF=3, Dual=4 }
...
It can be tested using the pcm_* and mixer_* routines taken from samsung's libaudio, you just need to call pcm_open without specifying PCM_MONO but just PCM_IN, since now both left and right channels will be populated. If you have access to Cyanogen Mod repository, just grab the arec.c source from there and remove the PCM_MONO flag. Beside this I suggest you to dump raw pcm audio and load it into something like Audacity, arec.c seems to produce a wrong riff header.
Now for the questions...
Any ideas on how to correctly setup the gain on both channels? Currently the gain of the headset mic is set to +15 dB on the input PGA and +0 dB on the adc channel while the gain of the internal mic is set to +10.5 dB on the input PGA and +0 dB on the adc channel. I also tried to use the same settings from Voodoo Sound high sensitivity path (with drc enabled), but no results so far... The default gain is far too low, I must talk very near to the headset mic.
Beside this, I've also noticed a strange behavior when recording from both mic. If they're very near, the audio recorded from the headset mic channel will be highly suppressed, if they're far apart, no suppression occurs. As far as I know, wm8994 do not perform noise cancellation on device, any clues on this? Anyway this is not a big deal, since the two microphones will be quite far during normal usage. By far the biggest problem is on the gain for the headset mic.
I hope someone might be interested on this extension to wm8994, this device is really powerful, it's a shame that samsung is using 1/10 of its power...
Attached to this post is the patch file, I've worked on the 2.6.35-12 (recently switched to -13) kernel from teamhacksung, you can get it on github (cannot post the link for the 8 post limit...), just apply the patch from the root kernel directory and rebuild the kernel image as usual.
Any help is highly appreciated
Thanks.
Bye!
EDIT: OPS I'm sorry but I forgot to mention that to enable dual mic recording, you have to activate its path of course through alsa_mixer, like this:
forgive me
Click to expand...
Click to collapse
@Quake2 : DO you have datasheet /pin diagram of wm8994
I would like to insert digital data on mic instead reading from analog input

Can the Nexus 7 be recognized as a bluetooth phone device?

I have my Nexus 7 installed in my car and I'm trying to get it to auto connect to my head unit. I've tried different apps, Tasker, and different settings and I believe the issue is because its a "media only" bluetooth device. Is there a way to add the "Phone Profile" like I have on my GNex to the Nexus 7?
I believe tablet talk has an option. I'll check and post A screenie
Sent from my SPH-L710 using xda premium
Sent from my SPH-L710 using xda premium
Thanks for the tip...I'll give it a shot. Hopefully this gives me the Phone profile in the Bluetooth settings.
Doesn't look like Tablet Talk will give the Nexus 7 the Phone Profile in the default bluetooth settings. Any other ideas?
Not really sure I don't have a Bluetooth headset. I just seen that in the settings.
Sent from my SPH-L710 using xda premium
You could try adding these services in the terminal:
Code:
% sdptool add HS
Headset service registered
% sdptool add HF
Handsfree service registered
% sdptool add HFAG
Handsfree AG service registered
You can also try to change the device class to "Phone, Smart phone":
Code:
% hciconfig hci0 class 0x5a020c
None of these changes will be visible in the GUI, but they might convince your car kit that it wants to auto connect. If it works, you can run these commands with Tasker and the Secure Settings plugin.
elmicha said:
You could try adding these services in the terminal:
Code:
% sdptool add HS
Headset service registered
% sdptool add HF
Handsfree service registered
% sdptool add HFAG
Handsfree AG service registered
You can also try to change the device class to "Phone, Smart phone":
Code:
% hciconfig hci0 class 0x5a020c
None of these changes will be visible in the GUI, but they might convince your car kit that it wants to auto connect. If it works, you can run these commands with Tasker and the Secure Settings plugin.
Click to expand...
Click to collapse
I'm having the same issue like the OP. I have android 4.2.1 and I can't find sdptool in system/bin/
I'm looking to do something similar here, and I know this topic has come up before. I want the N7 to act as a bluetooth "headset" for my N4 for a car install. It definitely lacks a phone profile.
Mega props if anyone figures out how to do that well.
YES!
SQurel23 said:
I have my Nexus 7 installed in my car and I'm trying to get it to auto connect to my head unit. I've tried different apps, Tasker, and different settings and I believe the issue is because its a "media only" bluetooth device. Is there a way to add the "Phone Profile" like I have on my GNex to the Nexus 7?
Click to expand...
Click to collapse
Finally, others who know my pain! It is really frustrating because I am trying to have my Nexus 7 basically stand in for my head unit. Its pretty annoying if you have to set it up each and every time you get in and out of the car though. I'm on the verge of returning the JVC unless someone has made some headway.
Edit - tried sdptool from the command prompt and it did not work. Tried before and after rebooting. Working to find out more about hciconfig. This doesn't work right away from the command prompt. Time to thread crawl some more.
AW: Can the Nexus 7 be recognized as a bluetooth phone device?
sdptool and hciconfig are parts of the "old" Bluetooth stack Bluez. With Android 4.2 a new Bluetooth stack by Broadcom has been introduced, and I guess the old Bluez commands don't work anymore. And nobody confirmed that these commands were even helpful in this situation.
Count me among those who desparately want the N7 to auto connect to my car radio.
*Bump*

Resources