Java 类android.telephony.CellInfoCdma 实例源码

项目:AIMSICDL    文件:DeviceApi18.java   
public static void loadCellInfo(TelephonyManager tm, Device pDevice) {
    int lCurrentApiVersion = android.os.Build.VERSION.SDK_INT;
    try {
        if (pDevice.mCell == null) {
            pDevice.mCell = new Cell();
        }
        List<CellInfo> cellInfoList = tm.getAllCellInfo();
        if (cellInfoList != null) {
            for (final CellInfo info : cellInfoList) {

                //Network Type
                pDevice.mCell.setNetType(tm.getNetworkType());

                if (info instanceof CellInfoGsm) {
                    final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
                    final CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity();
                    // Signal Strength
                    pDevice.mCell.setDBM(gsm.getDbm()); // [dBm]
                    // Cell Identity
                    pDevice.mCell.setCID(identityGsm.getCid());
                    pDevice.mCell.setMCC(identityGsm.getMcc());
                    pDevice.mCell.setMNC(identityGsm.getMnc());
                    pDevice.mCell.setLAC(identityGsm.getLac());

                } else if (info instanceof CellInfoCdma) {
                    final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
                    final CellIdentityCdma identityCdma = ((CellInfoCdma) info).getCellIdentity();
                    // Signal Strength
                    pDevice.mCell.setDBM(cdma.getDbm());
                    // Cell Identity
                    pDevice.mCell.setCID(identityCdma.getBasestationId());
                    pDevice.mCell.setMNC(identityCdma.getSystemId());
                    pDevice.mCell.setLAC(identityCdma.getNetworkId());
                    pDevice.mCell.setSID(identityCdma.getSystemId());

                } else if (info instanceof CellInfoLte) {
                    final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
                    final CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity();
                    // Signal Strength
                    pDevice.mCell.setDBM(lte.getDbm());
                    pDevice.mCell.setTimingAdvance(lte.getTimingAdvance());
                    // Cell Identity
                    pDevice.mCell.setMCC(identityLte.getMcc());
                    pDevice.mCell.setMNC(identityLte.getMnc());
                    pDevice.mCell.setCID(identityLte.getCi());

                } else if  (lCurrentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2 && info instanceof CellInfoWcdma) {
                    final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info).getCellSignalStrength();
                    final CellIdentityWcdma identityWcdma = ((CellInfoWcdma) info).getCellIdentity();
                    // Signal Strength
                    pDevice.mCell.setDBM(wcdma.getDbm());
                    // Cell Identity
                    pDevice.mCell.setLAC(identityWcdma.getLac());
                    pDevice.mCell.setMCC(identityWcdma.getMcc());
                    pDevice.mCell.setMNC(identityWcdma.getMnc());
                    pDevice.mCell.setCID(identityWcdma.getCid());
                    pDevice.mCell.setPSC(identityWcdma.getPsc());

                } else {
                    Log.i(TAG, mTAG + "Unknown type of cell signal!"
                            + "\n ClassName: " + info.getClass().getSimpleName()
                            + "\n ToString: " + info.toString());
                }
                if (pDevice.mCell.isValid()) {
                    break;
                }
            }
        }
    } catch (NullPointerException npe) {
       Log.e(TAG, mTAG + "loadCellInfo: Unable to obtain cell signal information: ", npe);
    }
}
项目:SignalAnalysis    文件:PhoneStateHelper.java   
/**
 * Get current cell info
 * 
 * @return cell information format as {@link String}
 */
