Skip to content

Commit

Permalink
feat: Add more device capabilities to feedback email
Browse files Browse the repository at this point in the history
Closes #479
  • Loading branch information
barbeau committed Jan 30, 2021
1 parent 70d8ec5 commit 5625b63
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
52 changes: 50 additions & 2 deletions GPSTest/src/main/java/com/android/gpstest/util/UIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<GnssType> 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<String> 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<SbasType> 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<String> 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());
Expand Down
10 changes: 10 additions & 0 deletions GPSTest/src/main/res/values/do_not_translate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@
<string name="capability_title_raw_measurements">Raw measurements: %1$s\n</string>
<string name="capability_title_nav_messages">Navigation messages: %1$s\n</string>
<string name="capability_title_nmea">NMEA: %1$s\n</string>
<string name="capability_title_dual_frequency">Dual frequency: %1$s\n</string>
<string name="capability_title_gnss_hardware_name">GNSS hardware name: %1$s\n</string>
<string name="capability_title_accumulated_delta_range">Accumulated delta range: %1$s\n</string>
<string name="capability_title_automatic_gain_control">Automatic gain control: %1$s\n</string>
<string name="capability_title_gnss_antenna_info">GNSS antenna info: %1$s\n</string>
<string name="capability_title_supported_gnss">Supported GNSS: %1$s\n</string>
<string name="capability_title_gnss_cf">GNSS CFs: %1$s\n</string>
<string name="capability_title_supported_sbas">Supported SBAS: %1$s\n</string>
<string name="capability_title_sbas_cf">SBAS CFs: %1$s\n</string>
<string name="capability_title_first_fix">First fix: %1$b\n</string>

<string name="capability_value_unknown">UNKNOWN</string>
<string name="capability_value_not_supported">NOT_SUPPORTED</string>
Expand Down

0 comments on commit 5625b63

Please sign in to comment.