cellularGroup, int subs
* Notification of the current Data and Voice network types. This method is called even when the values have not
* changed.
*
- * See {@link com.craxiom.networksurvey.CalculationUtils#getNetworkType(int)} for the possible string values.
+ * See {@link CalculationUtils#getNetworkType(int)} for the possible string values.
*
* @param dataNetworkType The data network type (e.g. "LTE"), which might be different than the voice network type.
* @param voiceNetworkType The voice network type (e.g. "LTE").
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/BluetoothSurveyRecordLogger.java b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/BluetoothSurveyRecordLogger.java
index 73cb6b3a..9ee7086d 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/BluetoothSurveyRecordLogger.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/BluetoothSurveyRecordLogger.java
@@ -11,8 +11,8 @@
import com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants;
import com.craxiom.networksurvey.listeners.IBluetoothSurveyRecordListener;
import com.craxiom.networksurvey.services.NetworkSurveyService;
-import com.craxiom.networksurvey.util.IOUtils;
import com.craxiom.networksurvey.util.MathUtils;
+import com.craxiom.networksurvey.util.NsUtils;
import java.sql.SQLException;
import java.util.List;
@@ -111,7 +111,7 @@ private void writeBluetoothRecordToLogFile(final BluetoothRecord bluetoothRecord
row.setGeometry(geomData);
row.setValue(BluetoothCsvConstants.DEVICE_SERIAL_NUMBER, data.getDeviceSerialNumber());
- row.setValue(BluetoothMessageConstants.TIME_COLUMN, IOUtils.getEpochFromRfc3339(data.getDeviceTime()));
+ row.setValue(BluetoothMessageConstants.TIME_COLUMN, NsUtils.getEpochFromRfc3339(data.getDeviceTime()));
row.setValue(BluetoothMessageConstants.MISSION_ID_COLUMN, data.getMissionId());
row.setValue(BluetoothMessageConstants.RECORD_NUMBER_COLUMN, data.getRecordNumber());
row.setValue(BluetoothCsvConstants.SPEED, data.getSpeed());
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/CellularSurveyRecordLogger.java b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/CellularSurveyRecordLogger.java
index dee35e63..ee95cb4a 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/CellularSurveyRecordLogger.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/CellularSurveyRecordLogger.java
@@ -28,8 +28,8 @@
import com.craxiom.networksurvey.constants.csv.UmtsCsvConstants;
import com.craxiom.networksurvey.listeners.ICellularSurveyRecordListener;
import com.craxiom.networksurvey.services.NetworkSurveyService;
-import com.craxiom.networksurvey.util.IOUtils;
import com.craxiom.networksurvey.util.MathUtils;
+import com.craxiom.networksurvey.util.NsUtils;
import com.google.common.base.Strings;
import java.sql.SQLException;
@@ -309,7 +309,7 @@ private void writeGsmRecordToLogFile(final GsmRecord gsmRecord)
row.setGeometry(geomData);
row.setValue(GsmCsvConstants.DEVICE_SERIAL_NUMBER, data.getDeviceSerialNumber());
- row.setValue(GsmMessageConstants.TIME_COLUMN, IOUtils.getEpochFromRfc3339(data.getDeviceTime()));
+ row.setValue(GsmMessageConstants.TIME_COLUMN, NsUtils.getEpochFromRfc3339(data.getDeviceTime()));
row.setValue(GsmMessageConstants.MISSION_ID_COLUMN, data.getMissionId());
row.setValue(GsmMessageConstants.RECORD_NUMBER_COLUMN, data.getRecordNumber());
row.setValue(GsmMessageConstants.GROUP_NUMBER_COLUMN, data.getGroupNumber());
@@ -404,7 +404,7 @@ private void writeCdmaRecordToLogFile(final CdmaRecord cdmaRecord)
row.setGeometry(geomData);
row.setValue(CdmaCsvConstants.DEVICE_SERIAL_NUMBER, data.getDeviceSerialNumber());
- row.setValue(CdmaMessageConstants.TIME_COLUMN, IOUtils.getEpochFromRfc3339(data.getDeviceTime()));
+ row.setValue(CdmaMessageConstants.TIME_COLUMN, NsUtils.getEpochFromRfc3339(data.getDeviceTime()));
row.setValue(CdmaMessageConstants.MISSION_ID_COLUMN, data.getMissionId());
row.setValue(CdmaMessageConstants.RECORD_NUMBER_COLUMN, data.getRecordNumber());
row.setValue(CdmaMessageConstants.GROUP_NUMBER_COLUMN, data.getGroupNumber());
@@ -490,7 +490,7 @@ private void writeUmtsRecordToLogFile(final UmtsRecord umtsRecord)
row.setGeometry(geomData);
row.setValue(UmtsCsvConstants.DEVICE_SERIAL_NUMBER, data.getDeviceSerialNumber());
- row.setValue(UmtsMessageConstants.TIME_COLUMN, IOUtils.getEpochFromRfc3339(data.getDeviceTime()));
+ row.setValue(UmtsMessageConstants.TIME_COLUMN, NsUtils.getEpochFromRfc3339(data.getDeviceTime()));
row.setValue(UmtsMessageConstants.MISSION_ID_COLUMN, data.getMissionId());
row.setValue(UmtsMessageConstants.RECORD_NUMBER_COLUMN, data.getRecordNumber());
row.setValue(UmtsMessageConstants.GROUP_NUMBER_COLUMN, data.getGroupNumber());
@@ -585,7 +585,7 @@ private void writeLteRecordToLogFile(final LteRecord lteRecord)
row.setGeometry(geomData);
row.setValue(LteCsvConstants.DEVICE_SERIAL_NUMBER, data.getDeviceSerialNumber());
- row.setValue(LteMessageConstants.TIME_COLUMN, IOUtils.getEpochFromRfc3339(data.getDeviceTime()));
+ row.setValue(LteMessageConstants.TIME_COLUMN, NsUtils.getEpochFromRfc3339(data.getDeviceTime()));
row.setValue(LteMessageConstants.MISSION_ID_COLUMN, data.getMissionId());
row.setValue(LteMessageConstants.RECORD_NUMBER_COLUMN, data.getRecordNumber());
row.setValue(LteMessageConstants.GROUP_NUMBER_COLUMN, data.getGroupNumber());
@@ -700,7 +700,7 @@ private void writeNrRecordToLogFile(final NrRecord nrRecord)
row.setGeometry(geomData);
row.setValue(NrCsvConstants.DEVICE_SERIAL_NUMBER, data.getDeviceSerialNumber());
- row.setValue(NrMessageConstants.DEVICE_TIME_COLUMN, IOUtils.getEpochFromRfc3339(data.getDeviceTime()));
+ row.setValue(NrMessageConstants.DEVICE_TIME_COLUMN, NsUtils.getEpochFromRfc3339(data.getDeviceTime()));
row.setValue(NrMessageConstants.MISSION_ID_COLUMN, data.getMissionId());
row.setValue(NrMessageConstants.RECORD_NUMBER_COLUMN, data.getRecordNumber());
row.setValue(NrMessageConstants.GROUP_NUMBER_COLUMN, data.getGroupNumber());
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/CsvRecordLogger.java b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/CsvRecordLogger.java
index 11c1e53d..52668aca 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/CsvRecordLogger.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/CsvRecordLogger.java
@@ -1,8 +1,6 @@
package com.craxiom.networksurvey.logging;
import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
@@ -11,6 +9,7 @@
import com.craxiom.networksurvey.constants.NetworkSurveyConstants;
import com.craxiom.networksurvey.services.NetworkSurveyService;
import com.craxiom.networksurvey.services.SurveyRecordProcessor;
+import com.craxiom.networksurvey.util.NsUtils;
import com.craxiom.networksurvey.util.PreferenceUtils;
import org.apache.commons.csv.CSVFormat;
@@ -186,7 +185,7 @@ private synchronized boolean prepareCsvForLogging()
Timber.i("Creating the log file: %s", loggingFileName);
- final String versionName = getVersionName();
+ final String versionName = NsUtils.getAppVersionName(applicationContext);
final List headerComments = new ArrayList<>();
headerComments.add("Created by Network Survey version=" + versionName);
@@ -426,19 +425,4 @@ public void reset()
recordCount.set(0);
}
}
-
- /**
- * @return The NS App version number, or an empty string if it could not be determined.
- */
- private String getVersionName()
- {
- try
- {
- PackageInfo info = applicationContext.getPackageManager().getPackageInfo(applicationContext.getPackageName(), 0);
- return info.versionName;
- } catch (PackageManager.NameNotFoundException e)
- {
- return "";
- }
- }
}
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/GnssRecordLogger.java b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/GnssRecordLogger.java
index 380a95eb..2288bd95 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/GnssRecordLogger.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/GnssRecordLogger.java
@@ -26,8 +26,8 @@
import com.craxiom.networksurvey.constants.csv.GnssCsvConstants;
import com.craxiom.networksurvey.listeners.IGnssSurveyRecordListener;
import com.craxiom.networksurvey.services.NetworkSurveyService;
-import com.craxiom.networksurvey.util.IOUtils;
import com.craxiom.networksurvey.util.MathUtils;
+import com.craxiom.networksurvey.util.NsUtils;
import java.sql.SQLException;
@@ -124,7 +124,7 @@ private void writeGnssRecordToLogFile(final GnssRecord gnssRecord)
row.setGeometry(geomData);
row.setValue(GnssCsvConstants.DEVICE_SERIAL_NUMBER, data.getDeviceSerialNumber());
- row.setValue(TIME_COLUMN, IOUtils.getEpochFromRfc3339(data.getDeviceTime()));
+ row.setValue(TIME_COLUMN, NsUtils.getEpochFromRfc3339(data.getDeviceTime()));
row.setValue(GnssMessageConstants.MISSION_ID_COLUMN, data.getMissionId());
row.setValue(RECORD_NUMBER_COLUMN, data.getRecordNumber());
row.setValue(GROUP_NUMBER_COLUMN, data.getGroupNumber());
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/PhoneStateRecordLogger.java b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/PhoneStateRecordLogger.java
index 76589674..a074baad 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/PhoneStateRecordLogger.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/PhoneStateRecordLogger.java
@@ -24,7 +24,7 @@
import com.craxiom.networksurvey.constants.csv.PhoneStateCsvConstants;
import com.craxiom.networksurvey.listeners.IDeviceStatusListener;
import com.craxiom.networksurvey.services.NetworkSurveyService;
-import com.craxiom.networksurvey.util.IOUtils;
+import com.craxiom.networksurvey.util.NsUtils;
import com.craxiom.networksurvey.util.MathUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -109,7 +109,7 @@ public void onPhoneState(PhoneState phoneState)
row.setValue(ALTITUDE_COLUMN, data.getAltitude());
row.setValue(PhoneStateCsvConstants.DEVICE_SERIAL_NUMBER, data.getDeviceSerialNumber());
- row.setValue(TIME_COLUMN, IOUtils.getEpochFromRfc3339(data.getDeviceTime()));
+ row.setValue(TIME_COLUMN, NsUtils.getEpochFromRfc3339(data.getDeviceTime()));
row.setValue(MISSION_ID_COLUMN, data.getMissionId());
row.setValue(RECORD_NUMBER_COLUMN, data.getRecordNumber());
row.setValue(PhoneStateCsvConstants.SPEED, data.getSpeed());
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/WifiSurveyRecordLogger.java b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/WifiSurveyRecordLogger.java
index f98d1697..2786d476 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/WifiSurveyRecordLogger.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/WifiSurveyRecordLogger.java
@@ -11,8 +11,8 @@
import com.craxiom.networksurvey.listeners.IWifiSurveyRecordListener;
import com.craxiom.networksurvey.model.WifiRecordWrapper;
import com.craxiom.networksurvey.services.NetworkSurveyService;
-import com.craxiom.networksurvey.util.IOUtils;
import com.craxiom.networksurvey.util.MathUtils;
+import com.craxiom.networksurvey.util.NsUtils;
import java.sql.SQLException;
import java.util.List;
@@ -112,7 +112,7 @@ private void writeWifiBeaconRecordToLogFile(final WifiRecordWrapper wifiRecordWr
row.setGeometry(geomData);
row.setValue(WifiCsvConstants.DEVICE_SERIAL_NUMBER, data.getDeviceSerialNumber());
- row.setValue(WifiBeaconMessageConstants.TIME_COLUMN, IOUtils.getEpochFromRfc3339(data.getDeviceTime()));
+ row.setValue(WifiBeaconMessageConstants.TIME_COLUMN, NsUtils.getEpochFromRfc3339(data.getDeviceTime()));
row.setValue(WifiBeaconMessageConstants.MISSION_ID_COLUMN, data.getMissionId());
row.setValue(WifiBeaconMessageConstants.RECORD_NUMBER_COLUMN, data.getRecordNumber());
row.setValue(WifiCsvConstants.SPEED, data.getSpeed());
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/model/CdrEvent.java b/networksurvey/src/main/java/com/craxiom/networksurvey/model/CdrEvent.java
index f68fc1dc..61a4567e 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/model/CdrEvent.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/model/CdrEvent.java
@@ -18,7 +18,7 @@
import com.craxiom.messaging.phonestate.NetworkType;
import com.craxiom.networksurvey.services.controller.CellularController;
-import com.craxiom.networksurvey.util.IOUtils;
+import com.craxiom.networksurvey.util.NsUtils;
import java.time.ZonedDateTime;
@@ -87,7 +87,7 @@ public String[] getCsvRowArray()
// getHeaders method, and new columns should not be inserted in the middle since consuming
// applications need to trust that the order will not change.
return new String[]{
- IOUtils.getRfc3339String(timestamp),
+ NsUtils.getRfc3339String(timestamp),
String.valueOf(location == null ? "" : location.getLatitude()),
String.valueOf(location == null ? "" : location.getLongitude()),
String.valueOf(location == null ? "" : location.getAltitude()),
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/services/NetworkSurveyService.java b/networksurvey/src/main/java/com/craxiom/networksurvey/services/NetworkSurveyService.java
index 43323d51..448e0ad5 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/services/NetworkSurveyService.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/services/NetworkSurveyService.java
@@ -16,7 +16,6 @@
import android.content.IntentFilter;
import android.content.RestrictionsManager;
import android.content.SharedPreferences;
-import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.location.Location;
@@ -70,8 +69,8 @@
import com.craxiom.networksurvey.services.controller.CellularController;
import com.craxiom.networksurvey.services.controller.GnssController;
import com.craxiom.networksurvey.services.controller.WifiController;
-import com.craxiom.networksurvey.util.IOUtils;
import com.craxiom.networksurvey.util.MathUtils;
+import com.craxiom.networksurvey.util.NsUtils;
import com.craxiom.networksurvey.util.PreferenceUtils;
import com.google.gson.Gson;
import com.google.protobuf.BoolValue;
@@ -1432,7 +1431,7 @@ private DeviceStatus generateDeviceStatus()
{
final DeviceStatusData.Builder dataBuilder = DeviceStatusData.newBuilder();
dataBuilder.setDeviceSerialNumber(deviceId)
- .setDeviceTime(IOUtils.getRfc3339String(ZonedDateTime.now()));
+ .setDeviceTime(NsUtils.getRfc3339String(ZonedDateTime.now()));
dataBuilder.setMdmOverride(BoolValue.newBuilder().setValue(mdmOverride).build());
if (primaryLocationListener != null)
@@ -1490,7 +1489,7 @@ private DeviceStatus generateDeviceStatus()
}
dataBuilder.setDeviceModel(Build.MODEL);
- dataBuilder.setAppVersion(getVersionName());
+ dataBuilder.setAppVersion(NsUtils.getAppVersionName(this));
final DeviceStatus.Builder statusBuilder = DeviceStatus.newBuilder();
statusBuilder.setMessageType(DeviceStatusMessageConstants.DEVICE_STATUS_MESSAGE_TYPE);
@@ -1500,21 +1499,6 @@ private DeviceStatus generateDeviceStatus()
return statusBuilder.build();
}
- /**
- * @return The NS App version number, or an empty string if it could not be determined.
- */
- private String getVersionName()
- {
- try
- {
- PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
- return info.versionName;
- } catch (PackageManager.NameNotFoundException e)
- {
- return "";
- }
- }
-
/**
* Stops generating device status reports if no more loggers are enabled.
*/
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/services/SurveyRecordProcessor.java b/networksurvey/src/main/java/com/craxiom/networksurvey/services/SurveyRecordProcessor.java
index d274a505..58bad0ac 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/services/SurveyRecordProcessor.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/services/SurveyRecordProcessor.java
@@ -99,7 +99,7 @@
import com.craxiom.networksurvey.model.NrRecordWrapper;
import com.craxiom.networksurvey.model.WifiRecordWrapper;
import com.craxiom.networksurvey.services.controller.CellularController;
-import com.craxiom.networksurvey.util.IOUtils;
+import com.craxiom.networksurvey.util.NsUtils;
import com.craxiom.networksurvey.util.LocationUtils;
import com.craxiom.networksurvey.util.MathUtils;
import com.craxiom.networksurvey.util.ParserUtils;
@@ -663,7 +663,7 @@ private PhoneState createPhoneStateMessage(TelephonyManager telephonyManager, in
}
dataBuilder.setDeviceSerialNumber(deviceId);
- dataBuilder.setDeviceTime(IOUtils.getRfc3339String(ZonedDateTime.now()));
+ dataBuilder.setDeviceTime(NsUtils.getRfc3339String(ZonedDateTime.now()));
dataBuilder.setMissionId(missionId);
dataBuilder.setRecordNumber(phoneStateRecordNumber++);
@@ -979,7 +979,7 @@ private GsmRecord generateGsmSurveyRecord(CellInfoGsm cellInfoGsm, int subscript
}
dataBuilder.setDeviceSerialNumber(deviceId);
- dataBuilder.setDeviceTime(IOUtils.getRfc3339String(ZonedDateTime.now()));
+ dataBuilder.setDeviceTime(NsUtils.getRfc3339String(ZonedDateTime.now()));
dataBuilder.setMissionId(missionId);
dataBuilder.setRecordNumber(recordNumber++);
dataBuilder.setGroupNumber(groupNumber);
@@ -1079,7 +1079,7 @@ private CdmaRecord generateCdmaSurveyRecord(CellInfoCdma cellInfoCdma, int subsc
}
dataBuilder.setDeviceSerialNumber(deviceId);
- dataBuilder.setDeviceTime(IOUtils.getRfc3339String(ZonedDateTime.now()));
+ dataBuilder.setDeviceTime(NsUtils.getRfc3339String(ZonedDateTime.now()));
dataBuilder.setMissionId(missionId);
dataBuilder.setRecordNumber(recordNumber++);
dataBuilder.setGroupNumber(groupNumber);
@@ -1166,7 +1166,7 @@ private UmtsRecord generateUmtsSurveyRecord(CellInfoWcdma cellInfoWcdma, int sub
}
dataBuilder.setDeviceSerialNumber(deviceId);
- dataBuilder.setDeviceTime(IOUtils.getRfc3339String(ZonedDateTime.now()));
+ dataBuilder.setDeviceTime(NsUtils.getRfc3339String(ZonedDateTime.now()));
dataBuilder.setMissionId(missionId);
dataBuilder.setRecordNumber(recordNumber++);
dataBuilder.setGroupNumber(groupNumber);
@@ -1282,7 +1282,7 @@ private LteRecord generateLteSurveyRecord(CellInfoLte cellInfoLte, int subscript
}
dataBuilder.setDeviceSerialNumber(deviceId);
- dataBuilder.setDeviceTime(IOUtils.getRfc3339String(ZonedDateTime.now()));
+ dataBuilder.setDeviceTime(NsUtils.getRfc3339String(ZonedDateTime.now()));
dataBuilder.setMissionId(missionId);
dataBuilder.setRecordNumber(recordNumber++);
dataBuilder.setGroupNumber(groupNumber);
@@ -1475,7 +1475,7 @@ private NrRecordWrapper generateNrSurveyRecord(CellInfoNr cellInfoNr, int subscr
}
dataBuilder.setDeviceSerialNumber(deviceId);
- dataBuilder.setDeviceTime(IOUtils.getRfc3339String(ZonedDateTime.now()));
+ dataBuilder.setDeviceTime(NsUtils.getRfc3339String(ZonedDateTime.now()));
dataBuilder.setMissionId(missionId);
dataBuilder.setRecordNumber(recordNumber++);
dataBuilder.setGroupNumber(groupNumber);
@@ -1585,7 +1585,7 @@ private WifiRecordWrapper generateWiFiBeaconSurveyRecord(ScanResult apScanResult
}
dataBuilder.setDeviceSerialNumber(deviceId);
- dataBuilder.setDeviceTime(IOUtils.getRfc3339String(ZonedDateTime.now()));
+ dataBuilder.setDeviceTime(NsUtils.getRfc3339String(ZonedDateTime.now()));
dataBuilder.setMissionId(missionId);
dataBuilder.setRecordNumber(wifiRecordNumber++);
@@ -1686,7 +1686,7 @@ private BluetoothRecord generateBluetoothSurveyRecord(BluetoothDevice device, in
}
dataBuilder.setDeviceSerialNumber(deviceId);
- dataBuilder.setDeviceTime(IOUtils.getRfc3339String(ZonedDateTime.now()));
+ dataBuilder.setDeviceTime(NsUtils.getRfc3339String(ZonedDateTime.now()));
dataBuilder.setMissionId(missionId);
dataBuilder.setRecordNumber(bluetoothRecordNumber++);
@@ -1773,7 +1773,7 @@ private GnssRecord generateGnssSurveyRecord(GnssMeasurement gnss, Map= version;
- }
-}
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/util/IOUtils.java b/networksurvey/src/main/java/com/craxiom/networksurvey/util/NsUtils.java
similarity index 90%
rename from networksurvey/src/main/java/com/craxiom/networksurvey/util/IOUtils.java
rename to networksurvey/src/main/java/com/craxiom/networksurvey/util/NsUtils.java
index b54080b6..b706ed81 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/util/IOUtils.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/util/NsUtils.java
@@ -1,24 +1,10 @@
-/*
- * Copyright (C) 2019 Sean J. Barbeau
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
package com.craxiom.networksurvey.util;
import android.Manifest;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.location.Location;
import android.telephony.TelephonyManager;
@@ -35,9 +21,9 @@
import timber.log.Timber;
/**
- * Originally from the GPS Test open source Android app. https://github.com/barbeau/gpstest
+ * A collection of general purpose util methods for use throughout the app.
*/
-public class IOUtils
+public class NsUtils
{
/**
* Return an ISO 8601 combined date and time string for specified date/time.
@@ -197,4 +183,20 @@ public static String serialize(double[][] data)
builder.replace(builder.length() - 2, builder.length(), "]");
return builder.toString();
}
+
+ /**
+ * @return The NS App version name (with any flavor suffix), or an empty string if it could not be determined.
+ */
+ public static String getAppVersionName(Context context)
+ {
+ try
+ {
+ final PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
+ final String versionSuffix = context.getString(R.string.version_suffix);
+ return info.versionName + versionSuffix;
+ } catch (PackageManager.NameNotFoundException e)
+ {
+ return "";
+ }
+ }
}
diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/util/UIUtils.java b/networksurvey/src/main/java/com/craxiom/networksurvey/util/UIUtils.java
index 66a2b3ef..46bbc724 100644
--- a/networksurvey/src/main/java/com/craxiom/networksurvey/util/UIUtils.java
+++ b/networksurvey/src/main/java/com/craxiom/networksurvey/util/UIUtils.java
@@ -15,13 +15,8 @@
*/
package com.craxiom.networksurvey.util;
-import static com.craxiom.networksurvey.view.GnssSkyView.MAX_VALUE_CN0;
-import static com.craxiom.networksurvey.view.GnssSkyView.MIN_VALUE_CN0;
-
import android.content.Context;
import android.location.Location;
-import android.view.View;
-import android.view.ViewGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
@@ -183,7 +178,7 @@ public static String formatLocationForDisplay(Location location, TextView locati
// Constants below must match string values in do_not_translate.xml
case "dd":
// Decimal degrees
- formattedLocation = IOUtils.createLocationShare(location, includeAltitude);
+ formattedLocation = NsUtils.createLocationShare(location, includeAltitude);
if (chipDecimalDegrees != null)
{
chipDecimalDegrees.setChecked(true);
@@ -192,7 +187,7 @@ public static String formatLocationForDisplay(Location location, TextView locati
case "dms":
// Degrees minutes seconds
- formattedLocation = IOUtils.createLocationShare(getDMSFromLocation(Application.get(), location.getLatitude(), COORDINATE_LATITUDE),
+ formattedLocation = NsUtils.createLocationShare(getDMSFromLocation(Application.get(), location.getLatitude(), COORDINATE_LATITUDE),
getDMSFromLocation(Application.get(), location.getLongitude(), COORDINATE_LONGITUDE),
(location.hasAltitude() && includeAltitude) ? Double.toString(location.getAltitude()) : null);
if (chipDMS != null)
@@ -203,7 +198,7 @@ public static String formatLocationForDisplay(Location location, TextView locati
case "ddm":
// Degrees decimal minutes
- formattedLocation = IOUtils.createLocationShare(getDDMFromLocation(Application.get(), location.getLatitude(), COORDINATE_LATITUDE),
+ formattedLocation = NsUtils.createLocationShare(getDDMFromLocation(Application.get(), location.getLatitude(), COORDINATE_LATITUDE),
getDDMFromLocation(Application.get(), location.getLongitude(), COORDINATE_LONGITUDE),
(location.hasAltitude() && includeAltitude) ? Double.toString(location.getAltitude()) : null);
if (chipDegreesDecimalMin != null)
@@ -214,7 +209,7 @@ public static String formatLocationForDisplay(Location location, TextView locati
default:
// Decimal degrees
- formattedLocation = IOUtils.createLocationShare(location, includeAltitude);
+ formattedLocation = NsUtils.createLocationShare(location, includeAltitude);
if (chipDecimalDegrees != null)
{
chipDecimalDegrees.setChecked(true);
diff --git a/networksurvey/src/main/res/values/strings.xml b/networksurvey/src/main/res/values/strings.xml
index 56181243..dcdda1a6 100644
--- a/networksurvey/src/main/res/values/strings.xml
+++ b/networksurvey/src/main/res/values/strings.xml
@@ -73,6 +73,7 @@ but work independently, so you have full control over how you handle your data.<
Deny Permission
v%1$s
+
Could not turn on logging, the app is not ready
diff --git a/networksurvey/src/test/java/com/craxiom/networksurvey/CalculationUtilsUnitTest.java b/networksurvey/src/test/java/com/craxiom/networksurvey/CalculationUtilsUnitTest.java
index 4b416393..d150118a 100644
--- a/networksurvey/src/test/java/com/craxiom/networksurvey/CalculationUtilsUnitTest.java
+++ b/networksurvey/src/test/java/com/craxiom/networksurvey/CalculationUtilsUnitTest.java
@@ -5,6 +5,8 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
+import com.craxiom.networksurvey.util.CalculationUtils;
+
import org.junit.Test;
/**
diff --git a/networksurvey/src/test/java/com/craxiom/networksurvey/SortedSetTest.java b/networksurvey/src/test/java/com/craxiom/networksurvey/SortedSetTest.java
index 243c4b98..09c40ce0 100644
--- a/networksurvey/src/test/java/com/craxiom/networksurvey/SortedSetTest.java
+++ b/networksurvey/src/test/java/com/craxiom/networksurvey/SortedSetTest.java
@@ -6,7 +6,7 @@
import com.craxiom.messaging.bluetooth.Technology;
import com.craxiom.networksurvey.fragments.model.BluetoothViewModel;
import com.craxiom.networksurvey.model.SortedSet;
-import com.craxiom.networksurvey.util.IOUtils;
+import com.craxiom.networksurvey.util.NsUtils;
import com.google.protobuf.FloatValue;
import com.google.protobuf.Int32Value;
@@ -95,7 +95,7 @@ private BluetoothRecord getFakeBluetoothRecord(String sourceAddress, float signa
final BluetoothRecordData.Builder dataBuilder = BluetoothRecordData.newBuilder();
dataBuilder.setDeviceSerialNumber("ee4d453e4c6f73fa");
dataBuilder.setDeviceName("BT Pixel");
- dataBuilder.setDeviceTime(IOUtils.getRfc3339String(ZonedDateTime.now()));
+ dataBuilder.setDeviceTime(NsUtils.getRfc3339String(ZonedDateTime.now()));
dataBuilder.setLatitude(51.470334);
dataBuilder.setLongitude(-0.486594);
dataBuilder.setAltitude(184.08124f);