Android RIL Modem GPRS - android

I am trying integrate a GPRS modem in Android 6.0.1 without success. Modem works well at hardware level and answer correctly AT commands. In Android UI I only see SIM card not present and nothing related to modem works.
In Android log I can see a lot of subId=-2, phoneId=-1, slotId=-1, I think my problem is because of this wrong numbers.
Someone with experience in Android RIL could help me to understand how this numbers are generate and where?
I think my reference-ril.c is OK, and I can't understand why this Id are not generate correctly.

In almost all the case PhoneId equals slotId, it means which SIM card slot the current subscription is on.
SubId maintain a record for SIM cards that have been inserted. eg, You insert a card with Iccid 46332223***3232 and the telephony record it as a subId=1, for another card with Iccid 46332223***9900, telephony record it as SubId=2.....Next when you insert 46332223***3232 again, telephony will know it's an acquaintance card, and SubId will again set as subId=1. So it's for other cards.
If SIM card is not presented, pls first check the GET_SIM_STATUS in your log, if the state is absent, you should check the modem part.

Related

How do I disable SIM slot 1 in Android API Level 27

I am trying to disable SIM Slot 1 in an application built in Kotlin.
This application is for API Level 27(Android 8.1, will be part of built-in app in the ROM), and you can assume that I can gain whatever permissions from the system as we are dealing with the ROM build-in app.
In the Android source code of "android/telephony/TelephonyManager.java" I see this function.
setSimPowerStateForSlot(getSlotIndex(), powerUp)
But appearantly, I cannot get access to this method by calling
telephonyManager = this.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
telephonyManager!!.setSimPowerStateForSlot(0, powerDown)
I saw in another post that somebody have done this successfully, but can anybody to guide me how to do this?
Again, my goal is:
Some routine here to check if the phone is in DSDS mode, and there is a SIM card inserted in SIM Slot 2. (Done work here)
Turn off SIM 1 completely so that in the system, there is only one sim which is SIM 2 (Nolonger DSDS, and only allow SIM 2 to be active. SIM 1 shall not try to scan network nor try to register at all)

Operation on Second SIM Android

I am developing one Android app for that I need to stop and start mobile data.
The problem is that how can I determine whether the mobile is dual SIM or not?
Also if it is dual SIM then how can I do my operation on second SIM?
Thanks !
Safely and decently, you can't.
If you're ready to limit your app to certain devices and give up on it being future proof, you can determine whether the mobile phone is dual SIM by trying to do something that only a specific dual SIM phone can do. If it works, it's surely dual SIM. If it doesn't, well... You won't know. Maybe it's a chipset you didn't cover.
I'll give you an example. If you wish to cover Mediatek chipsets, try this:
long gprsConnectionSimSetting =
Settings.System.getLong(context.getContentResolver(),
"gprs_connection_sim_setting");
It is a Mediatek powered dual SIM phone, if gprsConnectionSimSetting holds one of these values: 0, 1 or 2.
Value 0 stands for "mobile data disabled on both SIMs", value 1 means "mobile data goes through SIM1" and, you've guessed it, value 2 tells us that SIM2 is being used for mobile data.

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

TelephonyManager.getLine1Number() failing?

I want to get phone number of android device. I use this code:
TelephonyManager tm = (TelephonyManager)this.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber= tm.getLine1Number();
On my phone (HTC Wildfire) I can not get phone number - all I get is empty string. If I run code on emulatur, phone number is normally showed.
If I go to Settings=>About phone=>Phone identity->Phone number, phone number is "Unknown".
Where is the problem? Is something wrong with my SIM?
We had the same problem in our project. The conclusion was that it depends on the SIM card.
What happened to us:
Galaxy S with AT&T SIM card: can read phone number, Settings shows number
Same Galaxy with an European SIM card: cannot read the number and "unknown" in Settings (cell phone was perfectly functional, just couldn't read the number)
This has been reported in other forums as well.
In the end we decided to ask the user for the phone number. A bit more involved, actually: if( "SIM card present" && "cannot read the cell number") "ask user"; . Otherwise we will keep bugging the user that doesn't a SIM card in the first place.
Instead of the phone number use the SIM card serial number, which always exists and is always a valid value.
telephonyManager.getSimSerialNumber();
SIM serial number is unique within the operator at least. So combined with
telephonyManager.getNetworkOperator();
you'll have a unique identifier for a subscriber within a country.
This combined with
telephonyManager.getNetworkCountryIso();
you'll have a globally unique identifier for a subscriber.
Hope this will help.
Cheers.
SIM card stores phone number and it can be edited by you. Cant say for Android, but on WM you can easily edit your phone number, which is stored on SIM card.
Of course, it does not mean that you can change your phone number on the fly. Actually, you are free to write there any number you like, and the programs will believe, that this is your real number :)
When I've moved a SIM card into a new phone, I've sometimes found that the phone number does not show up in Settings -> About phone -> Status -> My phone number.
My data points:
AT&T Atrix putting completely new SIM in it says “Voice MSISDN Line1 null”.
T-Mobile G1 putting new SIM card into it correctly displays the phone number.
T-Mobile G2 moving SIM card from my old G1 into is says "Unknown".
Telephone number available if the SIM card is allows it get his.
In our company I found only one SIM, which is allowed get number. I'm tetsting this SIM on all android device. All ok. getLine1Number() is ok.
Now I'm looking for get phone number for other SIM. Have send sms to our sms-server or other android device(with the processing of SMS)
I use a simcard which only permits data transfer. It doesn't permit phone calls.
When I try to get phonenumber with getLine1Number(), I get empty string.

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.

Categories

Resources