[Q] Cell signal not being reported correctly - Zooper Widget General

Hi!
When my phone is on LTE I notice that the NCSIGN is a positive number when it should be negative. When I turn off LTE and 3G comes on it goes to its correct negative number. NCSIG will report 99 when on LTE.
I can do this in tasker but what good are the functions in Zooper if you have to go outside to get information for something it already provides?
Is there a work around for this? Without getting into a fairly lengthy if .. then statement. Cause then I'd have to be checking whether or not the phone is in LTE or not. /sigh
Side question: Is there a function that will translate what NCCONN or NCCONNS is to its respective 2G,3G,3G-HSPA,4G-WiMax,4G or 4G-LTE laymen terms? Like EVDOrA or Ev as the short version of it goes is one of the 3G's. This might have to be a lengthy if .. then statement but it would be useful!
Any help is good help and I thank you much for it! :good:

MrBiggzz said:
Hi!
When my phone is on LTE I notice that the NCSIGN is a positive number when it should be negative. When I turn off LTE and 3G comes on it goes to its correct negative number. NCSIG will report 99 when on LTE.
I can do this in tasker but what good are the functions in Zooper if you have to go outside to get information for something it already provides?
Is there a work around for this? Without getting into a fairly lengthy if .. then statement. Cause then I'd have to be checking whether or not the phone is in LTE or not. /sigh
Side question: Is there a function that will translate what NCCONN or NCCONNS is to its respective 2G,3G,3G-HSPA,4G-WiMax,4G or 4G-LTE laymen terms? Like EVDOrA or Ev as the short version of it goes is one of the 3G's. This might have to be a lengthy if .. then statement but it would be useful!
Any help is good help and I thank you much for it! :good:
Click to expand...
Click to collapse
Please use the search function to see if there is already a thread about your problem before posting a new one.
Here is a thread about your problem with explanations and some ideas about workarounds: http://forum.xda-developers.com/showthread.php?t=2600763
Send from my secret moonbase via space carrier pigeons

Sorry.
I saw that thread before and since I've really dove into it Zooper this week the if statement makes sense now.
I do search. Sometimes I just don't know what I'm searching for!
Thanks for the point out!
Sent from my Nexus 5 using Tapatalk

MrBiggzz said:
Hi!
When my phone is on LTE I notice that the NCSIGN is a positive number when it should be negative. When I turn off LTE and 3G comes on it goes to its correct negative number. NCSIG will report 99 when on LTE.
I can do this in tasker but what good are the functions in Zooper if you have to go outside to get information for something it already provides?
Is there a work around for this? Without getting into a fairly lengthy if .. then statement. Cause then I'd have to be checking whether or not the phone is in LTE or not. /sigh
Side question: Is there a function that will translate what NCCONN or NCCONNS is to its respective 2G,3G,3G-HSPA,4G-WiMax,4G or 4G-LTE laymen terms? Like EVDOrA or Ev as the short version of it goes is one of the 3G's. This might have to be a lengthy if .. then statement but it would be useful!
Any help is good help and I thank you much for it! :good:
Click to expand...
Click to collapse
Several others have posted concerning a similar problem. I posted about it a week ago in this thread, where I proposed that the problem is that Zooper pulls incorrect info when the phone is on LTE (it pulls the RSSI value, instead of the RSRP value). You can try the workarounds suggested above (YMMV) but it'd be nice to have LTE working in a straightforward manner (3G works fine)

Tasker incorrectly report LTE cell signal as well ( %CELLSIG ).
Sent from my Nexus 5 using Tapatalk

