Skip to content

Commit

Permalink
Adds CSV file logging for LTE, and a foreground service change for An…
Browse files Browse the repository at this point in the history
…droid 14

- Also refactors the cellular specific stuff out of the main service as that was growing way too big. I will refactor the other protocols out of the main service as I add CSV logging for them
- Still need to add CSV logging for all the other protocols
  • Loading branch information
christianrowlands committed Nov 2, 2023
1 parent 35da23d commit 09dfc0e
Show file tree
Hide file tree
Showing 29 changed files with 943 additions and 395 deletions.
1 change: 1 addition & 0 deletions networksurvey/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <!-- Needed to start the service at boot -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />

<uses-feature
android:name="android.hardware.location.gps"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ private NetworkSurveyConstants()
public static final int LOGGING_NOTIFICATION_ID = 1;

public static final String LOG_DIRECTORY_NAME = "NetworkSurveyData";
public static final String CSV_LOG_DIRECTORY_NAME = "NetworkSurveyData/csv";

public static final String GSM_FILE_NAME_PREFIX = "craxiom-gsm-";
public static final String CDMA_FILE_NAME_PREFIX = "craxiom-cdma-";
public static final String UMTS_FILE_NAME_PREFIX = "craxiom-umts-";
public static final String LTE_FILE_NAME_PREFIX = "craxiom-lte-";
public static final String NR_FILE_NAME_PREFIX = "craxiom-nr-";
public static final String CELLULAR_FILE_NAME_PREFIX = "craxiom-cellular-";
public static final String WIFI_FILE_NAME_PREFIX = "craxiom-wifi-";
public static final String BLUETOOTH_FILE_NAME_PREFIX = "craxiom-bluetooth-";
Expand Down Expand Up @@ -91,6 +97,7 @@ private NetworkSurveyConstants()
public static final String PROPERTY_GNSS_SCAN_INTERVAL_SECONDS = "gnss_scan_interval_seconds";
public static final String PROPERTY_DEVICE_STATUS_SCAN_INTERVAL_SECONDS = "device_status_scan_interval_seconds";
public static final String PROPERTY_LOG_ROLLOVER_SIZE_MB = "log_rollover_size_mb";
public static final String PROPERTY_LOG_FILE_TYPE = "log_file_type";

// The following key is used in the app_restrictions.xml file and in the app's shared preferences
public static final String PROPERTY_MQTT_START_ON_BOOT = "mqtt_start_on_boot";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.craxiom.networksurvey.constants;
package com.craxiom.networksurvey.constants.csv;

