Java 类android.telephony.cdma.CdmaCellLocation 实例源码

项目:GitHub    文件:StrUtils.java   
public static String getIpBaseStation() {
    TelephonyManager telMgr = (TelephonyManager) FDApplication
            .getInstance().getSystemService(Context.TELEPHONY_SERVICE);
    int cid = 0;
    int lac = 0;
    try {
        if (telMgr != null) {
            GsmCellLocation gc = (GsmCellLocation) telMgr.getCellLocation();
            if (null == gc) {
                return "0_0";
            }
            cid = gc.getCid();
            lac = gc.getLac();
        }
    } catch (Exception e) {
        if (telMgr != null) {
            CdmaCellLocation location = (CdmaCellLocation) telMgr
                    .getCellLocation();
            if (null == location) {
                return "0_0";
            }
            lac = location.getNetworkId();
            cid = location.getBaseStationId();
            cid /= 16;
        }
    }
    return lac + "_" + cid;
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
 * http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
 * @param location CdmaCellLocation
 * @return JSON
 */
public static String cdmaCellLocationJSON(CdmaCellLocation location){

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && location != null) {
        try {
            json.put("provider", CELLLOCATION_PROVIDER);
            json.put("type", CDMA);
            json.put("timestamp", calendar.getTimeInMillis());
            json.put("baseStationId", location.getBaseStationId()); // -1 if unknown
            json.put("networkId", location.getNetworkId()); // -1 if unknown
            json.put("systemId", location.getSystemId()); // -1 if unknown
            json.put("baseStationLatitude", CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLatitude()));
            json.put("baseStationLongitude", CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLongitude()));
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
 * http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
 * @param location CdmaCellLocation
 * @return JSON
 */
public static String cdmaCellLocationJSON(CdmaCellLocation location){

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && location != null) {
        try {
            json.put("provider", CELLLOCATION_PROVIDER);
            json.put("type", CDMA);
            json.put("timestamp", calendar.getTimeInMillis());
            json.put("baseStationId", location.getBaseStationId()); // -1 if unknown
            json.put("networkId", location.getNetworkId()); // -1 if unknown
            json.put("systemId", location.getSystemId()); // -1 if unknown
            json.put("baseStationLatitude", CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLatitude()));
            json.put("baseStationLongitude", CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLongitude()));
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
 * http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
 * @param location CdmaCellLocation
 * @return JSON
 */
public static String cdmaCellLocationJSON(CdmaCellLocation location){

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && location != null) {
        try {
            json.put("provider", CELLLOCATION_PROVIDER);
            json.put("type", CDMA);
            json.put("timestamp", calendar.getTimeInMillis());
            json.put("baseStationId", location.getBaseStationId()); // -1 if unknown
            json.put("networkId", location.getNetworkId()); // -1 if unknown
            json.put("systemId", location.getSystemId()); // -1 if unknown
            json.put("baseStationLatitude", CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLatitude()));
            json.put("baseStationLongitude", CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLongitude()));
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
项目:cordova-plugin-advanced-geolocation    文件:JSONHelper.java   
/**
 * Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
 * http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
 * @param location CdmaCellLocation
 * @return JSON
 */
public static String cdmaCellLocationJSON(CdmaCellLocation location){

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && location != null) {
        try {
            json.put("provider", CELLLOCATION_PROVIDER);
            json.put("type", CDMA);
            json.put("timestamp", calendar.getTimeInMillis());
            json.put("baseStationId", location.getBaseStationId()); // -1 if unknown
            json.put("networkId", location.getNetworkId()); // -1 if unknown
            json.put("systemId", location.getSystemId()); // -1 if unknown
            json.put("baseStationLatitude", CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLatitude()));
            json.put("baseStationLongitude", CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLongitude()));
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
项目:TowerCollector    文件:MeasurementUpdater.java   
private boolean isCellLocationEqual(CellLocation cl1, CellLocation cl2) {
    boolean result;
    if (cl1 instanceof GsmCellLocation && cl2 instanceof GsmCellLocation) {
        GsmCellLocation gsm1 = (GsmCellLocation) cl1;
        GsmCellLocation gsm2 = (GsmCellLocation) cl2;
        result = (gsm1.getCid() == gsm2.getCid()
                && gsm1.getLac() == gsm2.getLac()
                && gsm1.getPsc() == gsm2.getPsc());
        Log.d("isCellLocationEqual(): GSM equals = %s", result);
    } else if (cl1 instanceof CdmaCellLocation && cl2 instanceof CdmaCellLocation) {
        CdmaCellLocation cdma1 = (CdmaCellLocation) cl1;
        CdmaCellLocation cdma2 = (CdmaCellLocation) cl2;
        result = (cdma1.getBaseStationId() == cdma2.getBaseStationId()
                && cdma1.getNetworkId() == cdma2.getNetworkId()
                && cdma1.getSystemId() == cdma2.getSystemId());
        Log.d("isCellLocationEqual(): CDMA equal = %s", result);
    } else {
        // different types or nulls
        result = false;
        Log.d("isCellLocationEqual(): Different types or nulls");
    }
    return result;
}
项目:TowerCollector    文件:CellLocationConverter.java   
public void update(Measurement m, CellLocation cellLocation, int mcc, int mnc, NetworkGroup networkType) {
    if (cellLocation instanceof GsmCellLocation) {
        GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation;
        if (gsmCellLocation.getCid() <= 65535 && gsmCellLocation.getPsc() == NeighboringCellInfo.UNKNOWN_CID) {
            m.setGsmCellLocation(mcc, mnc, gsmCellLocation.getLac(), gsmCellLocation.getCid(), NetworkGroup.Gsm);
        } else {
            // fix invalid network types (unfortunately not possible to distinguish between UMTS and LTE)
            if (networkType == NetworkGroup.Gsm || networkType == NetworkGroup.Cdma)
                networkType = NetworkGroup.Unknown;
            int psc = gsmCellLocation.getPsc();
            if (psc == NeighboringCellInfo.UNKNOWN_CID || psc == Measurement.UNKNOWN_CID) {
                psc = Measurement.UNKNOWN_CID;
            } else if (psc >= 504) {
                // only UMTS networks support larger PSC
                networkType = NetworkGroup.Wcdma;
            }
            m.setGsmCellLocation(mcc, mnc, gsmCellLocation.getLac(), gsmCellLocation.getCid(), psc, networkType);
        }
    } else if (cellLocation instanceof CdmaCellLocation) {
        CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation;
        m.setCdmaCellLocation(cdmaCellLocation.getSystemId(), cdmaCellLocation.getNetworkId(), cdmaCellLocation.getBaseStationId());
    } else {
        throw new UnsupportedOperationException("Cell location type not supported `" + cellLocation.getClass().getName() + "`");
    }
}
项目:Easer    文件:CellLocationSingleData.java   
static CellLocationSingleData fromCellLocation(CellLocation location) {
    int cid, lac;
    if (location != null) {
        if (location instanceof GsmCellLocation) {
            cid = ((GsmCellLocation) location).getCid();
            lac = ((GsmCellLocation) location).getLac();
        }
        else if (location instanceof CdmaCellLocation) {
            cid = ((CdmaCellLocation) location).getBaseStationId();
            lac = ((CdmaCellLocation) location).getSystemId();
        } else {
            return null;
        }
        return new CellLocationSingleData(cid, lac);
    }
    return null;
}
项目:tabulae    文件:CellIdPre17API.java   
@Override
public TheDictionary next() {
    if (DEBUG) Log.d(TAG, "next:");
    TheDictionary map = new TheDictionary();
    try {
        if (i < 0) {
            if (cellLocation instanceof GsmCellLocation) {
                fill(map, ((GsmCellLocation) cellLocation));
            } else if (cellLocation instanceof CdmaCellLocation) {
                fill(map, ((CdmaCellLocation) cellLocation));
            } else {
                map.put("class", cellLocation.getClass().getName());
                map.put("string", cellLocation.toString());
            }
        } else {
            fill(map, neighboringCellInfoList.get(i));
        }
    }
    catch (Exception e) {
        throw new RuntimeException(e);
    }
    i++;
    if (DEBUG) Log.d(TAG, "next: map=" + map);
    return map;
}
项目:MiBandDecompiled    文件:ay.java   
ay(CellLocation celllocation)
{
    a = 0x7fffffff;
    b = 0x7fffffff;
    c = 0x7fffffff;
    d = 0x7fffffff;
    e = 0x7fffffff;
    if (celllocation != null)
    {
        if (celllocation instanceof GsmCellLocation)
        {
            GsmCellLocation gsmcelllocation = (GsmCellLocation)celllocation;
            e = gsmcelllocation.getCid();
            d = gsmcelllocation.getLac();
        } else
        if (celllocation instanceof CdmaCellLocation)
        {
            CdmaCellLocation cdmacelllocation = (CdmaCellLocation)celllocation;
            c = cdmacelllocation.getBaseStationId();
            b = cdmacelllocation.getNetworkId();
            a = cdmacelllocation.getSystemId();
            return;
        }
    }
}
项目:funf-v4    文件:CellTowerProbe.java   
private Bundle getData() {
    TelephonyManager manager = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
    CellLocation location = manager.getCellLocation();
    Bundle data = new Bundle();
    if (location instanceof GsmCellLocation) {
        GsmCellLocation gsmLocation = (GsmCellLocation) location;
        gsmLocation.fillInNotifierBundle(data);
        data.putInt(TYPE, TelephonyManager.PHONE_TYPE_GSM);
    } else if (location instanceof CdmaCellLocation) {
        CdmaCellLocation cdmaLocation = (CdmaCellLocation) location;
        cdmaLocation.fillInNotifierBundle(data);
        data.putInt(TYPE, TelephonyManager.PHONE_TYPE_CDMA);
    } else {
        data.putInt(TYPE, TelephonyManager.PHONE_TYPE_NONE);
    }
    return data;
}
项目:Misc    文件:MapLocationActivity.java   
private int[] getTowerValues() {
    // Find new values
    TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    // Find the location
    if (tm == null) {
        popupMsg("Could not get TelephonyManager");
        return null;
    }
    int phoneType = tm.getPhoneType();
    if (phoneType != TelephonyManager.PHONE_TYPE_CDMA) {
        popupMsg("Only CDMA is supported");
        return null;
    }
    CellLocation cl = tm.getCellLocation();
    if (cl == null) {
        popupMsg("Could not get Cell Location");
        return null;
    }
    if (!(cl instanceof CdmaCellLocation)) {
        popupMsg("Cell Location is is not a CdmaCellLocation class");
        return null;
    }
    CdmaCellLocation cdmacl = (CdmaCellLocation) cl;
    int lat = NetworkActivity.locToGoogle(cdmacl.getBaseStationLatitude());
    int lon = NetworkActivity.locToGoogle(cdmacl.getBaseStationLongitude());
    int nid = cdmacl.getNetworkId();
    int sid = cdmacl.getSystemId();
    int bid = cdmacl.getBaseStationId();
    Log.d(TAG, "  New values: " + " lat=" + lat + " lon=" + lon + " nid="
            + nid + " sid=" + sid + " bid=" + bid);
    return new int[] { lat, lon, nid, sid, bid };
}
项目:letv    文件:LetvUtils.java   
public static GSMInfo getGSMInfo(Context context) {
    try {
        GSMInfo info = new GSMInfo();
        TelephonyManager manager = (TelephonyManager) context.getSystemService("phone");
        if (manager != null) {
            CellLocation cellLocation = manager.getCellLocation();
            int lac = 0;
            int cellid = 0;
            if (cellLocation != null) {
                if (cellLocation instanceof GsmCellLocation) {
                    lac = ((GsmCellLocation) cellLocation).getLac();
                    cellid = ((GsmCellLocation) cellLocation).getCid();
                } else if (cellLocation instanceof CdmaCellLocation) {
                    cellid = ((CdmaCellLocation) cellLocation).getNetworkId();
                    lac = ((CdmaCellLocation) cellLocation).getBaseStationId();
                }
            }
            info.lac = lac;
            info.cid = cellid;
        }
        AMapLocation location = AMapLocationTool.getInstance().location();
        if (location != null) {
            info.latitude = location.getLatitude();
            info.longitude = location.getLongitude();
            return info;
        }
        info.latitude = Double.parseDouble(PreferencesManager.getInstance().getLocationLongitude());
        info.longitude = Double.parseDouble(PreferencesManager.getInstance().getLocationLatitude());
        return info;
    } catch (Exception e) {
        LogInfo.log("ZSM++ ==== GSM exception e == " + e.getMessage());
        e.printStackTrace();
        return null;
    }
}
项目:truth-android    文件:CdmaCellLocationSubject.java   
public static SubjectFactory<CdmaCellLocationSubject, CdmaCellLocation> type() {
  return new SubjectFactory<CdmaCellLocationSubject, CdmaCellLocation>() {
    @Override
    public CdmaCellLocationSubject getSubject(FailureStrategy fs, CdmaCellLocation that) {
      return new CdmaCellLocationSubject(fs, that);
    }
  };
}
项目:LBS    文件:GSMCellLocationLbs.java   
public static void getCurrentLocation(Context context) {
    TelephonyManager mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    // 返回值MCC + MNC
    String operator = mTelephonyManager.getNetworkOperator();
    int mcc = Integer.parseInt(operator.substring(0, 3));
    int mnc = Integer.parseInt(operator.substring(3));
    Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t");
    // 中国移动和中国联通获取LAC、CID的方式
    GsmCellLocation location = (GsmCellLocation) mTelephonyManager.getCellLocation();
    int lac = location.getLac();
    int cellId = location.getCid();



    // 中国电信获取LAC、CID的方式
    CdmaCellLocation location1 = (CdmaCellLocation) mTelephonyManager.getCellLocation();
    lac = location1.getNetworkId();
    cellId = location1.getBaseStationId();
    cellId /= 16;

    Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t LAC = " + lac + "\t CID = " + cellId);
    // 获取邻区基站信息
    List<NeighboringCellInfo> infos = mTelephonyManager.getNeighboringCellInfo();
    StringBuffer sb = new StringBuffer("总数 : " + infos.size() + "\n");
    for (NeighboringCellInfo info1 : infos) { // 根据邻区总数进行循环
        sb.append(" LAC : " + info1.getLac()); // 取出当前邻区的LAC
        sb.append(" CID : " + info1.getCid()); // 取出当前邻区的CID
        sb.append(" BSSS : " + (-113 + 2 * info1.getRssi()) + "\n"); // 获取邻区基站信号强度
    }

    Log.i(TAG, " 获取邻区基站信息:" + sb.toString());
}
项目:TowerCollector    文件:CdmaCellLocationValidator.java   
public boolean isValid(CdmaCellLocation cell) {
    boolean valid = (isBidInRange(cell.getBaseStationId()) && isNidInRange(cell.getNetworkId())
            && isSidInRange(cell.getSystemId()));
    if (!valid) {
        Log.w("isValid(): Invalid CdmaCellLocation [sid=%s, nid=%s, bid=%s]", cell.getSystemId(), cell.getNetworkId(), cell.getBaseStationId());
        Log.w("isValid(): Invalid CdmaCellLocation %s", cell);
    }
    return valid;
}
项目:TowerCollector    文件:CellLocationValidator.java   
public boolean isValid(CellLocation cellLocation, int mcc, int mnc) {
    if (cellLocation instanceof GsmCellLocation) {
        GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation;
        return getGsmValidator().isValid(gsmCellLocation, mcc, mnc);
    }
    if (cellLocation instanceof CdmaCellLocation) {
        CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation;
        return getCdmaValidator().isValid(cdmaCellLocation);
    }
    throw new UnsupportedOperationException("Cell location type not supported `" + cellLocation.getClass().getName() + "`");
}
项目:CellularSignal    文件:RadioInfo.java   
@Override
public void onCellLocationChanged(CellLocation location) {
    super.onCellLocationChanged(location);
    //Log.e(Tag,"onCellLocationChanged");
    if (location instanceof CdmaCellLocation) {
        cdma_SID = ((CdmaCellLocation) location).getSystemId();
        cdma_NID = ((CdmaCellLocation) location).getNetworkId();
        cdma_BSID = ((CdmaCellLocation) location).getBaseStationId();
        //Log.e(Tag,((CdmaCellLocation)location).toString());
    }
    ((MainActivity)mcontext).mSectionsPagerAdapter.notifyDataSetChanged();
}
项目:batteryhub    文件:Gsm.java   
public static CellInfo getCellInfo(Context context) {
      CellInfo cellInfo = new CellInfo();

      TelephonyManager manager = (TelephonyManager)
              context.getSystemService(Context.TELEPHONY_SERVICE);

      String netOperator = manager.getNetworkOperator();

      // Fix crash when not connected to network (airplane mode, underground,
      // etc)
      if (netOperator == null || netOperator.length() < 3) {
          return cellInfo;
      }

/*
 * FIXME: Actually check for mobile network status == connected before
 * doing this stuff.
 */

      if (Phone.getType(context).equals(PHONE_TYPE_CDMA)) {
          CdmaCellLocation cdmaLocation = (CdmaCellLocation) manager.getCellLocation();

          cellInfo.cid = cdmaLocation.getBaseStationId();
          cellInfo.lac = cdmaLocation.getNetworkId();
          cellInfo.mnc = cdmaLocation.getSystemId();
          cellInfo.mcc = Integer.parseInt(netOperator.substring(0, 3));
          cellInfo.radioType = Network.getMobileNetworkType(context);
      } else if (Phone.getType(context).equals(PHONE_TYPE_GSM)) {
          GsmCellLocation gsmLocation = (GsmCellLocation) manager.getCellLocation();

          cellInfo.mcc = Integer.parseInt(netOperator.substring(0, 3));
          cellInfo.mnc = Integer.parseInt(netOperator.substring(3));
          cellInfo.lac = gsmLocation.getLac();
          cellInfo.cid = gsmLocation.getCid();
          cellInfo.radioType = Network.getMobileNetworkType(context);
      }

      return cellInfo;
  }
项目:android-QoS    文件:LibPhoneStateListener.java   
private void checkCDMACellSID (CellLocation cell)
{
    if (cell instanceof CdmaCellLocation)
    {
        CdmaCellLocation cdmaCell = (CdmaCellLocation)cell;
        if (cdmaCell.getSystemId() <= 0)
        {
            Field getSIDPointer = null;
            Field getNIDPointer = null;
            int SID = 0, NID = 0, BID = cdmaCell.getBaseStationId();
            try {
                getSIDPointer = mPhoneState.previousServiceStateObj.getClass().getDeclaredField("mSystemId");
                if (getSIDPointer != null)
                {
                    getSIDPointer.setAccessible(true);
                    SID = (int) getSIDPointer.getInt(cdmaCell);
                }
                getNIDPointer = mPhoneState.previousServiceStateObj.getClass().getDeclaredField("mNetworkId");
                if (getNIDPointer != null)
                {
                    getNIDPointer.setAccessible(true);
                    NID = (int) getNIDPointer.getInt(cdmaCell);
                }
                cdmaCell.setCellLocationData(BID, cdmaCell.getBaseStationLatitude(), cdmaCell.getBaseStationLongitude(),
                                            SID, NID); // Update the SID and NID that we read from teh Servicestate
            } catch (Exception e) {
                //MMCLogger.logToFile(MMCLogger.Level.ERROR, TAG, "checkInnerGsmCellLocation","Field does not exist - mGsmCellLoc");
            }
        }
    }
}
项目:android-QoS    文件:CellLocationEx.java   
public int getBSLow(){
    if(cellLoc != null && cellLoc instanceof CdmaCellLocation) {
        return ((CdmaCellLocation) cellLoc).getBaseStationId();
    }
    else if(cellLoc != null && cellLoc instanceof GsmCellLocation) {
        return ((GsmCellLocation) cellLoc).getCid() & 0xffff;
    }

    return 0;
}
项目:android-QoS    文件:CellLocationEx.java   
public int getBSMid(){
    if(cellLoc != null && cellLoc instanceof CdmaCellLocation) {
        return ((CdmaCellLocation) cellLoc).getNetworkId();
    }
    else if(cellLoc != null && cellLoc instanceof GsmCellLocation) {
        return ((GsmCellLocation) cellLoc).getCid() >> 16;
    }

    return 0;
}
项目:android-QoS    文件:CellLocationEx.java   
public int getBSHigh(){
    if(cellLoc != null && cellLoc instanceof CdmaCellLocation) {
        return ((CdmaCellLocation) cellLoc).getSystemId();
    }
    else if(cellLoc != null && cellLoc instanceof GsmCellLocation) {
        return ((GsmCellLocation) cellLoc).getLac();
    }

    return 0;
}
项目:android-QoS    文件:CDMADevice.java   
/**
 * @return The System id, or -1 if it is unknown
 */
public int getSid() {
    CellLocation cellLoc = mTelephonyManager.getCellLocation();
    if(cellLoc != null && cellLoc instanceof CdmaCellLocation) {
        return ((CdmaCellLocation) cellLoc).getSystemId();
    }
    else {
        return -1;
    }
}
项目:openbmap    文件:WirelessLoggerService.java   
/**
 * A valid cdma cell must have basestation id, network id and system id set
 * @param cdmaLocation {@link CdmaCellLocation}
 * @return true if valid cdma id
 */
private boolean isValidCdmaCell(final CdmaCellLocation cdmaLocation) {
    if (cdmaLocation == null) {
        return false;
    }
    return ((cdmaLocation.getBaseStationId() != -1) && (cdmaLocation.getNetworkId() != -1) && (cdmaLocation.getSystemId() != -1));
}
项目:PhoneProfilesPlus    文件:PhoneStateScanner.java   
private void getCellLocation(CellLocation location) {

        if (location!=null) {

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

                if (location instanceof GsmCellLocation) {
                    GsmCellLocation gcLoc = (GsmCellLocation) location;
                    //PPApplication.logE("PhoneStateScanner.getCellLocation", "gsm location="+gcLoc);
                    if (gcLoc.getCid() != -1) {
                        //PPApplication.logE("PhoneStateScanner.getCellLocation", "gsm mCid="+gcLoc.getCid());
                        registeredCell = gcLoc.getCid();
                        lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                    }
                } else if (location instanceof CdmaCellLocation) {
                    CdmaCellLocation ccLoc = (CdmaCellLocation) location;
                    //PPApplication.logE("PhoneStateScanner.getCellLocation", "cdma location="+ccLoc);
                    if (ccLoc.getBaseStationId() != -1) {
                        //PPApplication.logE("PhoneStateScanner.getCellLocation", "cdma mCid="+ccLoc.getBaseStationId());
                        registeredCell = ccLoc.getBaseStationId();
                        lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                    }
                }
                //else {
                //    PPApplication.logE("PhoneStateScanner.getCellLocation", "unknown location="+location);
                //}

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

            }

        }
        else
            PPApplication.logE("PhoneStateScanner.getCellLocation", "location is null");
    }
