Java 类android.telephony.CellLocation 实例源码

项目:letv    文件:d.java   
public final void e() {
    if (this.p == 1) {
        CellLocation.requestLocationUpdate();
        this.p = 2;
        this.l.sendEmptyMessage(1);
        if (this.s.b().isWifiEnabled()) {
            this.s.b().startScan();
            this.r = false;
        } else if (this.e) {
            this.o = System.currentTimeMillis();
            if (c && this.s.b().setWifiEnabled(true)) {
                this.r = true;
            } else {
                this.l.sendEmptyMessageDelayed(5, 8000);
            }
        } else {
            this.l.sendEmptyMessageDelayed(5, 0);
        }
    }
}
项目:TowerCollector    文件:MeasurementUpdater.java   
public synchronized void setLastCellLocation(CellLocation cellLocation, NetworkGroup networkType,
                                             String operatorCode, String operatorName, List<NeighboringCellInfo> neighboringCells) {
    Log.d("setLastCellLocation(): Cell location updated: %s, network type: %s, operator code: %s, operator name: %s", cellLocation, networkType, operatorCode, operatorName);
    // check if any changes
    boolean cellChanged = (!isCellLocationEqual(lastCellLocation, cellLocation)
            || lastNetworkType != networkType
            || !lastOperatorCode.equals(operatorCode)
            || !lastOperatorName.equals(operatorName));
    // update last cell
    this.lastCellLocation = cellLocation;
    this.lastNetworkType = networkType;
    this.lastOperatorCode = operatorCode;
    this.lastOperatorName = operatorName;
    this.neighboringCells = neighboringCells;
    if (this.neighboringCells == null) {
        this.neighboringCells = EMPTY_NEIGHBORING_CELL_LIST;
    }
    if (cellChanged) {
        notifyIfReadyToProcess();
    }
}
项目: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;
}
项目:android-QoS    文件:LibPhoneStateListener.java   
/**
 * When the cell location gets changed, the new cellId is added to the cell id buffer in the 
 * owner. At the same time, the CELLCHANGE event is stored.
 */
@Override
public void onCellLocationChanged(CellLocation location) {
    super.onCellLocationChanged(location);

    try {
           checkCDMACellSID (location);
        processNewCellLocation(new CellLocationEx(location));

        // See if this cellLocation has inner GsmLocation
        checkInnerGsmCellLocation (location);
        LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "onCellLocationChanged", location.toString());

    } catch (InterruptedException intEx){
        LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "onCellLocationChanged", "InterruptedException: " + intEx.getMessage());
    }
    catch (Exception ex){
        String err = ex.toString();
        LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "onCellLocationChanged", "InterruptedException: " + err);
    }
}
项目:android-QoS    文件:LibPhoneStateListener.java   
public CellLocationEx getLastCellLocation(){
    if (mPhoneState.lastKnownMMCCellLocation != null)
        return mPhoneState.lastKnownMMCCellLocation;
    CellLocation cellLoc = telephonyManager.getCellLocation();
    if (cellLoc != null)
    {
        LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "getLastCellLocation", "null cell, getCellLocation() = " + cellLoc.toString());

        CellLocationEx mmcCell = new CellLocationEx(cellLoc);
        try {
            processNewCellLocation(mmcCell);
        } catch (InterruptedException e) {
        }
        return mmcCell;
    }
    LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "getLastCellLocation", "null cell, getCellLocation() = null");
    return null;
}
项目:android-QoS    文件:CellHistory.java   
public CellidSample (CellLocation cell)
        {
            CellLocationEx mmcCell = new CellLocationEx(cell);

            timestamp = System.currentTimeMillis();
            val1 = mmcCell.getBSHigh();
            val2 = mmcCell.getBSLow();
//          
//          if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA && mmcCell instanceof CdmaCellLocation)
//          {
//              lac = ((CdmaCellLocation)mmcCell).getSystemId();
//              cid = ((CdmaCellLocation)mmcCell).getBaseStationId();
//          }
//          else if (mmcCell instanceof GsmCellLocation)
//          {
//              lac = ((GsmCellLocation)mmcCell).getLac();
//              cid = ((GsmCellLocation)mmcCell).getCid();
//          }
        }
