I’d like to think that I’m normally a fairly easy-going person, but we all have our pet peeves and for me one of mine is my mobile phone network operator. They drive me nuts – I never get a signal anywhere!
Or at least, so I thought.
Last night, I put together a quick test to keep track of how much time my phone doesn’t have a signal.
It is technically very simple to do, but I’ll describe how it works in a moment. First, the results. Today was a “typical” work day – I spent most of it at my desk which is by a window on a first floor. I don’t work in a lead-lined bunker, and I didn’t hide the phone in a microwave (does that even work?) or anything like that.
I started the test at home this morning, when I normally start checking my emails and twitter. And it’s been running all day. While in my office, the phone was on my desk. The rest of the time it’s been in my pocket.
It looks like I have a signal more often than I thought – for over seven hours it had a signal, with only a little over three hours with no signal. I was expecting a result with time without a signal being greater than time with a signal.
This is hardly a scientific test, but I wonder if my perception is worse than reality? Maybe all it takes is a few times for the phone to not have a signal when I need it for me to get the impression that it “never” has a signal.
I wrote the test in C# as a simple .NET application to run on a Windows Mobile phone – because it was a quick way to throw together a simple one-use test app.
The .NET Compact Framework you get on Windows Mobile gives you a few boolean system properties relating to the phone radio you can check instantly. They let you easily identify whether the phone has a signal:
if (SystemState.PhoneRadioOff) { // the phone is off - e.g. in "airplane mode" // so I stopped all timers - not fair to make // any assumptions about the network } else if (SystemState.PhoneNoService) { // the phone is on, but does not have any signal } else if (SystemState.PhoneSearchingForService) { // the phone is on and doesn't currently have // a signal - but it is searching for a network } else { // otherwise... we must have an OK signal }
That’s it.
Then I just maintain a couple of TimeSpan
objects where I store the time spent with and without a signal.
In fact, I could have also used the integer system property SystemProperty.PhoneSignalStrength
which gives you the current signal strength as a number between 0 and 100, but I didn’t need anything that complicated.
Not only can you check the properties easily, but you don’t even need to poll these values to track changes in network status. You can register an event handler which will be notified when any of these system properties change:
SystemState phoneState = new SystemState(SystemProperty.PhoneRadioOff); phoneState.Changed += new ChangeEventHandler(StateChanged);
Then I have a simple event handler which is called when the value changes:
public void StateChanged(object sender, ChangeEventArgs args) { // the system property has changed! // sender is a SystemState object which tells // me which property has changed (the sender.Property attribute) // args contains the new property value (in args.NewValue) }
I used one event handler to handle notifications for changes to all three properties, but you could have three separate event handler methods and not bother checking which property type you are being notified about.
If you want to try the app yourself, you can get a CAB installer for it here. But don’t read too much into it – it’s really just a bit of fun 🙂
Tags: .net, ChangeEventHandler, compact framework, mobile, network status, notifications, radio, windows mobile
This is great software. But do you have to make log for signal?
@Martin – Sorry, I’m not sure what you mean. But the software doesn’t produce a log file, if that’s what you’re asking.