项目:tabulae    文件:CellIdPre17API.java   
public void fill(TheDictionary map, CdmaCellLocation value) throws Exception {
    if (value != null) {
        map.put("mcc", mcc);
        map.put("mnc", mnc);
        map.put("base_station_id", value.getBaseStationId());
        map.put("latitude", value.getBaseStationLatitude() / 14400.0);
        map.put("longitude", value.getBaseStationLongitude() / 14400.0);
        map.put("network_id", value.getNetworkId());
        map.put("systen_id", value.getSystemId());
        map.put("registered", true);
        determine_type(map);
    }
}
项目:MiBandDecompiled    文件:ai.java   
protected final List b(float f1)
    {
        ArrayList arraylist;
label0:
        {
            arraylist = new ArrayList();
            long l1 = System.currentTimeMillis();
            if (Math.abs(f1) <= 1.0F)
            {
                f1 = 1.0F;
            }
            if (c())
            {
                CellLocation celllocation = (CellLocation)j().get(1);
                if (celllocation != null && (celllocation instanceof CdmaCellLocation))
                {
                    CdmaCellLocation cdmacelllocation = (CdmaCellLocation)celllocation;
                    arraylist.add(Integer.valueOf(cdmacelllocation.getSystemId()));
                    arraylist.add(Integer.valueOf(cdmacelllocation.getNetworkId()));
                    arraylist.add(Integer.valueOf(cdmacelllocation.getBaseStationId()));
                    arraylist.add(Integer.valueOf(cdmacelllocation.getBaseStationLongitude()));
                    arraylist.add(Integer.valueOf(cdmacelllocation.getBaseStationLatitude()));
                    if ((double)(l1 - ((Long)j().get(0)).longValue()) > 50000D / (double)f1)
                    {
                        break label0;
                    }
                    arraylist.add(Integer.valueOf(1));
                }
            }
            return arraylist;
        }
        arraylist.add(Integer.valueOf(0));
        return arraylist;
    }
