2017年6月15日星期四

Android Decode eNB & cell id from ci

TelephonyManager tm = (TelephonyManage) Context.getSystemService(Context.TELEPHONY_SERVICE)
List<CellInfo> mCellInfo = tm.getALLCellInfo();
CellIdentityLte cellid = cellInfo.getCellIdentity();
String cellidHex = DecToHex(cellid.getCi());
String eNBHex = cellidHex.substring(0, cellidHex.length() - 2);
String lcidHex = cellidHex.substring(cellidHex.length() - 2);
int eNB = HexToDec(eNBHex);
int localCellid = exToDec(lcidHex);


// Decimal -> hexadecimal
 public String DecToHex(int dec){
    return String.format("%x", dec);
}

// hex -> decimal
public int HexToDec(String hex){
    return Integer.parseInt(hex, 16);
}

沒有留言:

發佈留言