Java Code Examples for android.telephony.cdma.CdmaCellLocation#getSystemId()

The following examples show how to use android.telephony.cdma.CdmaCellLocation#getSystemId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MeasurementUpdater.java    From TowerCollector with Mozilla Public License 2.0 6 votes vote down vote up
private boolean isCellLocationEqual(CellLocation cl1, CellLocation cl2) {
    boolean result;
    if (cl1 instanceof GsmCellLocation && cl2 instanceof GsmCellLocation) {
        GsmCellLocation gsm1 = (GsmCellLocation) cl1;
        GsmCellLocation gsm2 = (GsmCellLocation) cl2;
        result = (gsm1.getCid() == gsm2.getCid()
                && gsm1.getLac() == gsm2.getLac()
                && gsm1.getPsc() == gsm2.getPsc());
        Timber.d("isCellLocationEqual(): GSM equals = %s", result);
    } else if (cl1 instanceof CdmaCellLocation && cl2 instanceof CdmaCellLocation) {
        CdmaCellLocation cdma1 = (CdmaCellLocation) cl1;
        CdmaCellLocation cdma2 = (CdmaCellLocation) cl2;
        result = (cdma1.getBaseStationId() == cdma2.getBaseStationId()
                && cdma1.getNetworkId() == cdma2.getNetworkId()
                && cdma1.getSystemId() == cdma2.getSystemId());
        Timber.d("isCellLocationEqual(): CDMA equal = %s", result);
    } else {
        // different types or nulls
        result = false;
        Timber.d("isCellLocationEqual(): Different types or nulls");
    }
    return result;
}
 
Example 2
Source File: ay.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
ay(CellLocation celllocation)
{
    a = 0x7fffffff;
    b = 0x7fffffff;
    c = 0x7fffffff;
    d = 0x7fffffff;
    e = 0x7fffffff;
    if (celllocation != null)
    {
        if (celllocation instanceof GsmCellLocation)
        {
            GsmCellLocation gsmcelllocation = (GsmCellLocation)celllocation;
            e = gsmcelllocation.getCid();
            d = gsmcelllocation.getLac();
        } else
        if (celllocation instanceof CdmaCellLocation)
        {
            CdmaCellLocation cdmacelllocation = (CdmaCellLocation)celllocation;
            c = cdmacelllocation.getBaseStationId();
            b = cdmacelllocation.getNetworkId();
            a = cdmacelllocation.getSystemId();
            return;
        }
    }
}
 
Example 3
Source File: Gsm.java    From batteryhub with Apache License 2.0 5 votes vote down vote up
public static CellInfo getCellInfo(Context context) {
    CellInfo cellInfo = new CellInfo();

    TelephonyManager manager = (TelephonyManager)
            context.getSystemService(Context.TELEPHONY_SERVICE);

    String netOperator = manager.getNetworkOperator();

    // Fix crash when not connected to network (airplane mode, underground,
    // etc)
    if (netOperator == null || netOperator.length() < 3) {
        return cellInfo;
    }

    /*
     * FIXME: Actually check for mobile network status == connected before
     * doing this stuff.
     */

    if (Phone.getType(context).equals(PHONE_TYPE_CDMA)) {
        CdmaCellLocation cdmaLocation = (CdmaCellLocation) manager.getCellLocation();

        cellInfo.cid = cdmaLocation.getBaseStationId();
        cellInfo.lac = cdmaLocation.getNetworkId();
        cellInfo.mnc = cdmaLocation.getSystemId();
        cellInfo.mcc = Integer.parseInt(netOperator.substring(0, 3));
        cellInfo.radioType = Network.getMobileNetworkType(context);
    } else if (Phone.getType(context).equals(PHONE_TYPE_GSM)) {
        GsmCellLocation gsmLocation = (GsmCellLocation) manager.getCellLocation();

        cellInfo.mcc = Integer.parseInt(netOperator.substring(0, 3));
        cellInfo.mnc = Integer.parseInt(netOperator.substring(3));
        cellInfo.lac = gsmLocation.getLac();
        cellInfo.cid = gsmLocation.getCid();
        cellInfo.radioType = Network.getMobileNetworkType(context);
    }

    return cellInfo;
}
 
Example 4
Source File: CellTowerListCdma.java    From satstat with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Adds or updates a cell tower.
 * <p>
 * If the cell tower is already in the list, it is replaced; if not, a new
 * entry is created.
 * <p>
 * This method will set the cell's identity data. After this call,
 * {@link #isServing()} will return {@code true} for this cell. 
 * @return The new or updated entry.
 */
public CellTowerCdma update(CdmaCellLocation location) {
	CellTowerCdma result = this.get(location.getSystemId(), location.getNetworkId(), location.getBaseStationId());
	if (result == null) {
		result = new CellTowerCdma(location.getSystemId(), location.getNetworkId(), location.getBaseStationId());
		this.put(result.getText(), result);
	}
	result.setCellLocation(true);
	return result;
}