Example usage for android.telephony CellLocation getClass

List of usage examples for android.telephony CellLocation getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.restcomm.app.utillib.DataObjects.PhoneState.java

private String listCellLocationFields(CellLocation cell) {
    if (cell != null) {
        String strCells = "";

        Field[] fields = null;//from w ww .  j  a v a 2  s.  c om
        try {
            fields = cell.getClass().getDeclaredFields();
            int i;
            for (i = 0; i < fields.length; i++) {
                fields[i].setAccessible(true);
                if (!fields[i].getName().equals("CREATOR") && !fields[i].getName().equals("LOG_TAG")
                        && fields[i].getName().indexOf("INVALID") == -1
                        && fields[i].getName().indexOf("STRENGTH") == -1) {
                    strCells += fields[i].getName() + "=";
                    if (fields[i].get(cell) == null)
                        strCells += "null";
                    else
                        strCells += fields[i].get(cell).toString() + ",";
                }
            }

            //MMCLogger.logToFile(MMCLogger.Level.DEBUG, TAG, "listSignalFields", strSignals);
            return strCells;
        } catch (SecurityException e) {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "listCellFields", "SecurityException", e);
        } catch (Exception e) {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "listCellFields", "exception", e);
        }
    }
    return "";
}

From source file:uk.ac.horizon.ubihelper.service.channel.CellLocationChannel.java

@Override
protected boolean startPoll() {
    if (telephony != null) {
        CellLocation loc = telephony.getCellLocation();
        JSONObject value = new JSONObject();
        try {/*from w  w  w . ja  va 2s  . com*/
            value.put("timestamp", System.currentTimeMillis());
            if (loc instanceof GsmCellLocation) {
                GsmCellLocation gsm = (GsmCellLocation) loc;
                if (gsm.getCid() != (-1))
                    value.put("cid", gsm.getCid());
                if (gsm.getLac() != (-1))
                    value.put("lac", gsm.getLac());
                value.put("type", "gsm");
            } else if (loc instanceof CdmaCellLocation) {
                CdmaCellLocation cdma = (CdmaCellLocation) loc;
                if (cdma.getBaseStationId() != (-1))
                    value.put("baseStationId", cdma.getBaseStationId());
                if (cdma.getBaseStationLatitude() != Integer.MAX_VALUE)
                    value.put("baseStationLat", cdma.getBaseStationLatitude());
                if (cdma.getBaseStationLongitude() != Integer.MAX_VALUE)
                    value.put("baseStationLon", cdma.getBaseStationLongitude());
                if (cdma.getNetworkId() != (-1))
                    value.put("baseStationId", cdma.getNetworkId());
                if (cdma.getNetworkId() != (-1))
                    value.put("networkId", cdma.getNetworkId());
                if (cdma.getSystemId() != (-1))
                    value.put("systemId", cdma.getSystemId());
                value.put("type", "cdma");
            } else if (loc != null) {
                value.put("type", loc.getClass().getName());
            }
            if (includeNeighbours) {
                List<NeighboringCellInfo> neighbors = telephony.getNeighboringCellInfo();
                JSONArray ns = new JSONArray();
                value.put("neighbors", ns);
                for (NeighboringCellInfo neighbor : neighbors) {
                    JSONObject n = new JSONObject();
                    if (neighbor.getCid() != (-1))
                        n.put("cid", neighbor.getCid());
                    if (neighbor.getLac() != (-1))
                        n.put("lac", neighbor.getLac());
                    n.put("networkType", neighbor.getNetworkType());
                    n.put("rssi", neighbor.getRssi());
                    ns.put(n);
                }
            }
        } catch (JSONException e) {
            // shouldn't
        }
        onNewValue(value);
    }
    return false;
}

From source file:org.mozilla.mozstumbler.service.scanners.cellscanner.CellInfo.java

void setCellLocation(CellLocation cl, int networkType, String networkOperator, Integer gsmSignalStrength,
        Integer cdmaRssi) {/*from ww  w .ja  v a2 s . co m*/
    if (cl instanceof GsmCellLocation) {
        final int lac, cid;
        final GsmCellLocation gcl = (GsmCellLocation) cl;

        reset();
        mCellRadio = getCellRadioTypeName(networkType);
        setNetworkOperator(networkOperator);

        lac = gcl.getLac();
        cid = gcl.getCid();
        if (lac >= 0)
            mLac = lac;
        if (cid >= 0)
            mCid = cid;

        if (Build.VERSION.SDK_INT >= 9) {
            final int psc = gcl.getPsc();
            if (psc >= 0)
                mPsc = psc;
        }

        if (gsmSignalStrength != null) {
            mAsu = gsmSignalStrength;
        }
    } else if (cl instanceof CdmaCellLocation) {
        final CdmaCellLocation cdl = (CdmaCellLocation) cl;

        reset();
        mCellRadio = getCellRadioTypeName(networkType);

        setNetworkOperator(networkOperator);

        mMnc = cdl.getSystemId();

        mLac = cdl.getNetworkId();
        mCid = cdl.getBaseStationId();

        if (cdmaRssi != null) {
            mSignal = cdmaRssi;
        }
    } else {
        throw new IllegalArgumentException("Unexpected CellLocation type: " + cl.getClass().getName());
    }
}

