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

d.java 文件源码 项目:letv 阅读 38 收藏 0 点赞 0 评论 0
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);
        }
    }
}
MeasurementUpdater.java 文件源码 项目:TowerCollector 阅读 21 收藏 0 点赞 0 评论 0
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();
    }
}
MeasurementUpdater.java 文件源码 项目:TowerCollector 阅读 24 收藏 0 点赞 0 评论 0
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;
}
CellLocationConverter.java 文件源码 项目:TowerCollector 阅读 18 收藏 0 点赞 0 评论 0
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() + "`");
    }
}
CellLocationSingleData.java 文件源码 项目:Easer 阅读 17 收藏 0 点赞 0 评论 0
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;
}
LibPhoneStateListener.java 文件源码 项目:android-QoS 阅读 39 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
LibPhoneStateListener.java 文件源码 项目:android-QoS 阅读 38 收藏 0 点赞 0 评论 0
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;
}
CellHistory.java 文件源码 项目:android-QoS 阅读 18 收藏 0 点赞 0 评论 0
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();
//          }
        }
PhoneStateScanner.java 文件源码 项目:PhoneProfilesPlus 阅读 29 收藏 0 点赞 0 评论 0
@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();
}
CellIdPre17API.java 文件源码 项目:tabulae 阅读 19 收藏 0 点赞 0 评论 0
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);
}
ay.java 文件源码 项目:MiBandDecompiled 阅读 20 收藏 0 点赞 0 评论 0
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;
        }
    }
}
CellIdPre17API.java 文件源码 项目:Simplicissimus 阅读 17 收藏 0 点赞 0 评论 0
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);
}
CellbasedLocationProvider.java 文件源码 项目:LocalGSMLocationProvider 阅读 19 收藏 0 点赞 0 评论 0
/**
 * 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();
    }
}
CellIdPre17API.java 文件源码 项目:pyneo-wirelesslocation 阅读 23 收藏 0 点赞 0 评论 0
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);
}
NetworkInfoActivity.java 文件源码 项目:femtocatcher 阅读 23 收藏 0 点赞 0 评论 0
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);
    }
BackgroudLocService.java 文件源码 项目:geoPingProject 阅读 21 收藏 0 点赞 0 评论 0
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);
       }
}
GeoPingSlaveLocationService.java 文件源码 项目:geoPingProject 阅读 20 收藏 0 点赞 0 评论 0
/**
 * {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;
}
CellTowerProbe.java 文件源码 项目:funf-v4 阅读 24 收藏 0 点赞 0 评论 0
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;
}
MapLocationActivity.java 文件源码 项目:Misc 阅读 19 收藏 0 点赞 0 评论 0
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 };
}
LetvUtils.java 文件源码 项目:letv 阅读 19 收藏 0 点赞 0 评论 0
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;
    }
}
t.java 文件源码 项目:boohee_v5.6 阅读 28 收藏 0 点赞 0 评论 0
public void onCellLocationChanged(CellLocation cellLocation) {
    if (cellLocation != null) {
        try {
            this.a.if(this.a.d3.getCellLocation());
        } catch (Exception e) {
        }
    }
}
XTelephonyManager.java 文件源码 项目:XPrivacy 阅读 28 收藏 0 点赞 0 评论 0
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();
}
XTelephonyManager.java 文件源码 项目:smarper 阅读 26 收藏 0 点赞 0 评论 0
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();
}
CollectorService.java 文件源码 项目:TowerCollector 阅读 23 收藏 0 点赞 0 评论 0
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);
}
CellLocationValidator.java 文件源码 项目:TowerCollector 阅读 20 收藏 0 点赞 0 评论 0
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() + "`");
}
MobileUtils.java 文件源码 项目:TowerCollector 阅读 19 收藏 0 点赞 0 评论 0
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;
}
LegacyMeasurementProcessingEvent.java 文件源码 项目:TowerCollector 阅读 19 收藏 0 点赞 0 评论 0
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;
}
CellTracker.java 文件源码 项目:Android-IMSI-Catcher-Detector 阅读 20 收藏 0 点赞 0 评论 0
/**
 *  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();
}
CellLocationSlot.java 文件源码 项目:Easer 阅读 18 收藏 0 点赞 0 评论 0
@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));
    }
}
RadioInfo.java 文件源码 项目:CellularSignal 阅读 19 收藏 0 点赞 0 评论 0
@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();
}


问题


面经


文章

微信
公众号

扫码关注公众号