Reputation: 8768
I'm trying to make use of a mobile information about neighbouring cells, available on Android via TelephonyManager
class and its getNeighboringCellInfo
method. Below I'm posting a part of code (mostly taken from publicly available sources) which does the job, and one example of output which this code produces (shown in attached screenshot). The code and the image are placed "as is" without any changes, so it should be relatively easy to associate one with the other and make sure it should work correctly (of course, there can be errors which I overlooked).
The problem is that the list of neighbouring cells does often contain elements with "incorrect" (to my understanding) data, such as:
NeighboringCellInfo
with all properties - lac
, cid
, psc
- set to -1, and only rssi
field seems meaningful;NeighboringCellInfo
with lac
equal to 0; does this mean that the lac
is the same as current active cell?NeighboringCellInfo
with rssi
value outside the range [0, 31] and not UNKNOWN_RSSI
; such values can be as positive (33, as shown in the screenshot), as negative (they look like a proper raw rssi value, that is without the need to convert from asu
);Does all this mean a normal functioning of mobile technology, some sort of possibly powersaving optimizations, or a flaw in a specific device (LG Optimus One in my case)?
Please suggest how can one obtain consistent readings from cell environment on Android, if this is possible.
GsmCellLocation cellLocation = (GsmCellLocation)telephonyManager.getCellLocation();
String networkOperator = telephonyManager.getNetworkOperator();
int type = telephonyManager.getNetworkType();
String mcc = networkOperator.substring(0, 3);
String mnc = networkOperator.substring(3);
textMCC.setText("mcc: " + mcc + " mnc: " + mnc);
textMNC.setText("operator: " + networkOperator);
int cid = cellLocation.getCid();
int lac = cellLocation.getLac();
int psc = cellLocation.getPsc();
textGsmCellLocation.setText(cellLocation.toString());
textCID.setText("lac: " + String.valueOf(lac) + " cid: " + String.valueOf(cid) + " psc: " + String.valueOf(psc) + " type: " + String.valueOf(type) + " rssi: " + String.valueOf(currentCellRSSI));
TextView Neighboring = (TextView)findViewById(R.id.neighboring);
List<NeighboringCellInfo> NeighboringList = telephonyManager.getNeighboringCellInfo();
String stringNeighboring = "Neighboring List - Lac : Cid : Psc : type : 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
{
if(rssi >= 0 && rssi < 32)
{
dBm = String.valueOf(-113 + 2 * rssi) + " dBm";
}
else
{
dBm = "Unknown value:" + Integer.toString(rssi);
}
}
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);
Upvotes: 2
Views: 4492
Reputation: 5901
Neighboring cells are reported in two different ways:
On GSM/GPRS (which seems to be the network you were on when you took your screenshot) you should get the MCC/MNC/LAC/CID tuple for the neighboring cells. I see you get valid CID values. The PSC will always be -1 if you're on a GSM (2.xG) network, as the PSC has no meaning on GSM (PSC is a CDMA parameter and GSM is TDMA-based).
On UMTS things are different: For neighboring cells only the PSC is reported, and you will not find out their other parameters unless you connect to them.
LTE is in principle similar to UMTS, but with slightly different names: instead of LAC and CID you have TAC (Tracking Area Code) and CI (Cell Identity); instead of a PSC you have a PCI (Physical Cell ID). However, they do essentially the same as their UMTS counterparts.
Note, however, that implementation varies greatly between devices: Some phones will not report PSC even on 3G networks, and some will never report neighboring cells. The Nexus S (as most Samsung-built devices) reports neither.
Not sure about the LAC=0, though. It might mean "same LAC as current cell", in which case it would be interesting to see the output from the boundary of a Location Area, where the phone can pick up cells with multiple LACs. (Would we be seeing cells from both LAs? Or just from "our" LA? What LAC would be reported for cells from a neighboring LA?)
Upvotes: 3
Reputation: 4042
The mobile device should be aware of the neighbouring cells, so that it can hand over to a better cell if necessary. In any case, you've told it to get information about neighbouring cells, so that's what it should do. Your results don't seem to match up to what is described in the Android documentation either. I would report this problem to the device vendor as a firmware bug.
I can imagine a situation where you would see a neighbouring cell with a stronger signal if for example the cell was GSM, and the device preferred a UMTS cell with a weaker signal, but this should be obvious from the network type field.
Upvotes: 0