Symbian OS
read last symbian news on www.newlc.com read last symbian reviews on www.newlc.com
read last symbian tutorial on www.newlc.com read last symbian download on www.newlc.com
27 Dec 2006 - 11:47
Keywords :

Retrieving IMEI, IMSI, Network Info (Cell Id, Location Code) 3rd Edition.

In the 2nd edition there are many ways to retrieve the IMEI and IMSI. The one popularly used is the 3rd party “MobInfo Dll”. In Series 60 3rd edition there is no such third party Dll. Instead “CTelephony” needs to be used.

I've seen lots of threads for 2nd edition, but did not get good pointers for retrieving these parameters for 3rd edition.

Following is my contribution on how to retrieve IMEI and IMSI. Along with that you can also use this code to retrieve network info (Cell Id, Location code) It can further be extended to retrieve other network info.

Header File

#ifndef __SYSTEM_MANAGER_H__
#define __SYSTEM_MANAGER_H__

#include <Etel3rdParty.h>

class CystemManager : public CActive
{
public:
        typedef enum {EHandsetIMEI, EHandsetIMSI, EHandsetNetworkInfo } InfoType;
       
public:
        static CystemManager* NewL();

        // Destructor
        ~CSystemManager();

public:
// New functions
        void StartL();  // Request

        const TPtrC GetIMEI();
        const TPtrC GetIMSI();
        void GetNetworkInfoL(TUint& aLocation, TUint& aCellId);

private:
        // C++ constructor
        CSystemManager();
        // Second-phase constructor
        void ConstructL();



        // From CActive
        void RunL();

        // Cancel
        void DoCancel();

private:
        enum TGetInfoState
        {
                EStart = 1,
                EGetPhoneInfo,
                EDone
        };

private:
        InfoType                                                                 iPhoneInfoType;
        TInt                                                                         iState; // State of the active object
        CTelephony*                                                         iTelephony;
       
        CTelephony::TPhoneIdV1                                        iPhoneId;
        CTelephony::TSubscriberIdV1                         iSubscriberId;
        CTelephony::TNetworkInfoV1                                 iNetworkInfo;
       
        CActiveSchedulerWait                                         iActiveSchedulerWait;
        TBuf<CTelephony::KPhoneSerialNumberSize>iIMEI;
        TBuf<CTelephony::KIMSISize>                         iIMSI;
        TUint                                                                         iCellId;
        TUint                                                                         iLocationAreaCode;
};
#endif // __SYSTEM_MANAGER_H__

Source File

// System includes
#include <badesca.h>
#include <e32std.h>
#include <eikenv.h>
#include <eikappui.h>
#include <eikapp.h>
#include <etelbgsm.h>

//User includes
#include "SystemManager.h"

CSystemManager* CSystemManager::NewL()
{
        CSystemManager* self = new (ELeave) CSystemManager();
        CleanupStack::PushL(self);
        self->ConstructL();
        CleanupStack::Pop(self);

        return self;
}

CSystemManager::CSystemManager() : CActive(EPriorityHigh), // HIGH priority
                                                                iPhoneInfoType(EHandsetIMEI),
                                                                iState(EStart),
                                                                iTelephony(NULL),
                                                                iIMEI(0),
                                                                iIMSI(0),  
                                                                iCellId(0),
                                                                iLocationAreaCode(0)
{

}

void CSystemManager::ConstructL()
{
        iTelephony = CTelephony::NewL();
        CActiveScheduler::Add(this); // Add to scheduler
}

CSystemManager::~CSystemManager()
{
        Cancel(); // Cancel any request, if outstanding
        // Delete instance variables if any
        delete iTelephony;
}

void CSystemManager::DoCancel()
{
        switch(iPhoneInfoType)
        {
                case EHandsetIMEI:
                        iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
                        break;
                case EHandsetIMSI:
                        iTelephony->CancelAsync(CTelephony::EGetSubscriberIdCancel);
                        break;
                default:
                        iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
                        break;
        }
}

void CSystemManager::StartL()
{
        Cancel(); // Cancel any request, just to be sure
        iState = EGetPhoneInfo;
        switch(iPhoneInfoType)
        {
                case EHandsetIMEI:
                        {
                                CTelephony::TPhoneIdV1Pckg phoneIdPckg( iPhoneId );
                                iTelephony->GetPhoneId(iStatus, phoneIdPckg);
                        }
                        break;
                case EHandsetIMSI:
                        {
                                CTelephony::TSubscriberIdV1Pckg subscriberIdPckg( iSubscriberId );
                                iTelephony->GetSubscriberId(iStatus, subscriberIdPckg);
                        }
                        break;
                case EHandsetNetworkInfo:
                        {
                                CTelephony::TNetworkInfoV1Pckg networkInfoPckg( iNetworkInfo );
                                iTelephony->GetCurrentNetworkInfo(iStatus, networkInfoPckg);
                        }
                        break;       
        }
       
        SetActive(); // Tell scheduler a request is active
        iActiveSchedulerWait.Start();
}