项目:radiocells-scanner-android    文件:WirelessLoggerService.java   
/**
 * Create a {@link CellRecord} for the serving cell by parsing {@link CellLocation}
 *
 * @param cell     {@link CellLocation}
 * @param position {@link PositionRecord} Current position
 * @return Serialized cell record
 */
@SuppressLint("NewApi")
private CellRecord processServingCellLocation(final CellLocation cell, final PositionRecord position) {
    if (cell instanceof GsmCellLocation) {
        /*
* In case of GSM network set GSM specific values
*/
        final GsmCellLocation gsmLocation = (GsmCellLocation) cell;

        if (isValidGsmCell(gsmLocation)) {
            Log.i(TAG, "Assuming gsm (assumption based on cell-id" + gsmLocation.getCid() + ")");
            final CellRecord serving = processGsm(position, gsmLocation);

            if (serving == null) {
                return null;
            }

            return serving;
        }
    } else if (cell instanceof CdmaCellLocation) {
        final CdmaCellLocation cdmaLocation = (CdmaCellLocation) cell;
        if (isValidCdmaCell(cdmaLocation)) {
/*
 * In case of CDMA network set CDMA specific values
 * Assume CDMA network, if cdma location and basestation, network and system id are available
 */
            Log.i(TAG, "Assuming cdma for cell " + cdmaLocation.getBaseStationId());
            return processCdma(position, cdmaLocation);
        }
    }
    return null;
}
项目:radiocells-scanner-android    文件:WirelessLoggerService.java   
/**
 * A valid cdma cell must have basestation id, network id and system id set
 *
 * @param cdmaLocation {@link CdmaCellLocation}
 * @return true if valid cdma id
 */
