com.android.phone mic volume - Android Software Development

hello all
want to know if possible to increase mic volume of phone app. want to recompile packages/apps/Phone/src/com/android/phone and replace com.android.phone on milestone
A set volume with int like setStreamVolume
B manual amplitude akkumulation on raw byte stream
1st question where to find the point where the stream of the mic is requested in com/android/phone. If sb can tell, i will find the rest
2nd question is it possible to replace com.android.phone or have to parallel
...no problemo
searched the source
searched google
searched this forum
searched the source
nothing found
please answer solution, no ask why or say its wrong what i try
thx

will try to recompile and replace com.android.phone next weekend, if i find time. will then post the exact result of my attemts

no success to replace the phone app. is it possible?

since i noticed, that nobody has answered yet, i will try to figure out my idea in other words:
the original phone app for android has currently no functionality to set the microphone sensitivity directly. this is a problem if sb. wants to call another person who has a low speaker.
to solve this, i want to increase the microphone sensitivity by simply multiply the amplitude of the input stream (microphone stream).
Code:
0x20, 0x00, 0x7F, 0x00, 0x20, 0x00, 0x7F, 0x00
will be multiplied by 2 with saturation to
Code:
0x40, 0x00, 0x7F, 0x00, 0x40, 0x00, 0x7F, 0x00
expecting signed bytes as data format.
this will simulate that i will speak very clear even if i would speek normal. the saturation effect could be post processed to reduce crackling, but this is not high priority.
could anybody help me to start this? it will be grateful, even if it is a litte urgent.

Have you looked at AudioFlinger?
I"ve been studying HTC FM Tuner, and I noticed that AudioFlinger set the volumes to my audio streams (represented as threads). If you could find a way to access the "recording" thread from mic, then maybe you can increase volume. AudioFlinger is low level stuff, and I don't know how to access it, but that could be a possibility for you.
Here's more info on it.
http pdk.android.com |online-pdk|guide|audio.html
Look at my log for FM Radio
.774: DEBUG/FmReceiverService(101): ******* ******* Processing job:FM_SET_VOLUME TimeSent:11:58:06 PM
07-15 23:58:06.774: DEBUG/FmReceiverService(101): ***** ***** processCommands:[]
07-15 23:58:06.824: INFO/global(1108): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
07-15 23:58:06.824: DEBUG/AudioHardwareQSD(55): FM radio started.
07-15 23:58:06.824: DEBUG/AudioHardwareQSD(55): FM: Set Aux Gain 0 success
07-15 23:58:06.824: DEBUG/AudioFlinger(55): setStreamVolume(), stream:2, value:0.019055, output:1
07-15 23:58:06.824: DEBUG/AudioFlinger(55): setStreamVolume(), stream:4, value:0.501187, output:1
07-15 23:58:06.824: DEBUG/AudioFlinger(55): setStreamVolume(), stream:5, value:0.263027, output:1
07-15 23:58:06.824: DEBUG/AudioFlinger(55): setStreamVolume(), stream:7, value:1.000000, output:1

hello
does anybody know a good android developer forum ?

Related

GPRS

