Loading play-services-location-core/build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -15,10 +15,10 @@ dependencies { implementation "org.microg.nlp:location-v2:$nlpVersion" implementation "org.microg.nlp:location-v3:$nlpVersion" implementation "org.microg.nlp:service:$nlpVersion" implementation "org.microg.nlp:client:$nlpVersion" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion" api "org.microg.nlp:client:$nlpVersion" api "org.microg.nlp:ui:$nlpVersion" } Loading play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManager.java +16 −6 Original line number Diff line number Diff line Loading @@ -64,16 +64,26 @@ public class GoogleLocationManager implements LocationChangeListener { this.gpsProvider = null; } if (Utils.hasSelfPermissionOrNotify(context, Manifest.permission.ACCESS_COARSE_LOCATION)) { if (locationManager.getAllProviders().contains(NETWORK_PROVIDER)) { this.networkProvider = new UnifiedLocationProvider(context, this); } else { // TODO: Add ability to directly contact UnifiedNlp without the system location provider this.networkProvider = null; } mockProvider = new MockLocationProvider(this); } public void invokeOnceReady(Runnable runnable) { Runnable networkRunnable = () -> { if (networkProvider != null) { networkProvider.invokeOnceReady(runnable); } else { this.networkProvider = null; runnable.run(); } }; if (gpsProvider != null) { gpsProvider.invokeOnceReady(networkRunnable); } else { networkRunnable.run(); } mockProvider = new MockLocationProvider(this); } public Location getLastLocation(String packageName) { Loading play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package org.microg.gms.location; import android.os.RemoteException; import android.util.Log; import com.google.android.gms.common.internal.GetServiceRequest; import com.google.android.gms.common.internal.IGmsCallbacks; Loading @@ -33,6 +34,12 @@ public class GoogleLocationManagerService extends BaseService { @Override public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { impl.invokeOnceReady(() -> { try { callback.onPostInitComplete(0, impl.asBinder(), null); } catch (RemoteException e) { Log.w(TAG, e); } }); } } play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerServiceImpl.java +4 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,10 @@ public class GoogleLocationManagerServiceImpl extends IGoogleLocationManagerServ this.context = context; } public void invokeOnceReady(Runnable runnable) { getLocationManager().invokeOnceReady(runnable); } private GoogleLocationManager getLocationManager() { if (locationManager == null) locationManager = new GoogleLocationManager(context); Loading play-services-location-core/src/main/java/org/microg/gms/location/RealLocationProvider.java +6 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicBoolean; @SuppressWarnings("MissingPermission") public class RealLocationProvider { public static final String TAG = "GmsLocProviderReal"; private static final int MIN_GPS_TIME = 30000; private static final int MIN_GPS_TIME = 10000; private final LocationManager locationManager; private final String name; Loading Loading @@ -76,6 +76,11 @@ public class RealLocationProvider { if (newLocation != null) lastLocation = newLocation; } public void invokeOnceReady(Runnable runnable) { // Always ready runnable.run(); } public Location getLastLocation() { if (!connected.get()) { updateLastLocation(); Loading Loading
play-services-location-core/build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -15,10 +15,10 @@ dependencies { implementation "org.microg.nlp:location-v2:$nlpVersion" implementation "org.microg.nlp:location-v3:$nlpVersion" implementation "org.microg.nlp:service:$nlpVersion" implementation "org.microg.nlp:client:$nlpVersion" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion" api "org.microg.nlp:client:$nlpVersion" api "org.microg.nlp:ui:$nlpVersion" } Loading
play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManager.java +16 −6 Original line number Diff line number Diff line Loading @@ -64,16 +64,26 @@ public class GoogleLocationManager implements LocationChangeListener { this.gpsProvider = null; } if (Utils.hasSelfPermissionOrNotify(context, Manifest.permission.ACCESS_COARSE_LOCATION)) { if (locationManager.getAllProviders().contains(NETWORK_PROVIDER)) { this.networkProvider = new UnifiedLocationProvider(context, this); } else { // TODO: Add ability to directly contact UnifiedNlp without the system location provider this.networkProvider = null; } mockProvider = new MockLocationProvider(this); } public void invokeOnceReady(Runnable runnable) { Runnable networkRunnable = () -> { if (networkProvider != null) { networkProvider.invokeOnceReady(runnable); } else { this.networkProvider = null; runnable.run(); } }; if (gpsProvider != null) { gpsProvider.invokeOnceReady(networkRunnable); } else { networkRunnable.run(); } mockProvider = new MockLocationProvider(this); } public Location getLastLocation(String packageName) { Loading
play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package org.microg.gms.location; import android.os.RemoteException; import android.util.Log; import com.google.android.gms.common.internal.GetServiceRequest; import com.google.android.gms.common.internal.IGmsCallbacks; Loading @@ -33,6 +34,12 @@ public class GoogleLocationManagerService extends BaseService { @Override public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { impl.invokeOnceReady(() -> { try { callback.onPostInitComplete(0, impl.asBinder(), null); } catch (RemoteException e) { Log.w(TAG, e); } }); } }
play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerServiceImpl.java +4 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,10 @@ public class GoogleLocationManagerServiceImpl extends IGoogleLocationManagerServ this.context = context; } public void invokeOnceReady(Runnable runnable) { getLocationManager().invokeOnceReady(runnable); } private GoogleLocationManager getLocationManager() { if (locationManager == null) locationManager = new GoogleLocationManager(context); Loading
play-services-location-core/src/main/java/org/microg/gms/location/RealLocationProvider.java +6 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicBoolean; @SuppressWarnings("MissingPermission") public class RealLocationProvider { public static final String TAG = "GmsLocProviderReal"; private static final int MIN_GPS_TIME = 30000; private static final int MIN_GPS_TIME = 10000; private final LocationManager locationManager; private final String name; Loading Loading @@ -76,6 +76,11 @@ public class RealLocationProvider { if (newLocation != null) lastLocation = newLocation; } public void invokeOnceReady(Runnable runnable) { // Always ready runnable.run(); } public Location getLastLocation() { if (!connected.get()) { updateLastLocation(); Loading