【问题标题】:telephonyManager.getAllCellInfo() and subscriptionManager.getActiveSubscriptionInfoList() both returns different mnc (mobile Network code)telephonyManager.getAllCellInfo() 和 subscriptionManager.getActiveSubscriptionInfoList() 都返回不同的 mnc(移动网络代码)
【发布时间】:2021-12-30 13:29:03
【问题描述】:

我正在尝试获取双 sims 的信号强度,它在大多数手机上都可以正常工作,但对于某些手机(相同的 android 版本 [11] 但地理位置不同)我们从subscriptionManager.getActiveSubscriptionInfoList() 收到的 MNC 代码和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 ?

提前致谢..

【问题讨论】:

    标签: java android telephonymanager cellinfo android-subscriptionmanager


    【解决方案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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-27
      • 2011-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多