Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 2
Registered: ‎02-18-2010
My Device: 8900 Curve
My Carrier: Verizon

Using imeiToString to convert IMSI. Is it correct?

Hello All!

 

We try to get mcc and mnc from IMSI according to article DB-00691

 

It seems we have a problem with CDMA devices.

 

Our code:

 

public static Integer getMCC() {
        int mcc = 0;
        int networkType = RadioInfo.getNetworkType();
        if (networkType == RadioInfo.NETWORK_IDEN) {
            mcc = IDENInfo.getHomeMCC();
        } else {
            byte[] bs = getIMSI();
            mcc = imsiParseToMCC(bs);
        }
        return new Integer(mcc);
    }

    public static Integer getMNC() {
        int mnc = 0;
        int networkType = RadioInfo.getNetworkType();
        if (networkType == RadioInfo.NETWORK_IDEN) {
            mnc = 0;
        } else {
            byte[] bs = getIMSI();
            mnc = imsiParseToMNC(bs);
        }
        return new Integer(mnc);
    }

    private static int imsiParseToMCC(byte[] bs) {
        String imsi = GPRSInfo.imeiToString(bs);
        String mccString = imsi.substring(0, 3);
        int mcc = Integer.parseInt(mccString);
        return mcc;
    }

    private static int imsiParseToMNC(byte[] bs) {
        String imsi = GPRSInfo.imeiToString(bs);
        String mccString = imsi.substring(3, 6);
        int mcc = Integer.parseInt(mccString);
        return mcc;
    }

    private static byte[] getIMSI() {
        byte[] bs = null;
        int networkType = RadioInfo.getNetworkType();
        if (networkType == RadioInfo.NETWORK_CDMA) {
            bs = CDMAInfo.getIMSI();
        } else {
            try {
                bs = SIMCardInfo.getIMSI();
            } catch (SIMCardException e) {
                e.printStackTrace();
            }
        }
        return bs;
    }

 

We have to able to get MCC and MNC for CDMA, GSM and iDEN networks.

 

It works on device simulators. But real device (9630, Verizon, USA) doesn't work. We have MCC = 10

 

Is this code correct? Is it correct to use imeiToString to convert IMSI.

 

Thanks in advance.

Developer
Developer
Posts: 137
Registered: ‎06-01-2009
My Device: Not Specified

Re: Using imeiToString to convert IMSI. Is it correct?

IMSI is a unique number that is associated with all GSM and UMTS. In CDMA devices, there is nothing called IMSI.

New Contributor
Posts: 2
Registered: ‎02-18-2010
My Device: 8900 Curve
My Carrier: Verizon

Re: Using imeiToString to convert IMSI. Is it correct?

According to wiki - http://en.wikipedia.org/wiki/IMSI CDMA devices use IMSI.

 

And what about this article How to - Determine the country code of the current mobile subscriber?

 

 

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Using imeiToString to convert IMSI. Is it correct?

IMSI and IMEI are two different types of identifiers. Why do you expect imeiToString to work for IMSI?