implement LocationManager and orientation sensor using libportal

This commit is contained in:
Julian Winkler
2023-07-14 20:02:34 +02:00
parent c72f3ba7d2
commit 696e0ce714
13 changed files with 167 additions and 3 deletions

View File

@@ -0,0 +1,31 @@
package android.location;
import java.util.HashSet;
import java.util.Set;
public class LocationManager {
static Set<LocationListener> listeners = new HashSet<>();
public String getBestProvider(Criteria criteria, boolean enabledOnly) {
return "xdgportal";
}
public Location getLastKnownLocation(String provider) {
return null;
}
public void requestLocationUpdates (String provider, long minTimeMs, float minDistanceM, LocationListener listener) {
listeners.add(listener);
nativeGetLocation();
}
private native void nativeGetLocation();
private static void locationUpdated(double latitude, double longitude, double heading) {
for (LocationListener locationListener : listeners) {
locationListener.onLocationChanged(new Location(latitude, longitude, heading));
}
}
}