/**
* 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();
}
CellTracker.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:Android-IMSI-Catcher-Detector
作者:
评论列表
文章目录