public String getCellInfo() {
    if (DBG)
        Log.d(Config.TAG, TAG + "getCellInfo called");
    String ret = null;
    List<CellInfo> listCellInfo = mTelMgr.getAllCellInfo();
    if (listCellInfo != null)
        for (CellInfo a_Info : listCellInfo) {
            if (CellInfoCdma.class.isInstance(a_Info))
                ret = ret + "\n Cell info cdma: " + a_Info.toString();
            else if (CellInfoGsm.class.isInstance(a_Info))
                ret = ret + "\n Cell info gsm: " + a_Info.toString();
            else if (CellInfoLte.class.isInstance(a_Info)) {
                ret = ret + "\n Cell info lte: " + a_Info.toString();
                CellInfoLte cellInfoLte = (CellInfoLte) a_Info;
                CellIdentityLte cellIdentity = cellInfoLte
                        .getCellIdentity();
                Log.d(Config.TAG, TAG + " LTE - " + cellIdentity.getCi()
                        + cellIdentity.getTac() + cellIdentity.getPci());

            } else if (CellInfoWcdma.class.isInstance(a_Info))
                ret = ret + "\n Cell info : wcdma" + a_Info.toString();
        }
    return ret;
}
项目:chromium-net-for-android    文件:AndroidCellularSignalStrength.java   
/**
 * @return Signal strength (in dbM) from {@link cellInfo}. Returns {@link
 * CellularSignalStrengthError#ERROR_NOT_SUPPORTED} if the signal strength is unavailable.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private static int getSignalStrengthDbm(CellInfo cellInfo) {
    if (cellInfo instanceof CellInfoCdma) {
        return ((CellInfoCdma) cellInfo).getCellSignalStrength().getDbm();
    }
    if (cellInfo instanceof CellInfoGsm) {
        return ((CellInfoGsm) cellInfo).getCellSignalStrength().getDbm();
    }
    if (cellInfo instanceof CellInfoLte) {
        return ((CellInfoLte) cellInfo).getCellSignalStrength().getDbm();
    }
    if (cellInfo instanceof CellInfoWcdma) {
        return ((CellInfoWcdma) cellInfo).getCellSignalStrength().getDbm();
    }
    return CellularSignalStrengthError.ERROR_NOT_SUPPORTED;
}
项目:chromium-net-for-android    文件:AndroidCellularSignalStrength.java   
/**
 * @return the signal level from {@link cellInfo}. Returns {@link
 * CellularSignalStrengthError#ERROR_NOT_SUPPORTED} if the signal
 * level is unavailable with lower value indicating lower signal strength.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private static int getSignalStrengthLevel(CellInfo cellInfo) {
    if (cellInfo instanceof CellInfoCdma) {
        return ((CellInfoCdma) cellInfo).getCellSignalStrength().getLevel();
    }
    if (cellInfo instanceof CellInfoGsm) {
        return ((CellInfoGsm) cellInfo).getCellSignalStrength().getLevel();
    }
    if (cellInfo instanceof CellInfoLte) {
        return ((CellInfoLte) cellInfo).getCellSignalStrength().getLevel();
    }
    if (cellInfo instanceof CellInfoWcdma) {
        return ((CellInfoWcdma) cellInfo).getCellSignalStrength().getLevel();
    }
    return CellularSignalStrengthError.ERROR_NOT_SUPPORTED;
}
项目:open-rmbt    文件:CellInformationWrapper.java   
public CellInformationWrapper(CellInfo cellInfo) {
    setRegistered(cellInfo.isRegistered());
    this.setTimeStamp(cellInfo.getTimeStamp());

    if (cellInfo.getClass().equals(CellInfoLte.class)) {
        setTechnology(Technology.CONNECTION_4G);
        this.ci = new CellIdentity(((CellInfoLte) cellInfo).getCellIdentity());
        this.cs = new CellSignalStrength(((CellInfoLte) cellInfo).getCellSignalStrength());
    }
    else if (cellInfo.getClass().equals(CellInfoWcdma.class)) {
        setTechnology(Technology.CONNECTION_3G);
        this.ci = new CellIdentity(((CellInfoWcdma) cellInfo).getCellIdentity());
        this.cs = new CellSignalStrength(((CellInfoWcdma) cellInfo).getCellSignalStrength());
    }
    else if (cellInfo.getClass().equals(CellInfoGsm.class)) {
        setTechnology(Technology.CONNECTION_2G);
        this.ci = new CellIdentity(((CellInfoGsm) cellInfo).getCellIdentity());
        this.cs = new CellSignalStrength(((CellInfoGsm) cellInfo).getCellSignalStrength());
    }
    else if (cellInfo.getClass().equals(CellInfoCdma.class)) {
        setTechnology(Technology.CONNECTION_2G);
        this.ci = new CellIdentity(((CellInfoCdma) cellInfo).getCellIdentity());
        this.cs = new CellSignalStrength(((CellInfoCdma) cellInfo).getCellSignalStrength());
    }
}
项目:TPlayer    文件:MethodProxies.java   
private static CellInfo createCellInfo(VCell cell) {
    if (cell.type == 2) { // CDMA
        CellInfoCdma cdma = mirror.android.telephony.CellInfoCdma.ctor.newInstance();
        CellIdentityCdma identityCdma = mirror.android.telephony.CellInfoCdma.mCellIdentityCdma.get(cdma);
        CellSignalStrengthCdma strengthCdma = mirror.android.telephony.CellInfoCdma.mCellSignalStrengthCdma.get(cdma);
        mirror.android.telephony.CellIdentityCdma.mNetworkId.set(identityCdma, cell.networkId);
        mirror.android.telephony.CellIdentityCdma.mSystemId.set(identityCdma, cell.systemId);
        mirror.android.telephony.CellIdentityCdma.mBasestationId.set(identityCdma, cell.baseStationId);
        mirror.android.telephony.CellSignalStrengthCdma.mCdmaDbm.set(strengthCdma, -74);
        mirror.android.telephony.CellSignalStrengthCdma.mCdmaEcio.set(strengthCdma, -91);
        mirror.android.telephony.CellSignalStrengthCdma.mEvdoDbm.set(strengthCdma, -64);
        mirror.android.telephony.CellSignalStrengthCdma.mEvdoSnr.set(strengthCdma, 7);
        return cdma;
    } else { // GSM
        CellInfoGsm gsm = mirror.android.telephony.CellInfoGsm.ctor.newInstance();
        CellIdentityGsm identityGsm = mirror.android.telephony.CellInfoGsm.mCellIdentityGsm.get(gsm);
        CellSignalStrengthGsm strengthGsm = mirror.android.telephony.CellInfoGsm.mCellSignalStrengthGsm.get(gsm);
        mirror.android.telephony.CellIdentityGsm.mMcc.set(identityGsm, cell.mcc);
        mirror.android.telephony.CellIdentityGsm.mMnc.set(identityGsm, cell.mnc);
        mirror.android.telephony.CellIdentityGsm.mLac.set(identityGsm, cell.lac);
        mirror.android.telephony.CellIdentityGsm.mCid.set(identityGsm, cell.cid);
        mirror.android.telephony.CellSignalStrengthGsm.mSignalStrength.set(strengthGsm, 20);
        mirror.android.telephony.CellSignalStrengthGsm.mBitErrorRate.set(strengthGsm, 0);
        return gsm;
    }
}
项目:TowerCollector    文件:CellIdentityValidator.java   
public boolean isValid(CellInfo cellInfo) {
    if (cellInfo instanceof CellInfoGsm) {
        CellInfoGsm gsmCellInfo = (CellInfoGsm) cellInfo;
        // If is compatible with API 17 hack (PSC on GSM) return true
        boolean wcdmaApi17Valid = getWcdmaValidator().isValid(gsmCellInfo.getCellIdentity());
        if (wcdmaApi17Valid)
            return true;
        return getGsmValidator().isValid(gsmCellInfo.getCellIdentity());
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo instanceof CellInfoWcdma) {
        CellInfoWcdma wcdmaCellInfo = (CellInfoWcdma) cellInfo;
        return getWcdmaValidator().isValid(wcdmaCellInfo.getCellIdentity());
    }
    if (cellInfo instanceof CellInfoLte) {
        CellInfoLte lteCellInfo = (CellInfoLte) cellInfo;
        return getLteValidator().isValid(lteCellInfo.getCellIdentity());
    }
    if (cellInfo instanceof CellInfoCdma) {
        CellInfoCdma cdmaCellInfo = (CellInfoCdma) cellInfo;
        return getCdmaValidator().isValid(cdmaCellInfo.getCellIdentity());
    }
    throw new UnsupportedOperationException("Cell identity type not supported `" + cellInfo.getClass().getName() + "`");
}
项目:365browser    文件:AndroidCellularSignalStrength.java   
/**
 * @return Signal strength (in dbM) from {@link cellInfo}. Returns {@link
 * CellularSignalStrengthError#ERROR_NOT_SUPPORTED} if the signal strength is unavailable.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private static int getSignalStrengthDbm(CellInfo cellInfo) {
    if (cellInfo instanceof CellInfoCdma) {
        return ((CellInfoCdma) cellInfo).getCellSignalStrength().getDbm();
    }
    if (cellInfo instanceof CellInfoGsm) {
        return ((CellInfoGsm) cellInfo).getCellSignalStrength().getDbm();
    }
    if (cellInfo instanceof CellInfoLte) {
        return ((CellInfoLte) cellInfo).getCellSignalStrength().getDbm();
    }
    if (cellInfo instanceof CellInfoWcdma) {
        return ((CellInfoWcdma) cellInfo).getCellSignalStrength().getDbm();
    }
    return CellularSignalStrengthError.ERROR_NOT_SUPPORTED;
}
项目:365browser    文件:AndroidCellularSignalStrength.java   
/**
 * @return the signal level from {@link cellInfo}. Returns {@link
 * CellularSignalStrengthError#ERROR_NOT_SUPPORTED} if the signal
 * level is unavailable with lower value indicating lower signal strength.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private static int getSignalStrengthLevel(CellInfo cellInfo) {
    if (cellInfo instanceof CellInfoCdma) {
        return ((CellInfoCdma) cellInfo).getCellSignalStrength().getLevel();
    }
    if (cellInfo instanceof CellInfoGsm) {
        return ((CellInfoGsm) cellInfo).getCellSignalStrength().getLevel();
    }
    if (cellInfo instanceof CellInfoLte) {
        return ((CellInfoLte) cellInfo).getCellSignalStrength().getLevel();
    }
    if (cellInfo instanceof CellInfoWcdma) {
        return ((CellInfoWcdma) cellInfo).getCellSignalStrength().getLevel();
    }
    return CellularSignalStrengthError.ERROR_NOT_SUPPORTED;
}
项目:tabulae    文件:CellId.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static void fill(TheDictionary map, CellInfo value) throws Exception {
    if (value != null) {
        map.put("time_stamp", value.getTimeStamp());
        map.put("registered", value.isRegistered());
        if (value instanceof CellInfoCdma) {
            fill(map, ((CellInfoCdma) value).getCellIdentity());
            fill(map, ((CellInfoCdma) value).getCellSignalStrength());
        } else if (value instanceof CellInfoGsm) {
            fill(map, ((CellInfoGsm) value).getCellIdentity());
            fill(map, ((CellInfoGsm) value).getCellSignalStrength());
        } else if (value instanceof CellInfoWcdma) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                fill(map, ((CellInfoWcdma) value).getCellIdentity());
                fill(map, ((CellInfoWcdma) value).getCellSignalStrength());
            }
        } else if (value instanceof CellInfoLte) {
            fill(map, ((CellInfoLte) value).getCellIdentity());
            fill(map, ((CellInfoLte) value).getCellSignalStrength());
        } else {
            map.put("class", value.getClass().getName());
            map.put("string", value.toString());
        }
    }
}
项目:satstat    文件:CellTowerListCdma.java   
/**
 * 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, its signal strength and
 * whether it is the currently serving cell. If the API level is 18 or 
 * higher, it will also set the generation.
 * @return The new or updated entry.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public CellTowerCdma update(CellInfoCdma cell) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) 
        return null;
    CellIdentityCdma cid = cell.getCellIdentity();
    CellTowerCdma result = this.get(cid.getSystemId(), cid.getNetworkId(), cid.getBasestationId());
    if (result == null) {
        result = new CellTowerCdma(cid.getSystemId(), cid.getNetworkId(), cid.getBasestationId());
        this.put(result.getText(), result);
    }
    result.setCellInfo(true);
    result.setDbm(cell.getCellSignalStrength().getDbm());
    result.setServing(cell.isRegistered());
    return result;
}
项目:proto-collecte    文件:CellInfoUtil.java   
private static CommonCellInfo toCellularInfo(CellInfoCdma cellInfo) {

        CommonCellInfo res = new CommonCellInfo();
        CellIdentityCdma identityCdma = cellInfo.getCellIdentity();
        CellSignalStrength signalStrength = cellInfo.getCellSignalStrength();

        return res;
    }
项目:localcloud_fe    文件:CellLocationController.java   
private static void processCellInfos(List<CellInfo> cellInfos){
    if(cellInfos != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){

        for(CellInfo cellInfo : cellInfos){

            if(cellInfo instanceof  CellInfoWcdma){
                final CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoWCDMAJSON(cellInfoWcdma, _returnSignalStrength));
            }
            if(cellInfo instanceof CellInfoGsm){
                final CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoGSMJSON(cellInfoGsm, _returnSignalStrength));
            }
            if(cellInfo instanceof  CellInfoCdma){
                final CellInfoCdma cellIdentityCdma = (CellInfoCdma) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoCDMAJSON(cellIdentityCdma, _returnSignalStrength));
            }
            if(cellInfo instanceof  CellInfoLte){
                final CellInfoLte cellInfoLte = (CellInfoLte) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoLTEJSON(cellInfoLte, _returnSignalStrength));
            }

            Log.d(TAG,cellInfo.toString());
        }
    }
    else {
        Log.e(TAG, "CellInfoLocation returning null. Is it supported on this phone?");

        // There are several reasons as to why cell location data would be null.
        // * could be an older device running an unsupported version of the Android OS
        // * could be a device that doesn't support this capability.
        // * could be incorrect permissions: ACCESS_COARSE_LOCATION
        sendCallback(PluginResult.Status.ERROR,
                JSONHelper.errorJSON(CELLINFO_PROVIDER, ErrorMessages.CELL_DATA_IS_NULL()));
    }
}
项目:localcloud_fe    文件:CellLocationController.java   
private static void processCellInfos(List<CellInfo> cellInfos){
    if(cellInfos != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){

        for(CellInfo cellInfo : cellInfos){

            if(cellInfo instanceof  CellInfoWcdma){
                final CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoWCDMAJSON(cellInfoWcdma, _returnSignalStrength));
            }
            if(cellInfo instanceof CellInfoGsm){
                final CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoGSMJSON(cellInfoGsm, _returnSignalStrength));
            }
            if(cellInfo instanceof  CellInfoCdma){
                final CellInfoCdma cellIdentityCdma = (CellInfoCdma) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoCDMAJSON(cellIdentityCdma, _returnSignalStrength));
            }
            if(cellInfo instanceof  CellInfoLte){
                final CellInfoLte cellInfoLte = (CellInfoLte) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoLTEJSON(cellInfoLte, _returnSignalStrength));
            }

            Log.d(TAG,cellInfo.toString());
        }
    }
    else {
        Log.e(TAG, "CellInfoLocation returning null. Is it supported on this phone?");

        // There are several reasons as to why cell location data would be null.
        // * could be an older device running an unsupported version of the Android OS
        // * could be a device that doesn't support this capability.
        // * could be incorrect permissions: ACCESS_COARSE_LOCATION
        sendCallback(PluginResult.Status.ERROR,
                JSONHelper.errorJSON(CELLINFO_PROVIDER, ErrorMessages.CELL_DATA_IS_NULL()));
    }
}
项目:localcloud_fe    文件:CellLocationController.java   
private static void processCellInfos(List<CellInfo> cellInfos){
    if(cellInfos != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){

        for(CellInfo cellInfo : cellInfos){

            if(cellInfo instanceof  CellInfoWcdma){
                final CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoWCDMAJSON(cellInfoWcdma, _returnSignalStrength));
            }
            if(cellInfo instanceof CellInfoGsm){
                final CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoGSMJSON(cellInfoGsm, _returnSignalStrength));
            }
            if(cellInfo instanceof  CellInfoCdma){
                final CellInfoCdma cellIdentityCdma = (CellInfoCdma) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoCDMAJSON(cellIdentityCdma, _returnSignalStrength));
            }
            if(cellInfo instanceof  CellInfoLte){
                final CellInfoLte cellInfoLte = (CellInfoLte) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoLTEJSON(cellInfoLte, _returnSignalStrength));
            }

            Log.d(TAG,cellInfo.toString());
        }
    }
    else {
        Log.e(TAG, "CellInfoLocation returning null. Is it supported on this phone?");

        // There are several reasons as to why cell location data would be null.
        // * could be an older device running an unsupported version of the Android OS
        // * could be a device that doesn't support this capability.
        // * could be incorrect permissions: ACCESS_COARSE_LOCATION
        sendCallback(PluginResult.Status.ERROR,
                JSONHelper.errorJSON(CELLINFO_PROVIDER, ErrorMessages.CELL_DATA_IS_NULL()));
    }
}
项目:cordova-plugin-advanced-geolocation    文件:CellLocationController.java   
private static void processCellInfos(List<CellInfo> cellInfos){
    if(cellInfos != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){

        for(CellInfo cellInfo : cellInfos){

            if(cellInfo instanceof  CellInfoWcdma){
                final CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoWCDMAJSON(cellInfoWcdma, _returnSignalStrength));
            }
            if(cellInfo instanceof CellInfoGsm){
                final CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoGSMJSON(cellInfoGsm, _returnSignalStrength));
            }
            if(cellInfo instanceof  CellInfoCdma){
                final CellInfoCdma cellIdentityCdma = (CellInfoCdma) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoCDMAJSON(cellIdentityCdma, _returnSignalStrength));
            }
            if(cellInfo instanceof  CellInfoLte){
                final CellInfoLte cellInfoLte = (CellInfoLte) cellInfo;
                sendCallback(PluginResult.Status.OK,
                        JSONHelper.cellInfoLTEJSON(cellInfoLte, _returnSignalStrength));
            }

            Log.d(TAG,cellInfo.toString());
        }
    }
    else {
        Log.e(TAG, "CellInfoLocation returning null. Is it supported on this phone?");

        // There are several reasons as to why cell location data would be null.
        // * could be an older device running an unsupported version of the Android OS
        // * could be a device that doesn't support this capability.
        // * could be incorrect permissions: ACCESS_COARSE_LOCATION
        sendCallback(PluginResult.Status.ERROR,
                JSONHelper.errorJSON(CELLINFO_PROVIDER, ErrorMessages.CELL_DATA_IS_NULL()));
    }
}
项目:truth-android    文件:CellInfoCdmaSubject.java   
public static SubjectFactory<CellInfoCdmaSubject, CellInfoCdma> type() {
  return new SubjectFactory<CellInfoCdmaSubject, CellInfoCdma>() {
    @Override
    public CellInfoCdmaSubject getSubject(FailureStrategy fs, CellInfoCdma that) {
      return new CellInfoCdmaSubject(fs, that);
    }
  };
}
项目:Android-IMSI-Catcher-Detector    文件:DeviceApi18.java   
public static void loadCellInfo(TelephonyManager tm, Device pDevice) {
    int lCurrentApiVersion = Build.VERSION.SDK_INT;
    try {
        if (pDevice.cell == null) {
            pDevice.cell = new Cell();
        }
        List<CellInfo> cellInfoList = tm.getAllCellInfo();
        if (cellInfoList != null) {
            for (final CellInfo info : cellInfoList) {

                //Network Type
                pDevice.cell.setNetType(tm.getNetworkType());

                if (info instanceof CellInfoGsm) {
                    final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
                    final CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity();
                    // Signal Strength
                    pDevice.cell.setDbm(gsm.getDbm()); // [dBm]
                    // Cell Identity
                    pDevice.cell.setCellId(identityGsm.getCid());
                    pDevice.cell.setMobileCountryCode(identityGsm.getMcc());
                    pDevice.cell.setMobileNetworkCode(identityGsm.getMnc());
                    pDevice.cell.setLocationAreaCode(identityGsm.getLac());

                } else if (info instanceof CellInfoCdma) {
                    final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
                    final CellIdentityCdma identityCdma = ((CellInfoCdma) info).getCellIdentity();
                    // Signal Strength
                    pDevice.cell.setDbm(cdma.getDbm());
                    // Cell Identity
                    pDevice.cell.setCellId(identityCdma.getBasestationId());
                    pDevice.cell.setMobileNetworkCode(identityCdma.getSystemId());
                    pDevice.cell.setLocationAreaCode(identityCdma.getNetworkId());
                    pDevice.cell.setSid(identityCdma.getSystemId());

                } else if (info instanceof CellInfoLte) {
                    final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
                    final CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity();
                    // Signal Strength
                    pDevice.cell.setDbm(lte.getDbm());
                    pDevice.cell.setTimingAdvance(lte.getTimingAdvance());
                    // Cell Identity
                    pDevice.cell.setMobileCountryCode(identityLte.getMcc());
                    pDevice.cell.setMobileNetworkCode(identityLte.getMnc());
                    pDevice.cell.setCellId(identityLte.getCi());

                } else if  (lCurrentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2 && info instanceof CellInfoWcdma) {
                    final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info).getCellSignalStrength();
                    final CellIdentityWcdma identityWcdma = ((CellInfoWcdma) info).getCellIdentity();
                    // Signal Strength
                    pDevice.cell.setDbm(wcdma.getDbm());
                    // Cell Identity
                    pDevice.cell.setLocationAreaCode(identityWcdma.getLac());
                    pDevice.cell.setMobileCountryCode(identityWcdma.getMcc());
                    pDevice.cell.setMobileNetworkCode(identityWcdma.getMnc());
                    pDevice.cell.setCellId(identityWcdma.getCid());
                    pDevice.cell.setPrimaryScramblingCode(identityWcdma.getPsc());

                } else {
                    log.info("Unknown type of cell signal!"
                            + "\n ClassName: " + info.getClass().getSimpleName()
                            + "\n ToString: " + info.toString());
                }
                if (pDevice.cell.isValid()) {
                    break;
                }
            }
        }
    } catch (NullPointerException npe) {
        log.error("loadCellInfo: Unable to obtain cell signal information: ", npe);
    }
}
项目:365browser    文件:PlatformNetworksManager.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private static VisibleCell getVisibleCellPostJellyBeanMr1(
        @Nullable CellInfo cellInfo, long elapsedTime, long currentTime) {
    if (cellInfo == null) {
        return VisibleCell.UNKNOWN_VISIBLE_CELL;
    }
    long cellInfoAge = elapsedTime - TimeUnit.NANOSECONDS.toMillis(cellInfo.getTimeStamp());
    long cellTimestamp = currentTime - cellInfoAge;
    if (cellInfo instanceof CellInfoCdma) {
        CellIdentityCdma cellIdentityCdma = ((CellInfoCdma) cellInfo).getCellIdentity();
        return VisibleCell.builder(VisibleCell.CDMA_RADIO_TYPE)
                .setCellId(cellIdentityCdma.getBasestationId())
                .setLocationAreaCode(cellIdentityCdma.getNetworkId())
                .setMobileNetworkCode(cellIdentityCdma.getSystemId())
                .setTimestamp(cellTimestamp)
                .build();
    }
    if (cellInfo instanceof CellInfoGsm) {
        CellIdentityGsm cellIdentityGsm = ((CellInfoGsm) cellInfo).getCellIdentity();
        return VisibleCell.builder(VisibleCell.GSM_RADIO_TYPE)
                .setCellId(cellIdentityGsm.getCid())
                .setLocationAreaCode(cellIdentityGsm.getLac())
                .setMobileCountryCode(cellIdentityGsm.getMcc())
                .setMobileNetworkCode(cellIdentityGsm.getMnc())
                .setTimestamp(cellTimestamp)
                .build();
    }
    if (cellInfo instanceof CellInfoLte) {
        CellIdentityLte cellIdLte = ((CellInfoLte) cellInfo).getCellIdentity();
        return VisibleCell.builder(VisibleCell.LTE_RADIO_TYPE)
                .setCellId(cellIdLte.getCi())
                .setMobileCountryCode(cellIdLte.getMcc())
                .setMobileNetworkCode(cellIdLte.getMnc())
                .setPhysicalCellId(cellIdLte.getPci())
                .setTrackingAreaCode(cellIdLte.getTac())
                .setTimestamp(cellTimestamp)
                .build();
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2
            && cellInfo instanceof CellInfoWcdma) {
        // CellInfoWcdma is only usable JB MR2 upwards.
        CellIdentityWcdma cellIdentityWcdma = ((CellInfoWcdma) cellInfo).getCellIdentity();
        return VisibleCell.builder(VisibleCell.WCDMA_RADIO_TYPE)
                .setCellId(cellIdentityWcdma.getCid())
                .setLocationAreaCode(cellIdentityWcdma.getLac())
                .setMobileCountryCode(cellIdentityWcdma.getMcc())
                .setMobileNetworkCode(cellIdentityWcdma.getMnc())
                .setPrimaryScramblingCode(cellIdentityWcdma.getPsc())
                .setTimestamp(cellTimestamp)
                .build();
    }
    return VisibleCell.UNKNOWN_VISIBLE_CELL;
}
项目:smartcells    文件:CellManager.java   
/**
 * Create a measure from current CellInfo
 *
 * @return a current measure
 */
