Skip to content

Commit

Permalink
Sets the nonTerrestrialNetwork field in the phone state message (MQTT…
Browse files Browse the repository at this point in the history
…, gRPC, CSV, and GeoPackage)
  • Loading branch information
christianrowlands committed Oct 18, 2024
1 parent 116864a commit b4d4fa3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion networksurvey/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()) : ""
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
});
Expand Down Expand Up @@ -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<String> jsonList = new ArrayList<>();
for (NetworkRegistrationInfo info : data.getNetworkRegistrationInfoList())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<PhoneStateData.Builder> networkRegistrationInfoFunction)
private PhoneState createPhoneStateMessage(TelephonyManager telephonyManager, int subscriptionId,
ServiceState serviceState, Consumer<PhoneStateData.Builder> networkRegistrationInfoFunction)
{
final PhoneStateData.Builder dataBuilder = PhoneStateData.newBuilder();

Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit b4d4fa3

Please sign in to comment.