ailon's DevBlog: Development related stuff in my life

Introducing PhoneNameResolver–a lib to decipher Windows Phone models

1/21/2013 8:31:54 PM


On Windows Phone you can get information about device’s manufacturer and model using Microsoft.Phone.Info.DeviceStatus class. Unfortunately the results you get do not always represent model names people are used to (see the screenshot above). To make matters worse same models made for different network operators quite often return different values. Additionally returned value quite often changes between batches of the same model. With Windows Phone 8 Nokia went one step further and introduced so many variations of the model name that it became extremely painful to account for all of them manually. That’s why I decided to dedicate a few hours on a weekend to make a small lib that helps with this problem.

PhoneNameResolver (released under MIT license) is a very simple static class that has only one public method called Resolve(). You pass the manufacturer and model name from the DeviceStatus and it returns an object of type CanonicalPhoneName which contains resolved “canonical” (official and/or widely used) model name.

Here’s a sample:

var phone = PhoneNameResolver.Resolve(
    DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceName);
SomeTextBox.Text = phone.FullCanonicalName;

CanonicalManufacturer and CanonicalModel include manufacturer and model separately and are always set. In the case the lib wasn’t able to resolve the model they will be set to the same values passed to the method and IsResolved property will be set to false.

At the moment the lib resolves Nokia, HTC, Samsung and LG model names. The reported/canonical value pairs where collected from public unofficial sources so there’s absolutely no guarantee in the accuracy of the results.

The lib is basically a single C# file and all the model name definitions are included in the same file. I did this to make it extremely easy to just drop the file into your project and to make it work as fast and as config free as possible. That said this is probably not the best architecture to update model definitions without recompiling an app. I’m still open to ideas and this may change in the future. Please let me know your thoughts in the comments below.

Tags: ,

blog comments powered by Disqus
Copyright © 2003 - 2018 Alan Mendelevich
Powered by BlogEngine.NET