diff --git a/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java b/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java index 75fb13b21..9b47db5e8 100644 --- a/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java +++ b/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java @@ -76,6 +76,7 @@ import androidx.core.view.MenuItemCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.FragmentManager; +import androidx.lifecycle.ViewModelProviders; import com.android.gpstest.io.CsvFileLogger; import com.android.gpstest.io.JsonFileLogger; @@ -262,6 +263,8 @@ public class GpsTestActivity extends AppCompatActivity private ProgressBar progressBar = null; + DeviceInfoViewModel deviceInfoViewModel; + /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { @@ -309,6 +312,8 @@ public void onCreate(Bundle savedInstanceState) { csvFileLogger = new CsvFileLogger(getApplicationContext()); jsonFileLogger = new JsonFileLogger(getApplicationContext()); + + deviceInfoViewModel = ViewModelProviders.of(this).get(DeviceInfoViewModel.class); } @Override @@ -700,7 +705,7 @@ private void goToNavDrawerItem(int item) { locationString = LocationUtils.printLocationDetails(mLastLocation); } - UIUtils.sendEmail(this, email, locationString); + UIUtils.sendEmail(this, email, locationString, deviceInfoViewModel); break; } invalidateOptionsMenu(); diff --git a/GPSTest/src/main/java/com/android/gpstest/HelpActivity.java b/GPSTest/src/main/java/com/android/gpstest/HelpActivity.java index fe2c81bed..bdc7b7923 100644 --- a/GPSTest/src/main/java/com/android/gpstest/HelpActivity.java +++ b/GPSTest/src/main/java/com/android/gpstest/HelpActivity.java @@ -58,6 +58,7 @@ protected void onCreate(Bundle savedInstanceState) { .append("-" + BuildConfig.FLAVOR + ")\n"); version.append("GNSS HW Year: " + IOUtils.getGnssHardwareYear() + "\n"); + version.append("GNSS HW Name: " + IOUtils.getGnssHardwareModelName() + "\n"); String versionRelease = Build.VERSION.RELEASE; version.append("Platform: " + versionRelease + "\n"); diff --git a/GPSTest/src/main/java/com/android/gpstest/util/UIUtils.java b/GPSTest/src/main/java/com/android/gpstest/util/UIUtils.java index bef97b8c5..f40d1ad72 100644 --- a/GPSTest/src/main/java/com/android/gpstest/util/UIUtils.java +++ b/GPSTest/src/main/java/com/android/gpstest/util/UIUtils.java @@ -27,6 +27,7 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.location.Location; +import android.location.LocationManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -49,22 +50,28 @@ import com.android.gpstest.Application; import com.android.gpstest.BuildConfig; +import com.android.gpstest.DeviceInfoViewModel; import com.android.gpstest.R; import com.android.gpstest.dialog.ShareDialogFragment; import com.android.gpstest.io.CsvFileLogger; import com.android.gpstest.io.JsonFileLogger; import com.android.gpstest.model.GnssType; +import com.android.gpstest.model.SbasType; import com.google.android.material.chip.Chip; import java.io.File; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.concurrent.TimeUnit; import static android.content.Intent.createChooser; import static android.content.pm.PackageManager.GET_META_DATA; import static android.text.TextUtils.isEmpty; +import static com.android.gpstest.util.IOUtils.replaceNavstar; +import static com.android.gpstest.util.IOUtils.trimEnds; import static com.android.gpstest.view.GpsSkyView.MAX_VALUE_CN0; import static com.android.gpstest.view.GpsSkyView.MAX_VALUE_SNR; import static com.android.gpstest.view.GpsSkyView.MIN_VALUE_CN0; @@ -237,8 +244,10 @@ public static void setMargins(View v, int l, int t, int r, int b) { * Opens email apps based on the given email address * @param email address * @param location string that shows the current location + * @param deviceInfoViewModel view model that contains state of GNSS */ - public static void sendEmail(Context context, String email, String location) { + public static void sendEmail(Context context, String email, String location, DeviceInfoViewModel deviceInfoViewModel) { + LocationManager locationManager = (LocationManager) Application.get().getSystemService(Context.LOCATION_SERVICE); PackageManager pm = context.getPackageManager(); PackageInfo appInfo; @@ -272,7 +281,10 @@ public static void sendEmail(Context context, String email, String location) { body.append("Location: " + location + "\n"); } - body.append("GNSS HW Year: " + IOUtils.getGnssHardwareYear() + "\n"); + body.append("GNSS HW year: " + IOUtils.getGnssHardwareYear() + "\n"); + if (!IOUtils.getGnssHardwareModelName().trim().isEmpty()) { + body.append("GNSS HW name: " + IOUtils.getGnssHardwareModelName() + "\n"); + } // Raw GNSS measurement capability int capability = Application.getPrefs().getInt(Application.get().getString(R.string.capability_key_raw_measurements), PreferenceUtils.CAPABILITY_UNKNOWN); @@ -310,6 +322,42 @@ public static void sendEmail(Context context, String email, String location) { body.append(Application.get().getString(R.string.capability_title_delete_assist, PreferenceUtils.getCapabilityDescription(capability))); } + // First fix + body.append(Application.get().getString(R.string.capability_title_first_fix, location != null && deviceInfoViewModel.gotFirstFix())); + + // We need a fix to determine these attributes reliably + if (location != null && deviceInfoViewModel.gotFirstFix()) { + // Dual frequency + body.append(Application.get().getString(R.string.capability_title_dual_frequency, PreferenceUtils.getCapabilityDescription(deviceInfoViewModel.isNonPrimaryCarrierFreqInView()))); + // Supported GNSS + List gnss = new ArrayList<>(deviceInfoViewModel.getSupportedGnss()); + Collections.sort(gnss); + body.append(Application.get().getString(R.string.capability_title_supported_gnss, trimEnds(replaceNavstar(gnss.toString())))); + // GNSS CF + List gnssCfs = new ArrayList<>(deviceInfoViewModel.getSupportedGnssCfs()); + if (!gnssCfs.isEmpty()) { + Collections.sort(gnssCfs); + body.append(Application.get().getString(R.string.capability_title_gnss_cf, trimEnds(gnssCfs.toString()))); + } + // Supported SBAS + List sbas = new ArrayList<>(deviceInfoViewModel.getSupportedSbas()); + if (!sbas.isEmpty()) { + Collections.sort(sbas); + body.append(Application.get().getString(R.string.capability_title_supported_sbas, trimEnds(sbas.toString()))); + } + // SBAS CF + List sbasCfs = new ArrayList<>(deviceInfoViewModel.getSupportedSbasCfs()); + if (!sbasCfs.isEmpty()) { + Collections.sort(sbasCfs); + body.append(Application.get().getString(R.string.capability_title_sbas_cf, trimEnds(sbasCfs.toString()))); + } + // Accumulated delta range + body.append(Application.get().getString(R.string.capability_title_accumulated_delta_range, PreferenceUtils.getCapabilityDescription(Application.getPrefs().getInt(Application.get().getString(R.string.capability_key_measurement_delta_range), PreferenceUtils.CAPABILITY_UNKNOWN)))); + // Automatic gain control + body.append(Application.get().getString(R.string.capability_title_automatic_gain_control, PreferenceUtils.getCapabilityDescription(Application.getPrefs().getInt(Application.get().getString(R.string.capability_key_measurement_automatic_gain_control), PreferenceUtils.CAPABILITY_UNKNOWN)))); + } + // GNSS Antenna Info + body.append(Application.get().getString(R.string.capability_title_gnss_antenna_info, PreferenceUtils.getCapabilityDescription(SatelliteUtils.isGnssAntennaInfoSupported(locationManager)))); if (!TextUtils.isEmpty(BuildUtils.getPlayServicesVersion())) { body.append("\n" + BuildUtils.getPlayServicesVersion()); diff --git a/GPSTest/src/main/res/values/do_not_translate.xml b/GPSTest/src/main/res/values/do_not_translate.xml index 0fcb16cfd..f82fe850b 100644 --- a/GPSTest/src/main/res/values/do_not_translate.xml +++ b/GPSTest/src/main/res/values/do_not_translate.xml @@ -175,6 +175,16 @@ Raw measurements: %1$s\n Navigation messages: %1$s\n NMEA: %1$s\n + Dual frequency: %1$s\n + GNSS hardware name: %1$s\n + Accumulated delta range: %1$s\n + Automatic gain control: %1$s\n + GNSS antenna info: %1$s\n + Supported GNSS: %1$s\n + GNSS CFs: %1$s\n + Supported SBAS: %1$s\n + SBAS CFs: %1$s\n + First fix: %1$b\n UNKNOWN NOT_SUPPORTED