About Android Various dual sim phones get imei,imsi processing (MTK, Spreadtrum, Qualcomm, etc.)
At present domestic demand for dual-sim smartphones is still very large, a variety of complex business will involve the dual-SIM module, and the Android standard API does not provide support for dual sim. leading to domestic dual-SIM module standard confusion, the various manufacturers play each. At present, I know the dual-SIM solution is: MTK, Spreadtrum, Qualcomm, Broadcom and so on.
Due to the company's business needs, it is necessary to obtain their own imei,imsi for dual sim phones, so some research has also been done:
The first is the most widely used MTK platform, domestic cottage phone and some low-end brand dual sim are doing MTK dual-SIM Solution
private static void Initmtkdoublesim () {try {Telephonymanager TM = (Telephonymanager) mcontext.getsystemservice ( Context.telephony_service); class<?> C = class.forname ("Com.android.internal.telephony.Phone"); Field fields1 = C.getfield ("gemini_sim_1"); Fields1.setaccessible (true); simid_1 = (Integer) fields1.get (null); Field fields2 = C.getfield ("gemini_sim_2"); Fields2.setaccessible (true); simid_2 = (Integer) fields2.get (null); Method m = TelephonyManager.class.getDeclaredMethod ("Getsubscriberidgemini", int.class); imsi_1 = (String) M.invoke (tm , simid_1); imsi_2 = (String) M.invoke (tm, Simid_2); Method m1 = TelephonyManager.class.getDeclaredMethod ("Getdeviceidgemini", int.class); imei_1 = (String) M1.invoke (TM, simid_1); imei_2 = (String) M1.invoke (tm, Simid_2); Method mx = TelephonyManager.class.getDeclaredMethod ("Getphonetypegemini", int.class);p honetype_1 = (Integer) Mx.invoke (tm, simid_1);p honetype_2 = (Integer) Mx.invoke (tm, Simid_2), if (Textutils.isempty (imsi_1) && (! Textutils.isEmpty (imsi_2))) {Defaultimsi = imsi_2;} if (Textutils.isempty (imsi_2) && (! Textutils.isempty (imsi_1)) {defaultimsi = imsi_1;}} catch (Exception e) {ismtkdoublesim = False;return;} Ismtkdoublesim = true;}
It can be seen that the method of **gemini is provided in Telephonymanager, and it is easy to get the corresponding information by reflection.
And also
private static void Initmtkseconddoublesim () {try {Telephonymanager TM = (Telephonymanager) mcontext.getsystemservice ( Context.telephony_service); class<?> C = class.forname ("Com.android.internal.telephony.Phone"); Field fields1 = C.getfield ("gemini_sim_1"); Fields1.setaccessible (true); simid_1 = (Integer) fields1.get (null); Field fields2 = C.getfield ("gemini_sim_2"); Fields2.setaccessible (true); simid_2 = (Integer) fields2.get (null); Method mx = TelephonyManager.class.getMethod ("Getdefault", Int.class); Telephonymanager TM1 = (telephonymanager) Mx.invoke (tm, Simid_1); Telephonymanager tm2 = (telephonymanager) Mx.invoke (tm, simid_2); imsi_1 = Tm1.getsubscriberid (); imsi_2 = Tm2.getsubscriberid (); imei_1 = Tm1.getdeviceid (); imei_2 = Tm2.getdeviceid ();p honetype_1 = Tm1.getphonetype (); phonetype_2 = Tm2.getphonetype (); if (Textutils.isempty (imsi_1) && (! Textutils.isempty (imsi_2)) {defaultimsi = imsi_2;} if (Textutils.isempty (imsi_2) && (! Textutils.isempty (imsi_1))) {Defaultimsi = IMSI_1;}} catch (Exception e) {ismtkseconddoublesim = False;return;} Ismtkseconddoublesim = true;}
It seems that there is also a solution to the MTK platform, because there are gemini_sim_1 properties, this dual-card scheme is only found on the Lenovo 278t, there are two Telephonymanager instances, according to Getdefault method to obtain
The following is the Spreadtrum platform (seemingly not many mobile phones on the market AH):
private static void Initspreaddoublesim () {try {class<?> c = Class.forName (" Com.android.internal.telephony.PhoneFactory "); Method m = C.getmethod ("Getservicename", String.class, int.class); spreadtmservice = (String) M.invoke (c, Context.telephony_service, 1); Telephonymanager TM = (Telephonymanager) mcontext.getsystemservice (context.telephony_service); imsi_1 = Tm.getsubscriberid (); imei_1 = Tm.getdeviceid ();p honetype_1 = Tm.getphonetype (); Telephonymanager TM1 = (telephonymanager) mcontext.getsystemservice (spreadtmservice); imsi_2 = Tm1.getSubscriberId (); Imei_2 = Tm1.getdeviceid ();p honetype_2 = Tm1.getphonetype (); if (Textutils.isempty (imsi_1) && (! Textutils.isempty (imsi_2)) {defaultimsi = imsi_2;} if (Textutils.isempty (imsi_2) && (! Textutils.isempty (imsi_1)) {defaultimsi = imsi_1;}} catch (Exception e) {isspreaddoublesim = False;return;} Isspreaddoublesim = true;}
Is it still hard to find this without the Spreadtrum SDK?
The following is Qualcomm: (looks like Qualcomm did not do some of the interface is not dual-card implementation AH)
public static void Initqualcommdoublesim () {try {Telephonymanager TM = (Telephonymanager) mcontext.getsystemservice ( Context.telephony_service); class<?> cx = class.forname ("Android.telephony.MSimTelephonyManager"), Object obj =mcontext.getsystemservice (" Phone_msim "); simid_1 = 0;simid_2 = 1; Method mx = cx.getmethod ("getdatastate");//int stateimei_1 = (Integer) mx.invoke (Cx.newinstance ()); int stateimei_2 = TM. Getdatastate (); Method MDE = Cx.getmethod ("Getdefault"); Method MD = Cx.getmethod ("Getdeviceid", Int.class); Method ms = Cx.getmethod ("Getsubscriberid", Int.class); Method MP = Cx.getmethod ("Getphonetype"); Object obj = Mde.invoke (CX); Imei_1 = (string) md.invoke (obj, simid_1); imei_2 = (string) md.invoke (obj, simid_2); Imsi_1 = (string) ms.invoke (obj, simid_1); imsi_2 = (string) ms.invoke (obj, simid_2); int statephonetype_1 = Tm.getdatastate (); int statephonetype_2 = (Integer) mx.invoke (obj); LOG.E ("tag", Statephonetype_1 + "---" + statephonetype_2); class<?> msc = Class.forname ("Android.telephony.MSimSmsManager");//For (Method m:msc.getmethods ()) {//if (M.getname (). Equals (" Sendtextmessage ")) {//M.getparametertypes ();//}//LOG.E (" tag ", M.getname ());/}} catch (Exception e) {Isqualcommdoubl ESim = False;return;} Isqualcommdoublesim = true; }
Getphonetype&getdatastate method to see the bottom of the discovery is not a dual-SIM implementation, currently do not know what to do ...
Not to be continued ....