Java Code Examples for android.telephony.gsm.GsmCellLocation#getLac()
The following examples show how to use
android.telephony.gsm.GsmCellLocation#getLac() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MeasurementUpdater.java From TowerCollector with Mozilla Public License 2.0 | 6 votes |
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()); Timber.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()); Timber.d("isCellLocationEqual(): CDMA equal = %s", result); } else { // different types or nulls result = false; Timber.d("isCellLocationEqual(): Different types or nulls"); } return result; }
Example 2
Source File: ay.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
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; } } }
Example 3
Source File: Gsm.java From batteryhub with Apache License 2.0 | 5 votes |
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; }
Example 4
Source File: TelephonyActivity.java From nearbydemo with Eclipse Public License 1.0 | 5 votes |
private String getJsonCellPos() throws JSONException { TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); GsmCellLocation location = (GsmCellLocation) tm.getCellLocation(); if (location == null) { return null; } int cid = location.getCid(); int lac = location.getLac(); String netOperator = tm.getNetworkOperator(); int mcc = Integer.valueOf(netOperator.substring(0, 3)); int mnc = Integer.valueOf(netOperator.substring(3, 5)); System.out.println("cid" + cid + ",lac" + lac + ",mcc" + mcc + "" + ",mnc" + mnc); JSONObject jsonCellPos = new JSONObject(); jsonCellPos.put("version", "1.1.0"); jsonCellPos.put("host", "maps.google.com"); JSONArray array = new JSONArray(); JSONObject json1 = new JSONObject(); json1.put("location_area_code", "" + lac + ""); json1.put("mobile_country_code", "" + mcc + ""); json1.put("mobile_network_code", "" + mnc + ""); json1.put("age", 0); json1.put("cell_id", "" + cid + ""); array.put(json1); jsonCellPos.put("cell_towers", array); return jsonCellPos.toString(); }
Example 5
Source File: TelephonyActivity.java From nearbydemo with Eclipse Public License 1.0 | 5 votes |
public String getJsonCellPos1() { TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); GsmCellLocation location = (GsmCellLocation) tm.getCellLocation(); if (location == null) { return null; } int cid = location.getCid(); int lac = location.getLac(); String netOperator = tm.getNetworkOperator(); int mcc = Integer.valueOf(netOperator.substring(0, 3)); int mnc = Integer.valueOf(netOperator.substring(3, 5)); System.out.println("cid" + cid + ",lac" + lac + ",mcc" + mcc + "" + ",mnc" + mnc); holder = new JSONObject(); JSONArray array = new JSONArray(); JSONObject data = new JSONObject(); try { holder.put("version", "1.1.0"); holder.put("host", "maps.google.com"); holder.put("address_language", "zh_CN"); holder.put("request_address", true); holder.put("radio_type", "gsm"); holder.put("carrier", "HTC"); data.put("cell_id", cid); data.put("location_area_code", lac); data.put("mobile_countyr_code", mcc); data.put("mobile_network_code", mnc); array.put(data); holder.put("cell_towers", array); Log.i(TAG, "JSON��Ϣ��" + holder.toString()); return holder.toString(); } catch (JSONException e) { e.printStackTrace(); } return null; }
Example 6
Source File: CellTowerListLte.java From satstat with GNU General Public License v3.0 | 5 votes |
/** * Adds or updates a cell tower. * <p> * If the cell tower is already in the list, its data is updated; if not, a * new entry is created. * <p> * This method will set the cell's identity data. After this call, * {@link #isServing()} will return {@code true} for this cell. * @param networkOperator The network operator, as returned by {@link android.telephony.TelephonyManager#getNetworkOperator()}. * @param location The {@link android.telephony.GsmCellLocation}, as returned by {@link android.telephony.TelephonyManager#getCellLocation()}. * @return The new or updated entry. */ public CellTowerLte update(String networkOperator, GsmCellLocation location) { int mcc = CellTower.UNKNOWN; int mnc = CellTower.UNKNOWN; if (networkOperator.length() > 3) { mcc = Integer.parseInt(networkOperator.substring(0, 3)); mnc = Integer.parseInt(networkOperator.substring(3)); } CellTowerLte result = null; CellTowerLte cand = this.get(mcc, mnc, location.getLac(), location.getCid()); if ((cand != null) && CellTower.matches(location.getPsc(), cand.getPci())) result = cand; if (result == null) { cand = this.get(location.getPsc()); if ((cand != null) && CellTower.matches(mcc, cand.getMcc()) && CellTower.matches(mnc, cand.getMnc()) && CellTower.matches(location.getLac(), cand.getTac()) && CellTower.matches(location.getCid(), cand.getCi())) result = cand; } if (result == null) result = new CellTowerLte(mcc, mnc, location.getLac(), location.getCid(), location.getPsc()); if (result.getMcc() == CellTower.UNKNOWN) result.setMcc(mcc); if (result.getMnc() == CellTower.UNKNOWN) result.setMnc(mnc); if (result.getTac() == CellTower.UNKNOWN) result.setTac(location.getLac()); if (result.getCi() == CellTower.UNKNOWN) result.setCi(location.getCid()); if (result.getPci() == CellTower.UNKNOWN) result.setPci(location.getPsc()); this.put(result.getText(), result); this.put(result.getAltText(), result); result.setCellLocation(true); Log.d(this.getClass().getSimpleName(), String.format("Added GsmCellLocation for %s, %d G", result.getText(), result.getGeneration())); return result; }
Example 7
Source File: CellTowerListGsm.java From satstat with GNU General Public License v3.0 | 5 votes |
/** * Adds or updates a cell tower. * <p> * If the cell tower is already in the list, its data is updated; if not, a * new entry is created. * <p> * This method will set the cell's identity data. After this call, * {@link #isServing()} will return {@code true} for this cell. * @param networkOperator The network operator, as returned by {@link android.telephony.TelephonyManager#getNetworkOperator()}. * @param location The {@link android.telephony.GsmCellLocation}, as returned by {@link android.telephony.TelephonyManager#getCellLocation()}. * @return The new or updated entry. */ public CellTowerGsm update(String networkOperator, GsmCellLocation location) { int mcc = CellTower.UNKNOWN; int mnc = CellTower.UNKNOWN; if (networkOperator.length() > 3) { mcc = Integer.parseInt(networkOperator.substring(0, 3)); mnc = Integer.parseInt(networkOperator.substring(3)); } CellTowerGsm result = null; CellTowerGsm cand = this.get(mcc, mnc, location.getLac(), location.getCid()); if ((cand != null) && CellTower.matches(location.getPsc(), cand.getPsc())) result = cand; if (result == null) { cand = this.get(location.getPsc()); if ((cand != null) && CellTower.matches(mcc, cand.getMcc()) && CellTower.matches(mnc, cand.getMnc()) && CellTower.matches(location.getLac(), cand.getLac()) && CellTower.matches(location.getCid(), cand.getCid())) result = cand; } if (result == null) result = new CellTowerGsm(mcc, mnc, location.getLac(), location.getCid(), location.getPsc()); if (result.getMcc() == CellTower.UNKNOWN) result.setMcc(mcc); if (result.getMnc() == CellTower.UNKNOWN) result.setMnc(mnc); if (result.getLac() == CellTower.UNKNOWN) result.setLac(location.getLac()); if (result.getCid() == CellTower.UNKNOWN) result.setCid(location.getCid()); if (result.getPsc() == CellTower.UNKNOWN) result.setPsc(location.getPsc()); this.put(result.getText(), result); this.put(result.getAltText(), result); if ((result.getText() == null) && (result.getAltText() == null)) Log.d(this.getClass().getSimpleName(), String.format("Added %d G cell with no data from GsmCellLocation", result.getGeneration())); result.setCellLocation(true); return result; }
Example 8
Source File: NetUtil.java From ESeal with Apache License 2.0 | 4 votes |
/** * 获取手机基站的LAC (Location Aera Code) */ public static int getCellLocationLac(Activity activity) { TelephonyManager telephonyManager = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE); GsmCellLocation location = (GsmCellLocation) telephonyManager.getCellLocation(); return location.getLac(); }
Example 9
Source File: NetUtil.java From ESeal with Apache License 2.0 | 4 votes |
/** * 获取手机基站的LAC (Location Aera Code) */ public static int getCellLocationLac(Activity activity) { TelephonyManager telephonyManager = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE); GsmCellLocation location = (GsmCellLocation) telephonyManager.getCellLocation(); return location.getLac(); }