This source file includes following definitions.
- create
- start
- stop
- isRunning
- newLocationAvailable
- newErrorAvailable
- nativeNewLocationAvailable
- nativeNewErrorAvailable
package org.chromium.content.browser;
import android.content.Context;
import com.google.common.annotations.VisibleForTesting;
import org.chromium.base.CalledByNative;
import org.chromium.base.ThreadUtils;
import java.util.concurrent.FutureTask;
@VisibleForTesting
public class LocationProviderAdapter {
private LocationProviderFactory.LocationProvider mImpl;
private LocationProviderAdapter(Context context) {
mImpl = LocationProviderFactory.get(context);
}
@CalledByNative
static LocationProviderAdapter create(Context context) {
return new LocationProviderAdapter(context);
}
@CalledByNative
public boolean start(final boolean gpsEnabled) {
FutureTask<Void> task = new FutureTask<Void>(new Runnable() {
@Override
public void run() {
mImpl.start(gpsEnabled);
}
}, null);
ThreadUtils.runOnUiThread(task);
return true;
}
@CalledByNative
public void stop() {
FutureTask<Void> task = new FutureTask<Void>(new Runnable() {
@Override
public void run() {
mImpl.stop();
}
}, null);
ThreadUtils.runOnUiThread(task);
}
public boolean isRunning() {
assert ThreadUtils.runningOnUiThread();
return mImpl.isRunning();
}
public static void newLocationAvailable(double latitude, double longitude, double timestamp,
boolean hasAltitude, double altitude,
boolean hasAccuracy, double accuracy,
boolean hasHeading, double heading,
boolean hasSpeed, double speed) {
nativeNewLocationAvailable(latitude, longitude, timestamp, hasAltitude, altitude,
hasAccuracy, accuracy, hasHeading, heading, hasSpeed, speed);
}
public static void newErrorAvailable(String message) {
nativeNewErrorAvailable(message);
}
private static native void nativeNewLocationAvailable(
double latitude, double longitude, double timeStamp,
boolean hasAltitude, double altitude,
boolean hasAccuracy, double accuracy,
boolean hasHeading, double heading,
boolean hasSpeed, double speed);
private static native void nativeNewErrorAvailable(String message);
}