java类android.telephony.CellSignalStrengthWcdma的实例源码

DeviceApi18.java 文件源码 项目:AIMSICDL 阅读 24 收藏 0 点赞 0 评论 0
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);
    }
}
JSONHelper.java 文件源码 项目:localcloud_fe 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Converts CellInfoWcdma into JSON
 * Some devices may not work correctly:
 * - Reference 1: https://code.google.com/p/android/issues/detail?id=191492
 * - Reference 2: http://stackoverflow.com/questions/17815062/cellidentitygsm-on-android
 * @param cellInfo CellInfoWcdma
 * @return JSON
 */
public static String cellInfoWCDMAJSON(CellInfoWcdma 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", WCDMA);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityWcdma identityWcdma = cellInfo.getCellIdentity();

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

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

                json.put("cellSignalStrengthWcdma", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }
    return json.toString();
}
JSONHelper.java 文件源码 项目:localcloud_fe 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Converts CellInfoWcdma into JSON
 * Some devices may not work correctly:
 * - Reference 1: https://code.google.com/p/android/issues/detail?id=191492
 * - Reference 2: http://stackoverflow.com/questions/17815062/cellidentitygsm-on-android
 * @param cellInfo CellInfoWcdma
 * @return JSON
 */
public static String cellInfoWCDMAJSON(CellInfoWcdma 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", WCDMA);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityWcdma identityWcdma = cellInfo.getCellIdentity();

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

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

                json.put("cellSignalStrengthWcdma", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }
    return json.toString();
}
JSONHelper.java 文件源码 项目:localcloud_fe 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Converts CellInfoWcdma into JSON
 * Some devices may not work correctly:
 * - Reference 1: https://code.google.com/p/android/issues/detail?id=191492
 * - Reference 2: http://stackoverflow.com/questions/17815062/cellidentitygsm-on-android
 * @param cellInfo CellInfoWcdma
 * @return JSON
 */
public static String cellInfoWCDMAJSON(CellInfoWcdma 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", WCDMA);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityWcdma identityWcdma = cellInfo.getCellIdentity();

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

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

                json.put("cellSignalStrengthWcdma", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }
    return json.toString();
}
JSONHelper.java 文件源码 项目:cordova-plugin-advanced-geolocation 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Converts CellInfoWcdma into JSON
 * Some devices may not work correctly:
 * - Reference 1: https://code.google.com/p/android/issues/detail?id=191492
 * - Reference 2: http://stackoverflow.com/questions/17815062/cellidentitygsm-on-android
 * @param cellInfo CellInfoWcdma
 * @return JSON
 */
public static String cellInfoWCDMAJSON(CellInfoWcdma 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", WCDMA);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityWcdma identityWcdma = cellInfo.getCellIdentity();

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

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

                json.put("cellSignalStrengthWcdma", jsonSignalStrength);
            }
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }
    return json.toString();
}
CellSignalStrengthWcdmaSubject.java 文件源码 项目:truth-android 阅读 20 收藏 0 点赞 0 评论 0
public static SubjectFactory<CellSignalStrengthWcdmaSubject, CellSignalStrengthWcdma> type() {
  return new SubjectFactory<CellSignalStrengthWcdmaSubject, CellSignalStrengthWcdma>() {
    @Override
    public CellSignalStrengthWcdmaSubject getSubject(FailureStrategy fs, CellSignalStrengthWcdma that) {
      return new CellSignalStrengthWcdmaSubject(fs, that);
    }
  };
}
DeviceApi18.java 文件源码 项目:Android-IMSI-Catcher-Detector 阅读 22 收藏 0 点赞 0 评论 0
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);
    }
}
CellId.java 文件源码 项目:tabulae 阅读 20 收藏 0 点赞 0 评论 0
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static void fill(TheDictionary map, CellSignalStrengthWcdma 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());
    }
}
CellId.java 文件源码 项目:Simplicissimus 阅读 28 收藏 0 点赞 0 评论 0
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static void fill(TheDictionary map, CellSignalStrengthWcdma 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());
    }
}
CellId.java 文件源码 项目:pyneo-wirelesslocation 阅读 23 收藏 0 点赞 0 评论 0
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static void fill(TheDictionary map, CellSignalStrengthWcdma 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());
    }
}
CellInfoWcdmaAssert.java 文件源码 项目:assertj-android 阅读 20 收藏 0 点赞 0 评论 0
public CellInfoWcdmaAssert hasCellSignalStrength(CellSignalStrengthWcdma cellSignalStrength) {
  isNotNull();
  CellSignalStrengthWcdma actualCellSignalStrength = actual.getCellSignalStrength();
  assertThat(actualCellSignalStrength) //
      .overridingErrorMessage("Expected cell signal strength <%s> but was <%s>.", cellSignalStrength, actualCellSignalStrength) //
      .isEqualTo(cellSignalStrength);
  return this;
}
CellInformationWrapper.java 文件源码 项目:open-rmbt 阅读 23 收藏 0 点赞 0 评论 0
public CellSignalStrength(CellSignalStrengthWcdma ss) {
    setSignal(ss.getDbm());
    String desc = ss.toString();
    setSignal(ss.getDbm());
    setBitErrorRate(getSignalStrengthValueFromDescriptionString(desc, "ber"));
}
CellInfoWcdmaSubject.java 文件源码 项目:truth-android 阅读 19 收藏 0 点赞 0 评论 0
public CellInfoWcdmaSubject hasCellSignalStrength(CellSignalStrengthWcdma cellSignalStrength) {
  assertThat(actual().getCellSignalStrength())
      .named("cell signal strength")
      .isEqualTo(cellSignalStrength);
  return this;
}
CellSignalStrengthWcdmaSubject.java 文件源码 项目:truth-android 阅读 17 收藏 0 点赞 0 评论 0
private CellSignalStrengthWcdmaSubject(FailureStrategy failureStrategy, CellSignalStrengthWcdma subject) {
  super(failureStrategy, subject);
}
FirstActivity.java 文件源码 项目:Testes 阅读 30 收藏 0 点赞 0 评论 0
@SuppressLint("NewApi")
public void onSignalStrengthsChanged(CellSignalStrengthWcdma signalStrength) {
    //super.onSignalStrengthsChanged(signalStrength);

}
CellSignalStrengthWcdmaAssert.java 文件源码 项目:assertj-android 阅读 17 收藏 0 点赞 0 评论 0
public CellSignalStrengthWcdmaAssert(CellSignalStrengthWcdma actual) {
  super(actual, CellSignalStrengthWcdmaAssert.class);
}


问题


面经


文章

微信
公众号

扫码关注公众号