Hi I am very new to C# and compact framework. I have been coding for XDA's using eVB. I want to be able to enable the GPRS mode and also be able to Hangup.
Do I use RasDial? Is this an achievable task for a C# beginer? Could someone please give me some hints as how to achieve this.
Highflyer,
Firstly, why move over to C# when you can achieve what you want using VB.NET. Like yourself, I have ported across an eVB Rasdial app across to .NET CF. Secondly, with GPRS remember that you only pay for the data that is transferred over the connection, so you dont need to worry about the disconnection, but this can be done manually by putting the XDA into FLIGHT MODE. I think you will find another thread covering how to do this programmatically in this forum.
In my app, my XDA is sending and requesting XML packets over HTTP to a web server. To do this I use the HttpWebRequest and HttpWebResponse classes.
Here is a snippet of code
*******************************
Public Function Post(ByVal sURL As String, Optional ByVal strRequest As String = "", Optional ByVal blnRetValExpected As Boolean = False, Optional ByRef strReturned As String = "", Optional ByRef intStatus As Integer = 0) As Boolean
Dim WebReq As HttpWebRequest
Dim WebRes As HttpWebResponse
Dim bOK As Boolean
Try
WebReq = CType(WebRequest.Create(sURL), HttpWebRequest)
If strRequest <> "" Then
Dim encoding As New ASCIIEncoding
Dim byte1 As Byte() = encoding.GetBytes(strRequest)
WebReq.Method = "POST"
WebReq.ContentType = "application/x-www-form-urlencoded"
WebReq.ContentLength = strRequest.Length
Dim newStream As Stream = WebReq.GetRequestStream()
newStream.Write(byte1, 0, byte1.Length)
newStream.Close()
End If
WebRes = CType(WebReq.GetResponse(), HttpWebResponse)
If WebRes.StatusCode = HttpStatusCode.OK Then
bOK = True
End If
intStatus = WebRes.StatusCode
Catch ex As InvalidOperationException
bOK = False
Catch ex As WebException
bOK = False
Catch ex As ProtocolViolationException
bOK = False
End Try
If bOK And blnRetValExpected Then
If WebRes.ContentLength > 0 Then
Dim sResponse() As Byte
Dim ReceiveStream As Stream = WebRes.GetResponseStream()
Dim encode As encoding = encoding.GetEncoding("utf-8")
Dim ReadStream As New StreamReader(ReceiveStream, encode)
Dim strXML As String = ""
Try
strXML = ReadStream.ReadToEnd()
Catch ex As Exception
strXML = ""
bOK = false
Finally
ReadStream.Close()
End Try
strReturned = strXML
End If
End If
WebRes.Close()
Post = bOK
End Function
*******************************
What you will find with the above code is that there is no code for making the GPRS connection and RasDial is no longer required. This is due to the code being hidden away in the HttpWebRequest class and the GPRS connection will use the current connection if it exists or prompt the user for the connection to use. The prompting can be overcome by setting a defualt GPRS connection in Settings - Connection Manager, and saving the password along with it. HTH.
Tony,
Many thanks for your advice. The included sample code is very useful. The problem is I have to stick with C#, wether I like it or not. However I can follow your code to reporoduce something similar in C#. I have already used Post in eVB, to send data, however I changed over to using sockets (WinSock), since I understand there is lower data over head in using sockets. I appreciate any comments you may have with this choice.
One question, you mentioned that when we connect to GPRS we do not pay for actual connection. Is this right, my understanding was when the device connects to GPRS, some data is used to achieve this connection, thus just establishing a connection to GPRS would cost. I am thinking of the situation when GPRS has to be enabled and disabled hundreds of times a day.
Thanks again, looking forward to hear any comments.
Highflyer,
Regarding a connection charge - you may be right about this depending on the type of contract you are on, but as I mentioned once a connection is established you are only charged for the data that is transferred over the connection, so why not leave the connection open then there will only be the one connection charge. If the connection is lost due to poor signal then the underlying code of the web components will re-establish the connection as and when required. HTH.
Thanks for your advice.
I am still very interested to be able to perform RasDial using C#. As I said I have tried to write the code however due to my lack of experience in using C# the code does not work.
Any Ideas or advice anybody.
Thanks
WebRequest on Magician/XDA Mini?
Hi there!
I´m glad finding .NET developers here ;-)
I have a big, big problem:
On several XDA Mini´s (HTC Magician) the HttpWebRequest or WebRequest methods instantly return with an exception (ConnectFailure), even if Pocket IE or other software can reach the net. I´ve tested both, connection via ActiveSync and GPRS, but it does not work.
Any ideas on this? Is it a known issue, and is there a way to solve it?
Thanky in advance,

converting ASCII to Unicode

