android运营商相关信息获取代码收集
Posted 事在人为,幸福从不抱怨开始!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android运营商相关信息获取代码收集相关的知识,希望对你有一定的参考价值。
1,手机卡运营商获取:
private String getSimOperator(Context context)
String opeName = "";
TelephonyManager teleManager= (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String opeNum = teleManager.getSimOperator();
if ("46001".equals(opeNum ) || "46006".equals(opeNum ) || "46009".equals(opeNum ))
opeType = "中国联通";
else if ("46000".equals(opeNum ) || "46002".equals(opeNum ) || "46004".equals(opeNum ) || "46007".equals(operator))
opeType = "中国移动";
else if ("46003".equals(opeNum ) || "46005".equals(opeNum ) || "46011".equals(opeNum ))
opeType = "中国电信";
return opeType;
2,获取移动网络类型
private int getNetType()
TelephonyManager manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
switch (manager.getNetworkType())
case TelephonyManager.NETWORK_TYPE_GPRS:
case TelephonyManager.NETWORK_TYPE_CDMA:
case TelephonyManager.NETWORK_TYPE_GSM:
case TelephonyManager.NETWORK_TYPE_EDGE:
case TelephonyManager.NETWORK_TYPE_1xRTT:
case TelephonyManager.NETWORK_TYPE_IDEN:
return 2; // 2G网络
case TelephonyManager.NETWORK_TYPE_EVDO_A:
case TelephonyManager.NETWORK_TYPE_UMTS:
case TelephonyManager.NETWORK_TYPE_EVDO_0:
case TelephonyManager.NETWORK_TYPE_HSDPA:
case TelephonyManager.NETWORK_TYPE_HSUPA:
case TelephonyManager.NETWORK_TYPE_HSPA:
case TelephonyManager.NETWORK_TYPE_EVDO_B:
case TelephonyManager.NETWORK_TYPE_EHRPD:
case TelephonyManager.NETWORK_TYPE_HSPAP:
case TelephonyManager.NETWORK_TYPE_TD_SCDMA:
return 3; // 3G网络
case TelephonyManager.NETWORK_TYPE_LTE:
case TelephonyManager.NETWORK_TYPE_IWLAN:
return 4; // 4G网络
case TelephonyManager.NETWORK_TYPE_NR:
return 5;//5G网络
default:
return 0;
3,双卡网络判断及处理
https://www.jianshu.com/p/fbaf08eb59d7
4,信号参数获取
private class SimListener extends PhoneStateListener
@Override
public void onDataConnectionStateChanged(int state)
super.onDataConnectionStateChanged(state);
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength)
super.onSignalStrengthsChanged(signalStrength);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
List<CellSignalStrength> strengths = signalStrength.getCellSignalStrengths();
if (null != strengths && strengths.size() > 0)
CellSignalStrength strength = strengths.get(0);
if (strength instanceof CellSignalStrengthLte)
CellSignalStrengthLte lte = (CellSignalStrengthLte) strength;
int rsrp = lte.getRsrp();
int rsrq = lte.getRsrq();
int sinr = lte.getRssnr();
else if (strength instanceof CellSignalStrengthCdma)
CellSignalStrengthCdma wcdma = (CellSignalStrengthCdma) strength;
int rscp = wcdma.getDbm();
int ecio =wcdma.getCdmaEcio();
else
try
Integer rsrp = (Integer) signalStrength.getClass().getMethod("getLteRsrp").invoke(signalStrength);
Integer rsrq = (Integer) signalStrength.getClass().getMethod("getLteRsrq").invoke(signalStrength);
Integer sinr = (Integer) signalStrength.getClass().getMethod("getLteRssnr").invoke(signalStrength);
Integer ecio = (Integer) signalStrength.getClass().getMethod("getCdmaEcio").invoke(signalStrength) / 10;
Integer rscp =signalStrength.getClass().getMethod("getWcdmaRscp").invoke(signalStrength);
catch (Exception e)
@Override
public void onCellInfoChanged(List<CellInfo> cellInfo)
super.onCellInfoChanged(cellInfo);
以上是关于android运营商相关信息获取代码收集的主要内容,如果未能解决你的问题,请参考以下文章
微信小程序涉嫌通过中断用户体验限制用户操作的方式,收集与服务无关的用户个人信息,包括但不限于,手机号