|
25 | 25 | import androidx.work.Data;
|
26 | 26 | import androidx.work.WorkInfo;
|
27 | 27 | import androidx.work.WorkManager;
|
28 |
| - |
29 |
| -import com.fasterxml.jackson.core.JsonProcessingException; |
30 | 28 | import com.google.android.gms.maps.model.LatLng;
|
31 | 29 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
32 |
| -import com.jsoniter.output.JsonStream; |
33 | 30 | import com.kongzue.dialogx.dialogs.MessageDialog;
|
34 | 31 | import com.kongzue.dialogx.dialogs.PopTip;
|
35 |
| -import com.kongzue.dialogx.dialogs.TipDialog; |
36 | 32 | import com.kongzue.dialogx.dialogs.WaitDialog;
|
37 |
| -import com.lcl.lclmeasurementtool.constants.NetworkConstants; |
38 |
| -import com.lcl.lclmeasurementtool.database.Entity.AbstractViewModel; |
39 |
| -import com.lcl.lclmeasurementtool.database.Entity.Connectivity; |
40 |
| -import com.lcl.lclmeasurementtool.database.Entity.ConnectivityViewModel; |
41 |
| -import com.lcl.lclmeasurementtool.database.Entity.SignalStrength; |
42 |
| -import com.lcl.lclmeasurementtool.database.Entity.SignalViewModel; |
43 | 33 | import com.lcl.lclmeasurementtool.Functionality.NetworkTestViewModel;
|
44 | 34 | import com.lcl.lclmeasurementtool.Managers.CellularManager;
|
45 | 35 | import com.lcl.lclmeasurementtool.Managers.LocationServiceListener;
|
46 | 36 | import com.lcl.lclmeasurementtool.Managers.LocationServiceManager;
|
47 | 37 | import com.lcl.lclmeasurementtool.Managers.NetworkChangeListener;
|
48 | 38 | import com.lcl.lclmeasurementtool.Managers.NetworkManager;
|
49 |
| -import com.lcl.lclmeasurementtool.Managers.UploadManager; |
50 |
| -import com.lcl.lclmeasurementtool.Models.ConnectivityMessageModel; |
51 |
| -import com.lcl.lclmeasurementtool.Models.MeasurementDataModel; |
52 |
| -import com.lcl.lclmeasurementtool.Models.MeasurementDataReportModel; |
53 |
| -import com.lcl.lclmeasurementtool.Models.SignalStrengthMessageModel; |
54 | 39 | import com.lcl.lclmeasurementtool.Utils.AnalyticsUtils;
|
55 |
| -import com.lcl.lclmeasurementtool.errors.DecoderException; |
56 | 40 | import com.lcl.lclmeasurementtool.Utils.ECDSA;
|
57 | 41 | import com.lcl.lclmeasurementtool.Utils.Hex;
|
58 | 42 | import com.lcl.lclmeasurementtool.Utils.LocationUtils;
|
59 |
| -import com.lcl.lclmeasurementtool.Utils.SerializationUtils; |
60 | 43 | import com.lcl.lclmeasurementtool.Utils.SignalStrengthLevel;
|
61 | 44 | import com.lcl.lclmeasurementtool.Utils.TimeUtils;
|
62 | 45 | import com.lcl.lclmeasurementtool.Utils.UnitUtils;
|
| 46 | +import com.lcl.lclmeasurementtool.constants.NetworkConstants; |
| 47 | +import com.lcl.lclmeasurementtool.database.Entity.AbstractViewModel; |
| 48 | +import com.lcl.lclmeasurementtool.database.Entity.Connectivity; |
| 49 | +import com.lcl.lclmeasurementtool.database.Entity.ConnectivityViewModel; |
| 50 | +import com.lcl.lclmeasurementtool.database.Entity.SignalStrength; |
| 51 | +import com.lcl.lclmeasurementtool.database.Entity.SignalViewModel; |
63 | 52 | import com.lcl.lclmeasurementtool.databinding.HomeFragmentBinding;
|
| 53 | +import com.lcl.lclmeasurementtool.errors.DecoderException; |
64 | 54 | import com.microsoft.appcenter.analytics.Analytics;
|
65 | 55 |
|
66 |
| -import java.io.IOException; |
67 | 56 | import java.security.InvalidKeyException;
|
68 | 57 | import java.security.NoSuchAlgorithmException;
|
69 | 58 | import java.security.NoSuchProviderException;
|
@@ -168,17 +157,17 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
|
168 | 157 | return;
|
169 | 158 | }
|
170 | 159 | LatLng latLng = LocationUtils.toLatLng(location);
|
171 |
| - SignalStrengthMessageModel signalStrengthMessageModel = |
172 |
| - new SignalStrengthMessageModel( |
173 |
| - latLng.latitude, |
174 |
| - latLng.longitude, |
175 |
| - ts, |
176 |
| - dBm, |
177 |
| - level.getLevelCode(), |
178 |
| - cell_id, |
179 |
| - device_id); |
180 |
| - signalViewModel.insert(new SignalStrength(ts, dBm, level.getLevelCode(), latLng)); |
181 |
| - uploadData(signalStrengthMessageModel, sk_t, h_pkr, NetworkConstants.SIGNAL_ENDPOINT); |
| 160 | +// SignalStrengthMessageModel signalStrengthMessageModel = |
| 161 | +// new SignalStrengthMessageModel( |
| 162 | +// latLng.latitude, |
| 163 | +// latLng.longitude, |
| 164 | +// ts, |
| 165 | +// dBm, |
| 166 | +// level.getLevelCode(), |
| 167 | +// cell_id, |
| 168 | +// device_id); |
| 169 | +// signalViewModel.insert(new SignalStrength(ts, dBm, level.getLevelCode(), latLng)); |
| 170 | +// uploadData(signalStrengthMessageModel, sk_t, h_pkr, NetworkConstants.SIGNAL_ENDPOINT); |
182 | 171 | });
|
183 | 172 | }
|
184 | 173 | });
|
@@ -465,16 +454,16 @@ private void parseWorkInfo(List<WorkInfo> workInfoList) {
|
465 | 454 | return;
|
466 | 455 | }
|
467 | 456 | LatLng latLng = LocationUtils.toLatLng(location);
|
468 |
| - ConnectivityMessageModel connectivityMessageModel = |
469 |
| - new ConnectivityMessageModel( |
470 |
| - latLng.latitude, |
471 |
| - latLng.longitude, |
472 |
| - ts, |
473 |
| - prevUpload, |
474 |
| - prevDownload, |
475 |
| - prevPing, cell_id, device_id); |
476 |
| - connectivityViewModel.insert(new Connectivity(ts, prevPing, prevUpload, prevDownload, latLng)); |
477 |
| - uploadData(connectivityMessageModel, sk_t, h_pkr, NetworkConstants.CONNECTIVITY_ENDPOINT); |
| 457 | +// ConnectivityMessageModel connectivityMessageModel = |
| 458 | +// new ConnectivityMessageModel( |
| 459 | +// latLng.latitude, |
| 460 | +// latLng.longitude, |
| 461 | +// ts, |
| 462 | +// prevUpload, |
| 463 | +// prevDownload, |
| 464 | +// prevPing, cell_id, device_id); |
| 465 | +// connectivityViewModel.insert(new Connectivity(ts, prevPing, prevUpload, prevDownload, latLng)); |
| 466 | +// uploadData(connectivityMessageModel, sk_t, h_pkr, NetworkConstants.CONNECTIVITY_ENDPOINT); |
478 | 467 | });
|
479 | 468 | }
|
480 | 469 | WorkManager.getInstance(this.context).pruneWork();
|
@@ -530,28 +519,28 @@ private boolean isTestCompleted() {
|
530 | 519 | return prevDownload != -1.0 && prevPing != -1.0 && prevUpload != -1.0;
|
531 | 520 | }
|
532 | 521 |
|
533 |
| - private void uploadData(MeasurementDataModel data, byte[] sk_t, byte[] h_pkr, String endpoint) throws NoSuchAlgorithmException, |
534 |
| - InvalidKeySpecException, SignatureException, InvalidKeyException, JsonProcessingException, NoSuchProviderException { |
535 |
| - |
536 |
| - byte[] serialized = SerializationUtils.serializeToBytes(data); |
537 |
| - |
538 |
| - byte[] sig_m = ECDSA.Sign(serialized, ECDSA.DeserializePrivateKey(sk_t)); |
539 |
| - |
540 |
| - SharedPreferences preferences = this.activity.getPreferences(MODE_PRIVATE); |
541 |
| - boolean show_data = preferences.getBoolean("showData", false); |
542 |
| - |
543 |
| - MeasurementDataReportModel reportModel = new MeasurementDataReportModel(sig_m, h_pkr, serialized, show_data); |
544 |
| - |
545 |
| - // upload data |
546 |
| - UploadManager upload = UploadManager.Builder() |
547 |
| - .addPayload(JsonStream.serialize(reportModel)) |
548 |
| - .addEndpoint(endpoint); |
549 |
| - try { |
550 |
| - upload.post(); |
551 |
| - } catch (IOException e) { |
552 |
| - TipDialog.show(getString(R.string.upload_ioexception), WaitDialog.TYPE.ERROR); |
553 |
| - } |
554 |
| - } |
| 522 | +// private void uploadData(MeasurementDataModel data, byte[] sk_t, byte[] h_pkr, String endpoint) throws NoSuchAlgorithmException, |
| 523 | +// InvalidKeySpecException, SignatureException, InvalidKeyException, JsonProcessingException, NoSuchProviderException { |
| 524 | +// |
| 525 | +// byte[] serialized = SerializationUtils.serializeToBytes(data); |
| 526 | +// |
| 527 | +// byte[] sig_m = ECDSA.Sign(serialized, ECDSA.DeserializePrivateKey(sk_t)); |
| 528 | +// |
| 529 | +// SharedPreferences preferences = this.activity.getPreferences(MODE_PRIVATE); |
| 530 | +// boolean show_data = preferences.getBoolean("showData", false); |
| 531 | + |
| 532 | +// MeasurementDataReportModel reportModel = new MeasurementDataReportModel(sig_m, h_pkr, serialized, show_data); |
| 533 | +// |
| 534 | +// // upload data |
| 535 | +// UploadManager upload = UploadManager.Builder() |
| 536 | +// .addPayload(JsonStream.serialize(reportModel)) |
| 537 | +// .addEndpoint(endpoint); |
| 538 | +// try { |
| 539 | +// upload.post(); |
| 540 | +// } catch (IOException e) { |
| 541 | +// TipDialog.show(getString(R.string.upload_ioexception), WaitDialog.TYPE.ERROR); |
| 542 | +// } |
| 543 | +// } |
555 | 544 |
|
556 | 545 | private byte[][] retrieveKeysInformation() {
|
557 | 546 | SharedPreferences preferences = this.activity.getPreferences(MODE_PRIVATE);
|
|
0 commit comments