Skip to content

Commit 7bed14f

Browse files
committed
Cell & Location tracking changes & Other minor updates
Current status of cell & location tracking is as follows: - Enabling Cell Tracking (Only Option) requires GPS enabled to provide location details for the cell. - Currently as no other method has been tested the GPS lat/lng coordinates are used to populate both tables (Cell & Location) until another method is confirmed to work as required to provide the exact CELL LOCATION to be used within the Cell tracking table. - GPS location changes will only be tracked if more then 10 metres change in location has been registered. Other minor updates including additional logic checks added to all functions that request SIM variables to ensure the sim state is ready.
1 parent 76bdfc7 commit 7bed14f

File tree

6 files changed

+295
-186
lines changed

6 files changed

+295
-186
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<uses-permission android:name="android.permission.INTERNET" />
1717
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
1818
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
19+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
1920
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
2021

2122
<application

app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public long insertCell( int lac, int cellID,
7777
cellValues.put("Operator", simOperator);
7878
cellValues.put("OperatorName", simOperatorName);
7979

80-
if (!cellExists(cellID,latitude, longitude, signalInfo)) {
80+
if (!cellExists(cellID, latitude, longitude, signalInfo)) {
8181
return mDb.insert(CELL_TABLE, null, cellValues);
8282
}
8383
}
@@ -272,6 +272,39 @@ private void populateDefaultMCC(SQLiteDatabase db) {
272272
}
273273
}
274274

275+
/**
276+
* Parses the downloaded CSV from OpenCellID and adds Map Marker to identify known
277+
* Cell ID's
278+
*/
279+
public void updateOpenCellID () {
280+
String fileName = Environment.getExternalStorageDirectory()
281+
+ "/AIMSICD/OpenCellID/opencellid.csv";
282+
File file = new File(fileName);
283+
try {
284+
CSVReader csvReader = new CSVReader(new FileReader(file));
285+
List<String[]> csvCellID = csvReader.readAll();
286+
287+
for (int i=1; i<csvCellID.size(); i++)
288+
{
289+
//Insert details into OpenCellID Database
290+
long result =
291+
insertOpenCell(Double.parseDouble(csvCellID.get(i)[0]),
292+
Double.parseDouble(csvCellID.get(i)[1]),
293+
Integer.parseInt(csvCellID.get(i)[2]), Integer.parseInt(csvCellID.get(i)[3]),
294+
Integer.parseInt(csvCellID.get(i)[4]), Integer.parseInt(csvCellID.get(i)[5]),
295+
Integer.parseInt(csvCellID.get(i)[6]), Integer.parseInt(csvCellID.get(i)[7]));
296+
if (result == -1)
297+
{
298+
Log.e(TAG, "Error inserting OpenCellID database value");
299+
}
300+
}
301+
302+
} catch (Exception e) {
303+
Log.e (TAG, "Error parsing OpenCellID data - " + e.getMessage());
304+
}
305+
306+
}
307+
275308
/**
276309
* Exports the database tables to CSV files
277310
*/

app/src/main/java/com/SecUpwN/AIMSICD/fragments/DeviceFragment.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ public void onResume() {
6363
updateUI();
6464
}
6565

66-
@Override
67-
public void onStart() {
68-
super.onStart();
69-
updateUI();
70-
}
71-
7266
@Override
7367
public void onDestroy() {
7468
super.onDestroy();
@@ -107,9 +101,11 @@ private void updateUI() {
107101
switch (mAimsicdService.getPhoneID()) {
108102
case TelephonyManager.PHONE_TYPE_GSM: {
109103
content = (TextView) mView.findViewById(R.id.network_lac);
110-
content.setText(mAimsicdService.getLAC(true));
104+
content.setText(String.valueOf(mAimsicdService.getLAC(true)));
105+
tr = (TableRow) mView.findViewById(R.id.gsm_cellid);
106+
tr.setVisibility(View.VISIBLE);
111107
content = (TextView) mView.findViewById(R.id.network_cellid);
112-
content.setText(mAimsicdService.getCellId());
108+
content.setText(String.valueOf(mAimsicdService.getCellId()));
113109
break;
114110
}
115111
case TelephonyManager.PHONE_TYPE_CDMA: {
@@ -118,27 +114,33 @@ private void updateUI() {
118114
TableRow row = (TableRow) tableLayout.getChildAt(i);
119115
if (row != null) {
120116
if (row.getTag().equals("cdma")) {
121-
row.setVisibility(View.GONE);
122-
} else if( row.getTag().equals("gsm_network")) {
123117
row.setVisibility(View.VISIBLE);
118+
} else if( row.getTag().equals("gsm_network")) {
119+
row.setVisibility(View.GONE);
124120
}
125121
}
126122
}
127123
content = (TextView) mView.findViewById(R.id.network_netid);
128-
content.setText(mAimsicdService.getLAC(true));
124+
content.setText(String.valueOf(mAimsicdService.getLAC(true)));
129125
content = (TextView) mView.findViewById(R.id.network_sysid);
130-
content.setText(mAimsicdService.getSID());
126+
content.setText(String.valueOf(mAimsicdService.getSID()));
131127
content = (TextView) mView.findViewById(R.id.network_baseid);
132-
content.setText(mAimsicdService.getCellId());
128+
content.setText(String.valueOf(mAimsicdService.getCellId()));
129+
mAimsicdService.updateCdmaLocation();
130+
double[] location = mAimsicdService.getLastLocation();
131+
content = (TextView) mView.findViewById(R.id.network_cmda_lat);
132+
content.setText(String.valueOf(location[0]));
133+
content = (TextView) mView.findViewById(R.id.network_cmda_long);
134+
content.setText(String.valueOf(location[1]));
133135
break;
134136
}
135137
}
136138

137139
if (mAimsicdService.getNetID(true) == TelephonyManager.NETWORK_TYPE_LTE) {
138-
content = (TextView) mView.findViewById(R.id.network_lte_timing_advance);
139-
content.setText(mAimsicdService.getLteTimingAdvance());
140140
tr = (TableRow) mView.findViewById(R.id.lte_timing_advance);
141141
tr.setVisibility(View.VISIBLE);
142+
content = (TextView) mView.findViewById(R.id.network_lte_timing_advance);
143+
content.setText(String.valueOf(mAimsicdService.getLteTimingAdvance()));
142144
} else {
143145
tr = (TableRow) mView.findViewById(R.id.lte_timing_advance);
144146
tr.setVisibility(View.GONE);

0 commit comments

Comments
 (0)