一般写入的两个IMEI号和一个MEID号,输入*#06#*后显示遗漏一个IMEI号。

override/vendor/mediatek/proprietary/packages/apps/Dialer/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java

handleDeviceIdDisplay在这个方法下

注意是这个判断条件下

if (!ExtensionManager.getDialPadExtension().handleDeviceIdDisplay(

            holder,

            context.getResources().getBoolean(R.bool.show_device_id_in_hex_and_decimal),

            false)) {

注意括号位置!

在这个循环之下for (int slot = 0; slot < telephonyManager.getPhoneCount(); slot++) {

源码有这句String deviceId = telephonyManager.getDeviceId(slot);

这里获取的是一个IMEI号和一个meid号,所以这个方法不可取

注释掉用以下方法获取IMEI

String deviceId = android.os.SystemProperties.get(

                    com.freeme.provider.FreemeSettings.System.FREEME_SIM_GSM_IMEI_ARR[slot]);

然后最后呈现出来在dialog上的如下

if (!TextUtils.isEmpty(deviceId)) {

              addDeviceIdRow(

                  holder,

                  /*/tyd.yantao 20220805 display all IMEI and MEID apart avoid misssing

                  deviceId,

                  //*/

                  "IMEI : " + deviceId,

                  /* showDecimal */

                  context.getResources().getBoolean(R.bool.show_device_id_in_hex_and_decimal),

                  /* showBarcode */ false);

            }

源码只是把那个不可取获得的deviceID显示出来,这边我们另外一个方法就能获取到两个IMEI号,显示出来。接下来同样的把唯一一个MEID显示出来,源码这边是没有的,我们需要在最外面的括号中,就是刚开始说的那个判断之内,继续显示MEID,如下

//这个meid返回的是空的,所以不用这个String meid = android.os.SystemProperties.get(

                  com.freeme.provider.FreemeSettings.System.FREEME_SIM_CDMA_MEID);

     用这个方法获取

String meid = telephonyManager.getMeid(0) ;

            addDeviceIdRow(

                holder,

                "MEID : "+ meid,

                /* showDecimal */

                context.getResources().getBoolean(R.bool.show_device_id_in_hex_and_decimal),

                /* showBarcode */ false);

系统源码调取IMEIframework

里面有两个getDeviceId,调用的是2020行左右

public String getDeviceId(int slotIndex) {

android.util.Log.i("yantao","getDeviceId :2020");

        // FIXME this assumes phoneId == slotIndex

        try {

            IPhoneSubInfo info = getSubscriberInfoService();

            if (info == null)

                return null;

            return info.getDeviceIdForPhone(slotIndex, mContext.getOpPackageName(),

                    mContext.getAttributionTag());

        } catch (RemoteException ex) {

            return null;

        } catch (NullPointerException ex) {

            return null;

        }

    }

获取MEID号是带有参数的方法public String getMeid(int slotIndex),另外一个无参的也可以调用,所以可用//String meid = telephonyManager.getMeid();

就是TelephonyManager.getDefault().getMeid()

TelephonyManager.getDefault().getMeid(0)获取到的是一样的,反正就一个meid

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Youth King

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值