From 4b4e173addb6d4490cf613ba63136fac3fea770a Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Sat, 14 Feb 2015 23:18:28 +0100 Subject: [PATCH] Fix usage of deprecated LocationClient --- GmsApi | 2 +- SafeParcel | 2 +- build.gradle | 2 +- .../android/gms/location/LocationClient.java | 36 +++++++++---------- src/org/microg/gms/common/GmsConnector.java | 5 +-- .../api/AbstractPlayServicesClient.java | 5 +++ .../gms/common/api/GoogleApiClientImpl.java | 2 +- .../FusedLocationProviderApiImpl.java | 4 +-- 8 files changed, 32 insertions(+), 26 deletions(-) diff --git a/GmsApi b/GmsApi index 19b0b0f1..3243e7d3 160000 --- a/GmsApi +++ b/GmsApi @@ -1 +1 @@ -Subproject commit 19b0b0f1d782640c0e5a9a381a0191665de0b053 +Subproject commit 3243e7d3ecf2f7ff92279b61c4a7e7831356f5c7 diff --git a/SafeParcel b/SafeParcel index 3efecf38..a650ca5b 160000 --- a/SafeParcel +++ b/SafeParcel @@ -1 +1 @@ -Subproject commit 3efecf38ca8b1f89cd8f0c40eea4b497f1563d90 +Subproject commit a650ca5beac2a374460d820935b40f9539e692db diff --git a/build.gradle b/build.gradle index b581ecdf..15771b0c 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:1.0.0' + classpath 'com.android.tools.build:gradle:1.0.1' } } diff --git a/src/com/google/android/gms/location/LocationClient.java b/src/com/google/android/gms/location/LocationClient.java index 04190cef..b9df6c40 100644 --- a/src/com/google/android/gms/location/LocationClient.java +++ b/src/com/google/android/gms/location/LocationClient.java @@ -35,45 +35,45 @@ public class LocationClient extends AbstractPlayServicesClient { return LocationServices.FusedLocationApi.getLastLocation(googleApiClient); } - public PendingResult requestLocationUpdates(LocationRequest request, + public void requestLocationUpdates(LocationRequest request, LocationListener listener) { assertConnected(); - return LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, - listener); + LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, + listener).await(); } - public PendingResult requestLocationUpdates(LocationRequest request, + public void requestLocationUpdates(LocationRequest request, LocationListener listener, Looper looper) { assertConnected(); - return LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, - listener, looper); + LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, + listener, looper).await(); } - public PendingResult requestLocationUpdates(LocationRequest request, + public void requestLocationUpdates(LocationRequest request, PendingIntent callbackIntent) { assertConnected(); - return LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, - callbackIntent); + LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, + callbackIntent).await(); } - public PendingResult removeLocationUpdates(LocationListener listener) { + public void removeLocationUpdates(LocationListener listener) { assertConnected(); - return LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, listener); + LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, listener).await(); } - public PendingResult removeLocationUpdates(PendingIntent callbackIntent) { + public void removeLocationUpdates(PendingIntent callbackIntent) { assertConnected(); - return LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, - callbackIntent); + LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, + callbackIntent).await(); } - public PendingResult setMockMode(boolean isMockMode) { + public void setMockMode(boolean isMockMode) { assertConnected(); - return LocationServices.FusedLocationApi.setMockMode(googleApiClient, isMockMode); + LocationServices.FusedLocationApi.setMockMode(googleApiClient, isMockMode).await(); } - public PendingResult setMockLocation(Location mockLocation) { + public void setMockLocation(Location mockLocation) { assertConnected(); - return LocationServices.FusedLocationApi.setMockLocation(googleApiClient, mockLocation); + LocationServices.FusedLocationApi.setMockLocation(googleApiClient, mockLocation).await(); } } diff --git a/src/org/microg/gms/common/GmsConnector.java b/src/org/microg/gms/common/GmsConnector.java index 90712d9a..3621f8ec 100644 --- a/src/org/microg/gms/common/GmsConnector.java +++ b/src/org/microg/gms/common/GmsConnector.java @@ -45,6 +45,7 @@ public class GmsConnector connect() { Log.d(TAG, "connect()"); + apiClient.getApiConnection(api); Looper looper = apiClient.getLooper(); final AbstractPendingResult result = new AbstractPendingResult<>(looper); Message msg = new Message(); @@ -67,8 +68,8 @@ public class GmsConnector result = (AbstractPendingResult) msg.obj; try { - result.deliverResult(callback.onClientAvailable((C) apiClient.getApiConnection - (api))); + C connection = (C)apiClient.getApiConnection(api); + result.deliverResult(callback.onClientAvailable(connection)); } catch (RemoteException ignored) { } diff --git a/src/org/microg/gms/common/api/AbstractPlayServicesClient.java b/src/org/microg/gms/common/api/AbstractPlayServicesClient.java index 0bd98141..50fd1bc3 100644 --- a/src/org/microg/gms/common/api/AbstractPlayServicesClient.java +++ b/src/org/microg/gms/common/api/AbstractPlayServicesClient.java @@ -16,6 +16,8 @@ package org.microg.gms.common.api; +import android.util.Log; + import com.google.android.gms.common.GooglePlayServicesClient; import com.google.android.gms.common.api.GoogleApiClient; @@ -23,6 +25,7 @@ import org.microg.gms.common.ForwardConnectionCallbacks; import org.microg.gms.common.ForwardConnectionFailedListener; public class AbstractPlayServicesClient implements GooglePlayServicesClient { + private static final String TAG = "GmsPlatServicesClient"; protected final GoogleApiClient googleApiClient; @@ -36,11 +39,13 @@ public class AbstractPlayServicesClient implements GooglePlayServicesClient { @Override public void connect() { + Log.d(TAG, "connect()"); googleApiClient.connect(); } @Override public void disconnect() { + Log.d(TAG, "disconnect()"); googleApiClient.disconnect(); } diff --git a/src/org/microg/gms/common/api/GoogleApiClientImpl.java b/src/org/microg/gms/common/api/GoogleApiClientImpl.java index 10878613..db0c707e 100644 --- a/src/org/microg/gms/common/api/GoogleApiClientImpl.java +++ b/src/org/microg/gms/common/api/GoogleApiClientImpl.java @@ -123,7 +123,7 @@ public class GoogleApiClientImpl implements GoogleApiClient { public synchronized void connect() { Log.d(TAG, "connect()"); if (isConnected() || isConnecting()) { - Log.d(TAG, "Already connected/connecting, noting to do"); + Log.d(TAG, "Already connected/connecting, nothing to do"); return; } for (ApiConnection connection : apiConnections.values()) { diff --git a/src/org/microg/gms/location/FusedLocationProviderApiImpl.java b/src/org/microg/gms/location/FusedLocationProviderApiImpl.java index be46f446..f89a79af 100644 --- a/src/org/microg/gms/location/FusedLocationProviderApiImpl.java +++ b/src/org/microg/gms/location/FusedLocationProviderApiImpl.java @@ -129,8 +129,8 @@ public class FusedLocationProviderApiImpl implements FusedLocationProviderApi { @Override public Result onClientAvailable(LocationClientImpl client) throws RemoteException { - runnable.run(client); - return Status.SUCCESS; + runnable.run(client); + return Status.SUCCESS; } }).connect(); }