|
15 | 15 | import android.database.sqlite.SQLiteDatabase;
|
16 | 16 | import android.database.sqlite.SQLiteException;
|
17 | 17 | import android.database.sqlite.SQLiteOpenHelper;
|
| 18 | +import android.os.Vibrator; |
18 | 19 | import android.util.Log;
|
19 | 20 | import android.util.SparseArray;
|
20 | 21 | import java.io.File;
|
@@ -136,6 +137,7 @@ public class AIMSICDDbAdapter extends SQLiteOpenHelper{
|
136 | 137 | private final String[] mTables;
|
137 | 138 | private SQLiteDatabase mDb;
|
138 | 139 | private final Context mContext;
|
| 140 | + //private static Context context; // Added by E:V:A for toEventLog() |
139 | 141 |
|
140 | 142 | public AIMSICDDbAdapter(Context context) {
|
141 | 143 | super(context, DB_NAME, null, 1);
|
@@ -2179,6 +2181,8 @@ public void insertDetectionFlags(int code,
|
2179 | 2181 | * Issues: [ ] ALL events should be logged!!
|
2180 | 2182 | * [ ] To avoid repeated copies, only check last DB entries
|
2181 | 2183 | * [ ] Before inserting event, check that LAC/CID are not "-1".
|
| 2184 | + * [ ] Any related notifications are better put here as well, right? |
| 2185 | + * [ ] |
2182 | 2186 | *
|
2183 | 2187 | * Notes: a) Table item order:
|
2184 | 2188 | *
|
@@ -2250,6 +2254,71 @@ public void insertEventLog(String time,
|
2250 | 2254 | }
|
2251 | 2255 | }
|
2252 | 2256 |
|
| 2257 | + /* |
| 2258 | + // Defining a new simpler version of insertEventLog: |
| 2259 | + public void toEventLog(int DF_id, String DF_desc){ |
| 2260 | + // TODO: What to use here... |
| 2261 | + //private static Context context; |
| 2262 | + //mContext = context; |
| 2263 | + //this.context = context; |
| 2264 | + Cell cell; //TODO is this enough? |
| 2265 | +
|
| 2266 | + String time = MiscUtils.getCurrentTimeStamp(); // time |
| 2267 | + int lac = cell.getLAC(); // LAC |
| 2268 | + int cid = cell.getCID(); // CID |
| 2269 | + int psc = cell.getPSC(); // PSC [UMTS,LTE] |
| 2270 | + String gpsd_lat = String.valueOf(cell.getLat());// gpsd_lat |
| 2271 | + String gpsd_lon = String.valueOf(cell.getLon());// gpsd_lon |
| 2272 | + int gpsd_accu = (int)cell.getAccuracy(); // gpsd_accu |
| 2273 | +
|
| 2274 | + // skip CID/LAC of "-1" (due to crappy API, Roaming or Air-Plane Mode) |
| 2275 | + if (cid != -1 || lac != -1) { |
| 2276 | + // Check if LAST entry is the same! |
| 2277 | + String query = String.format( |
| 2278 | + "SELECT * from EventLog WHERE _id=(SELECT max(_id) from EventLog) AND CID=%d AND LAC=%d AND PSC=%d AND DF_id=%d", |
| 2279 | + cid, lac, psc, DF_id); |
| 2280 | + Cursor cursor = mDb.rawQuery(query,null); |
| 2281 | +
|
| 2282 | + // WARNING: By skipping duplicate events, we might be missing counts of Type-0 SMS etc. |
| 2283 | + boolean insertData = true; |
| 2284 | + if (cursor.getCount() > 0) { insertData = false; } |
| 2285 | + cursor.close(); |
| 2286 | +
|
| 2287 | + if(insertData){ |
| 2288 | + ContentValues eventLog = new ContentValues(); |
| 2289 | +
|
| 2290 | + eventLog.put("time", time ); // time |
| 2291 | + eventLog.put("LAC", lac ); // LAC |
| 2292 | + eventLog.put("CID", cid ); // CID |
| 2293 | + eventLog.put("PSC", psc ); // PSC [UMTS,LTE] |
| 2294 | + eventLog.put("gpsd_lat", gpsd_lat ); // gpsd_lat |
| 2295 | + eventLog.put("gpsd_lon", gpsd_lon ); // gpsd_lon |
| 2296 | + eventLog.put("gpsd_accu", gpsd_accu ); // gpsd_accu |
| 2297 | + eventLog.put("DF_id", DF_id); // DF_id |
| 2298 | + eventLog.put("DF_description", DF_desc); // DF_desc |
| 2299 | +
|
| 2300 | + mDb.insert("EventLog", null, eventLog); |
| 2301 | + Log.i(TAG, mTAG + ":insertEventLog(): Added New Event: id=" +DF_id+ " time=" +time+ " cid=" +cid); |
| 2302 | + // TODO: Insert notification sound and vibration here. |
| 2303 | + // Short 100 ms Vibration |
| 2304 | + //Vibrator v = (Vibrator) this.context.getSystemService(Context.VIBRATOR_SERVICE); |
| 2305 | + //v.vibrate(100); // Vibrate for 100 ms |
| 2306 | +
|
| 2307 | + // Short sound: |
| 2308 | + // TODO see issue #15 |
| 2309 | +
|
| 2310 | + } else { |
| 2311 | + // TODO This may need to be removed as it may spam the logcat buffer... |
| 2312 | + //Log.v(TAG, mTAG + ":insertEventLog(): Skipped inserting duplicate event"); |
| 2313 | + } |
| 2314 | + } |
| 2315 | + // TODO This may need to be removed as it may spam the logcat buffer... |
| 2316 | + //Log.v(TAG, mTAG + ":insertEventLog(): Skipped inserting bad CID/LAC data"); |
| 2317 | + } |
| 2318 | +*/ |
| 2319 | + |
| 2320 | + |
| 2321 | + |
2253 | 2322 | /**
|
2254 | 2323 | * Description: Inserts BTS Sector Type data into the SectorType table
|
2255 | 2324 | *
|
|
0 commit comments