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)
Related
I am looking to read all incomming calls from the calllog and listing them in my app, but I am unable to get SIM info.
I tried using Calllog.calls.PHONE_ACCOUNT_ID, but that seems to work for only single sim devices and not dual-sim.
I see theirs a property Calllog.calls.VIA_NUMBER, but that's only available for API >=24. but I need to support from API 16(Jelly Bean).
Its just a call log program, so I don't need to palace any calls/messages.
Guys I want to know if there are both the sims available and active in android dual sim phones irrespective of the device OS. I have already checked for few links that gives the result if the device is dual sim or not. But what I want to know is if there are two sim's installed in an android device. Please help me with a code snipnnet
Before API 22 you cannot detect if both the sims are present or not, though you can only check for single sim presence with TelephonyManager class in Android check more on DOCS and here is code snippet as well from similar answered SO question
From Android API 22
getActiveSubscriptionInfoList will get the SubscriptionInfo(s) of the currently inserted SIM(s). The records will be sorted by getSimSlotIndex() then by getSubscriptionId(). as mentioned on Android Docs
Since api 22 there is getActiveSubscriptionInfoList() method you can call.
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.
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.
I wanted to disable features related to CALL and SMS in my application based on whether SIM hardware is present or not. Now a beginners approach towards this will be checking the Phone type using :
if (telephonyManager1.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE)
If true then its supported.
Everything was fine until i came across Sony Tablet S which has a SIM support only for Data and Messaging. No voice support. So for this device i need to disable only CALL feature but continue with SMS support.
Sony tablet returns TelephonyManager.PHONE_TYPE_NONE so i can`t use the above methods.
Also ,
telephonyManager1.getSimState();
returns 1 i.e SIM_STATE_ABSENT which is also same in case of HTC FLYER which has no support for SIM hardware itself.
So is there any way in which i can come to know if SIM hardware is there(irrespective of SIM card inserted or not) ?
Use
PackageManager pm = this.getPackageManager();
boolean hasTelephony=pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
Edit:
Try using
TelephonyManager.getLine1Number()
If this returns null then you wont have telephony feature. Have not tried. give it a shot