Java 类android.telephony.CellSignalStrengthGsm 实例源码

项目: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);
    }
}
项目: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;
    }
}
项目:open-rmbt    文件:CellInformationWrapper.java   
public CellSignalStrength(CellSignalStrengthGsm ss) {
    setSignal(ss.getDbm());
    String desc = ss.toString();
    setSignal(ss.getDbm());
    setBitErrorRate(getSignalStrengthValueFromDescriptionString(desc, "ber"));
    setTimingAdvance(getSignalStrengthValueFromDescriptionString(desc, "mTa"));
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Converts CellInfoGsm into JSON
 * @param cellInfo CellInfoGsm
 * @return JSON
 */
public static String cellInfoGSMJSON(CellInfoGsm 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", GSM);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityGsm identityGsm = cellInfo.getCellIdentity();

            json.put("cid", identityGsm.getCid());
            json.put("lac", identityGsm.getLac());
            json.put("mcc", identityGsm.getMcc());
            json.put("mnc", identityGsm.getMnc());

            if (returnSignalStrength){
                final JSONObject jsonSignalStrength = new JSONObject();
                final CellSignalStrengthGsm cellSignalStrengthGsm = cellInfo.getCellSignalStrength();
                jsonSignalStrength.put("asuLevel", cellSignalStrengthGsm.getAsuLevel());
                jsonSignalStrength.put("dbm", cellSignalStrengthGsm.getDbm());
                jsonSignalStrength.put("level", cellSignalStrengthGsm.getLevel());

                json.put("cellSignalStrengthGsm", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }
    return json.toString();
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Converts CellInfoGsm into JSON
 * @param cellInfo CellInfoGsm
 * @return JSON
 */
public static String cellInfoGSMJSON(CellInfoGsm 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", GSM);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityGsm identityGsm = cellInfo.getCellIdentity();

            json.put("cid", identityGsm.getCid());
            json.put("lac", identityGsm.getLac());
            json.put("mcc", identityGsm.getMcc());
            json.put("mnc", identityGsm.getMnc());

            if (returnSignalStrength){
                final JSONObject jsonSignalStrength = new JSONObject();
                final CellSignalStrengthGsm cellSignalStrengthGsm = cellInfo.getCellSignalStrength();
                jsonSignalStrength.put("asuLevel", cellSignalStrengthGsm.getAsuLevel());
                jsonSignalStrength.put("dbm", cellSignalStrengthGsm.getDbm());
                jsonSignalStrength.put("level", cellSignalStrengthGsm.getLevel());

                json.put("cellSignalStrengthGsm", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }
    return json.toString();
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Converts CellInfoGsm into JSON
 * @param cellInfo CellInfoGsm
 * @return JSON
 */
public static String cellInfoGSMJSON(CellInfoGsm 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", GSM);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityGsm identityGsm = cellInfo.getCellIdentity();

            json.put("cid", identityGsm.getCid());
            json.put("lac", identityGsm.getLac());
            json.put("mcc", identityGsm.getMcc());
            json.put("mnc", identityGsm.getMnc());

            if (returnSignalStrength){
                final JSONObject jsonSignalStrength = new JSONObject();
                final CellSignalStrengthGsm cellSignalStrengthGsm = cellInfo.getCellSignalStrength();
                jsonSignalStrength.put("asuLevel", cellSignalStrengthGsm.getAsuLevel());
                jsonSignalStrength.put("dbm", cellSignalStrengthGsm.getDbm());
                jsonSignalStrength.put("level", cellSignalStrengthGsm.getLevel());

                json.put("cellSignalStrengthGsm", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }
    return json.toString();
}
项目:cordova-plugin-advanced-geolocation    文件:JSONHelper.java   
/**
 * Converts CellInfoGsm into JSON
 * @param cellInfo CellInfoGsm
 * @return JSON
 */
public static String cellInfoGSMJSON(CellInfoGsm 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", GSM);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityGsm identityGsm = cellInfo.getCellIdentity();

            json.put("cid", identityGsm.getCid());
            json.put("lac", identityGsm.getLac());
            json.put("mcc", identityGsm.getMcc());
            json.put("mnc", identityGsm.getMnc());

            if (returnSignalStrength){
                final JSONObject jsonSignalStrength = new JSONObject();
                final CellSignalStrengthGsm cellSignalStrengthGsm = cellInfo.getCellSignalStrength();
                jsonSignalStrength.put("asuLevel", cellSignalStrengthGsm.getAsuLevel());
                jsonSignalStrength.put("dbm", cellSignalStrengthGsm.getDbm());
                jsonSignalStrength.put("level", cellSignalStrengthGsm.getLevel());

                json.put("cellSignalStrengthGsm", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }
    return json.toString();
}
项目:truth-android    文件:CellSignalStrengthGsmSubject.java   
public static SubjectFactory<CellSignalStrengthGsmSubject, CellSignalStrengthGsm> type() {
  return new SubjectFactory<CellSignalStrengthGsmSubject, CellSignalStrengthGsm>() {
    @Override
    public CellSignalStrengthGsmSubject getSubject(FailureStrategy fs, CellSignalStrengthGsm that) {
      return new CellSignalStrengthGsmSubject(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);
    }
}
项目:tabulae    文件:CellId.java   
public static void fill(TheDictionary map, CellSignalStrengthGsm value) throws Exception {
    if (value != null) {
        int i;
        i = value.getAsuLevel();
        if (i != 99) map.put("asu_level", i);
        map.put("dbm", value.getDbm());
        map.put("level", value.getLevel());
    }
}
项目:Simplicissimus    文件:CellId.java   
public static void fill(TheDictionary map, CellSignalStrengthGsm value) throws Exception {
    if (value != null) {
        int i;
        i = value.getAsuLevel(); if (i != 99) map.put("asu_level", i);
        map.put("dbm", value.getDbm());
        map.put("level", value.getLevel());
    }
}
项目:pyneo-wirelesslocation    文件:CellId.java   
public static void fill(TheDictionary map, CellSignalStrengthGsm value) throws Exception {
    if (value != null) {
        int i;
        i = value.getAsuLevel(); if (i != 99) map.put("asu_level", i);
        map.put("dbm", value.getDbm());
        map.put("level", value.getLevel());
    }
}
项目:assertj-android    文件:CellInfoGsmAssert.java   
public CellInfoGsmAssert hasCellSignalStrength(CellSignalStrengthGsm cellSignalStrength) {
  isNotNull();
  CellSignalStrengthGsm actualCellSignalStrength = actual.getCellSignalStrength();
  assertThat(actualCellSignalStrength) //
      .overridingErrorMessage("Expected cell signal strength <%s> but was <%s>.", cellSignalStrength, actualCellSignalStrength) //
      .isEqualTo(cellSignalStrength);
  return this;
}
项目:truth-android    文件:CellInfoGsmSubject.java   
public CellInfoGsmSubject hasCellSignalStrength(CellSignalStrengthGsm cellSignalStrength) {
  assertThat(actual().getCellSignalStrength())
      .named("cell signal strength")
      .isEqualTo(cellSignalStrength);
  return this;
}
项目:truth-android    文件:CellSignalStrengthGsmSubject.java   
private CellSignalStrengthGsmSubject(FailureStrategy failureStrategy, CellSignalStrengthGsm subject) {
  super(failureStrategy, subject);
}
项目:spidey    文件:ScanService.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void startScan() {

    logMessage("starting tower scan... ");
    Scan scan = new Scan();

    // TODO: Get location from user?
    scan.setLocation(lastScanName);

    // TODO: use actual GPS Coordinates
    scan.setLatitude(lastScanLat);
    scan.setLongitude(lastScanLon);

    long scan_id = db.createScan(scan);

    List<CellInfo> cellInfos = (List<CellInfo>) this.telephonyManager
            .getAllCellInfo();

    // TODO: better error handling of null cellinfos
    if (cellInfos != null) {
        for (CellInfo cellInfo : cellInfos) {

            if (cellInfo instanceof CellInfoGsm) {
                CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;

                CellIdentityGsm cellIdentity = cellInfoGsm
                        .getCellIdentity();
                CellSignalStrengthGsm cellSignalStrengthGsm = cellInfoGsm
                        .getCellSignalStrength();

                int dbmLevel = cellSignalStrengthGsm.getDbm();

                com.spideyapp.sqlite.model.CellInfo cell = new com.spideyapp.sqlite.model.CellInfo(
                        cellIdentity.getCid(), cellIdentity.getLac(),
                        cellIdentity.getMcc(), cellIdentity.getMnc(),dbmLevel);

                db.createCell(cell, scan_id);

                shareCellInfo (cell);

            }
        }
    }

}
项目:assertj-android    文件:CellSignalStrengthGsmAssert.java   
public CellSignalStrengthGsmAssert(CellSignalStrengthGsm actual) {
  super(actual, CellSignalStrengthGsmAssert.class);
}