Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crash on location engine access and location request hang #535

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,10 @@ public void onError(@NonNull String message) {
case "locationComponent#getLastLocation":
{
Log.e(TAG, "location component: getLastLocation");
if (this.myLocationEnabled && locationComponent != null) {
if (this.myLocationEnabled
&& locationComponent != null
&& locationComponent.isLocationComponentActivated()
&& locationComponent.getLocationEngine() != null) {
Map<String, Object> reply = new HashMap<>();

mapLibreMap.getLocationComponent().getLocationEngine().getLastLocation(
Expand All @@ -1265,6 +1268,11 @@ public void onFailure(@NonNull Exception exception) {
result.error("", "", null); // ???
}
});
} else {
result.error(
"LOCATION DISABLED",
"Location is disabled or location component is unavailable",
null);
}
break;
}
Expand Down Expand Up @@ -2017,7 +2025,7 @@ public void setAttributionButtonMargins(int x, int y) {
}

private void updateMyLocationEnabled() {
if (this.locationComponent == null && myLocationEnabled) {
if (this.locationComponent == null && mapLibreMap.getStyle() != null && myLocationEnabled) {
enableLocationComponent(mapLibreMap.getStyle());
}

Expand All @@ -2035,6 +2043,7 @@ private void updateMyLocationEnabled() {
private void startListeningForLocationUpdates() {
if (locationEngineCallback == null
&& locationComponent != null
&& locationComponent.isLocationComponentActivated()
&& locationComponent.getLocationEngine() != null) {
locationEngineCallback =
new LocationEngineCallback<LocationEngineResult>() {
Expand All @@ -2056,6 +2065,7 @@ public void onFailure(@NonNull Exception exception) {}
private void stopListeningForLocationUpdates() {
if (locationEngineCallback != null
&& locationComponent != null
&& locationComponent.isLocationComponentActivated()
&& locationComponent.getLocationEngine() != null) {
locationComponent.getLocationEngine().removeLocationUpdates(locationEngineCallback);
locationEngineCallback = null;
Expand Down
Loading