Skip to content

Commit

Permalink
Bug cgeo#457 - Use of GnssStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
GalateeM committed May 10, 2024
1 parent 51ed74d commit 3e38c07
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ public class GpsConnection {
private final MyLocationListener llGPS;
private final MyLocationListener llNetwork;
private final MyGpsListener gpsListener;
private final MyGnssListener gnssListener;
private boolean isFixed;
private Timer mGpsTimer;
// temp variable for indicating whether network provider is enabled
private boolean networkProviderEnabled;
private boolean gpsProviderEnabled;
private GpsStatus gpsStatus;
private GnssStatus gnssStatus;

public GpsConnection(Context context) {
Logger.w(TAG, "onCreate()");
Expand All @@ -58,6 +60,7 @@ public GpsConnection(Context context) {
llGPS = new MyLocationListener();
llNetwork = new MyLocationListener();
gpsListener = new MyGpsListener();
gnssListener = new MyGnssListener();

// init basic fixing values
isFixed = false;
Expand Down Expand Up @@ -105,7 +108,6 @@ public GpsConnection(Context context) {
// add new listener GPS
try {
if (Build.VERSION.SDK_INT >= 24) {
MyGnssListener gnssListener = new MyGnssListener();
locationManager.registerGnssStatusCallback(gnssListener);
} else {
locationManager.addGpsStatusListener(gpsListener);
Expand All @@ -131,7 +133,11 @@ public void destroy() {
if (locationManager != null) {
disableNetwork();
locationManager.removeUpdates(llGPS);
locationManager.removeGpsStatusListener(gpsListener);
if (Build.VERSION.SDK_INT >= 24) {
locationManager.unregisterGnssStatusCallback(gnssListener);
} else {
locationManager.removeGpsStatusListener(gpsListener);
}
locationManager = null;
// XXX missing context to notify by widget
ManagerNotify.toastShortMessage(R.string.gps_disabled);
Expand Down

0 comments on commit 3e38c07

Please sign in to comment.