/**
* The constants associated with the CDR CSV file headers.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.craxiom.networksurvey.constants.csv;

/**
* The common constants associated with survey CSV records.
* <p>
* The constants in this class are intended to match the constants defined in the
* <a href="https://messaging.networksurvey.app/">Network Survey Messaging API</a>.
*/
public abstract class CellularCsvConstants extends SurveyCsvConstants
{
public static final String GROUP_NUMBER = "groupNumber";
public static final String SERVING_CELL = "servingCell";
public static final String PROVIDER = "provider";
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.craxiom.networksurvey.constants;
package com.craxiom.networksurvey.constants.csv;

/**
* Various CSV file constants.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.craxiom.networksurvey.constants.csv;

/**
* The constants associated with the LTE CSV file headers.
* <p>
* The constants in this class are intended to match the constants defined in the
* <a href="https://messaging.networksurvey.app/">Network Survey Messaging API</a>.
*
* @since 1.13
*/
public class LteCsvConstants extends CellularCsvConstants
{
private LteCsvConstants()
{
}

public static final String MCC = "mcc";
public static final String MNC = "mnc";
public static final String TAC = "tac";
public static final String ECI = "eci";
public static final String EARFCN = "earfcn";
public static final String PCI = "pci";
public static final String RSRP = "rsrp";
public static final String RSRQ = "rsrq";
public static final String TA = "ta";
public static final String SIGNAL_STRENGTH = "signalStrength";
public static final String LTE_BANDWIDTH = "lteBandwidth";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.craxiom.networksurvey.constants.csv;

/**
* The common constants associated with survey CSV records.
* <p>
* The constants in this class are intended to match the constants defined in the
* <a href="https://messaging.networksurvey.app/">Network Survey Messaging API</a>.
*/
public abstract class SurveyCsvConstants extends CsvConstants
{
public static final String DEVICE_TIME = "deviceTime";
public static final String MISSION_ID = "missionId";
public static final String RECORD_NUMBER = "recordNumber";
}
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ private void removeObservers()

private synchronized void updateLoggingState(NetworkSurveyService networkSurveyService)
{
// TODO Should we reflect the logging file types in the status?
viewModel.setCellularLoggingEnabled(networkSurveyService.isCellularLoggingEnabled());
viewModel.setWifiLoggingEnabled(networkSurveyService.isWifiLoggingEnabled());
viewModel.setBluetoothLoggingEnabled(networkSurveyService.isBluetoothLoggingEnabled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
NetworkSurveyConstants.PROPERTY_AUTO_START_BLUETOOTH_LOGGING,
NetworkSurveyConstants.PROPERTY_AUTO_START_GNSS_LOGGING,
NetworkSurveyConstants.PROPERTY_LOG_ROLLOVER_SIZE_MB,
NetworkSurveyConstants.PROPERTY_LOG_FILE_TYPE,
NetworkSurveyConstants.PROPERTY_CELLULAR_SCAN_INTERVAL_SECONDS,
NetworkSurveyConstants.PROPERTY_WIFI_SCAN_INTERVAL_SECONDS,
NetworkSurveyConstants.PROPERTY_BLUETOOTH_SCAN_INTERVAL_SECONDS,
Expand Down Expand Up @@ -185,7 +186,10 @@ private void updateUiForMdmIfNecessary()

final boolean mdmOverride = sharedPreferences.getBoolean(NetworkSurveyConstants.PROPERTY_MDM_OVERRIDE_KEY, false);

if (mdmOverride) return; // Nothing to do because all the preferences are enabled by default.
if (mdmOverride)
{
return; // Nothing to do because all the preferences are enabled by default.
}

final PreferenceScreen preferenceScreen = getPreferenceScreen();

Expand All @@ -200,6 +204,7 @@ private void updateUiForMdmIfNecessary()
updateBooleanPreferenceForMdm(preferenceScreen, mdmProperties, NetworkSurveyConstants.PROPERTY_AUTO_START_BLUETOOTH_LOGGING);
updateBooleanPreferenceForMdm(preferenceScreen, mdmProperties, NetworkSurveyConstants.PROPERTY_AUTO_START_GNSS_LOGGING);
updateLogRolloverSizeForMdm(preferenceScreen, mdmProperties);
updateIntPreferenceForMdm(preferenceScreen, mdmProperties, NetworkSurveyConstants.PROPERTY_LOG_FILE_TYPE);
updateIntPreferenceForMdm(preferenceScreen, mdmProperties, NetworkSurveyConstants.PROPERTY_CELLULAR_SCAN_INTERVAL_SECONDS);
updateIntPreferenceForMdm(preferenceScreen, mdmProperties, NetworkSurveyConstants.PROPERTY_WIFI_SCAN_INTERVAL_SECONDS);
updateIntPreferenceForMdm(preferenceScreen, mdmProperties, NetworkSurveyConstants.PROPERTY_BLUETOOTH_SCAN_INTERVAL_SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,48 @@ public interface ICellularSurveyRecordListener
* @param gsmRecord the GSM Record.
* @since 0.0.5
*/
void onGsmSurveyRecord(GsmRecord gsmRecord);
default void onGsmSurveyRecord(GsmRecord gsmRecord)
{
}

/**
* Called when a new CDMA Survey Record is ready.
*
* @param cdmaRecord the CDMA Record.
* @since 0.0.5
*/
void onCdmaSurveyRecord(CdmaRecord cdmaRecord);
default void onCdmaSurveyRecord(CdmaRecord cdmaRecord)
{
}

/**
* Called when a new UMTS Survey Record is ready.
*
* @param umtsRecord the UMTS Record.
* @since 0.0.5
*/
void onUmtsSurveyRecord(UmtsRecord umtsRecord);
default void onUmtsSurveyRecord(UmtsRecord umtsRecord)
{
}

/**
* Called when a new LTE Survey Record is ready.
*
* @param lteRecord the LTE Record.
*/
void onLteSurveyRecord(LteRecord lteRecord);
default void onLteSurveyRecord(LteRecord lteRecord)
{
}

/**
* Called when a new NR Survey Record is ready.
*
* @param nrRecord the New Radio (5G) record.
* @since 1.5.0
*/
void onNrSurveyRecord(NrRecord nrRecord);
default void onNrSurveyRecord(NrRecord nrRecord)
{
}

/**
* Called when a new batch of cellular survey records are ready.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class CdrLogger extends CsvRecordLogger implements ICdrEventListener
{
public CdrLogger(NetworkSurveyService networkSurveyService, Looper serviceLooper)
{
super(networkSurveyService, serviceLooper, NetworkSurveyConstants.LOG_DIRECTORY_NAME, NetworkSurveyConstants.CDR_FILE_NAME_PREFIX);
super(networkSurveyService, serviceLooper, NetworkSurveyConstants.CSV_LOG_DIRECTORY_NAME,
NetworkSurveyConstants.CDR_FILE_NAME_PREFIX, false);
}

@Override
Expand Down
Loading

0 comments on commit 09dfc0e

Please sign in to comment.