From e43a6436c64126ade800d5c1fe9bec20144c30eb Mon Sep 17 00:00:00 2001 From: Dave Mariano Date: Sun, 18 Jan 2015 18:20:37 -0500 Subject: [PATCH] Fixed Issue #91 - Lack of notification and tickerText in the event of cellID not existing in the OCID database. --- .../AIMSICD/adapters/AIMSICDDbAdapter.java | 2 +- .../SecUpwN/AIMSICD/service/CellTracker.java | 35 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java b/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java index af5420ebc..84e88ca16 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java @@ -320,7 +320,7 @@ boolean cellExists(int cellID) { /** * Checks to see if Cell already exists in OpenCellID database */ - boolean openCellExists(int cellID) { + public boolean openCellExists(int cellID) { Cursor cursor = mDb.rawQuery("SELECT * FROM " + OPENCELLID_TABLE + " WHERE CellID = " + cellID, null); diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java b/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java index b11a7410f..6a8d63c97 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java @@ -80,6 +80,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi private boolean mTrackingFemtocell; private boolean mFemtoDetected; private boolean mChangedLAC; + private boolean mCellIdNotInOpenDb; private Cell mMonitorCell; private boolean mTypeZeroSmsDetected; private LinkedBlockingQueue neighboringCellBlockingQueue; @@ -642,7 +643,6 @@ public void cancelNotification() { * Set or update the Notification */ void setNotification() { - String tickerText; String contentText = "Phone Type " + mDevice.getPhoneType(); @@ -651,6 +651,9 @@ void setNotification() { } else if (mChangedLAC) { Status.setCurrentStatus(Status.Type.MEDIUM, this.context); contentText = "Hostile Service Area: Changing LAC Detected!"; + } else if(mCellIdNotInOpenDb){ + Status.setCurrentStatus(Status.Type.MEDIUM, this.context); + contentText = "Cell ID does not exist in OpenCellID Database!"; } else if (mTrackingFemtocell || mTrackingCell || mMonitoringCell) { Status.setCurrentStatus(Status.Type.NORMAL, this.context); if (mTrackingFemtocell) { @@ -672,9 +675,30 @@ void setNotification() { tickerText = context.getResources().getString(R.string.app_name_short) + " - Status: Good. No Threats Detected."; break; case MEDIUM: //MEDIUM - tickerText = context.getResources().getString(R.string.app_name_short) + " - Hostile Service Area: Changing LAC Detected!"; + /** + * New Issue (Noticed from #91): + * Problem: + * Having multiple notifications will cause an issue with + * notifications themselves AND tickerText. It seems that the + * most recent notification raised would overwrite any previous, + * notification or tickerText. This results in loss of information + * for any notification before the last one. + * + * Solution?: + * Perhaps arranging a queue implementation to deal with text + * being passed into tickerText only when any previous text has + * been entirely displayed. + **/ + //Initialize tickerText as the app name string + tickerText = context.getResources().getString(R.string.app_name_short); if (mChangedLAC) { + //Append changing LAC text + tickerText += " - Hostile Service Area: Changing LAC Detected!"; contentText = "Hostile Service Area: Changing LAC Detected!"; + }else if (mCellIdNotInOpenDb) { + //Append Cell ID not existing in external db text + tickerText += " - Cell ID does not exist in OpenCellID Database!"; + contentText = "Cell ID does not exist in OpenCellID Database!"; } break; case ALARM: //DANGER @@ -731,6 +755,13 @@ public void run() { } else { mChangedLAC = false; } + //Check if CellID is in OpenCell database (issue #91) + if (!dbHelper.openCellExists(mMonitorCell.getCID())){ + mCellIdNotInOpenDb = true; + setNotification(); + } else { + mCellIdNotInOpenDb = false; + } dbHelper.close(); } break;