before Android 5.0, although there are mobile phones are dual-sim phones, but the dual-SIM program are ODM manufacturers themselves, or the chip manufacturers provide the source code to complete. Therefore, it is not always a huge project to get dual-sim information on a phone that is 4.4 or earlier. Although we have previously tried to use the reflection method to obtain
- Qualcomm's " Android.telephony.MSimTelephonyManager "Class
- MTK's " Com.mediatek.common.telephony. Itelephonyex.aidl "class,
print out the function of the method and parameters and class properties, and then to guess, but because the source can not read directly, and ODM manufacturers will also modify the corresponding code to implement other user itch point function (main card 3/4g network, secondary card traffic) and so on. So before the lollipop, the dual sim problem was temporarily abandoned. But there are ways to do other function calls. For example, create the following folder under your own project
Put the itelephony.aidl in, and then through the reflection TelephonymanagerGetitelephony() method to obtain the Itelephony instance, and then call the method such as Endcall () to implement if the call blacklist interception and other waysEg: after Android 5.0, Google's official API began to support multi-SIM cards, which is a good thing for developers, meaning that the application can achieve more and more functions. On the lollipop Google has added a isub.aidl file, from the name can be seen that this is a process service, so in the use of the same as Itelephony.adil, in their own projects to establish the corresponding Adil folder, the Isub.aidl pull in the line. It is invoked as follows:
For example, suppose now is a dual sim phone system is lollipop, we want to know which card is now used as a traffic card, so long must know the default traffic subid. The specific method is to call the Isub.aidlgetdefaultdatasubid ().
After the corresponding traffic card subid, you need to call theTelephonymanager under the Getsubscriberid (Long SubId) method, but this method is a bit of a pit place, It is in the 5.0 when the parameter of the long type, but to 5.1 of the time has been replaced by the int type, so in use must pay attention toSpecific use
By introducing the system's aidl, other methods can be called to show more functionality. In 6.0, Google further opened the SIM-related API we can useSubscriptionManager This APIThis use of the management class is simpler, similar to Telephonymanager. Get instance: Get the default data card information: Get the number of activated SIM cards:
, since you can get the SIM card information, there is an important thing to get, is how to listen to two SIM signal strength information and corresponding base station neighborhood information. Before 5.0 this was impossible, because before 5.0,Phonestatelistener This method has only one constructor without parameters, so it is not possible to register for monitoring, but the version after 5.0 has
But a big @hide will isolate you from the possibility of listening. And even the parameter protected also added @hide is obviously not open to ordinary developers.
However, we all know that reflection is a parameter that can be obtained to a class, and of course you can set the parameter value. The specific setting method, in the inheritanceimplementing constructors when Phonestatelistener
And the listener is set in the constructor.
Android uses reflex and aidl to obtain SIM card related information and register monitoring