Skip to content

Commit

Permalink
feat: Log more GNSS antenna info to Device Database
Browse files Browse the repository at this point in the history
* Log number of GNSS antennas and carrier frequencies for antennas
* Cleanup unused parameters
* Refactor CF utils to re-use code for finding antenna CF label
  • Loading branch information
barbeau committed Feb 10, 2021
1 parent 4262b2b commit 7982ed6
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 102 deletions.
14 changes: 14 additions & 0 deletions GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import com.android.gpstest.io.CsvFileLogger;
import com.android.gpstest.io.JsonFileLogger;
import com.android.gpstest.map.MapConstants;
import com.android.gpstest.util.CarrierFreqUtils;
import com.android.gpstest.util.IOUtils;
import com.android.gpstest.util.LocationUtils;
import com.android.gpstest.util.MathUtils;
Expand All @@ -93,6 +94,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand All @@ -108,6 +110,7 @@
import static com.android.gpstest.NavigationDrawerFragment.NAVDRAWER_ITEM_SETTINGS;
import static com.android.gpstest.NavigationDrawerFragment.NAVDRAWER_ITEM_SKY;
import static com.android.gpstest.NavigationDrawerFragment.NAVDRAWER_ITEM_STATUS;
import static com.android.gpstest.util.IOUtils.trimEnds;
import static com.android.gpstest.util.IOUtils.writeGnssMeasurementToAndroidStudio;
import static com.android.gpstest.util.IOUtils.writeNavMessageToAndroidStudio;
import static com.android.gpstest.util.IOUtils.writeNmeaToAndroidStudio;
Expand Down Expand Up @@ -1047,6 +1050,17 @@ private void addGnssAntennaListener() {
if (SatelliteUtils.isGnssAntennaInfoSupported(mLocationManager) && gnssAntennaInfoListener == null) {
// TODO - move this and other callbacks to background threads and only run on UI thread when updating UI
gnssAntennaInfoListener = list -> {
// Capture capabilities in preferences
PreferenceUtils.saveInt(Application.get().getString(R.string.capability_key_num_antenna), list.size());
List<String> cfs = new ArrayList<>(2);
for (GnssAntennaInfo info : list) {
cfs.add(CarrierFreqUtils.getCarrierFrequencyLabel(info));
}
if (!cfs.isEmpty()) {
Collections.sort(cfs);
PreferenceUtils.saveString(Application.get().getString(R.string.capability_key_antenna_cf), trimEnds(cfs.toString()));
}

if (mWriteAntennaInfoToFileJson &&
PermissionUtils.hasGrantedFileWritePermission(GpsTestActivity.this)) {
jsonFileLogger.onGnssAntennaInfoReceived(list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ class UploadDeviceInfoFragment : Fragment() {
capabilityNavMessagesString = ""
}

val gnssAntennaInfo = PreferenceUtils.getCapabilityDescription(SatelliteUtils.isGnssAntennaInfoSupported(locationManager))
val numAntennas: String
val antennaCfs: String
if (gnssAntennaInfo.equals(Application.get().getString(R.string.capability_value_supported))) {
numAntennas = PreferenceUtils.getInt(Application.get().getString(R.string.capability_key_num_antenna), -1).toString()
antennaCfs = PreferenceUtils.getString(Application.get().getString(R.string.capability_key_antenna_cf))
} else {
numAntennas = ""
antennaCfs = ""
}

// Upload device info to database
val bundle = bundleOf(
DevicePropertiesUploader.MANUFACTURER to Build.MANUFACTURER,
Expand All @@ -170,11 +181,13 @@ class UploadDeviceInfoFragment : Fragment() {
DevicePropertiesUploader.HARDWARE_CLOCK to "",
DevicePropertiesUploader.HARDWARE_CLOCK_DISCONTINUITY to "",
DevicePropertiesUploader.AUTOMATIC_GAIN_CONTROL to PreferenceUtils.getCapabilityDescription(Application.getPrefs().getInt(Application.get().getString(R.string.capability_key_measurement_automatic_gain_control), PreferenceUtils.CAPABILITY_UNKNOWN)),
DevicePropertiesUploader.GNSS_ANTENNA_INFO to PreferenceUtils.getCapabilityDescription(SatelliteUtils.isGnssAntennaInfoSupported(locationManager)),
DevicePropertiesUploader.GNSS_ANTENNA_INFO to gnssAntennaInfo,
DevicePropertiesUploader.APP_BUILD_FLAVOR to BuildConfig.FLAVOR,
DevicePropertiesUploader.USER_COUNTRY to userCountry,
DevicePropertiesUploader.ANDROID_BUILD_INCREMENTAL to Build.VERSION.INCREMENTAL,
DevicePropertiesUploader.ANDROID_BUILD_CODENAME to Build.VERSION.CODENAME
DevicePropertiesUploader.ANDROID_BUILD_CODENAME to Build.VERSION.CODENAME,
DevicePropertiesUploader.NUM_ANTENNAS to numAntennas,
DevicePropertiesUploader.ANTENNA_CFS to antennaCfs,
)

upload.isEnabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class DevicePropertiesUploader(private val inputData: Bundle) {
.appendQueryParameter(HARDWARE_CLOCK_DISCONTINUITY, inputData.getString(HARDWARE_CLOCK_DISCONTINUITY))
.appendQueryParameter(AUTOMATIC_GAIN_CONTROL, inputData.getString(AUTOMATIC_GAIN_CONTROL))
.appendQueryParameter(GNSS_ANTENNA_INFO, inputData.getString(GNSS_ANTENNA_INFO))
.appendQueryParameter(NUM_ANTENNAS, inputData.getString(NUM_ANTENNAS))
.appendQueryParameter(ANTENNA_CFS, inputData.getString(ANTENNA_CFS))
.appendQueryParameter(APP_VERSION_NAME, inputData.getString(APP_VERSION_NAME))
.appendQueryParameter(APP_VERSION_CODE, inputData.getString(APP_VERSION_CODE))
.appendQueryParameter(APP_BUILD_FLAVOR, inputData.getString(APP_BUILD_FLAVOR))
Expand Down Expand Up @@ -129,13 +131,14 @@ class DevicePropertiesUploader(private val inputData: Bundle) {
const val HARDWARE_CLOCK_DISCONTINUITY = "hardwareClockDiscontinuity"
const val AUTOMATIC_GAIN_CONTROL = "automaticGainControl"
const val GNSS_ANTENNA_INFO = "gnssAntennaInfo"
const val NUM_ANTENNAS = "numAntennas"
const val ANTENNA_CFS = "antennaCfs"
const val APP_VERSION_NAME = "appVersionName"
const val APP_VERSION_CODE = "appVersionCode"
const val APP_BUILD_FLAVOR = "appBuildFlavor"
const val USER_COUNTRY = "userCountry"
const val ANDROID_BUILD_INCREMENTAL = "androidBuildIncremental"
const val ANDROID_BUILD_CODENAME = "androidBuildCodename"
private const val RESULT_OK = "STATUS OK"
private const val RESULT_NO_EMULATOR_SUBMISSIONS = "NO EMULATOR SUBMISSIONS"
}
}
Loading

0 comments on commit 7982ed6

Please sign in to comment.