目前国内对于双卡智能手机的需求还是很大的,各种复杂的业务会涉及到双卡模块;而android标准的api又不提供对双卡的支持。导致国内双卡模块标准混乱,各个厂商各玩各的。目前我知道的双卡解决方案就有:mtk,展讯,高通,broadcom等。
由于公司业务需要,必须要对双卡手机获取各自的imei,imsi,所以也做了一些研究:
首先是最为应用广泛的mtk平台,国内山寨手机以及一些低端品牌双卡都是做的mtk的双卡解决方案
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); phoneType_1 = (Integer) mx.invoke(tm, simId_1); phoneType_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; }
可见,在TelephonyManager中提供了**Gemini的方法,可以用反射很方便地获取到相应的信息。
还有
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(); phoneType_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; }
看样子有似乎也是属于mtk平台的解决方案,因为都有GEMINI_SIM_1属性,这种双卡方案只在联想278t上发现过;有两个TelephonyManager实例,根据getDefault方法获取
下面是展讯平台的(貌似市面上手机不多啊):
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(); phoneType_1 = tm.getPhoneType(); TelephonyManager tm1 = (TelephonyManager) mContext.getSystemService(spreadTmService); imsi_2 = tm1.getSubscriberId(); imei_2 = tm1.getDeviceId(); phoneType_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; }
这个没有展讯sdk的话还是很难找的吧?
下面是高通的:(貌似高通做的不咋的有些接口没有双卡实现啊)
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) { isQualcommDoubleSim = false; return; } isQualcommDoubleSim = true; }
getPhoneType&getDataState 方法看了底层发现没有双卡实现,目前也不知道该咋办...
未完待续....
相关推荐
Android 读取IMSI 和IMEI号支持双卡双待,可以判断双卡双待通过那个卡上网,及读取双卡双待的电话卡的信息
android 显示手机号码,手机imei imsi 手机设备号,android 显示手机号码,手机imei imsi 手机设备号
简单的DEMO 用于查看Android手机的IMEI IMSI
双卡双待手机, 获取IMSI 使用了反射,兼容mtk展讯高通不同的芯片 一般手机都能够获取成功 没有高通手机,所以高通的没有亲测 谁测通了评论中回复一下哦
android平台获取手机IMSI,IMEI ,序列号,和 手机号的方法
双卡手机获取IMSI,兼容多款手机芯片 联发科、高通等多款cpu手机 尤其是各种中国神机
[android平台][获取手机IMSI、IMEI、序列号及手机号的用法]
VC++编写的手机设备信息读取,包括IMEI IMSI 设备ID
c#获取mobile手机的IMEI和IMSI!
android 获取手机上面的IMSI序列号、IMEI、MAC地址、IP地址、当前时间、当前经纬度、获取网络类型
Windows Mobile和Android获得IMEI、MEID和IMSI demo Windows Mobile是从别处拿来的, sim5.rar是IMEI、MEID和IMSI demo CallGetDeviceUniqueId是获取window mobile系统UID的另一个方式 Android很浅显,一起共享吧
IMSI获取 安卓手机IMSI 和IMEI获取,安装后打开即可看到
不同手机设备获取IMSI 不同手机设备获取IMSI 不同手机设备获取IMSI 不同手机设备获取IMSI 不同手机设备获取IMSI 不同手机设备获取IMSI
WIndow mobile 6.0 以上 获取IMSI和IMEI.rar
基于Android10.0的设备上,获取相应的MAC地址,手机IMEI号,手机号,手机MSISDN号,手机ICCID号,进行可行性验证,特别是MAC地址方面,在Android10.0前后的设备均进行相应的接口验证,保证其可用性。适合正在致力于...
获取手机IMEI号,sim卡的IMSI号,手机型号等 C#源码
绝对不是网络上搜索的那种获取IMEI的方式,100%原创 C++语言
IMSI国际移动用户识别码(IMSI) international mobile subscriber identity 国际上为唯一识别一个移动用户所分配的号码。从技术上讲,IMSI可以彻底解决国际漫游问题。但是由于北美目前仍有大量的AMPS系统使用MIN...
imsi和imei Windows Mobile平台获取 通过TPAI获取手机的imsi 以及imei号
获取android手机硬件信息,如通讯录,手机版本,系统版本,SDK版本,所有安装包,本机号码,设备ID,IMEI,IMSI,GPS 地理位置定位