The 3 different solutions of retrieving the MNC
- via GPRSInfo
- via RadioInfo
- via GPRSCellInfo
int mnc = GPRSInfo.getHomeMNC();
int currentIndex = RadioInfo.getCurrentNetworkIndex(); int mnc = RadioInfo.getMNC(currentIndex);
GPRSInfo.GPRSCellInfo cellInfo = GPRSInfo.getCellInfo(); int mnc = cellInfo.getMNC();
Note:in blackberry the returned MNC value is decimal, which is different with the MNC standard, which is hexadecimal.
I found that solution 1-2 are always consistent, they are always same if you are not in the roaming network. But in solution 3, in some cases you will get the wrong value. For example I tested the following UK carriers, the retrieved mnc values are all wrong:
From the above table, we can tell that all the mnc values are appended letter F at the end, if we removed the F, then the value is correct. This is the first time I have ever met. Actually I found this article mentioned this issue a little bit:
Conclusion
So the solution to get the correct MNC value from blackberry API should be: first check the last 4 bits value, if it is F (or more than 9), then right shift 4 bits, that is it!
I found that solution 1-2 are always consistent, they are always same if you are not in the roaming network. But in solution 3, in some cases you will get the wrong value. For example I tested the following UK carriers, the retrieved mnc values are all wrong:
Carrier Name | MNC(Hex) | retrieved(dec) | retrieved(hex) |
---|---|---|---|
3 UK | 20 | 527 | 20F |
Orange UK | 33 | 831 | 33F |
Vodafone UK | 15 | 351 | 15F |
T-Mobile | 30 | 783 | 30F |
O2 | 10 | 271 | 10F |
From the above table, we can tell that all the mnc values are appended letter F at the end, if we removed the F, then the value is correct. This is the first time I have ever met. Actually I found this article mentioned this issue a little bit:
...therefore the corresponding hexadecimal value returned by getMCC()or getMNC()may contain the letter F as padding. For example, for T-Mobile®, the MCCs can be identified as either 260 or 26F.If you want to use cellInfo ( ex. MCC, MNC, LAC, cellID) to get the current location via openCellID for example, then you need to be careful for this issue.
Conclusion
So the solution to get the correct MNC value from blackberry API should be: first check the last 4 bits value, if it is F (or more than 9), then right shift 4 bits, that is it!
No comments:
Post a Comment