telephonyManager.getAllCellInfo() 和 subscriptionManager.getActiveSubscriptionInfoList() 都是 returns 不同的 mnc(移动网络代码)

telephonyManager.getAllCellInfo() and subscriptionManager.getActiveSubscriptionInfoList() both returns different mnc (mobile Network code)

我正在尝试获取双 SIM 卡的信号强度,它在大多数手机上都能正常工作,但对于某些手机(相同 android 版本 [11] 但地理位置不同),MNC 代码是什么我们从 subscriptionManager.getActiveSubscriptionInfoList() 收到但 telephonyManager.getAllCellInfo() 不匹配。

我正在通过以下代码获取 getAllCellInfo

 ArrayList<CellInfo> allCellInfo = new ArrayList<>(telephonyManager.getAllCellInfo());

allCellInfo取值如下

allCellInfo Size:6
 CellInfoLte:{mRegistered=YES mTimeStamp=76968972213907ns mCellConnectionStatus=0 CellIdentityLte:{ mCi=483863 mPci=231 mTac=154 mEarfcn=38750 mBands=[] mBandwidth=2147483647 mMcc=405 mMnc=866 mAlphaLong=JIO 4G mAlphaShort=JIO 4G mAdditionalPlmns={} mCsgInfo=null} CellSignalStrengthLte: rssi=2147483647 rsrp=-100 rsrq=-13 rssnr=0 cqi=2147483647 ta=6 level=2 parametersUseForLevel=0 android.telephony.CellConfigLte :{ isEndcAvailable = false }}
 CellInfoLte:{mRegistered=NO mTimeStamp=76968972213907ns mCellConnectionStatus=0 CellIdentityLte:{ mCi=0 mPci=66 mTac=0 mEarfcn=38750 mBands=[] mBandwidth=2147483647 mMcc=null mMnc=null mAlphaLong= mAlphaShort= mAdditionalPlmns={} mCsgInfo=null} CellSignalStrengthLte: rssi=2147483647 rsrp=-100 rsrq=-14 rssnr=0 cqi=0 ta=0 level=2 parametersUseForLevel=0 android.telephony.CellConfigLte :{ isEndcAvailable = false }}
 CellInfoLte:{mRegistered=YES mTimeStamp=76969000601292ns mCellConnectionStatus=0 CellIdentityLte:{ mCi=109569537 mPci=0 mTac=9020 mEarfcn=1250 mBands=[] mBandwidth=2147483647 mMcc=405 mMnc=753 mAlphaLong=Vi India mAlphaShort=Vi India mAdditionalPlmns={} mCsgInfo=null} CellSignalStrengthLte: rssi=-59 rsrp=-111 rsrq=-9 rssnr=-2 cqi=2147483647 ta=0 level=1 parametersUseForLevel=0 android.telephony.CellConfigLte :{ isEndcAvailable = false }}
 CellInfoLte:{mRegistered=NO mTimeStamp=76969000601292ns mCellConnectionStatus=0 CellIdentityLte:{ mCi=0 mPci=67 mTac=0 mEarfcn=1250 mBands=[] mBandwidth=2147483647 mMcc=null mMnc=null mAlphaLong= mAlphaShort= mAdditionalPlmns={} mCsgInfo=null} CellSignalStrengthLte: rssi=2147483647 rsrp=-111 rsrq=-16 rssnr=0 cqi=0 ta=0 level=1 parametersUseForLevel=0 android.telephony.CellConfigLte :{ isEndcAvailable = false }}
 CellInfoLte:{mRegistered=NO mTimeStamp=76969000601292ns mCellConnectionStatus=0 CellIdentityLte:{ mCi=0 mPci=33 mTac=0 mEarfcn=1250 mBands=[] mBandwidth=2147483647 mMcc=null mMnc=null mAlphaLong= mAlphaShort= mAdditionalPlmns={} mCsgInfo=null} CellSignalStrengthLte: rssi=-59 rsrp=-112 rsrq=-11 rssnr=0 cqi=0 ta=0 level=1 parametersUseForLevel=0 android.telephony.CellConfigLte :{ isEndcAvailable = false }}
 CellInfoLte:{mRegistered=NO mTimeStamp=76969000601292ns mCellConnectionStatus=0 CellIdentityLte:{ mCi=0 mPci=403 mTac=0 mEarfcn=1250 mBands=[] mBandwidth=2147483647 mMcc=null mMnc=null mAlphaLong= mAlphaShort= mAdditionalPlmns={} mCsgInfo=null} CellSignalStrengthLte: rssi=-59 rsrp=-117 rsrq=-16 rssnr=0 cqi=0 ta=0 level=0 parametersUseForLevel=0 android.telephony.CellConfigLte :{ isEndcAvailable = false }}

subscriptionManager.getActiveSubscriptionInfoList() 的获取方式如下

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
    subManager = (SubscriptionManager)context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
    activeSubscriptionInfoList = subManager.getActiveSubscriptionInfoList();
}

activeSubscriptionInfoList 值如下

activeSubscriptionInfoList Size:2
 {id=2 iccId= simSlotIndex=0 carrierId=2018 displayName=Jio 4G carrierName=Jio 4G nameSource=0 iconTint=-13408298 number= dataRoaming=1 iconBitmap=android.graphics.Bitmap@58bcc24 mcc=405 mnc=856 countryIso=in isEmbedded=false nativeAccessRules=null cardString= cardId=1 isOpportunistic=false groupUUID=null isGroupDisabled=false profileClass=-1 ehplmns=null hplmns=null subscriptionType=0 groupOwner=null carrierConfigAccessRules=null areUiccApplicationsEnabled=true}
 {id=1 iccId= simSlotIndex=1 carrierId=1963 displayName=Vodafone IN carrierName=Vi India | Vodafone IN nameSource=1 iconTint=-16746133 number= dataRoaming=0 iconBitmap=android.graphics.Bitmap@c91138d mcc=405 mnc=67 countryIso=in isEmbedded=false nativeAccessRules=null cardString= cardId=0 isOpportunistic=false groupUUID=null isGroupDisabled=false profileClass=-1 ehplmns=null hplmns=null subscriptionType=0 groupOwner=null carrierConfigAccessRules=null areUiccApplicationsEnabled=true}

从上面的示例中,您可以看到我的设备中有两张 sim 卡,它们由 activeSubcriptionInfoList 获取,with MNC 856 for simSlot 0MNC 67 for simSlot 1

但是你可以清楚的看到allCellInfo没有MNC 856MNC 67,而是有MNC 866MNC 753

如何解决这个问题?如何将 CellInfo 列表映射到具有不同 MNC 值的 simSlot 0 和 SimSlot 1?

提前致谢..

我通过使用cellinfo的数组索引将其映射到simSlot 0/1解决了,

创建了新列表以仅存储已注册的 Cellinfo

ArrayList<CellInfo> registeredCellinfo = new ArrayList<>();
  for (CellInfo rcinfo : allCellInfo) {
    if (rcinfo.isRegistered()) {
       registeredCellinfo.add(rcinfo);
    }
 }

然后获取 simSlot 0 / simSlot 1 CellInfomation im 返回指定 simSlot 处的 registredCellInfo 元素,(registeredCellInfo 元素是有序的,simSlot 0 信息将在索引 0 中)

 return registeredCellinfo.get(slotIndex);