关于android各种双卡手机获取imei,imsi的处置(mtk,展讯,高通等)

摘要:
关于安卓系统中各种双卡手机对IMEI的收购,目前国内双卡智能手机对IMSI的处理需求仍然很大,各种复杂的业务将涉及双卡模块;Android标准api不支持双卡。由于该公司的业务需求,有必要为双卡手机获取各自的IMEI和IMSI,因此也进行了一些研究:首先,使用最广泛的mtk平台,国产山寨手机和一些低端品牌的双卡解决方案是由mtk的双卡方案privatestaticvoinitoMtkDoubleSim(){try{TelephonyManagertm=mContext.getSystemService;Class˂?TextUtils.isEmpty)){defaultImsi=imsi1;}}catch{isMtkDoubleSim=false;return;}isMtk2DoubleSim=true;}可以看出,在Telephony Manager中提供了**Gemini方法,它可以通过反射轻松地获得相应的信息。

关于android各种双卡手机获取imei,imsi的处理(mtk,展讯,高通等)

目前国内对于双卡智能手机的需求还是很大的,各种复杂的业务会涉及到双卡模块;而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各种双卡手机获取imei,imsi的处置(mtk,展讯,高通等)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇.Net 调式案例—实验4 高CPU(High CPU)回顾怎么卸载Apache_pn服务PHPnow使用问题下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

NativeCode中通过JNI反射调用Java层的代码,以获取IMEI为例

简单说,就是在NativeCode中做一些正常情况下可以在Java code中做的事儿,比如获取IMEI。 这种做法会使得静态分析Java层代码的方法失效。 JNIEXPORT jstring JNICALL Java_com_xxx_yyy_MainActivity_GetIMEI (JNIEnv* env, jobject mContext){...

打印手机IMEI 条码小工具

做了一个专用打印手机IMEI条码的小工具,有兴趣的朋友可以来联系索取。支持Zebra 105SL条码打印机。 由于需要的人比较多,特上传了一个地址,大家可以自行下载了。 下载 IMEI(International Mobile Equipment Identity)是国际移动设备身份码的缩写,国际移动装备辨识码,是由15位数字组成的"电子串号",它与每台...

iphone 通过获取IMSI判断运营商

IMSI 共有 15 位,其结构如下:   MCC+MNC+MSIN ,( MNC+MSIN=NMSI )   MCC : Mobile Country Code ,移动国家码, MCC 的资源由国际电联( ITU )统一分配和管理,唯一识别移动用户所属的国家,共 3 位,中国为 460;   MNC:Mobile Network Code ,移动网络码,...

高通adsp架构下sensor

一、高通sensor架构: linux驱动由浅入深系列:高通sensor架构实例分析之一(整体概览+AP侧代码分析) linux驱动由浅入深系列:高通sensor架构实例分析之二(adsp驱动代码结构) Linux驱动由浅入深系列:高通sensor架构实例分析之三(adsp上报数据详解、校准流程详解) 另一篇博客: qcom adsp sensor 二、...

【转载】mtk编译命令

mtk编译命令 目录1     目录………………………………………………………………………………22     new ………………………………………………………………………………..33     update……………………………………………………………………………..34     remake…………………………………………………………………………….....

高通CP Crash分析调试

1. 转换tlcore文件 获取 EBICS0.BIN tl2elf --qconly tlcore 2.使用T32 命令把Riva的dump信息从EBICS0文件分离出来 data.load.BINARY EBICS0.BIN 0x80000000  d.SAVE.BINARY wcn0.bin 0x8f000000++0x700000 3. 使用Ul...