2023-01-19 384
我会尝试在C/C ++(使用NDK)中获取设备的imei,并用JNI检索结果.
const char *res = exec_get_out("service call iphonesubinfo 3");
在外壳中工作,但不在我的应用程序中
我在清单中设置了READ_PHONE_STATE权限.这是针对棉花糖Android的目标(我已经在设置中接受了许可)
是否还有其他解决方案可以起作用,或者没有JNI环境不可能?
检查 this
#include <sys/system_properties.h>
//returns the string length of the value.
int ir = __system_property_get("ro.gsm.imei", imei_start);
if(ir > 0)
{
imei_start[15]=0;//strz end
printf("method1 got imei %s len %d\r\n",imei_start,strlen(imei_start));
strcpy(g_imei,imei_start);
}
else
{
printf("method1 imei failed - trying method2\r\n");
//old dumpsys imei getter
char* res = exec_get_out("dumpsys iphonesubinfo");
const char* imei_start_match = "ID = ";
int imei_start_match_len = strlen(imei_start_match);
char* imei_start = strstr(res,imei_start_match);
if(imei_start && strlen(imei_start)>=15+imei_start_match_len)
{
imei_start += imei_start_match_len;
imei_start[15] = 0;
printf("method2 IMEI [%s] len %d\r\n",imei_start,strlen(imei_start));
strcpy(g_imei,imei_start);
}
}
以上所述是小编给大家介绍的android在cc/c ++中获取NDK/JNI的IMEI,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!
原文链接:https://77isp.com/post/25880.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态