项目:PhoneProfilesPlus    文件:PhoneStateScanner.java   
@Override
public void onCellLocationChanged (CellLocation location) {
    super.onCellLocationChanged(location);

    PPApplication.logE("PhoneStateScanner.onCellLocationChanged", "telephonyManager="+telephonyManager);
    CallsCounter.logCounter(context, "PhoneStateScanner.onCellLocationChanged", "PhoneStateScanner_onCellLocationChanged");

    if (location == null)
        getCellLocation();
    else
        getCellLocation(location);

    if (registeredCell != Integer.MAX_VALUE) {
        DatabaseHandler db = DatabaseHandler.getInstance(context);
        db.updateMobileCellLastConnectedTime(registeredCell, lastConnectedTime);
    }

    doAutoRegistration();
    sendBroadcast();
}
项目:tabulae    文件:CellIdPre17API.java   
public CellIdPre17API(TelephonyManager telephonyManager, CellLocation cellLocation, List<NeighboringCellInfo> neighboringCellInfoList) {
    if (DEBUG) Log.d(TAG, "CellIdPre17API:");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        fallback_pre17api = true;
    }
    this.cellLocation = cellLocation;
    this.neighboringCellInfoList = neighboringCellInfoList;
    if (cellLocation != null) {
        this.i = -1;
    } else {
        this.i = 0;
    }
    String mccmnc = telephonyManager.getNetworkOperator();
    if (mccmnc != null && mccmnc.length() >= 5 && mccmnc.length() <= 6) {
        mcc = Integer.parseInt(mccmnc.substring(0, 3));
        mnc = Integer.parseInt(mccmnc.substring(3));
    } else {
        Log.e(TAG, "CellIdPre17API: wrong legnth (5-6) for mccmnc=" + mccmnc);
    }
    type = telephonyManager.getNetworkType();
    if (DEBUG)
        Log.d(TAG, "CellIdPre17API: mcc=" + mcc + ", mnc=" + mnc + ", type=" + type + " cellLocation=" + cellLocation + ", neighboringCellInfoList=" + neighboringCellInfoList);
}
项目: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;
        }
    }
}
项目:Simplicissimus    文件:CellIdPre17API.java   
public CellIdPre17API(TelephonyManager telephonyManager, CellLocation cellLocation, List<NeighboringCellInfo> neighboringCellInfoList) {
    if (DEBUG) Log.d(TAG, "CellIdPre17API:");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        this.fallback_pre17api = true;
    }
    this.cellLocation = cellLocation;
    this.neighboringCellInfoList = neighboringCellInfoList;
    if (cellLocation != null) {
        this.i = -1;
    }
    else {
        this.i = 0;
    }
    String mccmnc = telephonyManager.getNetworkOperator();
    if (mccmnc != null && mccmnc.length() >= 5 && mccmnc.length() <= 6) {
        mcc = Integer.parseInt(mccmnc.substring(0, 3));
        mnc = Integer.parseInt(mccmnc.substring(3));
    }
    else {
        Log.e(TAG, "CellIdPre17API: wrong legnth (5-6) for mccmnc=" + mccmnc);
    }
    type = telephonyManager.getNetworkType();
    if (DEBUG) Log.d(TAG, "CellIdPre17API: mcc=" + mcc + ", mnc=" + mnc + ", type=" + type + " cellLocation=" + cellLocation + ", neighboringCellInfoList=" + neighboringCellInfoList);
}
项目:LocalGSMLocationProvider    文件:CellbasedLocationProvider.java   
/**
 * Handle a modem event by trying to pull all information. The parameter inc defines if the
 * measurement counter should be increased on success.
 * @param inc True if the measurement counter should be increased.
 */
private void handle(boolean inc) {
    if (telephonyManager == null) return;
    final List<android.telephony.CellInfo> cellInfos = telephonyManager.getAllCellInfo();
    final List<NeighboringCellInfo> neighbours = telephonyManager.getNeighboringCellInfo();
    final CellLocation cellLocation = telephonyManager.getCellLocation();
    if (cellInfos == null || cellInfos.isEmpty()) {
        if (neighbours == null || neighbours.isEmpty()) {
            if (cellLocation == null || !(cellLocation instanceof GsmCellLocation)) return;
        }
    }
    if (inc) measurement.getAndIncrement();
    add(cellLocation);
    addNeighbours(neighbours);
    addCells(cellInfos);
    synchronized (recentCells) {
        cleanup();
    }
}
项目:pyneo-wirelesslocation    文件:CellIdPre17API.java   
public CellIdPre17API(TelephonyManager telephonyManager, CellLocation cellLocation, List<NeighboringCellInfo> neighboringCellInfoList) {
    if (DEBUG) Log.d(TAG, "CellIdPre17API:");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        this.fallback_pre17api = true;
    }
    this.cellLocation = cellLocation;
    this.neighboringCellInfoList = neighboringCellInfoList;
    if (cellLocation != null) {
        this.i = -1;
    }
    else {
        this.i = 0;
    }
    String mccmnc = telephonyManager.getNetworkOperator();
    if (mccmnc != null && mccmnc.length() >= 5 && mccmnc.length() <= 6) {
        mcc = Integer.parseInt(mccmnc.substring(0, 3));
        mnc = Integer.parseInt(mccmnc.substring(3));
    }
    else {
        Log.e(TAG, "CellIdPre17API: wrong legnth (5-6) for mccmnc=" + mccmnc);
    }
    type = telephonyManager.getNetworkType();
    if (DEBUG) Log.d(TAG, "CellIdPre17API: mcc=" + mcc + ", mnc=" + mnc + ", type=" + type + " cellLocation=" + cellLocation + ", neighboringCellInfoList=" + neighboringCellInfoList);
}
项目:femtocatcher    文件:NetworkInfoActivity.java   
public void startTracking() {
        mTelephonyManager = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
         mListener = new PhoneStateListener() {
             public void onCellLocationChanged(CellLocation location) {
                 Log.d(TAG, "Cell Location changed!");
                 getCellNetworkInfo();

             }
//           public void onServiceStateChanged(ServiceState s){
//               Log.d(TAG, "Service State changed!");
//               getServiceStateInfo(s);
//           }
        };
        mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_CELL_LOCATION);
        mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_SERVICE_STATE);
    }
