IMSI is an abbreviation for "International Mobile Subscriber Identity". The IMSI number is a unique 15-digit code that is attached to every SIM (Subscriber Identification Module) card and makes it possible for mobile networks to identify the home country and network of a subscriber.
UIQ platform
The IMSI number can be obtained from Sony Ericsson P800 and P900 smartphones for use in C++ applications by reading the contents of the file C:\System\data\imsi.txt
This file will be updated automatically if the SIM card is changed.
Some system processes keep this file open and therefore the file needs to be opened in shared mode for readers. This is done by using the EFileShareReadersOnly flag when opening the file. The following C++ code reads the contents of imsi.txt and displays it on the screen:
RFs fs;
fs.Connect();
RFile file;
_LIT(KImsiFileName,"C:\\System\\data\\imsi.txt");
TInt res = file.Open(fs,KImsiFileName,
EFileShareReadersOnly|EFileStreamText);
if(res != KErrNone)
{
gConsole->Printf(_L("Open failed: %d\n"),res);
}
else
{
TBuf8<128> buf;
file.Read(buf);
file.Close();
fs.Close();
TBuf<128> printBuf;
printBuf.Copy(buf);
gConsole->Printf(_L("IMSI: "));
gConsole->Printf(printBuf);
gConsole->Printf(_L("\n"));
}
Series 60 Platform
On the Series 60 platform, the same is possible for the phones that support the 3rd Party Telephony API (this means phones based on v7.0s except the Nokia 6600).
The IMSI can be obtained using the following code: CTelephony telephony = CTelephony::NewL();
TRequestStatus status;
CTelephony::TSubscriberIdV1 subscriberId;
CTelephony::TSubscriberIdV1Pckg subscriberIdPckg(subscriberId);
telephony->GetSubscriberId(status, subscriberIdPckg));
User::WaitForRequest(status);
User::LeaveIfError(status);
TPtrC theIMSI(subscriberId.iSubscriberId);
This tip was originally posted on SonyEricsson Developer Site for the UIQ version and on Symbian site for the Series 60 one
|