void CSystemManager::RunL()
{
        iState = EDone;
        if ( iActiveSchedulerWait.IsStarted() )
        {
                iActiveSchedulerWait.AsyncStop();
                if(iStatus == KErrNone)
                {
                        switch(iPhoneInfoType)
                        {
                                case EHandsetIMEI:
                                        iIMEI.Append(iPhoneId.iSerialNumber );
                                        break;
                                case EHandsetIMSI:
                                        iIMSI.Append(iSubscriberId.iSubscriberId );
                                        break;
                                case EHandsetNetworkInfo:
                                        iCellId = iNetworkInfo.iCellId;
                                        iLocationAreaCode = iNetworkInfo.iLocationAreaCode;
                                        break;
                        }
                }
                else
                {
               // ***********Handle Error here ************
                }
        }
}

const TPtrC CSystemManager::GetIMEI()
{
        iPhoneInfoType = EHandsetIMEI;
        iIMEI.Zero();

        StartL();
        TPtrC ptr(iIMEI.Ptr());
        return ptr;
}

const TPtrC CSystemManager::GetIMSI()
{
        iPhoneInfoType = EHandsetIMSI;
        iIMSI.Zero();

        StartL();
        TPtrC ptr(iIMSI.Ptr());
        return ptr;
}

void CSystemManager::GetNetworkInfoL(TUint& aLocationCode, TUint& aCellId)
{
        iPhoneInfoType = EHandsetNetworkInfo;
        StartL();
        aCellId = iCellId;
        aLocationCode = iLocationAreaCode;
       
        return;

}

Note: This piece of code requires "ReadDeviceData" Capability.

You can further extend the above code for retrieving other network information.

Vinay

Tutorial posted December 27th, 2006 by vinay

Submitted by Anonymous on Fri, 2007-01-19 18:27.

Hello all,

I write with regards to the authors' following comment:

"You can further extend the above code for retrieving other network information."

Any links to what these "other network information" might be would be greatly appreciarted.

Best, wirefree101


Submitted by Sahdev (not verified) on Fri, 2007-02-23 06:57.

Hi

I would like to ask, is there any way we can fetch these informations regarding the IMSI or network informations without the capabilities.

Regards


Submitted by vinay on Fri, 2007-03-02 07:42.

As I said earlier you can retrieve the MCC and MNC values.

The signal strength can be retrieved using "CTelephony::GetSignalStrength()" Go through the methods of CTelephony class to see what all information can be retrieved.
— Vink


Submitted by Anonymous on Sat, 2007-03-03 09:13.

How we can fetch the area code ( cell info ) in the third edition phones. Is it possible?

Submitted by Deepak Agharkar (not verified) on Thu, 2007-02-22 17:14.

All this information on the IMEI code sounds good. But how can one track a LOST or STOLEN mobile by using this IMEI code ? Is it possible to track the SIMcard number being currently used based on submitting this IMEI code to the Mobile Manufacturer ( Eg. Nokia, Samsung , Motorola etc)? Or can we track the cell phone service provider ( BPL, Hutch, Airtel etc.)in such a case and what is the procedure ?

Submitted by vinay on Fri, 2007-03-02 07:03.

Well, Whenever a mobile registers to the network the IMEI number is sent from the handset to the mobile station during the handshake. The EIR (Equipment Identity Register) maintains the list of mobiles which are identified by their IMEI. An operator can maintain a Gray list which lists the IMEIs that need to be traced, and/or a Black list which lists IMEIs that need to be blocked.

For deeper insight, go through this link, http://en.wikipedia.org/wiki/GSM_core_network

— Vink


Submitted by Anonymous on Sun, 2007-04-08 07:32.

i used the code provided by u to retrive cell id , location code . it is showing corect imei no but the cell id and location code are shown as 0 i tested it on nokia e50 can anybody help me.

Submitted by old_skool_dude69 on Sat, 2007-05-26 17:56.

i have a phone which i have put my new sim card in the sim has been sent from t-mobile to carry on my contract from my last phone which i lost contract i just need the imei code for a nokia 6230 (tac)


Submitted by isolated on Sat, 2008-02-09 22:20.

hi there,
i'm newbie in symbian programing.

i'm trying to get cell_id +signal strength (not only the one connected, but few others)

if anybody knows anything let me know

Thanks


Submitted by SymbianTG on Wed, 2008-02-20 07:57.


Hi

I try to get Cell Id using above code but i shown always cell id 0. i tested in E51. please help me for get cell id.

Regards


Submitted by Rama1962 on Sat, 2008-07-05 08:53.

When i use unprotected UID, i get the value for cellid and LAC.
But when i use Protected UID the value for cellid and LAC i get is 0.
How to resolve this? I need to use protected UID.


Submitted by sehgal_dheeraj on Sun, 2008-10-12 11:10.

hello every body,
I am new to this site, and found it very interesting. You guys are giving very useful informations about new mobile technology. But can you tell me some useful informations on this topic.
1) Is this programming is for PC's?
2)What kind of system requirements do we have to run this program?
3)In which computer Language this program is made?
4)Can we locate the IMEI no of the mobile ,whom i only know the number.
5) Can i check the location of the mobile with the help of this program.

Please provide thises informations, I'll be very thankful to you.

Regards,
Dheeraj


Submitted by krishven on Wed, 2009-08-19 06:54.

Nice article. I normally use the *#06# to find the imei number, & i used these procedure to unlock my mobile from http://www.mobile-unlocker.com/ but here to find the imei using java codes is very useful. Thanks for this information.



copyright 2003-2009 NewLC SARL