diff --git a/networksurvey/build.gradle b/networksurvey/build.gradle index dec17f95..cc72904c 100644 --- a/networksurvey/build.gradle +++ b/networksurvey/build.gradle @@ -15,7 +15,7 @@ apply plugin: 'dagger.hilt.android.plugin' ext.androidVersion = '28.0.0' ext.grpcVersion = '1.65.1' -ext.networkSurveyMessagingVersion = '1.5.0' +ext.networkSurveyMessagingVersion = '1.6.0' ext.navigationVersion = '2.8.1' android { diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/constants/csv/PhoneStateCsvConstants.java b/networksurvey/src/main/java/com/craxiom/networksurvey/constants/csv/PhoneStateCsvConstants.java index 4f893f9e..138b8141 100644 --- a/networksurvey/src/main/java/com/craxiom/networksurvey/constants/csv/PhoneStateCsvConstants.java +++ b/networksurvey/src/main/java/com/craxiom/networksurvey/constants/csv/PhoneStateCsvConstants.java @@ -16,4 +16,5 @@ private PhoneStateCsvConstants() public static final String SIM_OPERATOR = "simOperator"; public static final String NETWORK_REGISTRATION = "networkRegistrationInfo"; public static final String SLOT = "slot"; + public static final String NON_TERRESTRIAL_NETWORK = "nonTerrestrialNetwork"; } diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/PhoneStateCsvLogger.java b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/PhoneStateCsvLogger.java index 1a139f74..fc45aca4 100644 --- a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/PhoneStateCsvLogger.java +++ b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/PhoneStateCsvLogger.java @@ -8,6 +8,7 @@ import static com.craxiom.networksurvey.constants.csv.PhoneStateCsvConstants.LONGITUDE; import static com.craxiom.networksurvey.constants.csv.PhoneStateCsvConstants.MISSION_ID; import static com.craxiom.networksurvey.constants.csv.PhoneStateCsvConstants.NETWORK_REGISTRATION; +import static com.craxiom.networksurvey.constants.csv.PhoneStateCsvConstants.NON_TERRESTRIAL_NETWORK; import static com.craxiom.networksurvey.constants.csv.PhoneStateCsvConstants.RECORD_NUMBER; import static com.craxiom.networksurvey.constants.csv.PhoneStateCsvConstants.SIM_OPERATOR; import static com.craxiom.networksurvey.constants.csv.PhoneStateCsvConstants.SIM_STATE; @@ -59,13 +60,13 @@ String[] getHeaders() return new String[]{DEVICE_TIME, LATITUDE, LONGITUDE, ALTITUDE, SPEED, ACCURACY, MISSION_ID, RECORD_NUMBER, SIM_STATE, SIM_OPERATOR, NETWORK_REGISTRATION, - DEVICE_SERIAL_NUMBER, SLOT}; + DEVICE_SERIAL_NUMBER, SLOT, NON_TERRESTRIAL_NETWORK}; } @Override String[] getHeaderComments() { - return new String[]{"CSV Version=0.2.0"}; + return new String[]{"CSV Version=0.3.0"}; } @Override @@ -133,7 +134,8 @@ private String[] convertToObjectArray(PhoneState record) data.getSimOperator(), networkRegistrationJson, data.getDeviceSerialNumber(), - data.hasSlot() ? String.valueOf(data.getSlot().getValue()) : "" + data.hasSlot() ? String.valueOf(data.getSlot().getValue()) : "", + data.hasNonTerrestrialNetwork() ? String.valueOf(data.getNonTerrestrialNetwork().getValue()) : "" }; } 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 347dc570..9c8355e6 100644 --- a/networksurvey/src/main/java/com/craxiom/networksurvey/logging/PhoneStateRecordLogger.java +++ b/networksurvey/src/main/java/com/craxiom/networksurvey/logging/PhoneStateRecordLogger.java @@ -11,6 +11,7 @@ import static com.craxiom.networksurvey.constants.MessageConstants.MISSION_ID_COLUMN; import static com.craxiom.networksurvey.constants.MessageConstants.RECORD_NUMBER_COLUMN; import static com.craxiom.networksurvey.constants.MessageConstants.TIME_COLUMN; +import static com.craxiom.networksurvey.constants.csv.PhoneStateCsvConstants.NON_TERRESTRIAL_NETWORK; import static com.craxiom.networksurvey.constants.csv.PhoneStateCsvConstants.SLOT; import android.os.Looper; @@ -76,6 +77,7 @@ void createTables(GeoPackage geoPackage, SpatialReferenceSystem srs) throws SQLE tableColumns.add(FeatureColumn.createColumn(columnNumber++, SIM_STATE_COLUMN, GeoPackageDataType.TEXT, false, null)); tableColumns.add(FeatureColumn.createColumn(columnNumber++, SIM_OPERATOR_COLUMN, GeoPackageDataType.TEXT, false, null)); tableColumns.add(FeatureColumn.createColumn(columnNumber++, SLOT, GeoPackageDataType.SMALLINT, false, null)); + tableColumns.add(FeatureColumn.createColumn(columnNumber++, NON_TERRESTRIAL_NETWORK, GeoPackageDataType.BOOLEAN, false, null)); //noinspection UnusedAssignment tableColumns.add(FeatureColumn.createColumn(columnNumber++, NETWORK_REGISTRATION_COLUMN, GeoPackageDataType.TEXT, false, null)); }); @@ -122,6 +124,11 @@ public void onPhoneState(PhoneState phoneState) row.setValue(SLOT, data.getSlot().getValue()); } + if (data.hasNonTerrestrialNetwork()) + { + row.setValue(NON_TERRESTRIAL_NETWORK, data.getNonTerrestrialNetwork().getValue()); + } + List jsonList = new ArrayList<>(); for (NetworkRegistrationInfo info : data.getNetworkRegistrationInfoList()) { 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 d11f26e7..baa501ca 100644 --- a/networksurvey/src/main/java/com/craxiom/networksurvey/services/SurveyRecordProcessor.java +++ b/networksurvey/src/main/java/com/craxiom/networksurvey/services/SurveyRecordProcessor.java @@ -536,7 +536,7 @@ void onDeviceStatus(DeviceStatus deviceStatus) @RequiresApi(api = Build.VERSION_CODES.Q) public void onServiceStateChanged(ServiceState serviceState, TelephonyManager telephonyManager, int subscriptionId) { - notifyPhoneStateListeners(createPhoneStateMessage(telephonyManager, subscriptionId, + notifyPhoneStateListeners(createPhoneStateMessage(telephonyManager, subscriptionId, serviceState, builder -> { // The documentation indicates the getNetworkRegistrationInfoList method was added in API level 30, // but I found it works for API level 29 as well. I filed a bug: https://issuetracker.google.com/issues/190809962 @@ -637,13 +637,15 @@ public void onSmsEvent(CdrEventType smsEventType, String originatingAddress, Tel * @since 1.4.0 */ void onRegistrationFailed(@NonNull CellIdentity cellIdentity, int domain, - int causeCode, int additionalCauseCode, TelephonyManager telephonyManager, int subscriptionId) + int causeCode, int additionalCauseCode, TelephonyManager telephonyManager, + int subscriptionId, ServiceState serviceState) { - notifyPhoneStateListeners(createPhoneStateMessage(telephonyManager, subscriptionId, + notifyPhoneStateListeners(createPhoneStateMessage(telephonyManager, subscriptionId, serviceState, builder -> builder.addNetworkRegistrationInfo(ParserUtils.convertNetworkInfo(cellIdentity, domain, causeCode)))); } - private PhoneState createPhoneStateMessage(TelephonyManager telephonyManager, int subscriptionId, Consumer networkRegistrationInfoFunction) + private PhoneState createPhoneStateMessage(TelephonyManager telephonyManager, int subscriptionId, + ServiceState serviceState, Consumer networkRegistrationInfoFunction) { final PhoneStateData.Builder dataBuilder = PhoneStateData.newBuilder(); @@ -676,6 +678,11 @@ private PhoneState createPhoneStateMessage(TelephonyManager telephonyManager, in dataBuilder.setSimState(SimState.forNumber(telephonyManager.getSimState())); dataBuilder.setSimOperator(telephonyManager.getSimOperator()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) + { + dataBuilder.setNonTerrestrialNetwork(BoolValue.of(serviceState.isUsingNonTerrestrialNetwork())); + } + if (subscriptionId != SubscriptionManager.INVALID_SUBSCRIPTION_ID && subscriptionId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { dataBuilder.setSlot(Int32Value.of(subscriptionId));