我正在尝试获取双 sims 的信号强度,它在大多数手机上都可以正常工作,但对于某些手机(相同的 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 0
并且MNC 67 for simSlot 1
.
但是您可以清楚地看到 allCellInfo 没有MNC 856
and MNC 67
,而是有MNC 866
andMNC 753
如何解决这个问题?如何将 CellInfo 列表映射到具有不同 MNC 值的 simSlot 0 和 SimSlot 1?
提前致谢..