Example usage for android.telephony CellLocation toString

List of usage examples for android.telephony CellLocation toString

Introduction

In this page you can find the example usage for android.telephony CellLocation toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.restcomm.app.qoslib.UtilsOld.CellHistory.java

public long getLastCellSeen(CellLocation cellLoc) // MMCCellLocationOld cellInfo)
{
    if (cellLoc == null)
        return -1;
    if (tmLastCellUpdate + 60000 > System.currentTimeMillis() && cellLoc.toString().equals(lastCellString))
        return -1;
    long timelastSeen = 0;
    tmLastCellUpdate = System.currentTimeMillis();

    // Is it reporting an unknown cell id? ignore those
    //        int cellId = 0;//cellInfo.getBSLow(); //low
    //        if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM && cellLoc instanceof GsmCellLocation)
    //         cellId = ((GsmCellLocation)cellLoc).getCid();
    //      else if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA && cellLoc instanceof CdmaCellLocation)
    //         cellId = ((CdmaCellLocation)cellLoc).getBaseStationId();
    //      if (cellId <= 0)
    //         return -1;

    CellidSample smp = new CellidSample(cellLoc);
    cell_history.add(smp);/*from  w  w w  .j a va 2 s  .  c  om*/

    // How long has it been since we last saw this basestation
    //int bs_high = cellInfo.getBSHigh(), bs_mid = cellInfo.getBSMid(), bs_low = cellInfo.getBSLow();
    int bs_high = 0, bs_mid = 0, bs_low = 0;
    if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM
            && cellLoc instanceof GsmCellLocation) {
        GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLoc;
        bs_high = gsmCellLocation.getLac();
        bs_mid = gsmCellLocation.getCid() >> 16;
        bs_low = gsmCellLocation.getCid() & 0xffff;
    } else if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA
            && cellLoc instanceof CdmaCellLocation) {
        CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLoc;
        bs_high = cdmaCellLocation.getSystemId();
        bs_mid = cdmaCellLocation.getNetworkId();
        bs_low = cdmaCellLocation.getBaseStationId();
    }
    if (bs_low <= 0)
        return -1;
    int j;
    int histlen = cell_history.size();
    // How long has it been since we last saw this basestation
    long timestamp = System.currentTimeMillis();
    for (j = histlen - 2; j >= 0; j--) {
        if (cell_history.get(j).val2 == bs_low) //  && cell_history.get(j).val1 == bs_high)
        {
            // time last seen is the first timestamp after the cell was last seen
            // (the time this cell handed off to another cell)
            // (if the last known cell was this same cell, then the time last seen is now)
            timelastSeen = timestamp;
            break;
        } else
            timestamp = cell_history.get(j).timestamp;

    }

    return timelastSeen;
}

From source file:com.marianhello.cordova.bgloc.LocationUpdateService.java

/**
    * TODO Experimental cell-tower change system; something like ios significant changes.
    *//*from   w w  w .  ja  v a 2  s  .c  o  m*/
    public void onCellLocationChange(CellLocation cellLocation) {
        Log.i(TAG, "- onCellLocationChange" + cellLocation.toString());
        if (isDebugging) {
            Toast.makeText(this, "Cellular location change", Toast.LENGTH_LONG).show();
            startTone("chirp_chirp_chirp");
        }
        if (!isMoving && stationaryLocation != null) {
            criteria.setAccuracy(Criteria.ACCURACY_FINE);
            criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
            criteria.setPowerRequirement(Criteria.POWER_HIGH);
            locationManager.requestSingleUpdate(criteria, singleUpdatePI);
        }
    }

From source file:org.restcomm.app.qoslib.Services.LibPhoneStateListener.java

public CellLocationEx getLastCellLocation() {
    if (mPhoneState.lastKnownMMCCellLocation != null)
        return mPhoneState.lastKnownMMCCellLocation;
    CellLocation cellLoc = telephonyManager.getCellLocation();
    if (cellLoc != null) {
        LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "getLastCellLocation",
                "null cell, getCellLocation() = " + cellLoc.toString());

        CellLocationEx mmcCell = new CellLocationEx(cellLoc);
        try {//from  w  w  w.j a v  a 2s . c  om
            processNewCellLocation(mmcCell);
        } catch (InterruptedException e) {
        }
        return mmcCell;
    }
    LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "getLastCellLocation",
            "null cell, getCellLocation() = null");
    return null;
}

From source file:org.restcomm.app.qoslib.Services.LibPhoneStateListener.java

/**
 * When the cell location gets changed, the new cellId is added to the cell id buffer in the 
 * owner. At the same time, the CELLCHANGE event is stored.
 *//*from   ww w.j a v  a  2s  .c  om*/
@Override
public void onCellLocationChanged(CellLocation location) {
    super.onCellLocationChanged(location);

    try {
        checkCDMACellSID(location);
        processNewCellLocation(new CellLocationEx(location));

        // See if this cellLocation has inner GsmLocation
        checkInnerGsmCellLocation(location);
        LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "onCellLocationChanged", location.toString());

    } catch (InterruptedException intEx) {
        LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "onCellLocationChanged",
                "InterruptedException: " + intEx.getMessage());
    } catch (Exception ex) {
        String err = ex.toString();
        LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "onCellLocationChanged",
                "InterruptedException: " + err);
    }
}