Why one same USIM card has two IMSI? - android

I want to get IMSI invoking TelephonyManager.getSubscriberId(), but sometimes get 334050xxxxxx, and sometimes get 222013xxxxxx, why? I use the some one USIM card.

Most likely your card has Dual IMSI application (or Multi IMSI application). One IMSI is used for home and partners network, and another one for international use (roaming).
I suggest to use ICCID for identification, because it is unique for each card. You can use Telephony#getSimSerialNumber().

Related

How to read Sim card information with AOSP [duplicate]

I wonder if it's possible to access to the SIM card with an Android Application
You can get the IMEI like this (but is it what you want ?), just an exemple :
mTelephonyMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String imei = mTelephonyMgr.getDeviceId();
Likewise, you have
String getSimCountryIso():
Returns the ISO country code equivalent for the SIM provider's country code.
String getSimOperator(): Returns the MCC+MNC (mobile country code + mobile network code) of the provider of the SIM.
String getSimOperatorName(): Returns the Service Provider Name (SPN).
String getSimSerialNumber(): Returns the serial number of the SIM, if applicable.
int getSimState(): Returns a constant indicating the state of the device SIM card.
String getSubscriberId(): Returns the unique subscriber ID, for example, the IMSI for a GSM phone.
For more, take a look at this page
and don't forget to add the correct permission in the manifest (getDeviceId() => Requires Permission: READ_PHONE_STATE)
Without SmartCardAPI from SEEK(Secure Element Evaluation Kit) its never possible. In majority Android phones available in market SmartCardAPI is not implemented. So either you build your own Android after integrating the SmartCardAPI code or wait for some decent phone with this feature to come out. You can find the patch file for implementation here.
SmartCard API for Android might be of interest for you:
http://code.google.com/p/seek-for-android/
SIM card access is only possible for system applications:
Low level access to the SIM card is not available to third-party apps.
The OS handles all communications with the SIM card including access
to personal information (contacts) on the SIM card memory.
Applications also cannot access AT commands, as these are managed
exclusively by the Radio Interface Layer (RIL). The RIL provides no
high level APIs for these commands.
source: https://source.android.com/security/overview/app-security.html#sim-card-access
SEEK is most useful one,but majority Android phones are not support that.So,maybe we can assess SIM card by some other method like read SMS(in SIM card).
You should use IccFileHandler in interal api of android using java reflection .
It is located at framework/base/telephony

MSISDN : Is it a SIM Card Data? Why all The Provided Function (from Blackberry and Android) to fetch MSISDN not reliable?

I have several question about MSISDNs. I understand:
MSISDN is the basically the phone number
It is not IMSI
What i need to know further are:
Is MSISDN number burnt (stored) in SIM Card? If it is yes, are all providers make sure that there is MSISDN information in SIM Card? If it is no, to be clarified, None of programming code can fetch the MSISDN number?
Some people suggest to fetch MSISDN as below code. But both the code return null if "My Phone Number" is not set in device. On the other way around, it will return the "My Phone Number" if it is set.
Thus, the question is: "My Phone Number" equals to MSISDN?
TelephonyManager.getLine1Number(); --> for Android
Phone.getDevicePhoneNumber(true); --> for Blackberry
As code above, the return String data is fetched from the device itself or from the SIM Card?
I have some insight into the matter for you.
The MSISDN can be stored on the SIM card, however most network providers (all providers in South Africa) do not store the MSISDN on the SIM card. There are several reasons for this, the most notable being:
Dynamic MSISDN allocation: Prepaid SIMs are sometime allocated an MSISDN when they are first used. This means that the network has a pool of available MSISDNs and allocate them whenever a new prepaid SIM comes online. This means that when the SIMs are shipped they do not have an MSISDN yet, which means you can't store an MSISDN prior to shipping the SIMs. Some networks 'expire' MSISDN allocations after a period of inactivity, especially when their available numbers are running low, and return these numbers to the available pool.
Mobile Number Portability: Some countries allow mobile subscribers to keep their MSISDN but change networks. This means that the MSISDN will be moved from a SIM that is for 1 network to a SIM that is for another network.
So the user often ends up with the MSISDN entry on the SIM being blank. The user can still store the MSISDN on the SIM themselves, but this also allows them to store any arbitrary number, and it is not guaranteed to be set or to even be the subscribers actual phone number.
2. Those calls you asked about fetch the number that is stored in the SIM card. If the number is not set you won't get it, and if the user has the wrong number set then you will have the incorrect details.
3. Correct, this string is fetched from the SIM itself.
The only semi-reliable way I have for detecting MSISDN is via WAP/WEB when the Mobile Operator includes the MSISDN in the headers (you can do some webview trickery to see what headers are coming through) - however you only see these if the network supports it and if the user is on Mobile Data - i.e. It won't work if the user is on WiFi.
The other mechanism I can think of (the only guaranteed mechanism I can think of) is via a USSD session, as you always get the correct MSISDN from the operator, but I haven't found a way of programatically opening a USSD session and reading the response (in Android at least). I have a USSD service whose only output is the MSISDN but unfortunately this hasn't proven usable to me yet.
Since nobody replied in the last hour since you posted your question, here is what I know (although I am not an expert in this area, just have some experience):
MSISDN is the phone number; the number people can call you on.
It cannot be "burnt" into the sim card as you can change sim card (upgrade or changing to other operator) and keep your phone number = MSISDN. I think there is a mapping table at the operators that covert from sim card ID to MSISDN and back when call/data transfer is made. The MSISDN might be stored on the card.
You should take into account that MSISDN has BIGINT type.
Therefore outputting it make type transformation in advance,
like this