private boolean isValidCdmaCell(final CdmaCellLocation cdmaLocation) {
    if (cdmaLocation == null) {
        return false;
    }
    return ((cdmaLocation.getBaseStationId() != -1) && (cdmaLocation.getNetworkId() != -1) && (cdmaLocation.getSystemId() != -1));
}
项目:SignalAnalysis    文件:PhoneStateHelper.java   
/**
 * Set network info related to the connected cell: MCC, MNC, LAC, CellId
 */
public void setNetworkInfo() {
    if (DBG)
        Log.d(Config.TAG, TAG + "setNetworkInfo called");
    String temp = mTelMgr.getNetworkOperator();
    if ((temp != null) && (temp.length() >= 5)) {
        mMcc = temp.substring(0, 3);
        mMnc = temp.substring(3);
    }
    CellLocation oCell = mTelMgr.getCellLocation();
    if (oCell instanceof GsmCellLocation) {
        mLac = String.valueOf(((GsmCellLocation) oCell).getLac());
        mCellId = String.valueOf(((GsmCellLocation) oCell).getCid());
        mPsc = String.valueOf(((GsmCellLocation) oCell).getPsc());
    }
    if (oCell instanceof CdmaCellLocation) {
        String t = null;
        // (CdmaCellLocation) oCell

        t = "Base station id : "
                + ((CdmaCellLocation) oCell).getBaseStationId()
                + "base station latitude "
                + ((CdmaCellLocation) oCell).getBaseStationLatitude()
                + " base station longitude"
                + ((CdmaCellLocation) oCell).getBaseStationLongitude()
                + " network id" + ((CdmaCellLocation) oCell).getNetworkId()
                + " system id " + ((CdmaCellLocation) oCell).getSystemId();

        Log.d(Config.TAG, TAG + t);
    }

}
项目:Simplicissimus    文件:CellIdPre17API.java   
@Override
public TheDictionary next() {
    if (DEBUG) Log.d(TAG, "next:");
    TheDictionary map = new TheDictionary();
    try {
        if (i < 0) {
            if (cellLocation instanceof GsmCellLocation) {
                fill(map, ((GsmCellLocation)cellLocation));
            }
            else if (cellLocation instanceof CdmaCellLocation) {
                fill(map, ((CdmaCellLocation)cellLocation));
            }
            else {
                map.put("class", cellLocation.getClass().getName());
                map.put("string", cellLocation.toString());
            }
        }
        else {
            fill(map, neighboringCellInfoList.get(i));
        }
    }
    catch (Exception e) {
        throw new RuntimeException(e);
    }
    i++;
    if (DEBUG) Log.d(TAG, "next: map=" + map);
    return map;
}
项目:Simplicissimus    文件:CellIdPre17API.java   
public void fill(TheDictionary map, CdmaCellLocation value) throws Exception {
    if (value != null) {
        map.put("mcc", mcc);
        map.put("mnc", mnc);
        map.put("base_station_id", value.getBaseStationId());
        map.put("latitude", value.getBaseStationLatitude() / 14400.0);
        map.put("longitude", value.getBaseStationLongitude() / 14400.0);
        map.put("network_id", value.getNetworkId());
        map.put("systen_id", value.getSystemId());
        map.put("registered", true);
        determine_type(map);
    }
}
项目:skandroid-core    文件:CellTowersData.java   
@SuppressLint("NewApi")
private void addCellData(List<String> list) {
    DCSStringBuilder builder = new DCSStringBuilder();

    if (cellLocation == null) {
        // No location information currently available!
    } else if (cellLocation instanceof GsmCellLocation) {
        GsmCellLocation gsmLocation = (GsmCellLocation) cellLocation;
        builder.append(ID + GSM + VERSION);
        builder.append(time/1000);
        builder.append(GSM);
        builder.append(gsmLocation.getCid());
        builder.append(gsmLocation.getLac());
        builder.append(Build.VERSION.SDK_INT >= 9 ? gsmLocation.getPsc() : -1 );

    } else if (cellLocation instanceof CdmaCellLocation) {
        CdmaCellLocation cdmaLocation = (CdmaCellLocation) cellLocation;
        builder.append(ID + CDMA);
        builder.append(time/1000);
        builder.append(CDMA);
        builder.append(cdmaLocation.getBaseStationId());
        builder.append(cdmaLocation.getBaseStationLatitude());
        builder.append(cdmaLocation.getBaseStationLongitude());
        builder.append(cdmaLocation.getNetworkId());
        builder.append(cdmaLocation.getSystemId());
    }

    if (signal == null) {
        // No signal information currently available!
    } else if (signal.isGsm()) {
        builder.append(SKGsmSignalStrength.getGsmSignalStrength(signal));
        builder.append(signal.getGsmBitErrorRate());
    } else {
        builder.append(signal.getCdmaDbm());
        builder.append(signal.getCdmaEcio());
    }
    list.add(builder.build());
}
项目:skandroid-core    文件:CellTowersData.java   
@Override
public List<JSONObject> getPassiveMetric() {
    List<JSONObject> ret = new ArrayList<>();

    if (cellLocation == null) {
        // No location information currently available!
    } else if(cellLocation instanceof GsmCellLocation){
        ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.GSMLAC,time,((GsmCellLocation) cellLocation).getLac()+""));
        ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.GSMCID,time,((GsmCellLocation) cellLocation).getCid()+""));
    }else if(cellLocation instanceof CdmaCellLocation){
        CdmaCellLocation cdmaLocation = (CdmaCellLocation) cellLocation;
        ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.CDMABSID, time, cdmaLocation.getBaseStationId()+""));
        if (cdmaLocation.getBaseStationLatitude() != Integer.MAX_VALUE) {
            ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.CDMABSLAT, time,cdmaLocation.getBaseStationLatitude()+""));
        } 
        if (cdmaLocation.getBaseStationLongitude() != Integer.MAX_VALUE) {
            ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.CDMABSLNG, time, cdmaLocation.getBaseStationLongitude()+""));
        }
        ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.CDMANETWORKID,time,cdmaLocation.getNetworkId()+""));
        ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.CDMASYSTEMID,time, cdmaLocation.getSystemId()+""));
    }

    if (signal == null) {
        // No signal information currently available!
    } else if (signal.isGsm()) {
        ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.GSMSIGNALSTRENGTH,time, DCSConvertorUtil.convertGsmSignalStrength(SKGsmSignalStrength.getGsmSignalStrength(signal))));
    //  ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.GSMBER, time, DCSConvertorUtil.convertGsmBitErroRate(signal.getGsmBitErrorRate())));
    } else {
        ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.CDMADBM,time, signal.getCdmaDbm()+""));
        ret.add(PassiveMetric.create(PassiveMetric.METRIC_TYPE.CDMAECIO,time, signal.getCdmaEcio()+""));
    }
    return ret;
}
项目:MoST    文件:CellInput.java   
@Override
public void workToDo() {
    CellLocation cellLocation = _telephonyManager.getCellLocation();
    DataBundle b = _bundlePool.borrowBundle();
    if (cellLocation instanceof GsmCellLocation) {
        GsmCellLocation gsmLocation = (GsmCellLocation) cellLocation;
        b.putInt(KEY_GSM_CELL_ID, gsmLocation.getCid());
        b.putInt(KEY_GSM_LAC, gsmLocation.getLac());
        // gsmLocation.getPsc() require api 9
        // b.putInt(KEY_GSM_PSC, gsmLocation.getPsc());
        b.putInt(KEY_PHONE_TYPE, TelephonyManager.PHONE_TYPE_GSM);
    } else if (cellLocation instanceof CdmaCellLocation) {
        CdmaCellLocation cdmaLocation = (CdmaCellLocation) cellLocation;
        b.putInt(KEY_BASE_STATION_ID, cdmaLocation.getBaseStationId());
        b.putInt(KEY_BASE_STATION_LATITUDE, cdmaLocation.getBaseStationLatitude());
        b.putInt(KEY_BASE_STATION_LONGITUDE, cdmaLocation.getBaseStationLongitude());
        b.putInt(KEY_BASE_NETWORK_ID, cdmaLocation.getNetworkId());
        b.putInt(KEY_BASE_SYSTEM_ID, cdmaLocation.getSystemId());
        b.putInt(KEY_PHONE_TYPE, TelephonyManager.PHONE_TYPE_CDMA);
    } else {
        b.putInt(KEY_PHONE_TYPE, TelephonyManager.PHONE_TYPE_NONE);
    }

    b.putLong(Input.KEY_TIMESTAMP, System.currentTimeMillis());
    b.putInt(Input.KEY_TYPE, Input.Type.CELL.toInt());
    post(b);
    scheduleNextStart();
}
项目:pyneo-wirelesslocation    文件:CellIdPre17API.java   
@Override
public TheDictionary next() {
    if (DEBUG) Log.d(TAG, "next:");
    TheDictionary map = new TheDictionary();
    try {
        if (i < 0) {
            if (cellLocation instanceof GsmCellLocation) {
                fill(map, ((GsmCellLocation)cellLocation));
            }
            else if (cellLocation instanceof CdmaCellLocation) {
                fill(map, ((CdmaCellLocation)cellLocation));
            }
            else {
                map.put("class", cellLocation.getClass().getName());
                map.put("string", cellLocation.toString());
            }
        }
        else {
            fill(map, neighboringCellInfoList.get(i));
        }
    }
    catch (Exception e) {
        throw new RuntimeException(e);
    }
    i++;
    if (DEBUG) Log.d(TAG, "next: map=" + map);
    return map;
}
项目:pyneo-wirelesslocation    文件:CellIdPre17API.java   
public void fill(TheDictionary map, CdmaCellLocation value) throws Exception {
    if (value != null) {
        map.put("mcc", mcc);
        map.put("mnc", mnc);
        map.put("base_station_id", value.getBaseStationId());
        map.put("latitude", value.getBaseStationLatitude() / 14400.0);
        map.put("longitude", value.getBaseStationLongitude() / 14400.0);
        map.put("network_id", value.getNetworkId());
        map.put("systen_id", value.getSystemId());
        map.put("registered", true);
        determine_type(map);
    }
}
项目:femtocatcher    文件:NetworkInfoActivity.java   
public void getCellNetworkInfo() {

    if(mTelephonyManager != null) {
        text1 = "";
        Log.v(TAG, "getting cell network info");
        int phoneType = mTelephonyManager.getPhoneType();

        /* Check whether you are connected to a CDMA network */
        if(TelephonyManager.PHONE_TYPE_CDMA == phoneType) {
            text1 = text1 + "Cell on CDMA Phone network";
        }
        else {
            text1 = text1 + "Cell is not on CDMA Phone network";
            tv1.setText(text1);
            return;
        }

        /* Get the network type and name*/
        if(mTelephonyManager!=null) {
            int networkType = mTelephonyManager.getNetworkType();
            text1 = text1 + "\nNetwork Type = " + MainActivity.getNetworkTypeName(networkType);

            /* get network operator name */
            String operatorName = mTelephonyManager.getNetworkOperatorName();
            text1 = text1 +"\nNetwork Operator Name: "+operatorName;

            /* get CDMA cell location information */
            CdmaCellLocation c = (CdmaCellLocation) mTelephonyManager.getCellLocation();
            if(c!=null) {
                text1 = text1 + "\nBaseStation ID: "+c.getBaseStationId();
                text1 = text1 + "\nNetwork ID: "+c.getNetworkId();
                text1 = text1 + "\nSystem ID: "+c.getSystemId();                
                text1 = text1 + "\nLatitude: "+c.getBaseStationLatitude();
                text1 = text1 + "\nLongitude: "+c.getBaseStationLongitude();

                tv1.setText(text1);
            }
        }
    }
}
项目:mobile-mba-androidapp    文件:CellTowersData.java   
private void addCellData(List<String> list) {
    DCSStringBuilder builder = new DCSStringBuilder();

    if (cellLocation instanceof GsmCellLocation) {
        GsmCellLocation gsmLocation = (GsmCellLocation) cellLocation;
        builder.append(ID + GSM + VERSION);
        builder.append(time/1000);
        builder.append(GSM);
        builder.append(gsmLocation.getCid());
        builder.append(gsmLocation.getLac());
        builder.append(Build.VERSION.SDK_INT >= 9 ? gsmLocation.getPsc() : -1 );

    } else if (cellLocation instanceof CdmaCellLocation) {
        CdmaCellLocation cdmaLocation = (CdmaCellLocation) cellLocation;
        builder.append(ID + CDMA);
        builder.append(time/1000);
        builder.append(CDMA);
        builder.append(cdmaLocation.getBaseStationId());
        builder.append(cdmaLocation.getBaseStationLatitude());
        builder.append(cdmaLocation.getBaseStationLongitude());
        builder.append(cdmaLocation.getNetworkId());
        builder.append(cdmaLocation.getSystemId());
    }

    if (signal.isGsm()) {
        builder.append(signal.getGsmSignalStrength());
        builder.append(signal.getGsmBitErrorRate());
    } else {
        builder.append(signal.getCdmaDbm());
        builder.append(signal.getCdmaEcio());
    }
    list.add(builder.build());
}