如何在Android中获取无线网络控制器(RNC)?
答案 0 :(得分:4)
RNC id是4字节Cell Id的前2个字节(3GPP 25.401,section 6.1.5),如果网络类型是UMTS / HSxPA / HSPA +。
答案 1 :(得分:3)
基于此,请参阅我的代码,如何轻松获得RNCID + CID:
将CID转换为ByteArray:
public static byte[] convertByteArray__p(int p_int){
byte[] l_byte_array = new byte[4];
int MASK_c = 0xFF;
for (short i=0; i<=3; i++){
l_byte_array[i] = (byte) ((p_int >> (8*i)) & MASK_c);
}
return l_byte_array;
}
获取RNCID和CID:
public int getRNCID_or_CID__p(byte[] p_bytes, short p_which){
int MASK_c = 0xFF;
int l_result = 0;
if (p_which == Constants.CID_C) {
l_result = p_bytes[0] & MASK_c ;
l_result = l_result + ((p_bytes[1] & MASK_c ) << 8);
} else if (p_which == Constants.RNCID_C){
l_result = p_bytes[2] & MASK_c ;
l_result = l_result + ((p_bytes[3] & MASK_c ) << 8);
} else {
g_FileHandler.putLog__p('E', "getRNCID_or_CID__p invalid parameter");
}
return l_result;
}
然后你可以像这样轻松打电话:
byte[] l_byte_array = new byte[4];
l_byte_array = convertByteArray__p(l_cid);
int l_RNC_ID = getRNCID_or_CID__p(l_byte_array,Constants.RNCID_C);
int l_real_CID = getRNCID_or_CID__p(l_byte_array,Constants.CID_C);
常量RNCID_C(1)和CID_C(2)只是为了让我分开将通过哪个参数。