Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 0 additions & 252 deletions AIMSICD/src/main/java/com/secupwn/aimsicd/adapters/CardItemData.java
Original file line number Diff line number Diff line change
@@ -1,252 +0,0 @@
/* Android IMSI-Catcher Detector | (c) AIMSICD Privacy Project
* -----------------------------------------------------------
* LICENSE: http://git.io/vki47 | TERMS: http://git.io/vki4o
* -----------------------------------------------------------
*/
package com.secupwn.aimsicd.adapters;

import com.secupwn.aimsicd.utils.Cell;

import lombok.Getter;

/**
* Description: TODO: A few comments please!
* TODO: Where is this used exactly?
*
* Dependencies:
*
*
* Usage:
*
* Used to define methods in:
* OpenCellIdCardInflater.java
* EventLogCardInflater.java
*
*
* Issues:
* -----------------------------------------------------------------------------------------
* Notes:
*
* We often talk about "Network Type", when we actually refer to:
* "RAN" = Radio Access Network (cellular communication only)
* "RAT" = Radio Access Technology (any wireless communication technology, like WiMax etc.)
*
* As for this application, we shall use the terms:
* "Type" for the text values like ( UMTS/WCDMA, HSDPA, CDMA, LTE etc) and
* "RAT" for the numerical equivalent (As obtained by AOS API?)
*
* ------------------------------------------------------------------------------------------
*/
@Getter
public class CardItemData {
// OLD (in old DB tables)
private final String cellId;
private final String lac;
private final String mcc;
private final String mnc;
private final String net;
private final String signal;
private final String avgSigStr;
private final String samples;
private final String lat;
private final String lon;
private final String country;
private final String psc;
private final String timestamp;
private final String recordId;

// NEW (in new DB tables)
/*
private final String mtime;
private final String mLAC;
private final String mCID;
private final String mPSC;
private final String mgpsd_lat;
private final String mgpsd_lon;
private final String mgpsd_accu;
private final String mDF_id;
private final String mDF_description;
*/


// OLD items in old DB table structure

public CardItemData(Cell cell, String recordId) {

if (cell.getCellId() != Integer.MAX_VALUE && cell.getCellId() != -1) {
cellId = "CID: " + cell.getCellId() + " (0x" + Integer.toHexString(cell.getCellId()) + ")";
} else {
cellId = "N/A";
}

if (cell.getLocationAreaCode() != Integer.MAX_VALUE && cell.getLocationAreaCode() != -1) {
lac = "LAC: " + cell.getLocationAreaCode();
} else {
lac = "N/A";
}

if (cell.getMobileCountryCode() != Integer.MAX_VALUE && cell.getMobileCountryCode() != 0) {
mcc = "MCC: " + cell.getMobileCountryCode();
} else {
mcc = "N/A";
}

if (cell.getMobileNetworkCode() != Integer.MAX_VALUE && cell.getMobileNetworkCode() != 0) {
mnc = "MNC: " + cell.getMobileNetworkCode();
} else {
mnc = "N/A";
}

if (cell.getNetType() != Integer.MAX_VALUE && cell.getNetType() != -1) {
net = "Type: " + cell.getNetType() + " - " + cell.getRat();
} else {
net = "N/A";
}

if (cell.getPrimaryScramblingCode() != Integer.MAX_VALUE && cell.getPrimaryScramblingCode() != -1) {
psc = "PSC: " + cell.getPrimaryScramblingCode();
} else {
psc = "N/A";
}

if (cell.getRssi() != Integer.MAX_VALUE && cell.getRssi() != -1) {
signal = "RSSI: " + cell.getRssi();
} else if (cell.getDbm() != Integer.MAX_VALUE && cell.getDbm() != -1) {
signal = "dBm: " + cell.getDbm();
} else {
signal = "N/A";
}
// NEW (in new DB tables)


// end New

lat = "N/A";
lon = "N/A";
avgSigStr = "N/A";
samples = "N/A";
country = "N/A";
timestamp = "N/A";
this.recordId = recordId;

// NEW (in new DB tables)

// end New

}

public CardItemData(String cellID, String lac, String mcc, String mnc, String lat, String lng,
String avgSigStr, String samples, String recordId) {
cellId = cellID;
this.lac = lac;
this.mcc = mcc;
this.mnc = mnc;
net = "Network Type: N/A";
this.lat = lat;
lon = lng;
signal = "Signal: N/A";
this.avgSigStr = avgSigStr;
this.samples = samples;
psc = "PSC: N/A";
country = "Country: N/A";
timestamp = "Timestamp: N/A";
this.recordId = recordId;
}

public CardItemData(String cellID, String psc, String mcc, String mnc, String signal,
String recordId) {
cellId = cellID;
lac = "LAC: N/A";
this.mcc = mcc;
this.mnc = mnc;
lat = "Latitude: N/A";
lon = "Longitude: N/A";
net = "Network Type: N/A";
avgSigStr = "Avg Signal: N/A";
samples = "Samples: N/A";
this.signal = signal;
this.psc = psc;
country = "Country: N/A";
timestamp = "Timestamp: N/A";
this.recordId = recordId;
}

public CardItemData(String cellID, String lac, String mcc, String mnc, String signal,
String psc, String timestamp, String recordId) {
cellId = cellID;
this.lac = lac;
this.mcc = mcc;
this.mnc = mnc;
lat = "Latitude: N/A";
lon = "Longitude: N/A";
net = "Network Type: N/A";
this.signal = signal;
this.psc = psc;
avgSigStr = "Avg Signal: N/A";
samples = "Samples: N/A";
this.timestamp = timestamp;
country = "Country: N/A";
this.recordId = recordId;
}

public CardItemData(int type, String cellID, String lac, String mcc, String mnc, String signal,
String timestamp, String recordId) {
cellId = cellID;
this.lac = lac;
this.mcc = mcc;
this.mnc = mnc;
lat = "Latitude: N/A";
lon = "Longitude: N/A";
net = "Network Type: N/A";
this.signal = signal;
avgSigStr = "Avg Signal: N/A";
samples = "Samples: N/A";
this.timestamp = timestamp;
psc = "PSC: N/A";
country = "Country: N/A";
this.recordId = recordId;
}

public CardItemData(String cellID, String lac, String net, String lat, String lng,
String signal, String recordId) {
cellId = cellID;
this.lac = lac;
this.net = net;
mcc = "MCC: N/A";
mnc = "MNC: N/A";
this.lat = lat;
lon = lng;
this.signal = signal;
avgSigStr = "Avg Signal: N/A";
samples = "Samples: N/A";
psc = "PSC: N/A";
country = "Country: N/A";
timestamp = "Timestamp: N/A";
this.recordId = recordId;
}

public CardItemData(String country, String mcc, String lat, String lng, String recordId) {
cellId = "CellID: N/A";
lac = "LAC: N/A";
this.country = country;
this.mcc = mcc;
mnc = "MNC: N/A";
net = "Network Type: N/A";
signal = "Signal: N/A";
this.lat = lat;
lon = lng;
avgSigStr = "Avg Signal: N/A";
samples = "Samples: N/A";
psc = "PSC: N/A";
timestamp = "Timestamp: N/A";
this.recordId = recordId;
}

// NEW (in new DB tables)
// EventLog

//public String getAccu() {
// return mAccu;
//}

}
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,8 @@ public void onCellLocationChanged(CellLocation location) {
device.cell.setLocationAreaCode(cdmaCellLocation.getNetworkId()); // NID
device.cell.setCellId(cdmaCellLocation.getBaseStationId()); // BID
device.cell.setSid(cdmaCellLocation.getSystemId()); // SID
device.cell.setMobileNetworkCode(cdmaCellLocation.getSystemId()); // MNC <== BUG!??
// Note: MNC is NOT the same as SID. MCC/MNC comes from
// ro.cdma.home.operator.numeric, handled in Device.refreshDeviceInfo()
device.setNetworkName(tm.getNetworkOperatorName()); // ??
}
}
Expand Down Expand Up @@ -873,10 +874,11 @@ public void onLocationChanged(Location loc) {

case TelephonyManager.PHONE_TYPE_CDMA:
CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation;
device.cell.setCellId(cdmaCellLocation.getBaseStationId()); // BSID ??
device.cell.setCellId(cdmaCellLocation.getBaseStationId()); // BID
device.cell.setLocationAreaCode(cdmaCellLocation.getNetworkId()); // NID
device.cell.setSid(cdmaCellLocation.getSystemId()); // SID
device.cell.setMobileNetworkCode(cdmaCellLocation.getSystemId()); // MNC <== BUG!??
// Note: MNC is NOT the same as SID. MCC/MNC comes from
// ro.cdma.home.operator.numeric, handled in Device.refreshDeviceInfo()

break;
}
Expand Down
17 changes: 12 additions & 5 deletions AIMSICD/src/main/java/com/secupwn/aimsicd/utils/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,20 @@ public boolean equals(Object obj) {
public String toString() {
StringBuilder result = new StringBuilder();

result.append("cid - ").append(cellId).append("\n");
result.append("LAC - ").append(locationAreaCode).append("\n");
if (isCdma()) {
// CDMA uses BID/NID/SID instead of CID/LAC/PSC
result.append("BID - ").append(cellId).append("\n");
result.append("NID - ").append(locationAreaCode).append("\n");
result.append("SID - ").append(sid).append("\n");
} else {
result.append("cid - ").append(cellId).append("\n");
result.append("LAC - ").append(locationAreaCode).append("\n");
result.append("PSC - ").append(validatePscValue(primaryScramblingCode)).append("\n");
}
result.append("MCC - ").append(mobileCountryCode).append("\n");
result.append("MNC - ").append(mobileNetworkCode).append("\n");
result.append("DBm - ").append(dbm).append("\n");
result.append("PSC - ").append(validatePscValue(primaryScramblingCode)).append("\n");
result.append("Type - ").append(netType).append("\n");
result.append("Type - ").append(getRat()).append("\n");
result.append("Lon - ").append(lon).append("\n");
result.append("Lat - ").append(lat).append("\n");

Expand Down Expand Up @@ -428,4 +435,4 @@ public Cell[] newArray(int size) {
return new Cell[size];
}
};
}
}
7 changes: 3 additions & 4 deletions AIMSICD/src/main/java/com/secupwn/aimsicd/utils/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ public void refreshDeviceInfo(TelephonyManager tm, Context context) {
if (cdmaCellLocation != null) {
cell.setCellId(cdmaCellLocation.getBaseStationId());
cell.setLocationAreaCode(cdmaCellLocation.getNetworkId());
cell.setSid(cdmaCellLocation.getSystemId()); // one of these must be a bug !!
// See: http://stackoverflow.com/questions/8088046/android-how-to-identify-carrier-on-cdma-network
// and: https://github.com/klinker41/android-smsmms/issues/26
cell.setMobileNetworkCode(cdmaCellLocation.getSystemId()); // todo: check! (Also CellTracker.java)
cell.setSid(cdmaCellLocation.getSystemId()); // SID
// Note: MNC is NOT the same as SID. MCC/MNC comes from
// ro.cdma.home.operator.numeric, handled below

//Retrieve MCC through System Property
String homeOperator = Helpers.getSystemProp(context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ public static void loadCellInfo(TelephonyManager tm, Device pDevice) {
// Signal Strength
pDevice.cell.setDbm(cdma.getDbm());
// Cell Identity
pDevice.cell.setCellId(identityCdma.getBasestationId());
pDevice.cell.setMobileNetworkCode(identityCdma.getSystemId());
pDevice.cell.setLocationAreaCode(identityCdma.getNetworkId());
pDevice.cell.setSid(identityCdma.getSystemId());
pDevice.cell.setCellId(identityCdma.getBasestationId()); // BID
pDevice.cell.setLocationAreaCode(identityCdma.getNetworkId()); // NID
pDevice.cell.setSid(identityCdma.getSystemId()); // SID
// Note: MNC is NOT the same as SID. MCC/MNC should come from
// ro.cdma.home.operator.numeric system property, handled in Device.java

} else if (info instanceof CellInfoLte) {
final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
Expand Down