From 6f5bf2335138fda80460d906d1f2ec3d6ddfaec5 Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Sun, 4 Oct 2015 04:40:58 +0200 Subject: [PATCH] Enhance Location API --- .../gms/location/LocationSettingsResult.aidl | 3 + .../IGoogleLocationManagerService.aidl | 4 +- .../location/internal/ISettingsCallback.aidl | 5 - .../location/internal/ISettingsCallbacks.aidl | 7 ++ .../gms/location/LocationSettingsRequest.java | 19 ++++ .../gms/location/LocationSettingsResult.java | 60 ++++++++++++ .../gms/location/LocationSettingsStates.java | 92 +++++++++++++++++++ 7 files changed, 183 insertions(+), 7 deletions(-) create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/location/LocationSettingsResult.aidl delete mode 100644 play-services-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallback.aidl create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallbacks.aidl create mode 100644 play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsResult.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsStates.java diff --git a/play-services-api/src/main/aidl/com/google/android/gms/location/LocationSettingsResult.aidl b/play-services-api/src/main/aidl/com/google/android/gms/location/LocationSettingsResult.aidl new file mode 100644 index 00000000..54dad656 --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/location/LocationSettingsResult.aidl @@ -0,0 +1,3 @@ +package com.google.android.gms.location; + +parcelable LocationSettingsResult; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/location/internal/IGoogleLocationManagerService.aidl b/play-services-api/src/main/aidl/com/google/android/gms/location/internal/IGoogleLocationManagerService.aidl index be26aeac..40937c80 100644 --- a/play-services-api/src/main/aidl/com/google/android/gms/location/internal/IGoogleLocationManagerService.aidl +++ b/play-services-api/src/main/aidl/com/google/android/gms/location/internal/IGoogleLocationManagerService.aidl @@ -7,7 +7,7 @@ import android.os.Bundle; import com.google.android.gms.common.api.Status; import com.google.android.gms.location.places.AutocompleteFilter; import com.google.android.gms.location.places.internal.IPlacesCallbacks; -import com.google.android.gms.location.internal.ISettingsCallback; +import com.google.android.gms.location.internal.ISettingsCallbacks; import com.google.android.gms.location.internal.LocationRequestInternal; import com.google.android.gms.location.internal.LocationRequestUpdateData; import com.google.android.gms.location.places.NearbyAlertRequest; @@ -64,7 +64,7 @@ interface IGoogleLocationManagerService { LocationAvailability iglms34(String var1) = 33; IBinder iglms51() = 50; - void iglms63(in LocationSettingsRequest settingsRequest, ISettingsCallback callback, String packageName) = 62; + void requestLocationSettingsDialog(in LocationSettingsRequest settingsRequest, ISettingsCallbacks callback, String packageName) = 62; void iglms14(in LatLngBounds var1, int var2, in PlaceFilter var3, in PlacesParams var4, IPlacesCallbacks var5) = 13; void iglms15(String var1, in PlacesParams var2, IPlacesCallbacks var3) = 14; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallback.aidl b/play-services-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallback.aidl deleted file mode 100644 index f1ec017e..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallback.aidl +++ /dev/null @@ -1,5 +0,0 @@ -package com.google.android.gms.location.internal; - -interface ISettingsCallback { - // TODO -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallbacks.aidl b/play-services-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallbacks.aidl new file mode 100644 index 00000000..f710d11f --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallbacks.aidl @@ -0,0 +1,7 @@ +package com.google.android.gms.location.internal; + +import com.google.android.gms.location.LocationSettingsResult; + +interface ISettingsCallbacks { + void onLocationSettingsResult(in LocationSettingsResult result); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsRequest.java b/play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsRequest.java index cd52b8fa..3d5aa5a9 100644 --- a/play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsRequest.java +++ b/play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsRequest.java @@ -16,8 +16,27 @@ package com.google.android.gms.location; +import org.microg.gms.common.PublicApi; import org.microg.safeparcel.AutoSafeParcelable; +import org.microg.safeparcel.SafeParceled; +import java.util.List; + +@PublicApi public class LocationSettingsRequest extends AutoSafeParcelable { + @SafeParceled(1000) + private int versionCode = 2; + + @SafeParceled(value = 1, subClass = LocationRequest.class) + @PublicApi(exclude = true) + public List requests; + + @SafeParceled(2) + @PublicApi(exclude = true) + public boolean alwaysShow; + + @PublicApi(exclude = true) + public boolean needBle; + public static final Creator CREATOR = new AutoCreator(LocationSettingsRequest.class); } diff --git a/play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsResult.java b/play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsResult.java new file mode 100644 index 00000000..1ca160ea --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsResult.java @@ -0,0 +1,60 @@ +/* + * Copyright 2013-2015 microG Project Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.gms.location; + +import com.google.android.gms.common.api.Result; +import com.google.android.gms.common.api.Status; + +import org.microg.gms.common.PublicApi; +import org.microg.safeparcel.AutoSafeParcelable; +import org.microg.safeparcel.SafeParceled; + +@PublicApi +public class LocationSettingsResult extends AutoSafeParcelable implements Result { + + @SafeParceled(1000) + private int versionCode = 1; + + @SafeParceled(1) + private Status status; + + @SafeParceled(2) + private LocationSettingsStates settings; + + + public LocationSettingsStates getLocationSettingsStates() { + return settings; + } + + @Override + public Status getStatus() { + return status; + } + + @PublicApi(exclude = true) + public LocationSettingsResult(LocationSettingsStates settings, Status status) { + this.settings = settings; + this.status = status; + } + + @PublicApi(exclude = true) + public LocationSettingsResult(Status status) { + this.status = status; + } + + public static final Creator CREATOR = new AutoCreator(LocationSettingsResult.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsStates.java b/play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsStates.java new file mode 100644 index 00000000..c11d815b --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/location/LocationSettingsStates.java @@ -0,0 +1,92 @@ +/* + * Copyright 2013-2015 microG Project Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.gms.location; + +import org.microg.gms.common.PublicApi; +import org.microg.safeparcel.AutoSafeParcelable; +import org.microg.safeparcel.SafeParceled; + +@PublicApi +public class LocationSettingsStates extends AutoSafeParcelable { + + @SafeParceled(1000) + private int versionCode = 2; + + @SafeParceled(1) + private boolean gpsUsable; + + @SafeParceled(2) + private boolean networkLocationUsable; + + @SafeParceled(3) + private boolean bleUsable; + + @SafeParceled(4) + private boolean gpsPresent; + + @SafeParceled(5) + private boolean networkLocationPresent; + + @SafeParceled(6) + private boolean blePresent; + + public boolean isBlePresent() { + return blePresent; + } + + public boolean isBleUsable() { + return bleUsable; + } + + public boolean isGpsPresent() { + return gpsPresent; + } + + public boolean isGpsUsable() { + return gpsUsable; + } + + public boolean isLocationPresent() { + return isGpsPresent() || isNetworkLocationPresent(); + } + + public boolean isLocationUsable() { + return isGpsUsable() || isNetworkLocationUsable(); + } + + public boolean isNetworkLocationPresent() { + return networkLocationPresent; + } + + public boolean isNetworkLocationUsable() { + return networkLocationUsable; + } + + public LocationSettingsStates(boolean gpsUsable, boolean networkLocationUsable, boolean bleUsable, boolean gpsPresent, boolean networkLocationPresent, boolean blePresent) { + this.gpsUsable = gpsUsable; + this.networkLocationUsable = networkLocationUsable; + this.bleUsable = bleUsable; + this.gpsPresent = gpsPresent; + this.networkLocationPresent = networkLocationPresent; + this.blePresent = blePresent; + } + + @PublicApi(exclude = true) + + + public static final Creator CREATOR = new AutoCreator(LocationSettingsStates.class); +}