Check SIMCards's PIN - android

So I've research this subject and I didn't get much information, even though I did read a few threads here like Check SIM PIN with SDK Android and Ask user for SIM Card PIN but neither of them really answer the question - the app I'm trying to write is based on USSD and will run on devices with SIMCards.
I also read the thread Use system PIN dialog in Android application, but I'm not trying to overwrite the OS, I'm just trying to write a simple app that can check an entered String against the SIMCard PIN. On this last thread, a user (a.ch.) said that trying to access or even check the SIMCard PIN number is not allowed by the OS (at least without modifications, I suppose). Can you guys confirm or give me a link that mentions this prohibition?
Also, is it possible to, using only USSD, check the PIN? For example, I only know the MMI code to change PIN:
**04*Current PIN * New PIN * New PIN#.
And this actually returns fail or sucess messages, and if I make Current PIN = New PIN, I can actually identify if the PIN I introduced is correct or not, but I see this on a text message. Does the smartphone return this info in a attribute that I can check? How can I access the return code?
I need all the help I can get :)

Related

How to get the physical channel configuration of the cellphone via programming

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.

Read Preferred Network Type Setting

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)

Android - set pin for Bluetooth

I have been reading the Bluetooth documentation on Android's developer site.
I want to pair a Bluetooth device and then connect to it, but I don't want the request dialog to pop up (or even if it does set the pin using some API to dismiss it). I want to do it in Android 4.3+.
So far I see this involving the following steps:
1) App discovers device : use BroadcastReceiver to get BluetoothDevice
2) App pairs the device : uses BluetoothDevice.createBond(), and registers a BroadcastReceiver to get confirmation of pairing completion
3) App connects to device : uses BluetoothDevice.createRfCommSocketToServiceRecord(UUID)
My understanding is that the pop dialog for pairing will be shown to the user after step 2.
I know there is a setPin() API (now public) in the BluetoothDevice class.
If I call it right after step 2, will the dialog still appear and wait for user input, or will it appear and then dismiss, resulting in pairing success ?
Also does step 3 involve any input from the user ?
Step 3 doesn't involve user input.
I've been trying to do exactly the same, I use setPin() and it works, but the user Input dialogue is still there, there is an option to use cancelPairingUserInput but i'm not sure if this is still valid for API19 (that is the one which uses setPin() as far as I know...) or if there is another way to do it.
Hope this helps...

How to Get android WIFI security name (WPA/WPA2/PSK)

i have create custom WiFi setting UI in android application but i am struggle to get security name like (WPA/WPA2/PSK) i.e when user click on the WiFi list item so it display network information like Status , signal strength etc. all information accessed except Security.
i have tried WIFi configuration , manager but i am not able to get exact security name please help me how to get this thing
i am attach screen shot for more understanding.

Change network selection mode programmatically

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.

Categories

Resources