Android中的3G邻居小区的cellID和LAC / PSC

时间:2012-03-14 12:15:33

标签: android location 3g cellid

我正在尝试使用Android识别3G中的相邻小区位置,这是我使用getNeighboringCellInfo()获得的。当手机在GSM模式下工作时,我可以使用getCid()和getLac()来获取CellID和LAC,但对于3G,我只能使用getPsc(),我不太确定它是否足够识别一个细胞。

有人可以告诉我,我是否可以获得相邻细胞的CellID + LAC?如果那是不可能的,我如何使用PSC代码来识别一个单元?

3 个答案:

答案 0 :(得分:4)

在UMTS中,PSC是一种本地小区标识符。这是"本地"因为所有相邻小区以及这些小区的所有邻居都保证具有与当前小区不同的PSC。这也意味着您将不会遇到具有相同PSC的两个相邻单元。但是,可能存在具有相同PSC的细胞位于该国的不同地区。

UMTS小区的NeighboringCellInfo将仅设置PSC,而所有其他字段(MCC,MNC,LAC,CID)将无效。找出这些参数的唯一方法是为您遇到的每个单元存储所有字段(MCC,MNC,LAC,CID以及PSC),然后获取"未知" PSC在存储的数据中查找。 (您需要过滤服务小区的邻居,因为PSC只是本地唯一ID,而不是全局唯一ID。)

作为替代方案,单元的PSC以及其邻居之一的MCC / MNC / LAC / CID元组也是您可以使用的全局唯一ID。但请注意,每个单元格都有多个这样的标识符(每个邻居一个)。

答案 1 :(得分:3)

我可以为邻居小区获取cid和rssi。所以你试试这个代码,它只适用于物理材料(不要使用模拟器)。 在这里你用textview创建你的android xml。 ; - )

package app.tel;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.NeighboringCellInfo;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.widget.TextView;


public class TelephActivity extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   TextView textGsmCellLocation = (TextView)findViewById(R.id.gsmcelllocation);
   TextView textMCC = (TextView)findViewById(R.id.mcc);
   TextView textMNC = (TextView)findViewById(R.id.mnc);
   TextView textCID = (TextView)findViewById(R.id.cid);

   //retrieve a reference to an instance of TelephonyManager
   TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
   GsmCellLocation cellLocation = (GsmCellLocation)telephonyManager.getCellLocation();

   String networkOperator = telephonyManager.getNetworkOperator();
   String mcc = networkOperator.substring(0, 3);
   String mnc = networkOperator.substring(3);
   textMCC.setText("mcc: " + mcc);
   textMNC.setText("mnc: " + mnc);

   int cid = cellLocation.getCid();
   //int lac = cellLocation.getLac();
   textGsmCellLocation.setText(cellLocation.toString());
   textCID.setText("gsm cell id: " + String.valueOf(cid));

   TextView Neighboring = (TextView)findViewById(R.id.neighboring);
   List<NeighboringCellInfo> NeighboringList = telephonyManager.getNeighboringCellInfo();

   String stringNeighboring = "Neighboring List- Lac : Cid : RSSI\n";
   for(int i=0; i < NeighboringList.size(); i++){

    String dBm;
    int rssi = NeighboringList.get(i).getRssi();
    if(rssi == NeighboringCellInfo.UNKNOWN_RSSI){
     dBm = "Unknown RSSI";
    }else{
     dBm = String.valueOf(-113 + 2 * rssi) + " dBm";
    }

    stringNeighboring = stringNeighboring
     + String.valueOf(NeighboringList.get(i).getLac()) +" : "
     + String.valueOf(NeighboringList.get(i).getCid()) +" : "
     + String.valueOf(NeighboringList.get(i).getPsc()) +" : "
     + String.valueOf(NeighboringList.get(i).getNetworkType()) +" : "
     + dBm +"\n";
   }

   Neighboring.setText(stringNeighboring);
 }   
 }

答案 2 :(得分:0)

有时,当同一提供商的更多CID共享相同的塔/站点时,用于增加容量并以相同的diriction进行传输,则具有相同的PSC。因此,在这些情况下,您可以使用PSC来识别站点和beamdirection,但不能识别CID。