public Measure createMeasure() {
    // Create a measure
    Measure m = new Measure();
    m.timestamp = System.currentTimeMillis();
    TelephonyManager tel = (TelephonyManager) app.getSystemService(Context.TELEPHONY_SERVICE);
    for (CellInfo ci : tel.getAllCellInfo()) {
        TowerInfo ti = new TowerInfo();
        if (ci instanceof CellInfoCdma) {
            ti.type = TowerInfo.CDMA;
            ti.id = ((CellInfoCdma) ci).getCellIdentity().getBasestationId();
            ti.psc = -1;
            ti.dbm = ((CellInfoCdma) ci).getCellSignalStrength().getDbm();
        } else if (ci instanceof CellInfoGsm) {
            ti.type = TowerInfo.GSM;
            ti.id = ((CellInfoGsm) ci).getCellIdentity().getCid();
            ti.psc = -1; // undefined for GSM
            ti.dbm = ((CellInfoGsm) ci).getCellSignalStrength().getDbm();
        } else if (ci instanceof CellInfoLte) {
            ti.type = TowerInfo.LTE;
            ti.id = ((CellInfoLte) ci).getCellIdentity().getCi();
            ti.psc = -1;
            ti.dbm = ((CellInfoLte) ci).getCellSignalStrength().getDbm();
        } else if (ci instanceof CellInfoWcdma) {
            ti.type = TowerInfo.WCDMA;
            ti.id = ((CellInfoWcdma) ci).getCellIdentity().getCid();
            ti.psc = ((CellInfoWcdma) ci).getCellIdentity().getPsc();
            ti.dbm = ((CellInfoWcdma) ci).getCellSignalStrength().getDbm();
        }
        m.towerInfos.add(ti);
    }
    return m;
}
项目:PhoneProfilesPlus    文件:PhoneStateScanner.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void getAllCellInfo(List<CellInfo> cellInfo) {
    // only for registered cells is returned identify
    // SlimKat in Galaxy Nexus - returns null :-/
    // Honor 7 - returns empty list (not null), Dual SIM?

    if (cellInfo!=null) {

        if (Permissions.checkLocation(context.getApplicationContext())) {

            //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "---- start ----------------------------");

            for (CellInfo _cellInfo : cellInfo) {
                //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "registered="+_cellInfo.isRegistered());

                if (_cellInfo instanceof CellInfoGsm) {
                    //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm info="+_cellInfo);
                    CellIdentityGsm identityGsm = ((CellInfoGsm) _cellInfo).getCellIdentity();
                    if (identityGsm.getCid() != Integer.MAX_VALUE) {
                        //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm mCid="+identityGsm.getCid());
                        if (_cellInfo.isRegistered()) {
                            registeredCell = identityGsm.getCid();
                            lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                        }
                    }
                } else if (_cellInfo instanceof CellInfoLte) {
                    //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte info="+_cellInfo);
                    CellIdentityLte identityLte = ((CellInfoLte) _cellInfo).getCellIdentity();
                    if (identityLte.getCi() != Integer.MAX_VALUE) {
                        //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte mCi="+identityLte.getCi());
                        if (_cellInfo.isRegistered()) {
                            registeredCell = identityLte.getCi();
                            lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                        }
                    }
                } else if (_cellInfo instanceof CellInfoWcdma) {
                    //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma info="+_cellInfo);
                    //if (android.os.Build.VERSION.SDK_INT >= 18) {
                        CellIdentityWcdma identityWcdma = ((CellInfoWcdma) _cellInfo).getCellIdentity();
                        if (identityWcdma.getCid() != Integer.MAX_VALUE) {
                            //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid=" + identityWcdma.getCid());
                            if (_cellInfo.isRegistered()) {
                                registeredCell = identityWcdma.getCid();
                                lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                            }
                        }
                    //}
                    //else {
                    //    PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid=not supported for API level < 18");
                    //}
                } else if (_cellInfo instanceof CellInfoCdma) {
                    //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cdma info="+_cellInfo);
                    CellIdentityCdma identityCdma = ((CellInfoCdma) _cellInfo).getCellIdentity();
                    if (identityCdma.getBasestationId() != Integer.MAX_VALUE) {
                        //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid="+identityCdma.getBasestationId());
                        if (_cellInfo.isRegistered()) {
                            registeredCell = identityCdma.getBasestationId();
                            lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                        }
                    }
                }
                //else {
                //    PPApplication.logE("PhoneStateScanner.getAllCellInfo", "unknown info="+_cellInfo);
                //}
            }

            //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "---- end ----------------------------");

            PPApplication.logE("PhoneStateScanner.getAllCellInfo", "registeredCell=" + registeredCell);
        }

    }
    else
        PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cell info is null");
}
项目:myinfos    文件:CellDataFactory.java   
public static CellData parseData(CellInfo cellInfo) {
    if (cellInfo instanceof CellInfoGsm) {
        return parseCellGsm((CellInfoGsm) cellInfo);
    } else if (cellInfo instanceof CellInfoCdma) {
        return parseCellCdma((CellInfoCdma) cellInfo);
    } else if (cellInfo instanceof CellInfoWcdma) {
        return parseCellWcdma((CellInfoWcdma) cellInfo);
    } else if (cellInfo instanceof CellInfoLte) {
        return parseCellLte((CellInfoLte) cellInfo);
    } else {
        return null;
    }
}
项目:myinfos    文件:CellDataFactory.java   
private static CellData parseCellCdma(CellInfoCdma cellInfo) {
    CellData cellData = new CellData(CellData.Type.CDMA);
    cellData.dbm = cellInfo.getCellSignalStrength().getDbm();
    cellData.code = String.format(Locale.US, "%d-%d-%d",
            cellInfo.getCellIdentity().getNetworkId(),
            cellInfo.getCellIdentity().getSystemId(),
            cellInfo.getCellIdentity().getBasestationId());
    cellData.latitude = CellUtility.parsePosition(cellInfo.getCellIdentity().getLatitude());
    cellData.longitude = CellUtility.parsePosition(cellInfo.getCellIdentity().getLongitude());
    return cellData;
}
项目:Simplicissimus    文件:CellId.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static void fill(TheDictionary map, CellInfo value) throws Exception {
    if (value != null) {
        map.put("time_stamp", value.getTimeStamp());
        map.put("registered", value.isRegistered());
        if (value instanceof CellInfoCdma) {
            fill(map, ((CellInfoCdma)value).getCellIdentity());
            fill(map, ((CellInfoCdma)value).getCellSignalStrength());
        }
        else if (value instanceof CellInfoGsm) {
            fill(map, ((CellInfoGsm)value).getCellIdentity());
            fill(map, ((CellInfoGsm)value).getCellSignalStrength());
        }
        else if (value instanceof CellInfoWcdma) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                fill(map, ((CellInfoWcdma)value).getCellIdentity());
                fill(map, ((CellInfoWcdma)value).getCellSignalStrength());
            }
        }
        else if (value instanceof CellInfoLte) {
            fill(map, ((CellInfoLte)value).getCellIdentity());
            fill(map, ((CellInfoLte)value).getCellSignalStrength());
        }
        else {
            map.put("class", value.getClass().getName());
            map.put("string", value.toString());
        }
    }
}
项目:pyneo-wirelesslocation    文件:CellId.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static void fill(TheDictionary map, CellInfo value) throws Exception {
    if (value != null) {
        map.put("time_stamp", value.getTimeStamp());
        map.put("registered", value.isRegistered());
        if (value instanceof CellInfoCdma) {
            fill(map, ((CellInfoCdma)value).getCellIdentity());
            fill(map, ((CellInfoCdma)value).getCellSignalStrength());
        }
        else if (value instanceof CellInfoGsm) {
            fill(map, ((CellInfoGsm)value).getCellIdentity());
            fill(map, ((CellInfoGsm)value).getCellSignalStrength());
        }
        else if (value instanceof CellInfoWcdma) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                fill(map, ((CellInfoWcdma)value).getCellIdentity());
                fill(map, ((CellInfoWcdma)value).getCellSignalStrength());
            }
        }
        else if (value instanceof CellInfoLte) {
            fill(map, ((CellInfoLte)value).getCellIdentity());
            fill(map, ((CellInfoLte)value).getCellSignalStrength());
        }
        else {
            map.put("class", value.getClass().getName());
            map.put("string", value.toString());
        }
    }
}
项目:satstat    文件:CellTowerListCdma.java   
/**
 * Adds or updates a list of cell towers.
 * <p>
 * This method first calls {@link #removeSource(int)} with
 * {@link com.vonglasow.michael.satstat.data.CellTower#SOURCE_CELL_INFO} as
 * its argument. Then it iterates through all entries in {@code cells} and
 * updates each entry that is of type {@link android.telephony.CellInfoCdma}
 * by calling {@link #update(CellInfoCdma)}, passing that entry as the
 * argument.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void updateAll(List<CellInfo> cells) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) 
        return;
    this.removeSource(CellTower.SOURCE_CELL_INFO);
    if (cells == null)
        return;
    for (CellInfo cell : cells)
        if (cell instanceof CellInfoCdma)
            this.update((CellInfoCdma) cell);
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Converts CellInfoCdma into JSON
 * @param cellInfo CellInfoCdma
 * @return JSON
 */