How to get your own phone number in Android

I am trying to develop an application that needs the phone number of SIM Card every time a new SIM Card is inserted in the phone....Then i will use that phone number to get the user subscribed to an online server.I have read many forums and found something like this
TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
mPhoneNumber = tMgr.getLine1Number();
but everyone said that this is not an efficient method.If this is not an efficient method then which is the efficient method and also I cannot use any other property like SIM id or Subscriber ID etc.I only need the PHONE NUMBER. Any help would be appreciated.
As far as I know, this method would not always return right SIM number; it depends on the SIM card itself.
If you really want to get the SIM number, you can send a SMS to a specific phone, so you will get it.
TelephonyManager is not the right Solution,Because in some cases the
number is not stored in the SIM, Due to my suggestion,You should use
Shared Preference to store user's Phone number first time the
application is open, and after that the number will used whenever you
need in application.
Thank you.

Get Mobile no from real device

I want to get the mobile number of a sim which is inserted into the device. I know as pr the android SDK TelephoneManger is the class by which we can get it by getLine1Number() method. but it always returns null values.
Queries:
Can i get mobile number from
device?
Is it a sim dependent or in some case
also device dependent?
Any other ways to get the mobile number from device?
You are using correct and the only approach available to the common user (AFAIK). It is mainly SIM dependent (it is not obligatory to have ), and in some cases may be device dependent (getLine1Number() not correctly implemented).
To be more precise, IMSI uniquely identifies SIM. But MSISDN (the subscriber number) is not uniquely related to SIM, as it is possible to change MSISDN on the SIM. Network may use IMSI from SIM to find MSISDN in the HLR and establish the call.
So, MSISDN is not mandatory to be on the SIM.
You should look at this question and its comments.
Some SIM cards seems to cause getLine1Number() to return null... and no one has found a way to deal with this.
More information here
In that case you always save your phone no using SharedPreference by using the method getLine1Number() method. when you install your application then your phone number is saven and when when new sim card is used then send SMS to ur registered number. you have to always check after starting the application that your stored number is same with your new number.if same nothing will be happned ,if not same then ur app will send SMS.

Access the SIM Card with an Android Application?

I wonder if it's possible to access to the SIM card with an Android Application
You can get the IMEI like this (but is it what you want ?), just an exemple :
mTelephonyMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String imei = mTelephonyMgr.getDeviceId();
Likewise, you have
String getSimCountryIso():
Returns the ISO country code equivalent for the SIM provider's country code.
String getSimOperator(): Returns the MCC+MNC (mobile country code + mobile network code) of the provider of the SIM.
String getSimOperatorName(): Returns the Service Provider Name (SPN).
String getSimSerialNumber(): Returns the serial number of the SIM, if applicable.
int getSimState(): Returns a constant indicating the state of the device SIM card.
String getSubscriberId(): Returns the unique subscriber ID, for example, the IMSI for a GSM phone.
For more, take a look at this page
and don't forget to add the correct permission in the manifest (getDeviceId() => Requires Permission: READ_PHONE_STATE)
Without SmartCardAPI from SEEK(Secure Element Evaluation Kit) its never possible. In majority Android phones available in market SmartCardAPI is not implemented. So either you build your own Android after integrating the SmartCardAPI code or wait for some decent phone with this feature to come out. You can find the patch file for implementation here.
SmartCard API for Android might be of interest for you:
http://code.google.com/p/seek-for-android/
SIM card access is only possible for system applications:
Low level access to the SIM card is not available to third-party apps.
The OS handles all communications with the SIM card including access
to personal information (contacts) on the SIM card memory.
Applications also cannot access AT commands, as these are managed
exclusively by the Radio Interface Layer (RIL). The RIL provides no
high level APIs for these commands.
source: https://source.android.com/security/overview/app-security.html#sim-card-access
SEEK is most useful one,but majority Android phones are not support that.So,maybe we can assess SIM card by some other method like read SMS(in SIM card).
You should use IccFileHandler in interal api of android using java reflection .
It is located at framework/base/telephony

Categories

Resources