How Automatically Set An APN Depending On Network Provider - Stack Overflow
How Automatically Set An APN Depending On Network Provider - Stack Overflow
- Stack Overflow
When a new SIM (never used) is inserted in a new smartphone (never used), smartphone
seems to set a right APN without any manual settings. Is there a global table (inside
5 smartphone) with associations APN <-> network operator?
Note: Querying new SIM cards with AT commands seems they have preferred network
operators, but no APN saved in memory.
sim-card apn
Share Improve this question Follow asked Jan 27, 2017 at 16:48
aldo85ita
496 3 9 19
I'm not sure how this is ontopic for this site. – Andy Apr 17, 2018 at 23:30
@Andy, please note that the topic is also related to AT command.. in your opinion, what is the best site
related to? – aldo85ita Apr 18, 2018 at 12:02
id say superuser. Issuing at commands is no more programming than using telnet or ssh. – Andy Apr
18, 2018 at 22:18
I can comment on the SIM side and confirm that APN settings are not held within the SIM.
And yes in terms of network operators there is a file called EF_PLMN which holds the Mobile
4 Country Code (MCC) and Mobile Network Code (MNC) to allow a device to connect to the
correct network faster.
On the point of APN, it is my understanding that devices have internal (memory) APN listings
for major operators in that territory. When an operator orders a device they ensure that
"their" APN is correct. Yes a big issue is incorrect APNs for operators within the device and
that is the reason network operators need to send APN settings when they detect a SIM in a
new Device.
I do not have information on how to query this internal APN listing as it may be part of the
Firmware.
https://stackoverflow.com/questions/41898986/how-automatically-set-an-apn-depending-on-network-provider 1/3
5/28/24, 2:59 PM sim card - How automatically set an APN depending on network provider? - Stack Overflow
Share Improve this answer Follow answered Feb 9, 2017 at 12:55
QuickPrototype
873 7 19
About the first point: ok, preferred PLMN list can be inside EF_PLMN file, but it can be obtained from
network if you use EF_OPLMNwACT policy (please correct me if I'm wrong). About the second point:
what do you mean with "When an operator orders a device"? and how can network operator know that
a new SIM has been inserted and send APN settings? – aldo85ita Feb 11, 2017 at 9:44
EF_OPLMNwACT is not obtained from the network. it is set by the network operator when they order
the SIM. it allows an operator (Vodaphone, Orange etc.) to set the preferred roaming networks
including which access technology to use (2G,3G,4G). – QuickPrototype Feb 11, 2017 at 14:48
When a large operator (Vodaphone, Orange etc) orders some phones like Samsung, Nokia, Apple etc.
They first test a single device and ensure that the APN is correct. – QuickPrototype Feb 11, 2017 at
14:49
When you connect to a network your devices identifier "IMEI" is sent with some of the signalling (This
is how devices can be blacklisted). If the operator detects a change in IMEI it knows that the SIM is now
in a new phone. – QuickPrototype Feb 11, 2017 at 14:51
QuickPrototype, I understand what you mean and I thankyou for all informations. But, related to my
first question, "Is there a global table (inside smartphone) with associations APN <-> network
operator?", do you know any open source project with this table available? – aldo85ita Feb 26, 2017
at 9:33
For Android, the mobile devices pull the The MCC (Mobile Country One) and the MNC
(Mobile Network code) from the SIM card, and maybe other values.
2
Then, it configures the APN based on an internal SQlite database created by Android based
on XML files that contain APN settings in the following format:
<apn carrier="CarrierXYZ"
mcc="123"
mnc="123"
apn="carrierxyz"
type="default,supl,mms,ims,cbs"
mmsc="http://mms.carrierxyz.com"
mmsproxy="0.0.0.0"
mmsport="80"
bearer_bitmask="4|5|6|7|8|12"
/>
https://android.googlesource.com/device/sample/+/master/etc/apns-full-conf.xml
https://source.android.com/devices/tech/config/update
Share Improve this answer Follow edited Mar 15 at 12:14 answered Mar 7, 2022 at 12:17
Pratik Butani user14219984
61.7k 62 280 445 106 1 4
Having been through the approval's procedure for a big USA mobile network operator
(MNO), part of the approval's process involved automatically selecting the correct default APN
https://stackoverflow.com/questions/41898986/how-automatically-set-an-apn-depending-on-network-provider 2/3
5/28/24, 2:59 PM sim card - How automatically set an APN depending on network provider? - Stack Overflow
1 when the modem connects to the network. This can be overridden for special cases, for
example if the user needs to use an MNO supplied VPN which requires a special APN.
While I do not know if this is the same for every case, all phones go through an approval
process, and if it is a phone approved by the MNO then it is quite likely the MNO will insist
that at least a default APN is loaded if none has been supplied by the user. The network that
the SIM allows the phone to connect to can be read from the modem without an APN being
supplied, so it is quite easy to use this to look up a default APN from list. As phone companies
really do not want to change their software for each MNO, maintaining a list makes it easier
for the phone manufacturer, the MNO and the end user.
Share Improve this answer Follow answered Oct 13, 2020 at 11:40
andrew g
11 1
https://stackoverflow.com/questions/41898986/how-automatically-set-an-apn-depending-on-network-provider 3/3