Android 双SIM卡中的getAllCellInfo
有人知道从Android 双SIM卡中的getAllCellInfo,android,telephony,telephonymanager,cellinfo,Android,Telephony,Telephonymanager,Cellinfo,有人知道从TelephonyManager.getAllCellInfo()返回的列表上的单元格索引是否与SIM卡插槽号相关吗 我正在使用Android API 24… 经过一点实验后,运行方法updateCellInfo -如下所述-始终返回一个列表,其中第一个索引对应于设备的最后一个SIM卡插槽,最后一个索引对应于设备的第一个SIM卡插槽。 有人能证实这一点吗?这种相关性可信吗 private ArrayList<CellInfo> updateCellInfo(ArrayLis
TelephonyManager.getAllCellInfo()
返回的列表上的单元格索引是否与SIM卡插槽号相关吗
我正在使用Android API 24…
经过一点实验后,运行方法updateCellInfo
-如下所述-始终返回一个列表,其中第一个索引对应于设备的最后一个SIM卡插槽,最后一个索引对应于设备的第一个SIM卡插槽。
有人能证实这一点吗?这种相关性可信吗
private ArrayList<CellInfo> updateCellInfo(ArrayList<CellInfo> cellInfo)
{
//Create new ArrayList
ArrayList<CellInfo> cellInfos= new ArrayList<>();
//cellInfo is obtained from telephonyManager.getAllCellInfo()
if(cellInfo.size()!=0)
{
for (int i = 0; i < cellInfo.size(); i++)
{
//Return registered cells only
int index=0;
CellInfo temp=cellInfo.get(i);
if (temp.isRegistered())
{
cellInfos.add(index, temp);
index++;
}
}
}
return cellInfos;
}
private ArrayList updateCellInfo(ArrayList cellInfo)
{
//创建新的ArrayList
ArrayList cellInfos=新的ArrayList();
//cellInfo是从telephonyManager.getAllCellInfo()获得的
如果(cellInfo.size()!=0)
{
对于(int i=0;i
与SIM卡插槽号无关,它们会获取所有手机的手机信息
@Override
public List<CellInfo> getAllCellInfo(String callingPackage) {
if (!LocationAccessPolicy.canAccessCellLocation(mPhone.getContext(),
callingPackage, Binder.getCallingUid(), "getAllCellInfo")) {
return null;
}
if (DBG_LOC) log("getAllCellInfo: is active user");
WorkSource workSource = getWorkSource(null, Binder.getCallingUid());
List<CellInfo> cellInfos = new ArrayList<CellInfo>();
for (Phone phone : PhoneFactory.getPhones()) {
final List<CellInfo> info = phone.getAllCellInfo(workSource);
if (info != null) cellInfos.addAll(info);
}
return cellInfos;
}
@覆盖
公共列表getAllCellInfo(字符串调用包){
如果(!LocationAccessPolicy.canAccessCellLocation(mPhone.getContext()),则,
callingPackage,Binder.getCallingUid(),“getAllCellInfo”)){
返回null;
}
if(DBG_LOC)日志(“getAllCellInfo:是活动用户”);
WorkSource WorkSource=getWorkSource(null,Binder.getCallingUid());
List cellInfos=new ArrayList();
用于(电话:PhoneFactory.getPhones()){
最终列表信息=phone.getAllCellInfo(工作源);
如果(info!=null)cellInfos.addAll(info);
}
返回cellInfos;
}
只需为其他有相同问题的人添加此答案。
将CellInfo连接到SlotId的正确方法是收集包含SlotIndex信息的活动订阅列表(),并将其MNC代码与CellInfo MNC代码交叉引用。
如果您查看代码,可能会更容易
private CellInfo getSlotCellInfo(int slotIndex){
ArrayList<CellInfo> allCellInfo = new ArrayList<>(telephonyManager.getAllCellInfo());
SubscriptionManager subscriptionManager = SubscriptionManager.from(getActivity());
List<SubscriptionInfo> activeSubscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();
SubscriptionInfo subscriptionInfo;
for (int i = 0; i < activeSubscriptionInfoList.size(); i++) {
SubscriptionInfo temp = activeSubscriptionInfoList.get(i);
if (temp.getSimSlotIndex() == slotIndex) {
subscriptionInfo=temp;
break;
}
}
for (int index = 0; index < allCellInfo.size(); index++) {
int mnc = 0;
CellInfo temp = allCellInfo.get(index);
String cellType = checkCellType(temp);
if (cellType == "GSM") {
CellIdentityGsm identity = (((CellInfoGsm) temp).getCellIdentity());
mnc = identity.getMnc();
} else if (cellType == "WCDMA") {
CellIdentityWcdma identity = (((CellInfoWcdma) temp).getCellIdentity());
mnc = identity.getMnc();
} else if (cellType == "LTE") {
CellIdentityLte identity = (((CellInfoLte) temp).getCellIdentity());
mnc = identity.getMnc();
}
if (mnc == subscriptionInfo.getMnc()) {
return temp;
}
}
}
private CellInfo getSlotCellInfo(int-slotIndex){
ArrayList allCellInfo=新的ArrayList(telephonyManager.getAllCellInfo());
SubscriptionManager SubscriptionManager=SubscriptionManager.from(getActivity());
List activeSubscriptionInfoList=subscriptionManager.getActiveSubscriptionInfoList();
订阅信息订阅信息;
对于(int i=0;i
请解释您的代码行,以便其他用户了解其功能。谢谢这是TelephonyManager.getCellInfo()的实现,在这个方法中,所有手机都将获得自己的AllCellInfo,因此TelephonyManager.getCellInfo()与SIM卡插槽号无关,它们会获得所有手机的手机信息。有没有办法将此信息连接到slotId?非常感谢。