我在发布这个问题之前非常搜索。我正在LTE network
上进行Android Studio
监控和驾驶测试。
我找到了一种使用类RSRP
中的方法Asu Level
和LTE network
衡量getCellSignalStrength()
,getCellIdentity()
和其他CellInfo
测量的方法。但是,I am still searching for a manner to determine or calculate RSRQ, CQI, SINR, SNR, HO total attempts and HO successful attempts
。
如果有人能给我答案,我将不胜感激!
这就是我的尝试:
//start the signal strength listener
signalStrengthListener = new SignalStrengthListener();
((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).listen(signalStrengthListener, SignalStrengthListener.LISTEN_SIGNAL_STRENGTHS);
tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
try {
cellInfoList = tm.getAllCellInfo();
} catch (Exception e) {
Log.d("SignalStrength", "+++++++++++++++++++++++++++++++++++++++++ null array spot 1: " + e);
}
try {
for (CellInfo cellInfo : cellInfoList) {
if (cellInfo instanceof CellInfoLte) {
// gets RSRP cell signal strength:
cellSig = ((CellInfoLte) cellInfo).getCellSignalStrength().getDbm();
// Gets the LTE cell indentity: (returns 28-bit Cell Identity, Integer.MAX_VALUE if unknown)
cellID = ((CellInfoLte) cellInfo).getCellIdentity().getCi();
// Gets the LTE MCC: (returns 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown)
cellMcc = ((CellInfoLte) cellInfo).getCellIdentity().getMcc();
// Gets theLTE MNC: (returns 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown)
cellMnc = ((CellInfoLte) cellInfo).getCellIdentity().getMnc();
// Gets the LTE PCI: (returns Physical Cell Id 0..503, Integer.MAX_VALUE if unknown)
cellPci = ((CellInfoLte) cellInfo).getCellIdentity().getPci();
// Gets the LTE TAC: (returns 16-bit Tracking Area Code, Integer.MAX_VALUE if unknown)
cellTac = ((CellInfoLte) cellInfo).getCellIdentity().getTac();
}
}
} catch (Exception e) {
Log.d("SignalStrength", "++++++++++++++++++++++ null array spot 2: " + e);
}
}
@Override
protected void onPause() {
super.onPause();
try{
if(signalStrengthListener != null){tm.listen(signalStrengthListener, SignalStrengthListener.LISTEN_NONE);}
}catch(Exception e){
e.printStackTrace();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
try{
if(signalStrengthListener != null){tm.listen(signalStrengthListener, SignalStrengthListener.LISTEN_NONE);}
}catch(Exception e){
e.printStackTrace();
}
}
private class SignalStrengthListener extends PhoneStateListener{
@Override
public void onSignalStrengthsChanged(android.telephony.SignalStrength signalStrength) {
((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).listen(signalStrengthListener, SignalStrengthListener.LISTEN_SIGNAL_STRENGTHS);
tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
/*
int a = tm.getNetworkType();
CellLocation cl = tm.getCellLocation();
String did = tm.getDeviceId();
String sv = tm.getDeviceSoftwareVersion();
String netOp = tm.getNetworkOperatorName();
*/
String ltestr = signalStrength.toString();
String[] parts = ltestr.split(" ");
String cellSig2 = parts[9];
try {
cellInfoList = tm.getAllCellInfo();
for (CellInfo cellInfo : cellInfoList) {
if (cellInfo instanceof CellInfoLte) {
// cast to CellInfoLte and call all the CellInfoLte methods you need
// gets RSRP cell signal strength:
cellSig = ((CellInfoLte) cellInfo).getCellSignalStrength().getDbm();
// Gets the LTE cell identity: (returns 28-bit Cell Identity, Integer.MAX_VALUE if unknown)
cellID = ((CellInfoLte) cellInfo).getCellIdentity().getCi();
// Gets the LTE MCC: (returns 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown)
cellMcc = ((CellInfoLte) cellInfo).getCellIdentity().getMcc();
// Gets theLTE MNC: (returns 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown)
cellMnc = ((CellInfoLte) cellInfo).getCellIdentity().getMnc();
// Gets the LTE PCI: (returns Physical Cell Id 0..503, Integer.MAX_VALUE if unknown)
cellPci = ((CellInfoLte) cellInfo).getCellIdentity().getPci();
// Gets the LTE TAC: (returns 16-bit Tracking Area Code, Integer.MAX_VALUE if unknown)
cellTac = ((CellInfoLte) cellInfo).getCellIdentity().getTac();
}
}
} catch (Exception e) {
Log.d("SignalStrength", "+++++++++++++++++++++++++++++++ null array spot 3: " + e);
}
signalStrengthTextView.setText(String.valueOf(cellSig));
signalStrengthTextView2.setText(String.valueOf(cellSig2));
cellIDTextView.setText(String.valueOf(cellID));
cellMccTextView.setText(String.valueOf(cellMcc));
cellMncTextView.setText(String.valueOf(cellMnc));
cellPciTextView.setText(String.valueOf(cellPci));
cellTacTextView.setText(String.valueOf(cellTac));
super.onSignalStrengthsChanged(signalStrength);
}
}