hi ther i wonder if you could help me on this simple task. I'm creating a GPS application to run on the XDA2, i'm using eVC++ to do the implementation.
at the moment i'm reading the GPS signal via bluetooth over a virtual COM port, the signal coming from the GPS if a ASCII sinal and i'm duimping this into a char buffer.
However i need to convert this to UNICODE in order to display it on the Pocket PC, how's best to convert a buffer full of ASCII into Unicode so i may display it?
I tried using MultiByteToWideChar(), but it doesn't seem to work properly, maybe i haven't set it up correctly? Could someone point me in the right direction!
Below is an example of what i tried:
Code:
char buf[50]; // contains output from GPS
TCHAR Message[50]; //where i intended to put the message so i could display it
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buf, -1, Message, 0);
Thank in advance
I'm sure it's not the right way to go about it, but I generally wsprintf for short strings.
However, don't listen to me, I'm a mad man. Check this page out instead:
http://www.i18nguy.com/unicode/c-unicode.html
V
Thanks for that, out of curiosity, how would you use wsprintf to convert ASCII to unicode, i tried that before with no real success!
The last value passed to MultiByteToWideChar tells this function the size of the result buffer, Message in your case. You have passed zero, all that does is makes the function return the size of a TCHAR variable it needs to put the Ascii input buf into.
You need to put sizeof(Message) as the last parameter and not zero.
The other way (better way ?) of doing this is first you call the MultiByteToWideChar function with the zero parameter as you have and then you malloc the result * sizeof(TCHAR).
Thanks for the advise, after looking into the function more i realised this is where i was going wrong, and i have now managed to make the conversion. Thanks for pointing that out though!

lineGetID returns a NULL handle

