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!
Related
I'm trying to develop a simple application to my Omnia 2 in DirectX in VB.NET, but i stuck, really hard. I want to load a simple texture from a file, but the TextureLoader.FromFile gave me an InvalidCallException error. I don't know what to do, because the code is working on the emulator, but throw this error on the phone. I googled it, a lot, but found nothing.
I hope someone can help me in this.
Here's some code fragment. Please someone help me.
Code:
Function InitializeGraphics() As Boolean
Dim Parameters As PresentParameters = New PresentParameters()
Parameters.Windowed = True
Parameters.SwapEffect = SwapEffect.Discard
DeviceForm = New Device(0, DeviceType.Default, Me, CreateFlags.None, Parameters)
Me.OnCreateDevice(DeviceForm, Nothing)
Return True
End Function
Private Sub OnCreateDevice(ByVal sender As Object, _
ByVal e As EventArgs)
Dim dev As Device = CType(sender, Device)
spriteTexture = TextureLoader.FromFile(dev, "\Storage card\Picture.png")
Using s As Surface = spriteTexture.GetSurfaceLevel(0)
Dim desc As SurfaceDescription = s.Description
textureSize = New Rectangle(0, 0, desc.Width, desc.Height)
End Using
sprite = New Sprite(DeviceForm)
End Sub
Here's some picture from the exceptions details.
Nevermind. I solved it.
This is an Advanced UI SDK for developing finger-friendly Application UIs.
The reason for developing this SDK was mainly to learn about programming for Windows Mobile and the Compact Framework 3.5. I also developed this SDK because I could not find good UI controls that gave total display control to the programmer while taking care of all of the Physics, windowing, and frame buffering AND was open source.
Finally, this SDK was originally developed as part of the XDAFacebook application that I am currently developing.
I am releasing this SDK and its source so that people can have a good foundation to build finger-friendly Windows Mobile applications, and so that programmers starting off in the Windows Mobile world won't have to start from scratch when creating useful UI Controls.
Here are some of the features and uses of this SDK.
Features:
Fully customizable
Easily create custom UI Controls
Resolution independent
Full physics for rendering smooth scrolling
Uses:
Quickly create UI controls
Develop full UI SDKs
Learn basic UI programming for .net CF 3.5
I ask that if you use these controls, please provide feedback so that everyone can benefit!
Thank you and I hope you find these controls useful!
SDK Documentation
Even though the controls are easy to implement, they can seem intimidating at first. Here is an over-view of the core pieces to the SDK:
The IXFItem Interface:
Here are Properties of the interface
PHP:
XFPanelBase Parent { get; set; } // The item's List container
XFItemState State { get; set; } /* An Enum to describe the current item's state
This could include things like [B]Selected[/B] or [B]Normal[/B]*/
Bitmap Buffer { get; set; } // This is the item's cache buffer. Allows for speedy rendering
XFItemStyle Style { get; set; } // CSS like style object. Allows for easy customization
XFItemType ItemType { get; set; } /* Enum to label the type of the current object.
For example, [B]Clickable[/B] or [B]Display[/B] meaning the item won't change*/
The following are the methods that need to be implemented
PHP:
int GetHeight(); /* This returns the height of the item. This value is usually calulated
but in some instances is static. The value should be cached because this method
is called several times during the rendering process.*/
void ResetHeight(); // What ever needs to be done to reset the height cache
void ItemPaint(Graphics g, int x, int y); // Where the magic happens. More on this later
XFItemClickResult GetClickResult(); // An enum is return with what the action of clicking this item was.
The main part of the interface is the ItemPaint method. This method is called from the XFPanelList and passes a Graphics object created from the Buffer Bitmap of the Item. In this method, you do all of your graphics logic, drawing it with the supplied graphics object. The x and y are any offset numbers that should influence when the objects are based. Most of the time, these numbers will be 0, 0.
Because the programmer has total control over how the item is rendered, special care must be used when creating the items, to draw all the features with respect to the XFItemStyle object. This object usually is created in CTOR. An example of the XFItemStyle object being created in one of the SenseUI XFItem's CTORs:
PHP:
public SenseItem()
{
ItemType = XFItemType.Clickable;
Style = new XFItemStyle()
{
BoarderBottomColor = Color.FromArgb(189, 182, 189),
DashStyleBottom = System.Drawing.Drawing2D.DashStyle.Dash,
TextColor = Color.Black,
TextFont = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular),
SelectedTextFont = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular),
SecondaryTextFont = new Font(FontFamily.GenericSansSerif, 7, FontStyle.Regular),
SelectedSecondaryTextFont = new Font(FontFamily.GenericSansSerif, 7, FontStyle.Regular),
SecondaryTextColor = Color.FromArgb(57, 52, 57),
SelectedTextColor = Color.White,
SelectedBackgroundColor = Color.FromArgb(43, 36, 43),
SelectedSecondaryTextColor = Color.FromArgb(182, 178, 182),
Padding = 11,
PaddingBottom = 12,
PaddingLeft = 10,
PaddingRight = 16
};
}
You will also notice that the ItemType is also set here.
How you use the Style is a little more involved. In the ItemPaint, the programmer should base all of the features off of what is in the Style object. Here is an example of how the above Style object was used in the ItemPaint method:
PHP:
public void ItemPaint(Graphics g, int x, int y)
{
int width = Parent == null ? Screen.PrimaryScreen.WorkingArea.Width : Parent.Width;
XFControlUtils.DrawBoarders(Style, g, 0, 0, width, GetHeight());
int currX = Style.PaddingLeft;
int currY = Style.PaddingTop;
int mHeight = 0;
int sHeight = 0;
if (Icon != null)
currX += _iconSize + Style.PaddingLeft;
SizeF mText = new SizeF();
if (!string.IsNullOrEmpty(MainText))
{
mText = XFControlUtils.GetEllipsisStringMeasure(width - currX - Style.PaddingRight, MainText, Style.TextFont);
MainText = XFControlUtils.EllipsisWord(width - currX - Style.PaddingRight, MainText, Style.TextFont);
}
SizeF sText = new SizeF();
if (!string.IsNullOrEmpty(SecondaryText))
{
sText = XFControlUtils.GetEllipsisStringMeasure(width - currX - Style.PaddingRight, SecondaryText, Style.SecondaryTextFont);
SecondaryText = XFControlUtils.EllipsisWord(width - currX - Style.PaddingRight, SecondaryText, Style.SecondaryTextFont);
}
mHeight = (GetHeight() / 2) - ((int)mText.Height / 2);
if (!string.IsNullOrEmpty(SecondaryText))
{
mHeight = (GetHeight() / 2) - _textSpace - (int)mText.Height;
sHeight = (GetHeight() / 2) + _textSpace;
}
if (State == XFItemState.Selected)
{
XFControlUtils.DrawBackgroundSelected(Style, g, x, y, width, GetHeight());
if (!string.IsNullOrEmpty(MainText))
using (SolidBrush b = new SolidBrush(Style.SelectedTextColor))
g.DrawString(MainText, Style.SelectedTextFont, b, currX, mHeight);
if (!string.IsNullOrEmpty(SecondaryText))
using (SolidBrush b = new SolidBrush(Style.SelectedSecondaryTextColor))
g.DrawString(SecondaryText, Style.SelectedSecondaryTextFont, b, currX, sHeight);
}
else
{
if (!string.IsNullOrEmpty(MainText))
using (SolidBrush b = new SolidBrush(Style.TextColor))
g.DrawString(MainText, Style.TextFont, b, currX, mHeight);
if (!string.IsNullOrEmpty(SecondaryText))
using (SolidBrush b = new SolidBrush(Style.SecondaryTextColor))
g.DrawString(SecondaryText, Style.SecondaryTextFont, b, currX, sHeight);
}
if (Icon != null)
XFControlUtils.DrawAlphaFirstPix(g, Icon, Style.PaddingLeft, Style.PaddingTop);
}
That is as complex as it gets. Other than doing normal Event Handling for ClickReturns, this is all that is required to create beautiful UI Controls for your application.
I hope that this helps! Feel free to PM me or post a reply if you need further clarification.
Class List
Form Controls:
XFPanelContainer - The main control that interacts with the Form.
XFPanels:
XFPanelBase - Basic building block. Handles most of the generic functionality
XFPanelList - Can add IXFItem items.
XFPanelHeader - The top header bar for an XFPanelContainer
XFItems
IXFItem - Interface that all XFItems inherate
XFItemSimpleText - Simple item that displays text
XFItemBack - Special item that allows a panel to slide back
XFItemLoading - Item that allows for work to be down in the background.
XFControlUtils: Library of static, useful utilities for this SDK
DrawAlpha - Draws an image with a supplied Graphics object with a specific level of opacity
DrawAlphaFirstPix - Draws an image and renders all pixels that are the same color as pixel (1,1) are 100% transparent
DrawJustifiedString - draws a justified string
GetEllipsisStringMeasure - Takes a string and if it is more than the supplied width, clips the string and adds a trailing "..." at the end
EllipsisWord - same as the GetEllipsisStringMeasure, except it ellipsis at the words and not at the char level.
GetSizedString - Takes a string and adds "\n" so that the string wraps according to the supplied width
Many Others!
Sense UI Example
Here is a working example. I made this Sense UI example in about 3 hours 15 hours. It isn't complete but gives a good example of how to/why use this SDK. There are 3 screenshots of what this demo looks like.
I'll explain some of the pieces of code when I get some time later today.
The other great example of how to use this SDK is the XFAFacebook Application.
The source for this project is located @ http://code.google.com/p/xda-winmo-facebook/source/browse/#svn/trunk/XFSenseUI
There are a few screenshots of the XDAFacebook application included.
Finally, a quick start tutorial.
Start a new Smart Device project.
Add a reference to the XFControls.dll
Place the following lines of code in the Form1 constructor (after the InitializeComponent()
Code:
XFPanelContainer container = new XFPanelContainer();
container.Dock = DockStyle.Fill;
Controls.Add(container);
XFPanelList list = new XFPanelList();
container.SetMainPanel(list);
list.ShowScrollbar(true);
for (int i = 0; i < 50; i++)
{
list.Add("This is item " + i);
}
Run the project and you will get an output like the "SimpleText.png"
It's that easy!
UPDATE: I've added the XFSense to the Google Code page and have made some pretty extensive updates to it. I've added a few controls including sliders, toggles, checkboxes and radio buttons. It still isn't complete but I will be working to make it a full fledge Sense SDK.
Stay tuned!
Releases:
Initial Release - 9/1/10
When major updates occur, the DLLs will be posted here. The best thing to do is pull the source from the Google Code page and use that.
This will guarantee the freshes code will be used for your projects
Instructions:
Download and unzip the latest XFControls.zip from below.
Add the .dll as a reference.
Program!
The source can be found at: http://code.google.com/p/xda-winmo-facebook/source/browse/#svn/trunk/XDAFacebook/XFControls
List of downloads:
10/6/10 - Updated for speed and better scrolling! - XFControls 0.2.zip
9/1/10 - Initial upload - XFControls 0.1.zip
Other things I might have missed
Reserved Other
Sounds interesting! Definitely looking forward to some screenshots.
kliptik said:
Sounds interesting! Definitely looking forward to some screenshots.
Click to expand...
Click to collapse
Screenshots are up!
Only 3 downloads?! Hmmm.... I figured more people would be interested in a finger-friendly and open source UI SDK...
Is there something wrong with my posts? Are they too confusing?
Let me know what I can do to help! This has taken me a good deal of time to write and I would hope that it would be of use to someone else...
joe_coolish said:
Only 3 downloads?! Hmmm.... I figured more people would be interested in a finger-friendly and open source UI SDK...
Is there something wrong with my posts? Are they too confusing?
Let me know what I can do to help! This has taken me a good deal of time to write and I would hope that it would be of use to someone else...
Click to expand...
Click to collapse
Just DL'd a copy. I'm super swamped at the moment trying to get the next release of KD-Font out, but I'll try and check this out when I get a chance.
Thank you for your contribution!
I will definitely give this a test run at some point. Good work!
you have to add you own graphics to this sdk?
janneman22 said:
you have to add you own graphics to this sdk?
Click to expand...
Click to collapse
yes, this is a UI SDK. it is used to create user controls. The core code handles all the caching and physics, but the programmer must create the actual controls. including the graphics. look at the sense UI example to see how you can implement your own custom UI controls. like i said in the post, it only took about 3 hours to create those controls. most of which was spent creating graphics.
joe_coolish said:
yes, this is a UI SDK. it is used to create user controls. The core code handles all the caching and physics, but the programmer must create the actual controls. including the graphics. look at the sense UI example to see how you can implement your own custom UI controls. like i said in the post, it only took about 3 hours to create those controls. most of which was spent creating graphics.
Click to expand...
Click to collapse
oh right. but does it place controls in the toolbox, or have you to create the controls hard coded?
i could help you to make some grapics packages for this sdk
Ok, I've updated the binaries to be the latest and greatest. The scrolling is super smooth and things are starting to look pretty good!
I also will be updating the XFSense and I'll probably be extending it a little more because I plan on bringing it into the XDA Facebook app.
As always, let me know what you think!
EDIT: Oh, and to answer the question about adding objects to the toolbox, I have not added the OCX files (or whatever they are) so that they can be added to the tool box. But, after you've added the container and the panels, everything is logic after that, so adding the items to the toolbox really doesn't benefit too much.
As far as graphics, I would love help with graphics! Send me a PM and we'll talk!
joe_coolish said:
Here is a working example. I made this Sense UI example in about 3 hours. It isn't complete but gives a good example of how to/why use this SDK. There are 3 screenshots of what this demo looks like.
I'll explain some of the pieces of code when I get some time later today.
The other great example of how to use this SDK is the XFAFacebook Application.
The source for this project is located @ http://code.google.com/p/xda-winmo-facebook/source/browse/
There are a few screenshots of the XDAFacebook application included.
Finally, a quick start tutorial.
Start a new Smart Device project.
Add a reference to the XFControls.dll
Place the following lines of code in the Form1 constructor (after the InitializeComponent()
Code:
XFPanelContainer container = new XFPanelContainer();
container.Dock = DockStyle.Fill;
Controls.Add(container);
XFPanelList list = new XFPanelList();
container.SetMainPanel(list);
list.ShowScrollbar(true);
for (int i = 0; i < 50; i++)
{
list.Add("This is item " + i);
}
Run the project and you will get an output like the "SimpleText.png"
It's that easy!
Click to expand...
Click to collapse
Very nice control. I downloaded the sample (had problem with missing XFControl project but downloaded it from code.google).
Have a couple questions, how would i go about adding image to a child panel?
What I'm trying to so is have about 75 items on the main screen and each item will have sub-panel, when clicking on sub-panel I need to have label x2 and image.
Also when compiling the project I get error:
"Error 1 'XFControls.XFPanels.XFPanelHeader' does not contain a definition for 'BackgroundImage' and no extension method 'BackgroundImage' accepting a first argument of type 'XFControls.XFPanels.XFPanelHeader' could be found (are you missing a using directive or an assembly reference?) C:\downloads\C#\XFSenseUI\XFSenseUIDemo\Form1.cs 39 24 XFSenseUIDemo"
Alright, I'll post an example if I get some time in a bit. But as for the error, it is because the Core XFControls has been modified since the last time I updated this thread. You can download the freshes code from the google code page or use the attached DLL. I'd suggest the Google Code page, since it gets updated more frequently. But then you get all the XDAFacebook with it, so it can also be negative.
Basically to add an image to an XFItem to be added to the XFPanelList, you can either create your own item by inheriting from the IXFItem and doing all the image manipulation in the ItemDraw() method.
For an example of how to do that, look at the XFItemImageDisplay item in the XFControls.XFPanels.XFPanelItems namespace.
If you need something specific, let me know and I'll see if I can whip up an example
I'm new to C# and the compact framework so sample would be good...
Thanks
JarekG said:
I'm new to C# and the compact framework so sample would be good...
Thanks
Click to expand...
Click to collapse
Ok, could you describe how you want the control to look? Also, what you want to supply to the constructor? IE a path for an image, upper text, lower text, maybe even some style things. ETC
I have a simple benchmark that I have been running on Windows Mobile devices for years. I don't have a Windows Phone 7 device myself, so I'm wondering if someone has a few minutes to run a test. I think the results may be interesting.
Here's the snippit: (in VB.NET, but C++ equivalent is fine):
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim limit, counter
limit = DateAdd("S", 10, Now)
counter = 0
Do Until Now > limit
counter = counter + 1
Loop
MsgBox(counter / 10, 0, "iterations")
End Sub
As benchmarks goes, it's as simple as it gets.
Post your results here - and I'll add them to the table and give a link.
I'm too lazy to convert it to C#, and windows phone 7 only runs C#. If you convert it to C# I will run it on two different phones.
athompson said:
I'm too lazy to convert it to C#, and windows phone 7 only runs C#. If you convert it to C# I will run it on two different phones.
Click to expand...
Click to collapse
Code:
private void Button1_Click(System.Object sender, System.EventArgs e)
{
dynamic limit = null;
dynamic counter = null;
limit = DateAndTime.DateAdd("S", 10, DateAndTime.Now);
counter = 0;
while (!(DateAndTime.Now > limit)) {
counter = counter + 1;
}
Interaction.MsgBox(counter / 10, 0, "iterations");
}
Developer Fusion has a converter. I can't link to it because I don't have good enough reputation yet.
Cheers!
DateAndTime doesn't seem to be available on windows phone 7 (Interation isn't either but I can work around that easily enough. Not sure what you'd want me to do with the DateAndTime problem).
Hmm, just posted it into a windows phone project. There are quite a few errors. I'll see if I can get it working
Code:
private void button1_Click(object sender, RoutedEventArgs e)
{
double counter;
DateTime limit = DateTime.Now.AddSeconds(10.0);
counter = 0;
while (!(DateTime.Now > limit))
{
counter = counter + 1;
}
MessageBox.Show(counter / 10 + " iterations");
}
I think this is what he was trying to accomplish, but in C#?
In the Samsung SGH-i917 I got 31702.2. Sorry, I forgot my other phone has something messed up and I can't load apps on it right now.
FWIW the emulator gets 55272.4 on my 64 bit 3.2GHZ computer.
Great progress! If you get a chance to post your project somewhere so other can run it to see if there is much variation between devices.
Meanwhile, try this out on your device:
nsbasic.com/speedtest.htm
It's the same test in JavaScript. I managed to run it on some sort of Samsung Windows Phone 7 device: it scored 40,000. Hmmm... JavaScript is faster than C#?
The same test on an Android device gets 400,000. The clock speed of the devices is the same.
We can't run C++ on these devices. If we could, I expect the result would be in the 2,000,000 range.
Wow, you're right. On my SGH-i917 I got 35,903 on the nsbasic.com/speedtest.htm . The IE team must feel proud of themselves.
But the times are fairly close, so it probably has more to do with the precise functions we are using than with the speed of javascript or C# in general applications.
Checking the DateTime each and every loop is a killer for performance. I'm not able to test a WP7 solution right now, but simply dropping the DateTime system and replacing it with an Async Timer running in it's own thread in a .NET 4.0 Console app running on my netbook made it jump from 720287 loops/sec, to a huge 241633375 loops/sec. A performance increase of 33546%.
In JS, the date functions are more optimised than in .NET, mainly because date and date manipulation functions make up a reasonable portion of Sunspider, which developers use, among other benchmarks, to track performance improvements in JS. In .NET, besides not really being tracked in the same way, DateTime's rarely used in performance-critical situations, particularly to track the passage of time, which is where MS recommend the usage of timers where suitable.
Code of C# implementation with Timers:
Code:
class Program
{
static bool loop = true;
static void Main(string[] args)
{
int count = 0;
DateTime finish = DateTime.Now.AddSeconds(10);
System.Timers.Timer time = new System.Timers.Timer(1000);
time.Elapsed += new System.Timers.ElapsedEventHandler(time_Elapsed);
time.Start();
while (loop)
count++;
Console.WriteLine("{0} Iterations", count);
}
static void time_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
loop = false;
}
}
athompson said:
Wow, you're right. On my SGH-i917 I got 35,903 on the nsbasic.com/speedtest.htm .
Click to expand...
Click to collapse
I got 40,995 on my HD7
Hounsell makes a good point, one which exposes the weakness of any benchmark: they really do not tell you how your own app will perform.
I urge everyone reading this to treat it as just for fun. If you need a benchmark that applies to your app, you should construct something that is relevant to your situation.
ghenne said:
Meanwhile, try this out on your device:
nsbasic.com/speedtest.htm
It's the same test in JavaScript. I managed to run it on some sort of Samsung Windows Phone 7 device: it scored 40,000. Hmmm... JavaScript is faster than C#?
The same test on an Android device gets 400,000. The clock speed of the devices is the same.
Click to expand...
Click to collapse
my HD2 running an mdeejay build of android sense with the s6.1 kernel just scored 385000 in the regular windows mobile it ranked only 98317.
I got a 40,995 on my Samsung SGH-i917 Focus.
Here is a WP7 Benchmark tool
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.
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