public static String cellInfoCDMAJSON(CellInfoCdma cellInfo, boolean returnSignalStrength){

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo != null) {
        try {
            json.put("provider", CELLINFO_PROVIDER);
            json.put("type", CDMA);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityCdma identityCdma = cellInfo.getCellIdentity();

            json.put("latitude", CdmaCellLocation.convertQuartSecToDecDegrees(identityCdma.getLatitude()));
            json.put("longitude", CdmaCellLocation.convertQuartSecToDecDegrees(identityCdma.getLongitude()));
            json.put("basestationId", identityCdma.getBasestationId());
            json.put("networkId", identityCdma.getNetworkId());
            json.put("systemId", identityCdma.getSystemId());

            if (returnSignalStrength){
                final JSONObject jsonSignalStrength = new JSONObject();
                final CellSignalStrengthCdma cellSignalStrengthCdma = cellInfo.getCellSignalStrength();
                jsonSignalStrength.put("asuLevel", cellSignalStrengthCdma.getAsuLevel());
                jsonSignalStrength.put("cdmaDbm", cellSignalStrengthCdma.getCdmaDbm());
                jsonSignalStrength.put("cdmaEcio", cellSignalStrengthCdma.getCdmaEcio());
                jsonSignalStrength.put("cdmaLevel", cellSignalStrengthCdma.getCdmaLevel());
                jsonSignalStrength.put("dbm", cellSignalStrengthCdma.getDbm());
                jsonSignalStrength.put("evdoDbm", cellSignalStrengthCdma.getEvdoDbm());
                jsonSignalStrength.put("evdoEcio", cellSignalStrengthCdma.getEvdoEcio());
                jsonSignalStrength.put("evdoLevel", cellSignalStrengthCdma.getEvdoLevel());
                jsonSignalStrength.put("evdoSnr", cellSignalStrengthCdma.getEvdoSnr());
                jsonSignalStrength.put("level", cellSignalStrengthCdma.getLevel());

                json.put("cellSignalStrengthCdma", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Converts CellInfoCdma into JSON
 * @param cellInfo CellInfoCdma
 * @return JSON
 */
public static String cellInfoCDMAJSON(CellInfoCdma cellInfo, boolean returnSignalStrength){

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo != null) {
        try {
            json.put("provider", CELLINFO_PROVIDER);
            json.put("type", CDMA);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityCdma identityCdma = cellInfo.getCellIdentity();

            json.put("latitude", CdmaCellLocation.convertQuartSecToDecDegrees(identityCdma.getLatitude()));
            json.put("longitude", CdmaCellLocation.convertQuartSecToDecDegrees(identityCdma.getLongitude()));
            json.put("basestationId", identityCdma.getBasestationId());
            json.put("networkId", identityCdma.getNetworkId());
            json.put("systemId", identityCdma.getSystemId());

            if (returnSignalStrength){
                final JSONObject jsonSignalStrength = new JSONObject();
                final CellSignalStrengthCdma cellSignalStrengthCdma = cellInfo.getCellSignalStrength();
                jsonSignalStrength.put("asuLevel", cellSignalStrengthCdma.getAsuLevel());
                jsonSignalStrength.put("cdmaDbm", cellSignalStrengthCdma.getCdmaDbm());
                jsonSignalStrength.put("cdmaEcio", cellSignalStrengthCdma.getCdmaEcio());
                jsonSignalStrength.put("cdmaLevel", cellSignalStrengthCdma.getCdmaLevel());
                jsonSignalStrength.put("dbm", cellSignalStrengthCdma.getDbm());
                jsonSignalStrength.put("evdoDbm", cellSignalStrengthCdma.getEvdoDbm());
                jsonSignalStrength.put("evdoEcio", cellSignalStrengthCdma.getEvdoEcio());
                jsonSignalStrength.put("evdoLevel", cellSignalStrengthCdma.getEvdoLevel());
                jsonSignalStrength.put("evdoSnr", cellSignalStrengthCdma.getEvdoSnr());
                jsonSignalStrength.put("level", cellSignalStrengthCdma.getLevel());

                json.put("cellSignalStrengthCdma", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Converts CellInfoCdma into JSON
 * @param cellInfo CellInfoCdma
 * @return JSON
 */
public static String cellInfoCDMAJSON(CellInfoCdma cellInfo, boolean returnSignalStrength){

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo != null) {
        try {
            json.put("provider", CELLINFO_PROVIDER);
            json.put("type", CDMA);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityCdma identityCdma = cellInfo.getCellIdentity();

            json.put("latitude", CdmaCellLocation.convertQuartSecToDecDegrees(identityCdma.getLatitude()));
            json.put("longitude", CdmaCellLocation.convertQuartSecToDecDegrees(identityCdma.getLongitude()));
            json.put("basestationId", identityCdma.getBasestationId());
            json.put("networkId", identityCdma.getNetworkId());
            json.put("systemId", identityCdma.getSystemId());

            if (returnSignalStrength){
                final JSONObject jsonSignalStrength = new JSONObject();
                final CellSignalStrengthCdma cellSignalStrengthCdma = cellInfo.getCellSignalStrength();
                jsonSignalStrength.put("asuLevel", cellSignalStrengthCdma.getAsuLevel());
                jsonSignalStrength.put("cdmaDbm", cellSignalStrengthCdma.getCdmaDbm());
                jsonSignalStrength.put("cdmaEcio", cellSignalStrengthCdma.getCdmaEcio());
                jsonSignalStrength.put("cdmaLevel", cellSignalStrengthCdma.getCdmaLevel());
                jsonSignalStrength.put("dbm", cellSignalStrengthCdma.getDbm());
                jsonSignalStrength.put("evdoDbm", cellSignalStrengthCdma.getEvdoDbm());
                jsonSignalStrength.put("evdoEcio", cellSignalStrengthCdma.getEvdoEcio());
                jsonSignalStrength.put("evdoLevel", cellSignalStrengthCdma.getEvdoLevel());
                jsonSignalStrength.put("evdoSnr", cellSignalStrengthCdma.getEvdoSnr());
                jsonSignalStrength.put("level", cellSignalStrengthCdma.getLevel());

                json.put("cellSignalStrengthCdma", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
项目:cordova-plugin-advanced-geolocation    文件:JSONHelper.java   
/**
 * Converts CellInfoCdma into JSON
 * @param cellInfo CellInfoCdma
 * @return JSON
 */
public static String cellInfoCDMAJSON(CellInfoCdma cellInfo, boolean returnSignalStrength){

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo != null) {
        try {
            json.put("provider", CELLINFO_PROVIDER);
            json.put("type", CDMA);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityCdma identityCdma = cellInfo.getCellIdentity();

            json.put("latitude", CdmaCellLocation.convertQuartSecToDecDegrees(identityCdma.getLatitude()));
            json.put("longitude", CdmaCellLocation.convertQuartSecToDecDegrees(identityCdma.getLongitude()));
            json.put("basestationId", identityCdma.getBasestationId());
            json.put("networkId", identityCdma.getNetworkId());
            json.put("systemId", identityCdma.getSystemId());

            if (returnSignalStrength){
                final JSONObject jsonSignalStrength = new JSONObject();
                final CellSignalStrengthCdma cellSignalStrengthCdma = cellInfo.getCellSignalStrength();
                jsonSignalStrength.put("asuLevel", cellSignalStrengthCdma.getAsuLevel());
                jsonSignalStrength.put("cdmaDbm", cellSignalStrengthCdma.getCdmaDbm());
                jsonSignalStrength.put("cdmaEcio", cellSignalStrengthCdma.getCdmaEcio());
                jsonSignalStrength.put("cdmaLevel", cellSignalStrengthCdma.getCdmaLevel());
                jsonSignalStrength.put("dbm", cellSignalStrengthCdma.getDbm());
                jsonSignalStrength.put("evdoDbm", cellSignalStrengthCdma.getEvdoDbm());
                jsonSignalStrength.put("evdoEcio", cellSignalStrengthCdma.getEvdoEcio());
                jsonSignalStrength.put("evdoLevel", cellSignalStrengthCdma.getEvdoLevel());
                jsonSignalStrength.put("evdoSnr", cellSignalStrengthCdma.getEvdoSnr());
                jsonSignalStrength.put("level", cellSignalStrengthCdma.getLevel());

                json.put("cellSignalStrengthCdma", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
项目:truth-android    文件:CellInfoCdmaSubject.java   
private CellInfoCdmaSubject(FailureStrategy failureStrategy, CellInfoCdma subject) {
  super(failureStrategy, subject);
}
项目:CellularSignal    文件:RadioInfo.java   
@Override
public void onCellInfoChanged(List<CellInfo> cellInfoList) {
    super.onCellInfoChanged(cellInfoList);


    if (cellInfoList == null) {
        //Log.e(Tag,"onCellInfoChanged is null");
        return;
    }

    //Log.e(Tag,"onCellInfoChanged size "+cellInfoList.size());

    for (CellInfo cellInfo : cellInfoList) {

        if (!cellInfo.isRegistered())
            continue;

        if (cellInfo instanceof CellInfoLte) {

            CellInfoLte lteinfo = (CellInfoLte) cellInfo;

            lte_MCC = lteinfo.getCellIdentity().getMcc();
            lte_MNC = lteinfo.getCellIdentity().getMnc();
            lte_CI = lteinfo.getCellIdentity().getCi();
            lte_PCI = lteinfo.getCellIdentity().getPci();
            lte_TAC = lteinfo.getCellIdentity().getTac();
            //Log.e(Tag,lteinfo.toString());

        } else if (cellInfo instanceof CellInfoCdma) {

            CellInfoCdma cdmainfo = (CellInfoCdma) cellInfo;

            cdma_SID = cdmainfo.getCellIdentity().getSystemId();
            cdma_NID = cdmainfo.getCellIdentity().getNetworkId();
            cdma_BSID = cdmainfo.getCellIdentity().getBasestationId();

            //Log.e(Tag,cdmainfo.toString());
        } else if (cellInfo instanceof CellInfoGsm) {
            CellInfoGsm gsmInfo = (CellInfoGsm) cellInfo;

            gsm_MCC = gsmInfo.getCellIdentity().getMcc();
            gsm_MNC = gsmInfo.getCellIdentity().getMnc();
            gsm_CID = gsmInfo.getCellIdentity().getCid();
            gsm_LAC = gsmInfo.getCellIdentity().getLac();

        } else if (cellInfo instanceof CellInfoWcdma) {
            CellInfoWcdma wcdmaInfo = (CellInfoWcdma) cellInfo;

            wcdma_MCC = wcdmaInfo.getCellIdentity().getMcc();
            wcdma_MNC = wcdmaInfo.getCellIdentity().getMnc();
            wcdma_CID = wcdmaInfo.getCellIdentity().getCid();
            wcdma_LAC = wcdmaInfo.getCellIdentity().getLac();
            wcdma_PSC = wcdmaInfo.getCellIdentity().getPsc();
        }
    }

    ((MainActivity)mcontext).mSectionsPagerAdapter.notifyDataSetChanged();
}
项目:CellularSignal    文件:RadioInfo.java   
private void getCellIdentity() {
    List<CellInfo> cellInfoList = mTM.getAllCellInfo();

    if (cellInfoList == null) {
        //Log.e(Tag,"getAllCellInfo is null");
        return;
    }
    //Log.e(Tag,"getAllCellInfo size "+cellInfoList.size());

    for (CellInfo cellInfo : cellInfoList) {

        if (!cellInfo.isRegistered())
            continue;

        if (cellInfo instanceof CellInfoLte) {

            CellInfoLte lteinfo = (CellInfoLte) cellInfo;

            lte_MCC = lteinfo.getCellIdentity().getMcc();
            lte_MNC = lteinfo.getCellIdentity().getMnc();
            lte_CI = lteinfo.getCellIdentity().getCi();
            lte_PCI = lteinfo.getCellIdentity().getPci();
            lte_TAC = lteinfo.getCellIdentity().getTac();
            //Log.e(Tag,lteinfo.toString());

        } else if (cellInfo instanceof CellInfoCdma) {

            CellInfoCdma cdmainfo = (CellInfoCdma) cellInfo;

            cdma_SID = cdmainfo.getCellIdentity().getSystemId();
            cdma_NID = cdmainfo.getCellIdentity().getNetworkId();
            cdma_BSID = cdmainfo.getCellIdentity().getBasestationId();

            //Log.e(Tag,cdmainfo.toString());
        } else if (cellInfo instanceof CellInfoGsm) {
            CellInfoGsm gsmInfo = (CellInfoGsm) cellInfo;

            gsm_MCC = gsmInfo.getCellIdentity().getMcc();
            gsm_MNC = gsmInfo.getCellIdentity().getMnc();
            gsm_CID = gsmInfo.getCellIdentity().getCid();
            gsm_LAC = gsmInfo.getCellIdentity().getLac();

        } else if (cellInfo instanceof CellInfoWcdma) {
            CellInfoWcdma wcdmaInfo = (CellInfoWcdma) cellInfo;

            wcdma_MCC = wcdmaInfo.getCellIdentity().getMcc();
            wcdma_MNC = wcdmaInfo.getCellIdentity().getMnc();
            wcdma_CID = wcdmaInfo.getCellIdentity().getCid();
            wcdma_LAC = wcdmaInfo.getCellIdentity().getLac();
            wcdma_PSC = wcdmaInfo.getCellIdentity().getPsc();
        }
    }
}
项目:assertj-android    文件:CellInfoCdmaAssert.java   
public CellInfoCdmaAssert(CellInfoCdma actual) {
  super(actual, CellInfoCdmaAssert.class);
}