java类android.telephony.gsm.GsmCellLocation的实例源码

StrUtils.java 文件源码 项目:GitHub 阅读 30 收藏 0 点赞 0 评论 0
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;
}
JSONHelper.java 文件源码 项目:localcloud_fe 阅读 29 收藏 0 点赞 0 评论 0
/**
 * Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
 * http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
 * @param location GsmCellLocation
 * @return JSON
 */
public static String gsmCellLocationJSON(GsmCellLocation location){

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

    if(location != null){
        try {
            json.put("provider", CELLLOCATION_PROVIDER);
            json.put("type", GSM);
            json.put("timestamp", calendar.getTimeInMillis());
            json.put("cid", location.getCid());
            json.put("lac", location.getLac());
            json.put("psc", location.getPsc());
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
JSONHelper.java 文件源码 项目:localcloud_fe 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
 * http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
 * @param location GsmCellLocation
 * @return JSON
 */
public static String gsmCellLocationJSON(GsmCellLocation location){

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

    if(location != null){
        try {
            json.put("provider", CELLLOCATION_PROVIDER);
            json.put("type", GSM);
            json.put("timestamp", calendar.getTimeInMillis());
            json.put("cid", location.getCid());
            json.put("lac", location.getLac());
            json.put("psc", location.getPsc());
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
JSONHelper.java 文件源码 项目:localcloud_fe 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
 * http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
 * @param location GsmCellLocation
 * @return JSON
 */
public static String gsmCellLocationJSON(GsmCellLocation location){

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

    if(location != null){
        try {
            json.put("provider", CELLLOCATION_PROVIDER);
            json.put("type", GSM);
            json.put("timestamp", calendar.getTimeInMillis());
            json.put("cid", location.getCid());
            json.put("lac", location.getLac());
            json.put("psc", location.getPsc());
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
JSONHelper.java 文件源码 项目:cordova-plugin-advanced-geolocation 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
 * http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
 * @param location GsmCellLocation
 * @return JSON
 */
public static String gsmCellLocationJSON(GsmCellLocation location){

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

    if(location != null){
        try {
            json.put("provider", CELLLOCATION_PROVIDER);
            json.put("type", GSM);
            json.put("timestamp", calendar.getTimeInMillis());
            json.put("cid", location.getCid());
            json.put("lac", location.getLac());
            json.put("psc", location.getPsc());
        }
        catch(JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}
CellInfoObserver.java 文件源码 项目:cellservice 阅读 17 收藏 0 点赞 0 评论 0
public CellInfo getNewCellInfo() {
    try {
        TelephonyManager tm = (TelephonyManager) CellService.get().getSystemService(Context.TELEPHONY_SERVICE);
        GsmCellLocation location = (GsmCellLocation) tm.getCellLocation();

        /* Why I use this Bitmask:
         * https://stackoverflow.com/questions/9808396/android-cellid-not-available-on-all-carriers#12969638
         */
        int cellID = location.getCid();// & 0xffff;
        int lac = location.getLac();

        String networkOperator = tm.getNetworkOperator();
        int mcc = Integer.parseInt(networkOperator.substring(0, 3));
        int mnc = Integer.parseInt(networkOperator.substring(3));

        return new CellInfo(cellID, lac, mnc, mcc, tm.getNetworkType());
    } catch (Exception e) {
        return new FakeCellInfo();
    }
}
MeasurementUpdater.java 文件源码 项目:TowerCollector 阅读 19 收藏 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 阅读 22 收藏 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 阅读 26 收藏 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;
}
CellIdPre17API.java 文件源码 项目:tabulae 阅读 22 收藏 0 点赞 0 评论 0
@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;
}
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;
        }
    }
}
CellbasedLocationProvider.java 文件源码 项目:LocalGSMLocationProvider 阅读 20 收藏 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();
    }
}
BackgroudLocService.java 文件源码 项目:geoPingProject 阅读 22 收藏 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 阅读 22 收藏 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;
}
SearchActivity.java 文件源码 项目:GiveIndiaApp 阅读 48 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);

    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
       GsmCellLocation cellLocation = (GsmCellLocation)telephonyManager.getCellLocation();

       String networkOperator = telephonyManager.getNetworkOperator();
      // String mcc = networkOperator.substring(0, 3);
      // String mnc = networkOperator.substring(3);


      // int cid = cellLocation.getCid();
      //int lac = cellLocation.getLac();

       String mcc="404", mnc = "92", lac="1202", cid="31693";

    new RequestTask(this).execute("http://akarthik10.heliohost.org/scripts/cfg/loc.php?mcc="+mcc+"&mnc="+mnc+"&lac="+lac+"&cid="+cid);
}
CellTowerProbe.java 文件源码 项目:funf-v4 阅读 25 收藏 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;
}
LetvUtils.java 文件源码 项目:letv 阅读 24 收藏 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;
    }
}
XTelephonyManager.java 文件源码 项目:XPrivacy 阅读 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();
}
XTelephonyManager.java 文件源码 项目:smarper 阅读 27 收藏 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();
}
GsmCellLocationSubject.java 文件源码 项目:truth-android 阅读 18 收藏 0 点赞 0 评论 0
public static SubjectFactory<GsmCellLocationSubject, GsmCellLocation> type() {
  return new SubjectFactory<GsmCellLocationSubject, GsmCellLocation>() {
    @Override
    public GsmCellLocationSubject getSubject(FailureStrategy fs, GsmCellLocation that) {
      return new GsmCellLocationSubject(fs, that);
    }
  };
}
GSMCellLocationLbs.java 文件源码 项目:LBS 阅读 19 收藏 0 点赞 0 评论 0
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());
}
GsmCellLocationValidator.java 文件源码 项目:TowerCollector 阅读 18 收藏 0 点赞 0 评论 0
public boolean isValid(GsmCellLocation cell, int mcc, int mnc) {
    boolean valid = isValid(cell.getCid(), cell.getLac(), mnc, mcc, cell.getPsc());
    if (!valid) {
        Log.w("isValid(): Invalid GsmCellLocation [mcc=%s, mnc =%s, lac=%s, cid=%s, psc=%s]", mcc, mnc, cell.getLac(), cell.getCid(), cell.getPsc());
        Log.w("isValid(): Invalid GsmCellLocation %s", cell);
    }
    return valid;
}
CellLocationValidator.java 文件源码 项目:TowerCollector 阅读 17 收藏 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 阅读 20 收藏 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;
}
Gsm.java 文件源码 项目:batteryhub 阅读 18 收藏 0 点赞 0 评论 0
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;
  }
XTelephonyManager.java 文件源码 项目:xprivacy-mod 阅读 25 收藏 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();
}
CellLocationEx.java 文件源码 项目:android-QoS 阅读 22 收藏 0 点赞 0 评论 0
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;
}
CellLocationEx.java 文件源码 项目:android-QoS 阅读 20 收藏 0 点赞 0 评论 0
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;
}
CellLocationEx.java 文件源码 项目:android-QoS 阅读 23 收藏 0 点赞 0 评论 0
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;
}
WirelessLoggerService.java 文件源码 项目:openbmap 阅读 23 收藏 0 点赞 0 评论 0
/**
 * A valid gsm cell must have cell id != -1
 * Note: cells with cid > max value 0xffff are accepted (typically UMTS cells. We handle them separately
 * @param gsmLocation {@link GsmCellLocation}
 * @return true if valid gsm cell
 */
private boolean isValidGsmCell(final GsmCellLocation gsmLocation) {
    if (gsmLocation == null) {
        return false;
    }
    final Integer cid = gsmLocation.getCid();
    return (cid > 0 && cid != Integer.MAX_VALUE);
}


问题


面经


文章

微信
公众号

扫码关注公众号