-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify insertEventLog usage #583
Labels
Comments
@banjaxbanjo What do I need to do to change this? I.e. the correct dependencies to implement the getters directly into the insertEventLog? |
I'm thinking something like this: // Defining a new simple version of insertEventLog:
public void sinsertEventLog(int DF_id, String DF_desc){
time = MiscUtils.getCurrentTimeStamp() ); // time
lac = mMonitorCell.getLAC(); // LAC
cid = mMonitorCell.getCID(); // CID
psc = mMonitorCell.getPSC(); // PSC [UMTS,LTE]
gpsd_lat = String.valueOf(mMonitorCell.getLat()); // gpsd_lat
gpsd_lon = String.valueOf(mMonitorCell.getLon()); // gpsd_lon
gpsd_accu = (int)mMonitorCell.getAccuracy(); // gpsd_accu
// skip CID/LAC of "-1" (due to crappy API, Roaming or Air-Plane Mode)
if (cid != -1 OR lac !=-1) {
// Check if LAST entry is the same!
String query = String.format(
"SELECT * from EventLog WHERE _id=(SELECT max(_id) from EventLog) AND CID=%d AND LAC=%d AND PSC=%d AND DF_id=%d",
cid, lac, psc, DF_id);
Cursor cursor = mDb.rawQuery(query,null);
// WARNING: By skipping duplicate events, we might be missing counts of Type-0 SMS etc.
boolean insertData = true;
if (cursor.getCount() > 0) { insertData = false; }
cursor.close();
if(insertData){
ContentValues eventLog = new ContentValues();
eventLog.put("time", time ); // time
eventLog.put("LAC", lac ); // LAC
eventLog.put("CID", cid ); // CID
eventLog.put("PSC", psc ); // PSC
eventLog.put("gpsd_lat", gpsd_lat ); // gpsd_lat
eventLog.put("gpsd_lon", gpsd_lon ); // gpsd_lon
eventLog.put("gpsd_accu", gpsd_accu ); // gpsd_accu
eventLog.put("DF_id", DF_id); // DF_id
eventLog.put("DF_description", DF_desc); // DF_desc
mDb.insert("EventLog", null, eventLog);
Log.i(TAG, mTAG + ":insertEventLog(): Added New Event: id=" +DF_id+ " time=" +time+ " cid=" +cid);
} else {
// TODO This may need to be removed as it may spam the logcat buffer...
//Log.v(TAG, mTAG + ":insertEventLog(): Skipped inserting duplicate event");
}
}
// TODO This may need to be removed as it may spam the logcat buffer...
//Log.v(TAG, mTAG + ":insertEventLog(): Skipped inserting bad CID/LAC data");
} @banjaxbanjo Do you think that would work? |
@E3V3A, am I right if I assume that you already implemented this? If so, please close. |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the insertEventLog function looks like this:
However, this is highly inefficient as we need to always load all items that can be automatically loaded within function. The only variables we need to supply should be DF_id and DF_desc.
Like this:
insertEventLog(1, "Changing LAC");
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: