From f70578f78b3667d57d6168f4c0b1ebea29e84ad6 Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Mon, 2 Feb 2015 00:03:48 +0100 Subject: [PATCH] Fix async issues --- GmsApi | 2 +- .../android/gms/common/GooglePlayServicesUtil.java | 4 ++-- src/com/google/android/gms/common/api/Api.java | 2 +- .../android/gms/common/api/GoogleApiClient.java | 4 ++-- .../gms/location/FusedLocationProviderApi.java | 2 +- .../microg/gms/common/MultiConnectionKeeper.java | 13 +++++++++---- .../gms/location/GoogleLocationManagerClient.java | 2 +- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/GmsApi b/GmsApi index 3c19d84..5d2364f 160000 --- a/GmsApi +++ b/GmsApi @@ -1 +1 @@ -Subproject commit 3c19d84eaa9842a2526166a38ad445125dbd2300 +Subproject commit 5d2364f3dcc66bdd1ae19c91d76d77d2a4a785b6 diff --git a/src/com/google/android/gms/common/GooglePlayServicesUtil.java b/src/com/google/android/gms/common/GooglePlayServicesUtil.java index 6da29c4..01499ae 100644 --- a/src/com/google/android/gms/common/GooglePlayServicesUtil.java +++ b/src/com/google/android/gms/common/GooglePlayServicesUtil.java @@ -9,8 +9,8 @@ import android.content.DialogInterface; import android.content.pm.PackageManager; import android.util.Log; -import org.microg.gms.Constants; -import org.microg.gms.PublicApi; +import org.microg.gms.common.Constants; +import org.microg.gms.common.PublicApi; /** * Utility class for verifying that the Google Play services APK is available and up-to-date on diff --git a/src/com/google/android/gms/common/api/Api.java b/src/com/google/android/gms/common/api/Api.java index 3e5482a..60ab9a3 100644 --- a/src/com/google/android/gms/common/api/Api.java +++ b/src/com/google/android/gms/common/api/Api.java @@ -1,6 +1,6 @@ package com.google.android.gms.common.api; -import org.microg.gms.PublicApi; +import org.microg.gms.common.PublicApi; import org.microg.gms.common.api.ApiBuilder; /** diff --git a/src/com/google/android/gms/common/api/GoogleApiClient.java b/src/com/google/android/gms/common/api/GoogleApiClient.java index 672a1a7..e44f988 100644 --- a/src/com/google/android/gms/common/api/GoogleApiClient.java +++ b/src/com/google/android/gms/common/api/GoogleApiClient.java @@ -10,8 +10,8 @@ import android.view.View; import com.google.android.gms.common.ConnectionResult; -import org.microg.gms.Constants; -import org.microg.gms.PublicApi; +import org.microg.gms.common.Constants; +import org.microg.gms.common.PublicApi; import org.microg.gms.common.api.GoogleApiClientImpl; import java.util.HashMap; diff --git a/src/com/google/android/gms/location/FusedLocationProviderApi.java b/src/com/google/android/gms/location/FusedLocationProviderApi.java index 46a9106..8c48453 100644 --- a/src/com/google/android/gms/location/FusedLocationProviderApi.java +++ b/src/com/google/android/gms/location/FusedLocationProviderApi.java @@ -7,7 +7,7 @@ import android.os.Looper; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.PendingResult; -import org.microg.gms.Constants; +import org.microg.gms.common.Constants; public interface FusedLocationProviderApi { public static final String KEY_LOCATION_CHANGED = "com.google.android.location.LOCATION"; diff --git a/src/org/microg/gms/common/MultiConnectionKeeper.java b/src/org/microg/gms/common/MultiConnectionKeeper.java index bb454e5..84ce091 100644 --- a/src/org/microg/gms/common/MultiConnectionKeeper.java +++ b/src/org/microg/gms/common/MultiConnectionKeeper.java @@ -28,7 +28,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import static org.microg.gms.Constants.GMS_PACKAGE_NAME; +import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME; public class MultiConnectionKeeper { private static final String TAG = "GmsMultiConnectionKeeper"; @@ -48,7 +48,7 @@ public class MultiConnectionKeeper { return INSTANCE; } - public boolean bind(String action, ServiceConnection connection) { + public synchronized boolean bind(String action, ServiceConnection connection) { Log.d(TAG, "bind(" + action + ", " + connection + ")"); Connection con = connections.get(action); if (con != null) { @@ -66,7 +66,7 @@ public class MultiConnectionKeeper { return con.isBound(); } - public void unbind(String action, ServiceConnection connection) { + public synchronized void unbind(String action, ServiceConnection connection) { Log.d(TAG, "unbind(" + action + ", " + connection + ")"); Connection con = connections.get(action); if (con != null) { @@ -108,6 +108,7 @@ public class MultiConnectionKeeper { connection.onServiceDisconnected(componentName); } connected = false; + bound = false; } }; @@ -135,7 +136,11 @@ public class MultiConnectionKeeper { public void unbind() { Log.d(TAG, "Connection(" + actionString + ") : unbind()"); - context.unbindService(serviceConnection); + try { + context.unbindService(serviceConnection); + } catch (IllegalArgumentException e) { // not bound (whatever reason) + Log.w(TAG, e); + } bound = false; } diff --git a/src/org/microg/gms/location/GoogleLocationManagerClient.java b/src/org/microg/gms/location/GoogleLocationManagerClient.java index cbc24b2..8da05e6 100644 --- a/src/org/microg/gms/location/GoogleLocationManagerClient.java +++ b/src/org/microg/gms/location/GoogleLocationManagerClient.java @@ -25,7 +25,7 @@ import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.internal.IGmsServiceBroker; import com.google.android.gms.location.internal.IGoogleLocationManagerService; -import org.microg.gms.Constants; +import org.microg.gms.common.Constants; import org.microg.gms.common.GmsClient; public abstract class GoogleLocationManagerClient extends GmsClient {