So I have this partially figured out.
NOTE: This exact command will liklely not work on your phone. I have a Verizon S4 running Carbon, so CM internals.)
Have tasker run this shell command as root:
Code:
dumpsys telephony.registry | grep 'SignalStrength:' | cut -d " " -f 12
and store the results in a variable, then load the variable upon being set to a Zooper variable.
You will have to run the command without piping to cut to see all the output to figure out which field is your dBm.
For my phone, the 12th field in the signal strength line in the dump is the signal strength in dBm as reported by the ROM. (By the way, you can see where Zooper gets it's erroneous 99 value in the the output of the grep before the cut command.) So I can get Zooper to report dBm correctly on LTE, and ASU (its just dBm +140 for LTE).
BUT...
You have to run the dumpsys to get the variable in tasker to change. You can set it to run every two minutes at the most in tasker. Or make it on demand for Zooper, but I have not come up with a way to make it real time. And I am sure this will crush the battery if it runs every 2 minutes all day. But one step closer to getting Zooper to correctly report dBm. My guess is you need a custom API to do it right unless Google standardizes things.

OK.
So I have this almost completely figured out.
Here is the git for how Android does signal bars for LTE:
Code:
/**
* Get LTE as level 0..4
*
* @hide
*/
public int getLteLevel() {
/*
* TS 36.214 Physical Layer Section 5.1.3 TS 36.331 RRC RSSI = received
* signal + noise RSRP = reference signal dBm RSRQ = quality of signal
* dB= Number of Resource blocksxRSRP/RSSI SNR = gain=signal/noise ratio
* = -10log P1/P2 dB
*/
int rssiIconLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN, rsrpIconLevel = -1, snrIconLevel = -1;
if (mLteRsrp > -44) rsrpIconLevel = -1;
else if (mLteRsrp >= -85) rsrpIconLevel = SIGNAL_STRENGTH_GREAT;
else if (mLteRsrp >= -95) rsrpIconLevel = SIGNAL_STRENGTH_GOOD;
else if (mLteRsrp >= -105) rsrpIconLevel = SIGNAL_STRENGTH_MODERATE;
else if (mLteRsrp >= -115) rsrpIconLevel = SIGNAL_STRENGTH_POOR;
else if (mLteRsrp >= -140) rsrpIconLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
/*
* Values are -200 dB to +300 (SNR*10dB) RS_SNR >= 13.0 dB =>4 bars 4.5
* dB <= RS_SNR < 13.0 dB => 3 bars 1.0 dB <= RS_SNR < 4.5 dB => 2 bars
* -3.0 dB <= RS_SNR < 1.0 dB 1 bar RS_SNR < -3.0 dB/No Service Antenna
* Icon Only
*/
if (mLteRssnr > 300) snrIconLevel = -1;
else if (mLteRssnr >= 130) snrIconLevel = SIGNAL_STRENGTH_GREAT;
else if (mLteRssnr >= 45) snrIconLevel = SIGNAL_STRENGTH_GOOD;
else if (mLteRssnr >= 10) snrIconLevel = SIGNAL_STRENGTH_MODERATE;
else if (mLteRssnr >= -30) snrIconLevel = SIGNAL_STRENGTH_POOR;
else if (mLteRssnr >= -200)
snrIconLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
if (DBG) log("getLTELevel - rsrp:" + mLteRsrp + " snr:" + mLteRssnr + " rsrpIconLevel:"
+ rsrpIconLevel + " snrIconLevel:" + snrIconLevel);
/* Choose a measurement type to use for notification */
if (snrIconLevel != -1 && rsrpIconLevel != -1) {
/*
* The number of bars displayed shall be the smaller of the bars
* associated with LTE RSRP and the bars associated with the LTE
* RS_SNR
*/
return (rsrpIconLevel < snrIconLevel ? rsrpIconLevel : snrIconLevel);
}
if (snrIconLevel != -1) return snrIconLevel;
if (rsrpIconLevel != -1) return rsrpIconLevel;
/* Valid values are (0-63, 99) as defined in TS 36.331 */
if (mLteSignalStrength > 63) rssiIconLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
else if (mLteSignalStrength >= 12) rssiIconLevel = SIGNAL_STRENGTH_GREAT;
else if (mLteSignalStrength >= 8) rssiIconLevel = SIGNAL_STRENGTH_GOOD;
else if (mLteSignalStrength >= 5) rssiIconLevel = SIGNAL_STRENGTH_MODERATE;
else if (mLteSignalStrength >= 0) rssiIconLevel = SIGNAL_STRENGTH_POOR;
if (DBG) log("getLTELevel - rssi:" + mLteSignalStrength + " rssiIconLevel:"
+ rssiIconLevel);
return rssiIconLevel;
}
And here are where these values are in the variable mSignalStrength that falls out of my script above:
Code:
public String toString() {
return ("SignalStrength:"
+ " " + mGsmSignalStrength
+ " " + mGsmBitErrorRate
+ " " + mCdmaDbm
+ " " + mCdmaEcio
+ " " + mEvdoDbm
+ " " + mEvdoEcio
+ " " + mEvdoSnr
+ " " + mLteSignalStrength
+ " " + mLteRsrp
+ " " + mLteRsrq
+ " " + mLteRssnr
+ " " + mLteCqi
+ " " + (isGsm ? "gsm|lte" : "cdma"));
}
Because of the way it gets parsed out of the dumpsys, mLteRsrp is field 12, mLteRssnr is field 14, and if you are not on LTE, you can use mCdmaDbm, which is field 6. (You have to add three to the field because the dumpsys output leads with a few spaces.) The 17th field tells you if you are on LTE or not. So basically, you can calculate the bars by RSRP and then by SNR, then take the lowest of the two.
By the way, if you want to do bars for 3G on cdma:
Code:
**
* Get Evdo as level 0..4
*
* @hide
*/
public int getEvdoLevel() {
int evdoDbm = getEvdoDbm();
int evdoSnr = getEvdoSnr();
int levelEvdoDbm;
int levelEvdoSnr;
if (evdoDbm >= -65) levelEvdoDbm = SIGNAL_STRENGTH_GREAT;
else if (evdoDbm >= -75) levelEvdoDbm = SIGNAL_STRENGTH_GOOD;
else if (evdoDbm >= -90) levelEvdoDbm = SIGNAL_STRENGTH_MODERATE;
else if (evdoDbm >= -105) levelEvdoDbm = SIGNAL_STRENGTH_POOR;
else levelEvdoDbm = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
if (evdoSnr >= 7) levelEvdoSnr = SIGNAL_STRENGTH_GREAT;
else if (evdoSnr >= 5) levelEvdoSnr = SIGNAL_STRENGTH_GOOD;
else if (evdoSnr >= 3) levelEvdoSnr = SIGNAL_STRENGTH_MODERATE;
else if (evdoSnr >= 1) levelEvdoSnr = SIGNAL_STRENGTH_POOR;
else levelEvdoSnr = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
int level = (levelEvdoDbm < levelEvdoSnr) ? levelEvdoDbm : levelEvdoSnr;
if (DBG) log("getEvdoLevel=" + level);
return level;
}
So similar to LTE, you pick the lowest number of bars for EvdoDbm or EvdoSnr. The signal strengths correspond to #bars: 4, 3, 2, 1, 0
This is from the master branch.

Related

Basic Socket Opening

Hey all
I have the following code to open a socket on Windows Mobile 6.1:
Code:
string hostIP = "192.168.0.2";
IPAddress ip = IPAddress.Parse("192.168.0.2");
int port = 80;
IPEndPoint localEP = new IPEndPoint(ip,port);
Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream,ProtocolType.Tcp);
try
{
listener.Bind(localEP); // socket exception here
listener.Listen(15);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
The goal is to simply open a socket, so I can develop on top of this and receive web requests but I receive a socket exception on the line where the bind takes place. Any ideas what might be going on?
maybe the options?
serverIPEndPoint = new IPEndPoint( serverIP, serverPort );
listenerSock = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
listenerSock.SetSocketOption( SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1 );
listenerSock.Bind( serverIPEndPoint );
listenerSock.Listen( 200 );

[Q] Working with binary/hex registry values in VB.Net

I have a little problem with converting a binary or hex (it's hard to tell which but it's listed as reg_binary type) registry value to a string so i can output it to a file. That's about it really other than giving you the code i developed. It generates an InvalidCastException Error.
Code:
[SIZE=2][COLOR=#0000ff]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Alarm1Days [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Byte[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"AlarmDays"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], (0))[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sw [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.StreamWriter = IO.File.CreateText(DirPath1)[/SIZE]
[SIZE=2]sw.WriteLine(RegHead)[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0]"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""AlarmDays""=Hex:"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + Alarm1Days.ToString.PadLeft([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"0"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]CChar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]CStr[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](8))))[/SIZE]
[SIZE=2][SIZE=2]sw.Flush()[/SIZE][/SIZE]
[SIZE=2]sw.Close()[/SIZE]
I'd be very grateful if you guys would help with this. It's given me a nasty headache.
Hey M3PH,
Maybe this is not what you wanted but the below functions could be useful. I remember that I've used them in converting binary<->hex values in the past in one of my PC apps.
Code:
#Region "Decode/Encode Functions"
Function DecodeStr(ByVal str As String) As String
Dim dec_temp As String
Dim StrBuilder As New StringBuilder()
Dim bt64 As Byte() = Convert.FromBase64String(str)
For i = 0 To UBound(bt64) - 1
dec_temp = Convert.ToString(CInt(bt64(i)), 16)
If dec_temp.Length = 1 Then
dec_temp = 0 & dec_temp
End If
StrBuilder.Append(dec_temp & ",")
Next
dec_temp = Convert.ToString(CInt(bt64(UBound(bt64))), 16)
If dec_temp.Length = 1 Then
dec_temp = 0 & dec_temp
End If
Return StrBuilder.ToString & dec_temp
End Function
Function EncodeStr(ByVal str As String) As String
Dim enc_temp As String
Dim bt64 As Byte() = System.Text.Encoding.UTF8.GetBytes(str)
enc_temp = Convert.ToBase64String(bt64)
Return enc_temp
End Function
#End Region
Code:
'Using DecodeStr function in your example...
[SIZE=2][COLOR=#0000ff]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Alarm1Days [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"AlarmDays"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], (0))[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sw [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.StreamWriter = IO.File.CreateText(DirPath1)[/SIZE]
[SIZE=2]sw.WriteLine(RegHead)[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0]"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""AlarmDays""=Hex:"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & DecodeStr(Alarm1Days))[/SIZE]
[SIZE=2][SIZE=2]sw.Flush()[/SIZE][/SIZE]
[SIZE=2]sw.Close()[/SIZE]
Regards!
When calling the Registry.Getvalue() method against binary values, it returns an Array of 'Byte' values. In this case, the value for 'AlarmDays' is only one byte long, but it is actually a one element 'Byte' array. The compiler cannot implicitly convert from 'Byte()' to 'Byte' so it throws the invalid cast error.
Here's the fixed code:
Code:
Dim Alarm1Days As Byte() = Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0", "AlarmDays", (0))
Dim sw As IO.StreamWriter = IO.File.CreateText(DirPath1)
sw.WriteLine(RegHead)
sw.WriteLine("[HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0]")
sw.Write("""AlarmDays""=Hex:")
For Each ByteValue As Byte In Alarm1Days
sw.Write(ByteValue.ToString("X2"))
Next
sw.WriteLine()
sw.Flush()
sw.Close()
The For Each - Next code section is able to deal with any length of binary value returned. In the case of a one byte value above, you could actually get away with:
Code:
sw.Write(Alarm1Days(0).ToString("X2"))
The For Each method is safer.
thanks steph. i'm on holiday atm so i'll try it out when i get home and let you know
So i tired out your code, steph and it works pretty well but there is one thing i'm having trouble with at the moment. The for each statement seems to never end the line so you end up with one really long single line instead of lots of short ones. In an attempt to correct this i did the following:
Code:
[SIZE=2]
sw.WriteLine(RegHead)
sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0]"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""AlarmDays""=Hex:"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ByteValue [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Byte[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Alarm1Days
sw.Write(ByteValue.ToString([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"X2"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]))
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sw.Write(vbCrLf)
[/SIZE]
But that makes the for each output appear on a new line on it's own and this also is not what i need. I need the value name and then the data one the same line in the output file. Any ideas on how to achieve this?
WriteLine() automatically adds a carriage return & line feed pair to the end of whatever input it is given.
Write() doesn't.
Change
sw.WriteLine("""AlarmDays""=Hex:")
to
sw.Write("""AlarmDays""=Hex:")
P.S. WriteLine() and Write(vbCrLf) are identical.
stephj said:
WriteLine() automatically adds a carriage return & line feed pair to the end of whatever input it is given.
Write() doesn't.
Change
sw.WriteLine("""AlarmDays""=Hex:")
to
sw.Write("""AlarmDays""=Hex:")
P.S. WriteLine() and Write(vbCrLf) are identical.
Click to expand...
Click to collapse
I should have noticed that. Thanks for giving me a poke

[Q] Working on CWM - I know there is another thread

The issue appears to be with the IPS display and how colors are rendered, not the screen resolution.
I've done a little research and it appears that this may be the first android phone, along with it's over seas counter parts, to get a true IPS display.
Before I go trying to change the code to write properly on the display, can anyone confirm that no other android phone with an IPS display has gotten the CWM treatment?
If there has been another phone with an IPS display to get CWM, I may be able to find the custom code and integrate it into a build for us.
Thanks,
Johnny
After a quick search on google (very quick search) it looks like this is the firs ips display for android. So if this is just a rendering issue - why am I able to use 5652rgb followed by convert to go from rle to a nice png?
Not disagreeing with you, just trying to clarify...
Directly talking to the hardware
When a boot loader like this does what it does, it doesn't really on any underlying android display code to write things to the screen. I'm guessing in your comment you meant that you just changed the format of an image and displayed it while android was running.
The bootload does a check on hardware capabilities, then it configures the format to used based on the hardware available. Because they were getting a garbled screen I started looking in the CWM code to determine if there was anything that could possibly be causing that.
All that being said, I'm not new to development, but I am extremely new to android development... so there is a possibility that I'm on crack.
I'm going to do some more research now to determine if this is the problem since you, like I, believe that this is the first android phone with an IPS display.
Thanks,
Johnny
Thanks Johnny!
Directly talking to the hardware
I'm checking right now to determine what the pixel size should be and what it is. I have a feeling that it's being set as 4 instead of 8, which would through off the stride and cause the corrupted display that was being discussed in the thread on in the dev forum.
This may take me a while as I'm new to android development. Also, if someone here knows for sure that I'm going down the wrong path, please let me know. But as of now, this feels like this is more than likely the issue.
Johnny
Do you think there would be any benefit to look at the CWM code that is run for tablet's that have a similar resolution? Not sure if the code is actually different, but don't most tablets have a higher screen resolution - and wouldn't they have gone through similar issues?
Also very new to android development - and will also be looking to peak in the code to see if I can help figure anything out.
It appears to be the PIXEL format that is the problem:
#if defined(RECOVERY_BGRA)
#define PIXEL_FORMAT GGL_PIXEL_FORMAT_BGRA_8888
#define PIXEL_SIZE 4
#elif defined(RECOVERY_RGBX)
#define PIXEL_FORMAT GGL_PIXEL_FORMAT_RGBX_8888
#define PIXEL_SIZE 4
#elif defined(RECOVERY_RGBA)
#define PIXEL_FORMAT GGL_PIXEL_FORMAT_RGBA_8888
#define PIXEL_SIZE 4
#else
#define PIXEL_FORMAT GGL_PIXEL_FORMAT_RGB_565
#define PIXEL_SIZE 2
#endif
Click to expand...
Click to collapse
if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_BGRA_8888) {
vi.red.offset = 8;
vi.red.length = 8;
vi.green.offset = 16;
vi.green.length = 8;
vi.blue.offset = 24;
vi.blue.length = 8;
vi.transp.offset = 0;
vi.transp.length = 8;
} else if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_RGBX_8888) {
vi.red.offset = 24;
vi.red.length = 8;
vi.green.offset = 16;
vi.green.length = 8;
vi.blue.offset = 8;
vi.blue.length = 8;
vi.transp.offset = 0;
vi.transp.length = 8;
} else { /* RGB565*/
vi.red.offset = 11;
vi.red.length = 5;
vi.green.offset = 5;
vi.green.length = 6;
vi.blue.offset = 0;
vi.blue.length = 5;
vi.transp.offset = 0;
vi.transp.length = 0;
}
Click to expand...
Click to collapse
These two sections of code appear to be the culprit. I've been looking at this at work and don't have access to the Android SDK on this machine (and I can't install it). Does any one here know where the RECOVERY_BGRA or RECOVERY_RGBX get defined?
The thing is, the nitro is returning GGL_PIXEL_FORMAT_RGBA_8888, which means that it would fall down into the else in the above code and set it to a pixelsize of 2, which is probably wrong.
Also, the RGBA offset and lengths are probably wrong because of the same issue.
If anyone here has insight to this or could tell me where the recovery is defined it would either speed things up or just prove me wrong all together.
Thanks,
Johnny
If no one here knows how the recovery is defined I'll be able to figure it out at home better on my mac.
Thanks Johnny~
ORZ
The recovery image is stored in partition mmcblk0p13, I think you may find your answer there.
Sorry, this comment is not helping anything, but I just wanna say how interesting this thread is, and that thank you Johnny for helping out here
I'm fairly certain that I've changed the code to fix this this. It will be a very specific build that will only work for phones that do RGBA.
The problem is, since I'm so new to the Android system I haven't been able to actually figure out how to build the code yet. If someone on here has everything setup to do that I can zip up the code and give it to you.
If not, I'll have time this weekend to get everything setup and build it myself.
Johnny
Excellent! Be sure to check out the progress we are making in the "[DEV][CWM] ClockworkMod 5 Recovery For LG Nitro HD [Update]" thread in the development forum. We know how to boot into recovery now... Sounds like we are close.
@ johnnyfever
Well done! Come on! Looking forward to your good news!

[DEV] trying to port 2-way record to CM7/9

For the begging,
I found out that the problem for 2-way is on the libaudio.so, than I downloaded the source code from the github of samsung aries.
I found the file AudioHardware.cpp as the main one.
I googled the web and found a same file with 2-way and there is the code which do that
Code:
//wxj add for voice recorder
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <poll.h>
//wxj add end
Code:
//-------------- wxj add for voice recorder ----------------
#if RECORDER_MOMEM
/*
AT^DAUDREC=<ON/OFF>
<ON/OFF> 0 turn off record
1 turn on record
*/
#define MODEM_RECORD_INCALL_ON "at+audr=1\r"
#define MODEM_RECORD_INCALL_OFF "at+audr=0\r"
//define pty device for send at command
#define AUDIO_AT_PATH "/dev/ttymux4"
#define AUDIO_DATA_PATH "/dev/ttymux4"
#define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0])
static const char * s_finalResponsesError[] = {
"ERROR",
"+CMS ERROR:",
"+CME ERROR:",
};
/**
* returns 1 if line is a final response indicating success
* See 27.007 annex B
* WARNING: NO CARRIER and others are sometimes unsolicited
*/
static const char * s_finalResponsesSuccess[] = {
"OK",
};
static Mutex audioLockMutex;
static int isFinalResponseError(const char *line)
{
size_t i;
for (i = 0 ; i < NUM_ELEMS(s_finalResponsesError) ; i++) {
if (strcasestr(line, s_finalResponsesError[i])) {
return 1;
}
}
return 0;
}
static int isFinalResponseSuccess(const char *line)
{
size_t i;
for (i = 0 ; i < NUM_ELEMS(s_finalResponsesSuccess) ; i++) {
if (strcasestr(line, s_finalResponsesSuccess[i])) {
return 1;
}
}
return 0;
}
/**
* returns 1 if line is a final response, either error or success
* See 27.007 annex B
* WARNING: NO CARRIER and others are sometimes unsolicited
*/
static int isFinalResponse(const char *line)
{
return isFinalResponseSuccess(line) || isFinalResponseError(line);
}
static int s_fd = -1;
static int WriteATCommand(const char *s)
{
AutoMutex lock(audioLockMutex);
//int s_fd = open(AUDIO_AT_PATH,O_RDWR | O_NONBLOCK);
if ( s_fd < 0 ) {
LOGE(" AudioHardware ERROR OPEN AT interface, errno = %d ,s_fd = %d",errno,s_fd);
return -3;
}
size_t cur = 0;
size_t len = strlen(s);
ssize_t written;
LOGV(" AudioHardware AT> %s\n", s);
/* the main string */
while (cur < len) {
do {
written = write (s_fd, s + cur, len - cur);
} while (written < 0 && errno == EINTR);
if (written < 0) {
LOGE("AudioHardware write str error, errno = %d ",errno);
close(s_fd);
s_fd = 0;
return -1;
}
cur += written;
}
#if 0
/* the \r */
do {
written = write (s_fd, "\r" , 1);
} while ((written < 0 && errno == EINTR));
if (written < 0) {
LOGE(" AudioHardware write r error, errno = %d ",errno);
close(s_fd);
s_fd = 0;
return -1;
}
#endif
const int buf_len = 1024;
int readLen = 0, count = 0;
char* buffer = new char[buf_len];
//buffer[0] = '\0';
memset((void*)buffer, 0, buf_len);
bool final = false;
int tryTimes = 0;
int pollResult = 0;
for(;;){
while (0 == pollResult){
struct pollfd fpolls;
fpolls.fd = s_fd;
fpolls.events = POLLIN;
fpolls.revents = 0;
pollResult = poll(&fpolls, 1, 1000); //timeout 5 seconds
//data ready to be read
if (pollResult > 0 && POLLIN == fpolls.revents ){
LOGD(" AudioHardware data is available %d \n",__LINE__);
break;
}else if (pollResult < 0){
LOGD(" AudioHardware pollResult < 0 %d \n",__LINE__);
if (errno == EINTR){
continue;
}else{
break;
}
}else{
LOGE("timeout, but no data available");
if (tryTimes < 5){
tryTimes++;
}else{
LOGE("timeout, exit this command ");
delete []buffer;
close(s_fd);
s_fd = 0;
return -1;
}
}
}
do {
readLen = read (s_fd, buffer + count, buf_len - count);
} while ((readLen < 0 && errno == EINTR));
if (readLen > 0){
count += readLen;
}
if (isFinalResponse(buffer)){
final = true;
LOGD("at result=%s", buffer);
break;
}
tryTimes++;
if (tryTimes > 5){
break;
}
}
LOGV("AudioHardware AT>%s sucess", s);
delete []buffer;
//close(s_fd);
return 0;
}
#endif
//----------------- wxj add end for voice recorder -----------
I don't have linux or other way to compile the files, and I wish someone with more experience from me will compile it and I'm sure we will fine volunteers to test that.
the full cpp files are attached.
By the way, the lib file will be good even to the other ICS roms which based on samsung aries of CM
would be really cool to have that possibilty in more roms, so thx to come up with that and hopefully some dev has the time and knowledge to do this...
sry that i can't help you myself!
greetz,
sUsH
What model does this AudioHardware relate to? If this is related to MSMxxxx audio hardware, probably this will not work in any way. DEAR DEVELOPERS, can you help to continue this work to finally implement this feature? I think that we can start collecting dotations in order to make everybody involved in this project!!
I wish good luck and say THANKS to OP and all people who is able to help in any way!! I hope that this project will not stop and finally we add this so useful feature to our beloving Galaxy.
I'm afraid it does belong to msm, but even if not, there must be a way based on that, for just changing the code.
I can't find the source again but I think it was belong to defy
it IS definitely possible on our sgs, cause i remember some miui-rom i once flashed and used for a while, and with this rom two-way-call-recording was possible, meaning while in call i could just press the record-button and the call (both the caller and me) got recorded.
don't know if it was some dirty hack but it worked, i recorded plenty of calls with this rom. even automatic call recording was possible, so that everytime i got a call, it got recorded automagically.
if this is of interest, i could search for that specific miui-rom in my rom-archive.
greetz,
sUsH
sUsH667 said:
it IS definitely possible on our sgs, cause i remember some miui-rom i once flashed and used for a while, and with this rom two-way-call-recording was possible, meaning while in call i could just press the record-button and the call (both the caller and me) got recorded.
don't know if it was some dirty hack but it worked, i recorded plenty of calls with this rom. even automatic call recording was possible, so that everytime i got a call, it got recorded automagically.
if this is of interest, i could search for that specific miui-rom in my rom-archive.
greetz,
sUsH
Click to expand...
Click to collapse
Afaik, 2 way recording wasn't implemented on cm7/miui like ever. It was illegal and a dirty hack to.
Sent from my GT-I9000 using xda premium
siky_dude said:
It was illegal and a dirty hack to.
Sent from my GT-I9000 using xda premium
Click to expand...
Click to collapse
But remember that not in every country...
hmm, are you sure? i really have that in my mind.
well, i'll look through my rom-history and see which one i think it was, maybe i am wrong...
Rausio said:
But remember that not in every country...
Click to expand...
Click to collapse
Yeah... but if they changed something in the framework to enable recording it would become a upstream change... so everyone living in a legal/illegal country would have this feature... so it was never made as an upstream change.
Still, I never understand people that needed call recording. It's kind of creepy.
Sent from my GT-I9000 using xda premium
siky_dude said:
Yeah... but if they changed something in the framework to enable recording it would become a upstream change... so everyone living in a legal/illegal country would have this feature... so it was never made as an upstream change.
Still, I never understand people that needed call recording. It's kind of creepy.
Sent from my GT-I9000 using xda premium
Click to expand...
Click to collapse
it is legal in every country... the issue in USA is that the recorder partner should tell the other side that the conversation is recorded, for example in Israel, just one side should know that the conversation is under recording, to prevent illegal bugging.
and it's not creepy we should record conversation for a lot of reason, even for people who are on ways all time and want to remember the conversation issue, or even when we argument with the cellular/internet providers.
It was working fine on froyo:
http://forum.xda-developers.com/showthread.php?t=967297
And stayed as project on gingerbread:
http://forum.xda-developers.com/showthread.php?t=1089425
Guys, let's stop offtopic discussing how legal is call recording or not, and also is it useful feature or useless; it is being discussed in other threads many times.
And the project on gingerbread trying to modify existing libraries probably ended with no success after trying all possible things, so we have to follow this way meaning developing the missing code, and i think now it is the only right way.
P.S. Probably this code also relates to call recording:
Code:
#if RECORDER_MOMEM
if(devices == AudioSystem::DEVICE_IN_VOICE_CALL) {
LOGV("set begin recording voice ");
mDevices = devices;
mVoiceRecorderFD = ::open(AUDIO_DATA_PATH,O_RDWR | O_NONBLOCK);
int i = 0;
while(mVoiceRecorderFD < 0) {
i++;
LOGV("AudioStreamInALSA::set i = %d ",i);
usleep(5000);
mVoiceRecorderFD = ::open(AUDIO_DATA_PATH,O_RDWR | O_NONBLOCK);
if(i > 20) {
LOGE(" AudioStreamInALSA::setDevice open muxaudio failure ",i);
return NO_INIT;
}
}
s_fd = mVoiceRecorderFD;
WriteATCommand(MODEM_RECORD_INCALL_ON);
return NO_ERROR;
}
#endif
l2tp, the code you brought here, seems to be related to ALSA (our galaxy) and is not related to the one I brought.
It's seems to be better chance.
Hey guys, did anybody try to do something on this?
Let's not give up!
siky_dude said:
Yeah... but if they changed something in the framework to enable recording it would become a upstream change... so everyone living in a legal/illegal country would have this feature... so it was never made as an upstream change.
Still, I never understand people that needed call recording. It's kind of creepy.
Sent from my GT-I9000 using xda premium
Click to expand...
Click to collapse
Disabling camera shutter sound is also illegal for some countries. But you can disable it on Cyanogenmod settings. It just warns you about legality.
I have the coding skills but not the time to fully do this. I just thought I'd post and offer to assist if anyone wants to lead the project.
Plz do not give up!!
l2tp said:
Hey guys, did anybody try to do something on this?
Let's not give up!
Click to expand...
Click to collapse
I have also been waiting for this ever since I lost the feature after moving from Froyo to GB. :crying: It was a wonderful feature which eradicated the need for keeping a pen and paper ready for long office conference calls, specially when on the road. I was using some automatic recording script with customizable file naming convention and was in bliss!
In terms of legality, please let's keep that out of the equation as already pointed out with the camera shutter analogy. :silly:
The way I saw it, the legality thing was brought into picture by the MIUI 'porting' teams after the Froyo -> GB upgrade and instead of trying to 'fix' it, the questionable legality argument got presented.
Frankly, since the hardware supports it, it is only a question of finding and tweaking the correct sources. I do not have access to a compiler at the moment, but if someone needs help with code-reading/ review, please continue posting here or on pastebin. :fingers-crossed:
+1 this would be awesome!
2 way call recording is very important for me. Still using Darky 9.5 (Froyo) because of that, but I would like to try a GB or ICS ROM if a patch was available.

Advice on strategy

I'm developing a WP7 app, working alongside a Windows (server) application. They are talking with each other using sockets.
As soon as the WP7 app opens, I wish to perform a network scan to find the server application.
I already found out how to get the IP address of the WP7. So let's say I know the server should be somewhere at 192.168.0.*. How do I go about scanning this network?
I tried many things, the last of which is the code below. The problem here is that somehow the TIMEOUT_MILLISECONDS parameter seems to be like playing roulette (tried everything in the range of 100-2000 with different success). In addition, if I sweep the whole subnet like in the code below the phone cannot seem to handle the work. I only get it to work if I set the timeout to 2000 (which is way to long) and by scanning up to 5 IP's in the for-loop, instead of the whole subnet.
Is there anyone that knows a better and much more efficient(!) way to do this?
Code:
string thisIP = "192.168.0.101"; // I normally get this from some other function
string[] arrIP = thisIP.ToString().Split('.');
string IPBase = arrIP[0] + "." + arrIP[1] + "." + arrIP[2] + ".";
//MessageBox.Show(address.ToString());
for (int i = 2; i < 254; i++) {
string IP = IPBase + i;
CheckConnection CheckConn = new CheckConnection();
string resultConnect = CheckConn.Connect(IP, int.Parse(Resource1.port));
if (resultConnect == "Success") {
CheckConn.Send("isAlive");
string result = CheckConn.Receive();
if (result.Contains("yes")) {
// We have found the server
break;
}
}
CheckConn.Close();
}
Code:
public class CheckConnection
{
// Cached Socket object that will be used by each call for the lifetime of this class
Socket _socket = null;
static ManualResetEvent _clientDone = new ManualResetEvent(false);
const int TIMEOUT_MILLISECONDS = 100;
const int MAX_BUFFER_SIZE = 2048;
public string Connect(string hostName, int portNumber) {
string result = string.Empty;
DnsEndPoint hostEntry = new DnsEndPoint(hostName, portNumber);
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
socketEventArg.RemoteEndPoint = hostEntry;
socketEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(delegate(object s, SocketAsyncEventArgs e) {
result = e.SocketError.ToString();
_clientDone.Set();
});
_clientDone.Reset();
_socket.ConnectAsync(socketEventArg);
_clientDone.WaitOne(TIMEOUT_MILLISECONDS);
return result;
}
public string Send(string data) {
string response = "Operation Timeout";
if (_socket != null) {
SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
socketEventArg.RemoteEndPoint = _socket.RemoteEndPoint;
socketEventArg.UserToken = null;
socketEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(delegate(object s, SocketAsyncEventArgs e) {
response = e.SocketError.ToString();
_clientDone.Set();
});
byte[] payload = Encoding.UTF8.GetBytes(data);
socketEventArg.SetBuffer(payload, 0, payload.Length);
_clientDone.Reset();
_socket.SendAsync(socketEventArg);
// Block the UI thread for a maximum of TIMEOUT_MILLISECONDS seconds.
// If no response comes back within this time then proceed
_clientDone.WaitOne(TIMEOUT_MILLISECONDS);
}
else {
response = "Socket is not initialized";
}
return response;
}
public string Receive() {
string response = "Operation Timeout";
if (_socket != null) {
SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
socketEventArg.RemoteEndPoint = _socket.RemoteEndPoint;
socketEventArg.SetBuffer(new Byte[MAX_BUFFER_SIZE], 0, MAX_BUFFER_SIZE);
socketEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(delegate(object s, SocketAsyncEventArgs e) {
if (e.SocketError == SocketError.Success) {
response = Encoding.UTF8.GetString(e.Buffer, e.Offset, e.BytesTransferred);
response = response.Trim('\0');
}
else {
response = e.SocketError.ToString();
}
_clientDone.Set();
});
_clientDone.Reset();
_socket.ReceiveAsync(socketEventArg);
_clientDone.WaitOne(TIMEOUT_MILLISECONDS);
}
else {
response = "Socket is not initialized";
}
return response;
}
public void Close() {
if (_socket != null) {
_socket.Close();
}
}
}
Why you don't know the server IP?
I can't help you with your subnet scanning problem, don't have experience with that corner of WP7 programming.
But I do wonder what kind of arrangement leads to the problem that your app does not know the server address and therefore has to scan for it. Is neither a fixed IP available for your server nor some kind of DNS service up to tell you the current IP?
Even if there are multiple servers running and the phone has the job to somehow decide which one of those is responsible for it, you still could set up some kind of super-server that the phones could ask first which server they should address.
In any way, phones scanning subnets to find servers as some routine app startup action is a bad idea, if you ask me.
Please note that by 'server' I'm just revering to a software that accepts socket connections. This software is installed into a Windows computer that most likely has it's IP from DHCP.
The server software itself could present it's IP address so the end-user can type this address into the client on their WP7. Nice for tech-savvy folks, but that's not how software should be designed in my opinion. People don't need to know what an IP address is and shouldn't be force into typing 'weird numbers'. Properly designed software just have to work instantly and developers (again in my opinion) need to take care of a good design and that includes making things plug-and-play where they can.
Take a look at 'PC Remote' and you will see the kind of easy plug-and-play experience I'm looking for.
Did you check broadcast?
I'm really not network guy, but from Googling I got the impression that people use broadcast instead of IP range scanning for such IP number discovery tasks, and there seems to be a way to do broadcast on WP7 (albeit only using some tricks / hardly documented functionalilty):
E.g. see this thread:
http://stackoverflow.com/questions/8533471/udp-broadcasting-in-windows-phone-7
Which links to this:
http://forums.create.msdn.com/forums/t/88975.aspx
This makes sense to me after reading that broadcast is also the method how a client finds its DHCP server - isn't that the exact same scenario like yours?
Did you already check this way of looking at the problem, or maybe rule it out already for some reason?
It's better if you use a multicast group to send/receive packages. I had way better experience with it than using the Broadcast IP.
You need to join the multicast group with the phone and with the server app. I know there are multicast classes but I found it easier and mor convient to implement it with a socket...
And after you found the server, I'd use a persistent tcp connection which should improve your network performance (udp and wp7 is sometimes really strange...)
Thanks rbrunner7 and chabun for your comments, I appreciate your input!
rbrunner7 said:
Did you already check this way of looking at the problem, or maybe rule it out already for some reason?
Click to expand...
Click to collapse
I did, briefly, but abandoned this path after reading about the physical network equipment (switches etc.) having the need to support broadcasting which might not always be the case.
Anyway, your mentioned post describes 'limited broadcasting', which might be exactly what I should be looking for. Hopefully hardware limitations will not be applicable; I will look into this method further and will let you know how it works out!
roady001 said:
the physical network equipment (switches etc.) having the need to support broadcasting which might not always be the case.
Click to expand...
Click to collapse
I had the same doubts about that as it's also the case for multicasting. Most modern equipement supports it though and you can always provide the possibility to manually enter the server ip if you can't discover one via multicast/broadcast

Categories

Resources