Hi everybody
I tried to achieve a handle for readFile/writeFile operations using lineGetID.
The call to the function passed without errors. My problem is that the handle that I get is 0..., and I should make IO operations some how...
My code:
lRet := lineGetID( FLineHandle, 0, 0, LINECALLSELECT_LINE, PVarString, szClassType );
if lRet = 0 then
begin
FDevHandle := (LPHANDLE(PByte(PVarString) + PVarString^.dwStringOffset ))^;
// some more non relevant code which checks the validity of FDevHandle....
end;
The call to lineGetID is done after successful call to lineGetOpen. I test my application on i-mate jam with WM2003.
Thanks ahead
Kobi
I solved the problem
Hi everybody
For those who encounters the same problem as mine here is the solution that I finally found:
1. The Handle is NULL if we call the lineGetID using LINECALLSELECT_LINE. We should call lineGetID after getting into the LINECALLSTATE_CONNECTED state and use the LINECALLSTATE_CALL parameter. This information was found in the MSDN.
2. The lineGetID (as well as other line functions) doesn't report (I use TAPI 2.0 with WM-2003 on i-mate jam - the cellular line channel) the error LINEERR_STRUCTURETOOSMALL, so immediately after calling the lineGetID I added the following line (I use free pascal compiler):
if (Result = 0) and (PVarString^.dwTotalSize < PVarString^.dwNeededSize) then
Result := integer(LINEERR_STRUCTURETOOSMALL);
After this line comes the characteristic TAPI code which checks if either we should reallocate the previous block, or we can already use the data that call should have given to us.
Just after considering these 2 issues I got a vaild Handle...
Kobi
Hi Kobi,
I also having difficulties creating handle to write data on this TAPI Line, Can you please help me translate your code in VB.NET or C#, I am using VB and C# on developing application in WM2003.
Many thanks in Advance,
Eefendi
More complete code
Hi Eefendi
I neither know VB.NET nor C#, so it will be in Pascal, but I will add comments.
The code itself should be activated after you received the LINE_CALLSTATECONNECTED message/event (depends on the mechanism you selected when you called lineInitialize).
The CallHandle is a variable holds the handle of the call you want to achieve a handle to its stream (you achieve CallHandle, in incoming call for example, using LINE_CALLSTATEOFFERING message/event). The final result we want is stored in Handle. The line itself should be opened using "comm" or "comm/datamodem" class type.
var
VarSize,
Res : integer;
PVarString : LPVARSTRING;
szClassType : PWideChar = 'comm/datamodem';
// these variables definitions is equivalent to the following C code:
// int VarSize, Res;
// LPVARSTRING PVarString;
// TCHAR *szClassType = "comm/datamodem";
begin
VarSize := sizeof(VARSTRING);
Handle := 0;
repeat
GetMem( PVarString, VarSize ); // alloc VarSize bytes
PVarString^.TotalSize := VarSize;
Res := lineGetID( 0, 0, CallHandle, LINECALLSELECT_CALL, PVarString, szClassType );
if (Res = 0) and (PVarString^.TotalSize < PVarString^.NeededSize) then
Res := LINEERR_STRUCTURETOOSMALL;
if Res = LINEERR_STRUCTURETOOSMALL then
VarSize := PVarString^.NeededSize
else
if Res = 0 then // no error
Handle := LPHANDLE(PByte(PVarString) + PVarString^.dwStringOffset)^;
FreeMem( PVarString, PVarString^.TotalSize ); // free memory
until Res <> LINEERR_STRUCTURETOOSMALL; // finish the repeat until loop if this condition is TRUE
if (Handle <> 0) and (Handle <> INVALID_HANDLE_VALUE) then
//;use it as you wish....
end;
Some help to you for conversion:
1. PVarString^.TotalSize using C means PVarString->TotalSize
2. PByte using C means char*
3. type cast for example to PByte is done by PByte(...) while using C it is done by (PByte)...
4. Refering to a value which is referenced by the pointer P and storing it in variable X is done by "X := P^;". using C it is done by "X = *P;".
5. The operator <> means not equal. in C it is !=.
I hope it will be easy to you to translate it to C or any other language you want.
Good luck with your project.
Kobi
TAPI does seem to pop up a lot.
Have you looked at my code I posted a while back here ?
http://forum.xda-developers.com/viewtopic.php?t=18978
Hi Vangelderp and Kobi,
thanks for spending your time answering my questions and also thanks for the code provided. I use VB.Net 2003 on programming my pocket PC 2003, you guys provide me the code using pointer data type which is not supported in VB.net, so I am having trouble converting it. ( When I was learning C++, pointer is always make me confuse :roll: ). I wish you guys will be kind enough helping me convert it to VB.Net, just for small part to get Handle. :wink:
Mant Thanks in advance,
Eefendi

Play Sound While on Call