From source file:uk.ac.horizon.ubihelper.service.channel.CellStrengthChannel.java

protected void update(CellLocation loc, SignalStrength ss) {
    if (loc == null && telephony != null)
        loc = telephony.getCellLocation();
    // TODO Auto-generated method stub
    JSONObject value = new JSONObject();
    try {//from   w w w. j  a v a2 s.  c  o m
        value.put("timestamp", System.currentTimeMillis());
        if (loc instanceof GsmCellLocation) {
            GsmCellLocation gsm = (GsmCellLocation) loc;
            if (gsm.getCid() != (-1))
                value.put("cid", gsm.getCid());
            if (gsm.getLac() != (-1))
                value.put("lac", gsm.getLac());
            value.put("type", "gsm");
        } else if (loc instanceof CdmaCellLocation) {
            CdmaCellLocation cdma = (CdmaCellLocation) loc;
            if (cdma.getBaseStationId() != (-1))
                value.put("baseStationId", cdma.getBaseStationId());
            if (cdma.getBaseStationLatitude() != Integer.MAX_VALUE)
                value.put("baseStationLat", cdma.getBaseStationLatitude());
            if (cdma.getBaseStationLongitude() != Integer.MAX_VALUE)
                value.put("baseStationLon", cdma.getBaseStationLongitude());
            if (cdma.getNetworkId() != (-1))
                value.put("baseStationId", cdma.getNetworkId());
            if (cdma.getNetworkId() != (-1))
                value.put("networkId", cdma.getNetworkId());
            if (cdma.getSystemId() != (-1))
                value.put("systemId", cdma.getSystemId());
            value.put("type", "cdma");
        } else if (loc != null) {
            value.put("type", loc.getClass().getName());
        }

        if (ss != null) {
            if (ss.getCdmaDbm() != (-1))
                value.put("cdmsDbm", ss.getCdmaDbm());
            if (ss.getCdmaEcio() != (-1))
                value.put("cdmaEcio", ss.getCdmaEcio());
            if (ss.getEvdoDbm() != (-1))
                value.put("evdoDbm", ss.getEvdoDbm());
            if (ss.getEvdoEcio() != (-1))
                value.put("evdiEcio", ss.getEvdoEcio());
            if (ss.getEvdoSnr() != (-1))
                value.put("evdoSnr", ss.getEvdoSnr());
            if (ss.getGsmBitErrorRate() != (-1))
                value.put("gsmBER", ss.getGsmBitErrorRate());
            if (ss.getGsmSignalStrength() != (-1))
                value.put("gsmSS", ss.getGsmSignalStrength());
            value.put("gsm", ss.isGsm());
        }
    } catch (JSONException e) {
        // shouldn't
    }
    onNewValue(value);
}

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

private void checkInnerGsmCellLocation(CellLocation cell) {
    if (cell != null) {
        String strCells = "";

        Field getFieldPointer = null;
        try {// ww  w . j  a va 2 s.com
            getFieldPointer = cell.getClass().getDeclaredField("mGsmCellLoc"); //NoSuchFieldException 

        } catch (Exception e) {
            //MMCLogger.logToFile(MMCLogger.Level.ERROR, TAG, "checkInnerGsmCellLocation","Field does not exist - mGsmCellLoc");
        }
        if (getFieldPointer != null) {
            //now we're in business!
            try {
                getFieldPointer.setAccessible(true);
                GsmCellLocation gsmCell = (GsmCellLocation) getFieldPointer.get(cell);
                if (gsmCell != null) {
                    int bsHigh = gsmCell.getLac();
                    int bsLow = gsmCell.getCid();
                    LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "checkInnerGsmCellLocation",
                            "Obtained mGsmCellLoc LAC=" + gsmCell.getLac() + " toString=" + gsmCell.toString());

                    if (mPhoneState.getNetworkType() == mPhoneState.NETWORK_NEWTYPE_LTE) {
                        int psc = 0;
                        if (android.os.Build.VERSION.SDK_INT >= 10)
                            psc = gsmCell.getPsc();
                        String neighbors = owner.getCellHistory().updateLteNeighborHistory(bsHigh, bsLow, psc);
                        owner.getIntentDispatcher().updateLTEIdentity(neighbors);
                        owner.getReportManager().setNeighbors(neighbors);
                    }
                }
            } catch (Exception e) {
                Log.d(TAG, "Could not get the inner GSM", e);
            }
        }
    }
}