项目:geoPingProject    文件:BackgroudLocService.java   
private void sendGsmBrodcat(CellLocation location) {
    Log.d(TAG, "onCellLocationChanged : " + location);
        if (location instanceof GsmCellLocation) {
            String networkOperator = telephonyManager.getNetworkOperator();
            if (networkOperator != null) {
                // Mobile Country Code
                 int mcc = Integer.parseInt(networkOperator.substring(0, 3));
                 // Mobile Network Code
                int mnc = Integer.parseInt(networkOperator.substring(3));
                Log.d(TAG, String.format("networkOperator mcc=%s / mnc=%s", mcc, mnc));
            }

           GsmCellLocation gsmLocation = (GsmCellLocation)location;
           int cid = gsmLocation.getCid();
           int lac = gsmLocation.getLac();
            sendGsmBrodcat(cid, lac);
       }
}
项目:geoPingProject    文件:GeoPingSlaveLocationService.java   
/**
 * {link http://www.devx.com/wireless/Article/40524/0/page/2}
 */
private int[] getCellId() {
    int[] cellId = new int[0];
    CellLocation cellLoc = telephonyManager.getCellLocation();
    if (cellLoc != null && (cellLoc instanceof GsmCellLocation)) {
        GsmCellLocation gsmLoc = (GsmCellLocation) cellLoc;
        gsmLoc.getPsc();
        // gsm cell id
        int cid = gsmLoc.getCid();
        // gsm location area code
        int lac = gsmLoc.getLac();
        // On a UMTS network, returns the primary scrambling code of the
        // serving cell.
        int psc = gsmLoc.getPsc();
        Log.d(TAG, String.format("Cell Id : %s  / Lac : %s  / Psc : %s", cid, lac, psc));
        if (psc > -1) {
            cellId = new int[3];
            cellId[2] = psc;
        } else {
            cellId = new int[2];
        }
        cellId[0] = cid;
        cellId[1] = lac;
    }
    return cellId;
}
项目: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;
    }
}
项目:boohee_v5.6    文件:t.java   
public void onCellLocationChanged(CellLocation cellLocation) {
    if (cellLocation != null) {
        try {
            this.a.if(this.a.d3.getCellLocation());
        } catch (Exception e) {
        }
    }
}
项目:XPrivacy    文件:XTelephonyManager.java   
private static CellLocation getDefacedCellLocation(int uid) {
    int cid = (Integer) PrivacyManager.getDefacedProp(uid, "CID");
    int lac = (Integer) PrivacyManager.getDefacedProp(uid, "LAC");
    if (cid > 0 && lac > 0) {
        GsmCellLocation cellLocation = new GsmCellLocation();
        cellLocation.setLacAndCid(lac, cid);
        return cellLocation;
    } else
        return CellLocation.getEmpty();
}
项目:smarper    文件:XTelephonyManager.java   
private static CellLocation getDefacedCellLocation(int uid) {
    int cid = (Integer) PrivacyManager.getDefacedProp(uid, "CID");
    int lac = (Integer) PrivacyManager.getDefacedProp(uid, "LAC");
    if (cid > 0 && lac > 0) {
        GsmCellLocation cellLocation = new GsmCellLocation();
        cellLocation.setLacAndCid(lac, cid);
        return cellLocation;
    } else
        return CellLocation.getEmpty();
}
项目:TowerCollector    文件:CollectorService.java   
private void processCellLocation(CellLocation cellLocation, List<NeighboringCellInfo> neighboringCells) {
    // get network type
    int networkTypeInt = telephonyManager.getNetworkType();
    NetworkGroup networkType = NetworkTypeUtils.getNetworkGroup(networkTypeInt);
    // get network operator (may be unreliable for CDMA)
    String networkOperatorCode = telephonyManager.getNetworkOperator();
    String networkOperatorName = telephonyManager.getNetworkOperatorName();
    Log.d("processCellLocation(): Operator code = '%s', name = '%s'", networkOperatorCode, networkOperatorName);
    Log.d("processCellLocation(): Reported %s neighboring cells", (neighboringCells != null ? neighboringCells.size() : null));
    measurementUpdater.setLastCellLocation(cellLocation, networkType, networkOperatorCode, networkOperatorName, neighboringCells);
}
项目: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() + "`");
}
项目:TowerCollector    文件:MobileUtils.java   
private static boolean isApi1CellInfoAvailable(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    CellLocation cell;
    try {
        cell = telephonyManager.getCellLocation();
    } catch (SecurityException ex) {
        Log.d("isApi1CellInfoAvailable(): Result = coarse location permission is denied", ex);
        return false;
    }
    if (cell == null) {
        Log.d("isApi1CellInfoAvailable(): Result = no cell location");
        return false;
    }
    int mcc = Measurement.UNKNOWN_CID;
    int mnc = Measurement.UNKNOWN_CID;
    if (cell instanceof GsmCellLocation) {
        String operatorCode = telephonyManager.getNetworkOperator();
        int[] mccMncPair = getMccMncPair(operatorCode);
        if (mccMncPair == null) {
            Log.d("isApi1CellInfoAvailable(): Result = no operator code");
            return false;
        }
        mcc = mccMncPair[0];
        mnc = mccMncPair[1];
    }
    CellLocationValidator validator = new CellLocationValidator();
    boolean result = validator.isValid(cell, mcc, mnc);
    Log.d("isApi1CellInfoAvailable(): Result = %s", result);
    return result;
}
项目:TowerCollector    文件:LegacyMeasurementProcessingEvent.java   
public LegacyMeasurementProcessingEvent(Location lastLocation, long lastLocationObtainedTime,
                                        CellLocation lastCellLocation, SignalStrength lastSignalStrength, NetworkGroup lastNetworkType,
                                        String lastOperatorCode, String lastOperatorName, List<NeighboringCellInfo> neighboringCells,
                                        int minDistance) {
    this.lastLocation = lastLocation;
    this.lastLocationObtainedTime = lastLocationObtainedTime;
    this.lastCellLocation = lastCellLocation;
    this.lastSignalStrength = lastSignalStrength;
    this.lastNetworkType = lastNetworkType;
    this.neighboringCells = neighboringCells;
    this.lastOperatorCode = lastOperatorCode;
    this.lastOperatorName = lastOperatorName;
    this.minDistance = minDistance;
}
项目:Android-IMSI-Catcher-Detector    文件:CellTracker.java   
/**
 *  Description:    This snippet sets a global variable (SharedPreference) to indicate
 *                  if Neighboring cells info CAN be obtained or has been obtained
 *                  previously. If it has been and suddenly there are none, we can
 *                  raise a flag of CID being suspicious.
 *
 *                  The logic is:
 *
 *                      IF NC has never been seen on device:
 *                          - NC list is NOT supported on this AOS/HW, so we do nothing.
 *                      IF NC has been seen before,
 *                          - NC list IS supported on this AOS/HW, so we set:
 *                              nc_list_present : "true"
 *                      IF NC list has been seen before AND current CID doesn't provide
 *                      one, we raise an alarm or flag.
 *
 *
 *  Notes:      a)  Not sure where to place this test, but let's try it here..
 *              b)  In TinyDB, the getBoolean() returns "false" by default, if empty.
 *
 *              c)   This will be called on every cell change (ref:  issue #346)
 *              d)  *** https://github.com/CellularPrivacy/Android-IMSI-Catcher-Detector/issues/383
 *
 *  Issue:
 *          [ ] We need a timer or "something" to reverse a positive detection once
 *              we're out and away from the fake BTS cell.
 *          [ ] We need to add this to EventLog
 *          [ ] We need to add detection tickers etc...
 *          [x] We need to use a global and persistent variable and not a system property
 *
 */
