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

Log Exceptions (#230) #14

Merged
merged 1 commit into from
Jul 1, 2017
Merged
Show file tree
Hide file tree
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 @@ -37,6 +37,8 @@ public interface FusedLocationProviderApi {
* Network location is enabled and the {@link android.location.LocationManager} has a last known
* Network location
*
* This method can return null if there is a problem getting the availability.
*
* @param client The client to return availability for.
* @return The availability of location data.
* @throws IllegalStateException if the client is not connected at the time of this call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.util.Log;

import java.util.List;
import java.util.Map;
Expand All @@ -31,6 +32,7 @@
public class FusedLocationProviderApiImpl extends ApiImpl
implements FusedLocationProviderApi, EventCallbacks, ServiceConnection {

private static final String TAG = FusedLocationProviderApiImpl.class.getSimpleName();
private Context context;
private FusedLocationServiceConnectionManager serviceConnectionManager;
private FusedLocationServiceCallbackManager serviceCallbackManager;
Expand Down Expand Up @@ -123,19 +125,25 @@ public boolean isConnected() {

@Override public Location getLastLocation(LostApiClient client) {
throwIfNotConnected(client);
Location location = null;
try {
return service.getLastLocation();
location = service.getLastLocation();
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to get last Location", e);
} finally {
return location;
}
}

@Override public LocationAvailability getLocationAvailability(LostApiClient client) {
throwIfNotConnected(client);
LocationAvailability availability = null;
try {
return service.getLocationAvailability();
availability = service.getLocationAvailability();
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to get LocationAvailability", e);
} finally {
return availability;
}
}

Expand Down Expand Up @@ -179,7 +187,7 @@ private void requestLocationUpdatesInternal(LocationRequest request) {
try {
service.requestLocationUpdates(request);
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to request location updates", e);
}
}

Expand All @@ -190,7 +198,7 @@ private void removeLocationUpdatesInternal(List<LocationRequest> requests) {
try {
service.removeLocationUpdates(requests);
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to remove location updates", e);
}
}

Expand Down Expand Up @@ -244,7 +252,8 @@ private void checkAllListenersPendingIntentsAndCallbacks() {
try {
service.setMockMode(isMockMode);
} catch (RemoteException e) {
throw new RuntimeException(e);
String mode = isMockMode ? "enabled" : "disabled";
Log.e(TAG, "Error occurred trying to set mock mode " + mode, e);
}
return new SimplePendingResult(true);
}
Expand All @@ -255,7 +264,7 @@ private void checkAllListenersPendingIntentsAndCallbacks() {
try {
service.setMockLocation(mockLocation);
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to set mock location", e);
}
return new SimplePendingResult(true);
}
Expand All @@ -266,7 +275,7 @@ private void checkAllListenersPendingIntentsAndCallbacks() {
try {
service.setMockTrace(path, filename);
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to set mock trace", e);
}
return new SimplePendingResult(true);
}
Expand All @@ -288,7 +297,7 @@ void registerRemoteCallback() {
try {
service.init(remoteCallback);
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to register remote callback", e);
}
}
}
Expand All @@ -298,7 +307,7 @@ void unregisterRemoteCallback() {
try {
service.init(null);
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to unregister remote callback", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.os.Looper;
import android.os.RemoteException;
import android.support.annotation.RequiresPermission;
import android.util.Log;

import java.io.File;
import java.util.List;
Expand All @@ -19,6 +20,7 @@

public class FusedLocationProviderServiceDelegate implements LocationEngine.Callback {

private static final String TAG = FusedLocationProviderServiceDelegate.class.getSimpleName();
private Context context;

private boolean mockMode;
Expand Down Expand Up @@ -76,7 +78,7 @@ public void reportLocation(Location location) {
try {
callback.onLocationChanged(location);
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to report a new Location", e);
}
}
}
Expand Down Expand Up @@ -130,7 +132,7 @@ private void notifyLocationAvailabilityChanged() {
try {
callback.onLocationAvailabilityChanged(availability);
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to report a new LocationAvailability", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import android.content.Context;
import android.location.Location;
import android.os.RemoteException;
import android.util.Log;

import java.util.ArrayList;

import static android.content.ContentValues.TAG;

/**
* Handles callbacks received in {@link FusedLocationProviderApiImpl} from
* {@link FusedLocationProviderService}.
Expand All @@ -29,11 +32,11 @@ void onLocationChanged(Context context, Location location, LostClientManager cli

ReportedChanges changes = clientManager.reportLocationChanged(location);

LocationAvailability availability;
LocationAvailability availability = null;
try {
availability = service.getLocationAvailability();
} catch (RemoteException e) {
throw new RuntimeException(e);
Log.e(TAG, "Error occurred trying to get LocationAvailability", e);
}

ArrayList<Location> locations = new ArrayList<>();
Expand Down