1. Download our Official Android App: Forums for Android!

Android: getallcellinfo()/getneighboringcellinfo() detects unknown cell info

Discussion in 'Android Development' started by hzy11137, Oct 11, 2017.

  1. hzy11137

    hzy11137 Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    1
    Joined:
    Oct 11, 2017

    Oct 11, 2017
    1
    0
    15
    I'm trying to get the information of the cell tower nearby in the Eclipse. And, I want to ask why can't I get the MCC, MNC, CI, TAC information (all are max value of Integer) of the non-registered base station nearby by using getAllCellInfo()? And why can't I get LAC and CID by using getNeighboringCellInfo()?


    This is my codes of getAllCellInfo:
    TelephonyManager mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    List<CellInfo> infos = mTelephonyManager.getAllCellInfo();

    if (infos != null) {
    if (infos.size() == 0)
    return;
    for (CellInfo i : infos) {
    if (i instanceof CellInfoGsm) {
    Log.i("Location", "Base Station(CellInfoGsm) Info Nearby: " + i.toString() + "\n");
    } else if (i instanceof CellInfoCdma) {
    Log.i("Location", "Base Station(CellInfoCdma) Info Nearby: " + i.toString() + "\n");
    } else if (i instanceof CellInfoLte) {
    Log.i("Location", "Base Station(CellInfoLte) Info Nearby: " + i.toString() + "\n");
    } else if (i instanceof CellInfoWcdma) {
    Log.i("Location", "Base Station(CellInfoWcdma) Info Nearby: " + i.toString() + "\n");
    } else {
    Log.i("Location", "Base Station(CellInfoGsm) Info Nearby: UNKNOWN" + "\n");
    }
    }
    }
    I test the codes above using Lenovo PB2-690Y(Android 6.0.1, API 23),but the results in the logcat is as follow:
    10-10 11:48:28.090: I/Location(18765): Base Station(CellInfoLte) Info Nearby: CellInfoLte:{mRegistered=YES mTimeStampType=oem_ril mTimeStamp=948186856440416ns CellIdentityLte:{ mMcc=302 mMnc=720 mCi=24371977 mPci=457 mTac=33333} CellSignalStrengthLte: ss=19 rsrp=-103 rsrq=-7 rssnr=2147483647 cqi=2147483647 ta=2147483647}
    10-10 11:48:28.090: I/Location(18765): Base Station(CellInfoLte) Info Nearby: CellInfoLte:{mRegistered=NO mTimeStampType=oem_ril mTimeStamp=948186856440416ns CellIdentityLte:{ mMcc=2147483647 mMnc=2147483647 mCi=2147483647 mPci=466 mTac=2147483647} CellSignalStrengthLte: ss=10 rsrp=-112 rsrq=-10 rssnr=2147483647 cqi=2147483647 ta=2147483647}

    I also use the deprecated API --- getNeighboringCellInfo:

    TelephonyManager mTelephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);

    List<NeighboringCellInfo> infos = mTelephonyManager.getNeighboringCellInfo();
    StringBuffer sb = new StringBuffer("Total Number of Base Stations : " + infos.size() + "\n");
    for (NeighboringCellInfo info1 : infos) {
    sb.append(" LAC : " + info1.getLac());
    sb.append(" CID : " + info1.getCid());
    sb.append(" BSSS : " + (-113 + 2 * info1.getRssi()) + "\n");
    }

    Log.i("Location","Base station info "+sb);

    I used the same configuration to test the old API, and the logcat result is :
    10-10 12:22:26.565: I/Location(20670): Base station info Total Number of Base Stations : 1
    10-10 12:22:26.565: I/Location(20670): LAC : -1 CID : -1 BSSS : 35
     

    Advertisement

Share This Page

Loading...