public void checkForNeighborCount(CellLocation location) {
    log.info("CheckForNeighborCount()");

    emptyNeighborCellsList = false;

    Integer neighborCellsCount = 0;
    if (tm != null && tm.getNeighboringCellInfo() != null) { // See # 383
        neighborCellsCount = tm.getNeighboringCellInfo().size();
    }

    // NC list present for that network type? (default is false)
    String ncListVariableByType = "nc_list_present_" + tm.getNetworkType();
    Boolean nclSupportedByNetwork = tinydb.getBoolean(ncListVariableByType);

    if (neighborCellsCount > 0) {
        log.debug("NeighboringCellInfo size: " + neighborCellsCount);
        if (!nclSupportedByNetwork)  {
            log.debug("Setting " + ncListVariableByType + " to: true");
            tinydb.putBoolean(ncListVariableByType, true);
        }
    } else if (neighborCellsCount == 0 && nclSupportedByNetwork) {
        // Detection 7a
        log.info("ALERT: No neighboring cells detected for CID: " + device.cell.getCellId());

        emptyNeighborCellsList = true;

        @Cleanup Realm realm = Realm.getDefaultInstance();
        dbHelper.toEventLog(realm, 4, "No neighboring cells detected"); // (DF_id, DF_desc)
    } else  {
        // Todo: remove cid string when working.
        log.debug("NC list not supported by this networkn type or not supported by AOS on this device. Nothing to do.");
        log.debug("Setting " + ncListVariableByType + " to: false");
        tinydb.putBoolean(ncListVariableByType, false);
    }
    setNotification();
}
项目:Easer    文件:CellLocationSlot.java   
@Override
synchronized public void onCellLocationChanged(CellLocation location) {
    super.onCellLocationChanged(location);
    curr = CellLocationSingleData.fromCellLocation(location);
    if (type == EventType.any) {
        changeSatisfiedState(target.contains(curr));
    } else if (type == EventType.none) {
        changeSatisfiedState(!target.contains(curr));
    }
}
项目: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();
}
项目:xprivacy-mod    文件:XTelephonyManager.java   
private static CellLocation getDefacedCellLocation(int uid) {
    int cid = (Integer) PrivacyManager.getDefacedProp(uid, "CID");
    int lac = (Integer) PrivacyManager.getDefacedProp(uid, "LAC");
    if (cid > 0 && lac > 0) {
        GsmCellLocation cellLocation = new GsmCellLocation();
        cellLocation.setLacAndCid(lac, cid);
        return cellLocation;
    } else
        return CellLocation.getEmpty();
}
项目: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    文件: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;
    }
}
项目:dd-collector    文件:EventLogBuilder.java   
public static final CellLocation getCellLocation() {
    try {
        return AirplugAnalyticTracker.telephonyManager.getCellLocation();
    } catch (SecurityException e) {
        return null;
    }
}
项目:android_external_UnifiedNlpApi    文件:CellBackendHelper.java   
@SuppressWarnings("deprecation")
private synchronized void fallbackScan() {
    if (lastScan + MIN_UPDATE_INTERVAL > System.currentTimeMillis()) return;
    List<CellInfo> allCellInfo = telephonyManager.getAllCellInfo();
    if ((allCellInfo == null || allCellInfo.isEmpty()) && telephonyManager.getNetworkType() > 0) {
        allCellInfo = new ArrayList<CellInfo>();
        CellLocation cellLocation = telephonyManager.getCellLocation();
        CellInfo cellInfo = fromCellLocation(cellLocation);
        if (cellInfo != null) allCellInfo.add(cellInfo);
    }
    onCellsChanged(allCellInfo);
}
项目: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");
    }
项目:PhoneProfilesPlus    文件:PhoneStateScanner.java   
@SuppressLint("MissingPermission")
private void getCellLocation() {
    if (telephonyManager != null) {
        CellLocation location = null;
        if (Permissions.checkLocation(context.getApplicationContext()))
            location = telephonyManager.getCellLocation();
        getCellLocation(location);
    }
}
项目:tabulae    文件:WirelessEnvListener.java   
public void run() {
    //if (DEBUG) Log.d(TAG, "run:");
    try {
        onCellInfoChanged(null);
        telephonyManager.listen(this, PhoneStateListener.LISTEN_CELL_INFO | PhoneStateListener.LISTEN_SERVICE_STATE);
        CellLocation.requestLocationUpdate();
    }
    catch (Exception ignore) {
    }
}
项目:MiBandDecompiled    文件:ai.java   
protected final List a(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 GsmCellLocation))
                {
                    arraylist.add(Integer.valueOf(((GsmCellLocation)celllocation).getLac()));
                    arraylist.add(Integer.valueOf(((GsmCellLocation)celllocation).getCid()));
                    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;
    }
项目: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;
    }