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
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
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
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
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
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)
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
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
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.
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
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.