Hello,
Does anyone know how to play a sound (preferably through the earpiece) while on a phone call? I found some code on the internet somewhere that allows me to play sound, but when I make a call, it doesn’t work. Here is the code I have now.
Code:
Public Class Sound
Private m_soundBytes() As Byte
Private m_fileName As String
Public Declare Function WCE_PlaySound Lib "CoreDll.dll" Alias "PlaySound" (ByVal szSound As String, ByVal hMod As IntPtr, ByVal flags As Integer) As Integer
Public Declare Function WCE_PlaySoundBytes Lib "CoreDll.dll" Alias "PlaySound" (ByVal szSound() As Byte, ByVal hMod As IntPtr, ByVal flags As Integer) As Integer
Private Enum Flags
SND_SYNC = &H0 ' play synchronously (default)
SND_ASYNC = &H1 ' play asynchronously
SND_NODEFAULT = &H2 ' silence (!default) if sound not found
SND_MEMORY = &H4 ' pszSound points to a memory file
SND_LOOP = &H8 ' loop the sound until next sndPlaySound
SND_NOSTOP = &H10 ' don't stop any currently playing sound
SND_NOWAIT = &H2000 ' don't wait if the driver is busy
SND_ALIAS = &H10000 ' name is a registry alias
SND_ALIAS_ID = &H110000 ' alias is a predefined ID
SND_FILENAME = &H20000 ' name is file name
SND_RESOURCE = &H40004 ' name is resource name or atom
End Enum
' Construct the Sound object to play sound data from the specified file.
Public Sub New(ByVal fileName As String)
m_fileName = fileName
End Sub
' Construct the Sound object to play sound data from the specified stream.
Public Sub New(ByVal stream As IO.Stream)
' read the data from the stream
m_soundBytes = New Byte(stream.Length) {}
stream.Read(m_soundBytes, 0, Fix(stream.Length))
End Sub 'New
' Play the sound
Public Sub Play()
' If a file name has been registered, call WCE_PlaySound,
' otherwise call WCE_PlaySoundBytes.
If Not (m_fileName Is Nothing) Then
WCE_PlaySound(m_fileName, IntPtr.Zero, Fix(Flags.SND_ASYNC Or Flags.SND_FILENAME))
Else
WCE_PlaySoundBytes(m_soundBytes, IntPtr.Zero, Fix(Flags.SND_ASYNC Or Flags.SND_MEMORY))
End If
End Sub
End Class
I am writing this for my Kaiser on WM6, but support for earlier devices would be nice if possible.
Thanks,
Jay
i'm also trying to create an application that vibrates the phone whenever call is connected but somehow the OS mutes all sounds and vibrations while you are making a call.
The code you have, IMHO, plays the sound through the loudspeaker, not the earpiece.
what you would have to do, because i have done it, is set the registry settings under the control panel (under local machine) and there is an option to set different sounds for differnt events/actions/calls/messages etc
try API PlayEventSound
this idea is already integrated in LC minutes though i didnt have much time to work it out like it should be.
It would be nice to have a complete customization of this idea.
mrpotter said:
try API PlayEventSound
Click to expand...
Click to collapse
Thank you mrpotter. PlayEventSound did what I was looking for
It may play a sound environmental background during a call to simulate being in a traffic jam or in the countryside?
Example
Can anyone post an example of how to use API playeventsound in .net ?

[Q] RS232 serial signal input via 3.5mm audio port of android smartphone

Hi and first thank you for reading my question!
I have a device, which gives me an output of essentially just a RS232 serial signal (1200 baud, 8 databits, no parity bits, one stop bit). This output comes in to my android phone via the 3.5mm audio jack.
I want to store every data bit into a variable, display or calculate something and when the next bits come in, it should override the variable.
I know exactly what to do with it after I thave the databits in variables but I have no idea on how to do the basic input / stream / read from audio jack thing...
More informations about my signal The payload is transmitted in 9 byte packets:
Code:
1: command byte as ASCII character ('I','A','S','L','R','C' or ' ')
2-6: time in ASCII chars (2:34:56)
7: checksum (64 + sum of time digits)
8: CR (carriage return, ASCII code 0x0D)
9: LF (line feed, ASCII code 0x0A)
I also think I have to store the input into a buffer and then read the signals from the buffer... But how do I write serial input from audio jack into a buffer?
Maybe something like this will work:
Code:
try
{
int N = AudioRecord.getMinBufferSize(8000,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT);
recorder = new AudioRecord(AudioSource.MIC, 1200, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, N*10);
track = new AudioTrack(AudioManager.STREAM_MUSIC, 1200,
AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, N*10, AudioTrack.MODE_STREAM);
recorder.startRecording();
track.play();
/*
* Loops until something outside of this thread stops it.
* Reads the data from the recorder and writes it to the audio track for playback.
*/
while(!stopped)
{
Log.i("Map", "Writing new data to buffer");
short[] buffer = buffers[ix++ % buffers.length];
N = recorder.read(buffer,0,buffer.length);
track.write(buffer, 0, buffer.length);
}
}
catch(Throwable x)
{
Log.w("Audio", "Error reading voice audio", x);
}
/*
* Frees the thread's resources after the loop completes so that it can be run again
*/
finally
{
recorder.stop();
recorder.release();
track.stop();
track.release();
}
}
Please help me, thank you!

Categories

Resources