Skip to content

Commit

Permalink
Fix mock locations
Browse files Browse the repository at this point in the history
  • Loading branch information
andreynovikov committed Mar 13, 2024
1 parent 12105f5 commit 1cbb8b4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions app/src/main/java/mobi/maptrek/location/LocationService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Andrey Novikov
* Copyright 2024 Andrey Novikov
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
Expand Down Expand Up @@ -299,11 +299,17 @@ public static boolean isGpsProviderEnabled(Context context) {

private void connect() {
logger.debug("connect()");
mLastLocationMillis = -SKIP_INITIAL_LOCATIONS;
mContinuous = false;
mJustStarted = true;
if (enableMockLocations && BuildConfig.DEBUG) {
mMockLocationTicker = 0;
mMockCallback.post(mSendMockLocation);
mLocationsEnabled = true;
return;
}
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (mLocationManager != null) {
mLastLocationMillis = -SKIP_INITIAL_LOCATIONS;
mContinuous = false;
mJustStarted = true;
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= 24) {
mLocationManager.registerGnssStatusCallback(mGnssStatusCallback);
Expand All @@ -322,11 +328,6 @@ private void connect() {
logger.error("Missing ACCESS_FINE_LOCATION permission");
}
}
if (enableMockLocations && BuildConfig.DEBUG) {
mMockLocationTicker = 0;
mMockCallback.post(mSendMockLocation);
mLocationsEnabled = true;
}
}

private void disconnect() {
Expand Down

0 comments on commit 1cbb8b4

Please sign in to comment.