I want to get the PCI of both primary serving cell and secondary serving cell in 5G NSA, but it seems that I cannot get what I want using getAllCellInfo(). It seems that I need to parse the physical channel configuration as below:
{{mConnectionStatus=PrimaryServing,...,mRat=LTE,...,mPhysicalCellId=123},
{mConnectionStatus=SecondaryServing,...,mRat=NR,...}
Does anyone know how to get the (real-time) configuration? Or can I get the PCIs in another way? Thanks very much!
About PhysicalChannelConfig
The only possible way how to obtain PhysicalChannelConfig is via TelephonyManager.registerTelephonyCallback method. You can for example pass an instance of TelephonyCallback.PhysicalChannelConfigListener and you'll start obtaining what you need.
Please note that permission Manifest.permission.READ_PRECISE_PHONE_STATE is required, so your app needs to be a system app of carrier-privileged app.
There were some attempts to adjust this protection level, current status can be seen here. But as of Android 12 there's no way how to get PhysicalChannelConfig if you are a regular developer.
About PCIs
You can sometimes get PCIs of serving LTE and NR NSA cells via getAllCellInfo() as you mentioned. Sometimes there's one instance of CellInfoNr with PCI is present. This behaviour is device-specific.
Generally speaking - Android does not provide any official API you request.
Related
I am trying to read the Preferred network type setting from the device. But nowhere android API's are available.
Use case:
Trying to read the Preferred network type and connected network type so that if the device has LTE enabled and the user is forcefully switched back to the lower network(3G,2G); then there should be a notification sent to the user.
I have checked the system setting code, But it's deprecated.
Settings.Secure.getString(getApplicationContext().getContentResolver(),
Settings.System.NETWORK_PREFERENCE);
Is there any alternate way to read the system secured settings(By reflection?).
And Also is it possible to write back the setting with the user permission?
Help is much appreciated.
I think the right code is:
Settings.Global.getString(context.getContentResolver(),Settings.Global.NETWORK_PREFERENCE)
I'm developping an app which may send sensitive data and I want to be sure that i don't send them on a public or weak protected network.
That's why I'd like to get the current security used on wifi network on Android.
I found this post but I'm not sure of the accuracy of the solution.
Indeed, the allowedKeyManagement method seems to return the supported protocols, but it's not explicitely said to return the current active protocol beeing used.
Is there a sure way to get the effective protection used on the cirrent wifi network ?
Thanks
I can suggest one method
Get list of all configured network using getConfiguredNetworks API
Loop through all entries and find the current Network using WifiConfiguration.status API. The status should be CURRENT for current network
For that current network, get the allowedKeyManagement and check that it is not NONE.
Could I get MCC & MNC of the other party, either on an incoming or an outgoing call?
I am aware that you can get your own information from the SIM card but I am interested for the information of my contacts.
I guess I must be able to retrieve such information during a phone call.
So two main questions:
Is it allowed from the protocol?
Are there any classes inside Android API that provide such information? (looked up inside TelephonyManager but did not find any)
Like payeli has answered: No, you cannot.
Firstly, because there is no API for accessing the other party's cellular information. Secondly, because Android doesn't actually know. You can delve into the source code of the TelephonyManager, and you'll see that it only contains information about the local telephony provider.
Furthermore, the internal Android class Connection also shows no hint of any such information. (Regardless of the information it contains, it isn't accessible from the API, not even via reflection.)
That being said, there are currently services that provide some insight into phone numbers. Here in the Netherlands, KPN provides an API for looking up caller information, including the current coverage state of the phone, whether it's roaming or not, and other details. I'm not sure if the API is public yet or not, but perhaps there's a similar service available in your region.
No, you can only retrieve the MCC and MNC of your phone, not for third party numbers to which you make or recieve calls.
Reason: Calls target a phone number, not the MCC/MNC of the sending/receiving devices. The MCC / MNC tuple is used to uniquely identify a mobile phone operator/carrier, so if user is using carrierX at present, he will have one value of MCC/MNC, and if user changes mobile carrier/operator but retains same phone number, the the value of MCC/MNC will change but phone-number will still be constant.
So the mapping between phone number of a contact and MCC/MNC of their carrier are not fixed. So:
Could I get MCC & MNC of the other party, either on an incoming or an outgoing call? NO
Android provides the following method to determine the network operator:
http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkOperatorName()
However even the documentation specifically says:
Returns the alphabetic name of current registered operator.
Availability: Only when user is registered to a network. Result may be unreliable on CDMA networks (use getPhoneType() to determine if on a CDMA network).
The problem is that we need a reliable way to detect the carrier so we can identify the traffic source. Has anyone had a similar problem and if so, what is the best solution?
My phone is on Verizon Wireless. On a daily basis, I drive through areas where my phone is roaming and/or has poor reception. Using scripting layer for android, I will log the results of calling getOperatorName() once every ten minutes over the next week.
There is another method that might work in the android.telephony.cdma api. The documentation there is missing the reliability disclaimer. You would only get a Network ID instead of a name. Unfortunately, this requires API level 5 instead of 1 if that matters to you.
Logging the results of the getOperatorName() method yielded nothing special. When I had no service it consistently returned null and when I had service it consistently returned "Verizon Wireless." I'm sure that's not very helpful.
Edit: Addition and correction.
Added - Explanation of link
Corrected - API level 5 not 17
Edit 2: Test results
I am currently looking for a solution for this problem as well. According to this thread one could use CdmaCellLocation.getNetworkId and CdmaCellLocation.getSystemId. Since there are no CDMA networks in Germany, I am unable to check if this works...
You think maybe this was one precurser to Google pulling cdma support? Play within the frameworks or find you another playground is what I hear Google saying. Well that and the fact that carrier apps burned into roms have at times left gaping holes in security.
As to a possible answer to your question... from where are you able to pull info? APN settings might tell you or an assert to a known carrier line in build.prop could pull the info I might need for example. (I do the hobby roms). Then again if you physically inspect a phone, the carrier is usually branded ;) From what vantage are you pulling the info?
Rob
I'm trying (wondering if it's even possible) to write an app, that would change the network selection mode automatically, based on some criteria. E.g. change the network operator from Vodafone to T-Mobile (assuming that the SIM card registration will succeed, but I'm not worried about it atm)
Unfortunately, I can't seem to find any way in the API to do it. Anyone has any idea?
I assume, since it's not in the public APIs, there might still be a way to do it, if the phone is rooted. Is that true? If so, where should I look?
Thanks in advance
Sorry but you can't.
You can have a look into the TelephonyManager .
You can know the current operator: getSimOperator(Name) / getNetworkOperator(Name).
You can also check this thread saying "I learn that for the sake of security there aren't any public APIs to manage this so the only option is to send the user to the system PreferenceScreen within my app."
How about using android.telephony.CarrierConfigManager? I read about it on https://developer.android.com/reference/android/telephony/CarrierConfigManager.html and it seems to allow you to change alot of carrier-specific parameters, although the app must be signed with the certificate that has a matching signature to one on the SIM, so it can usually only be implemented by the carrier issuing the SIM. See also https://source.android.com/devices/tech/config/carrier.
I havent found an actual method to actively switch carrier, but if anywhere, I'd expect it to be there.