diff options
| -rwxr-xr-x | api/system-current.txt | 15 | ||||
| -rw-r--r-- | location/java/android/location/GnssRequest.aidl | 22 | ||||
| -rw-r--r-- | location/java/android/location/GnssRequest.java | 147 | ||||
| -rw-r--r-- | location/java/android/location/LocationManager.java | 24 |
4 files changed, 208 insertions, 0 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index f0a5b400a807..e5674dfda8a3 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3849,6 +3849,20 @@ package android.location { method @NonNull public android.location.GnssReflectingPlane.Builder setLongitudeDegrees(@FloatRange(from=-180.0F, to=180.0f) double); } + public final class GnssRequest implements android.os.Parcelable { + method public int describeContents(); + method public boolean isFullTracking(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.location.GnssRequest> CREATOR; + } + + public static final class GnssRequest.Builder { + ctor public GnssRequest.Builder(); + ctor public GnssRequest.Builder(@NonNull android.location.GnssRequest); + method @NonNull public android.location.GnssRequest build(); + method @NonNull public android.location.GnssRequest.Builder setFullTracking(boolean); + } + public final class GnssSingleSatCorrection implements android.os.Parcelable { method public int describeContents(); method @FloatRange(from=0.0f, fromInclusive=false) public float getCarrierFrequencyHz(); @@ -4122,6 +4136,7 @@ package android.location { method public boolean isProviderEnabledForUser(@NonNull String, @NonNull android.os.UserHandle); method @RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG) public boolean isProviderPackage(@NonNull String); method @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE) public boolean registerGnssBatchedLocationCallback(long, boolean, @NonNull android.location.BatchedLocationCallback, @Nullable android.os.Handler); + method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.LOCATION_HARDWARE}) public boolean registerGnssMeasurementsCallback(@NonNull android.location.GnssRequest, @NonNull java.util.concurrent.Executor, @NonNull android.location.GnssMeasurementsEvent.Callback); method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@Nullable android.location.LocationRequest, @NonNull android.location.LocationListener, @Nullable android.os.Looper); method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@Nullable android.location.LocationRequest, @NonNull java.util.concurrent.Executor, @NonNull android.location.LocationListener); method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@Nullable android.location.LocationRequest, @NonNull android.app.PendingIntent); diff --git a/location/java/android/location/GnssRequest.aidl b/location/java/android/location/GnssRequest.aidl new file mode 100644 index 000000000000..581abcce6651 --- /dev/null +++ b/location/java/android/location/GnssRequest.aidl @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2020, The Android Open Source Project + * + * 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 android.location; + +/** + * @hide + */ +parcelable GnssRequest; diff --git a/location/java/android/location/GnssRequest.java b/location/java/android/location/GnssRequest.java new file mode 100644 index 000000000000..2afb265f638c --- /dev/null +++ b/location/java/android/location/GnssRequest.java @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * 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 android.location; + +import android.annotation.NonNull; +import android.annotation.SystemApi; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * This class contains extra parameters to pass to a GNSS provider implementation. + * @hide + */ +@SystemApi +public final class GnssRequest implements Parcelable { + private final boolean mFullTracking; + + /** + * Creates a {@link GnssRequest} with a full list of parameters. + */ + private GnssRequest(boolean fullTracking) { + mFullTracking = fullTracking; + } + + /** + * Represents whether to enable full GNSS tracking. + * + * <p>If true, GNSS chipset switches off duty cycling. In such a mode, no clock + * discontinuities are expected, and when supported, carrier phase should be continuous in + * good signal conditions. All non-blacklisted, healthy constellations, satellites and + * frequency bands that the chipset supports must be reported in this mode. The GNSS chipset + * is allowed to consume more power in this mode. If false, GNSS chipset optimizes power via + * duty cycling, constellations and frequency limits, etc. + */ + public boolean isFullTracking() { + return mFullTracking; + } + + @NonNull + public static final Creator<GnssRequest> CREATOR = + new Creator<GnssRequest>() { + @Override + @NonNull + public GnssRequest createFromParcel(@NonNull Parcel parcel) { + return new GnssRequest(parcel.readBoolean()); + } + + @Override + public GnssRequest[] newArray(int i) { + return new GnssRequest[i]; + } + }; + + @NonNull + @Override + public String toString() { + StringBuilder s = new StringBuilder(); + s.append("GnssRequest["); + s.append("FullTracking=").append(mFullTracking); + s.append(']'); + return s.toString(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (!(obj instanceof GnssRequest)) return false; + + GnssRequest other = (GnssRequest) obj; + if (mFullTracking != other.mFullTracking) return false; + + return true; + } + + @Override + public int hashCode() { + return mFullTracking ? 1 : 0; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel parcel, int flags) { + parcel.writeBoolean(mFullTracking); + } + + /** Builder for {@link GnssRequest} */ + public static final class Builder { + private boolean mFullTracking; + + /** + * Constructs a {@link Builder} instance. + */ + public Builder() { + } + + /** + * Constructs a {@link Builder} instance by copying a {@link GnssRequest}. + */ + public Builder(@NonNull GnssRequest request) { + mFullTracking = request.isFullTracking(); + } + + /** + * Set the value of whether to enable full GNSS tracking, which is false by default. + * + * <p>If true, GNSS chipset switches off duty cycling. In such a mode, no clock + * discontinuities are expected, and when supported, carrier phase should be continuous in + * good signal conditions. All non-blacklisted, healthy constellations, satellites and + * frequency bands that the chipset supports must be reported in this mode. The GNSS chipset + * is allowed to consume more power in this mode. If false, GNSS chipset optimizes power via + * duty cycling, constellations and frequency limits, etc. + * + * <p>Full tracking requests always override non-full tracking requests. If any full + * tracking request occurs, all listeners on the device will receive full tracking GNSS + * measurements. + */ + @NonNull public Builder setFullTracking(boolean value) { + mFullTracking = value; + return this; + } + + /** Builds a {@link GnssRequest} instance as specified by this builder. */ + @NonNull + public GnssRequest build() { + return new GnssRequest(mFullTracking); + } + } +} diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 197787e5b6e6..b50f3c40b199 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -2162,6 +2162,30 @@ public class LocationManager { } /** + * Registers a GNSS Measurement callback. + * + * @param request extra parameters to pass to GNSS measurement provider. For example, if {@link + * GnssRequest#isFullTrackingEnabled()} is true, GNSS chipset switches off duty + * cycling. + * @param executor the executor that the callback runs on. + * @param callback a {@link GnssMeasurementsEvent.Callback} object to register. + * @return {@code true} if the callback was added successfully, {@code false} otherwise. + * @throws IllegalArgumentException if request is null + * @throws IllegalArgumentException if executor is null + * @throws IllegalArgumentException if callback is null + * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present + * @hide + */ + @SystemApi + @RequiresPermission(allOf = {ACCESS_FINE_LOCATION, LOCATION_HARDWARE}) + public boolean registerGnssMeasurementsCallback( + @NonNull GnssRequest request, + @NonNull @CallbackExecutor Executor executor, + @NonNull GnssMeasurementsEvent.Callback callback) { + throw new RuntimeException(); + } + + /** * Injects GNSS measurement corrections into the GNSS chipset. * * @param measurementCorrections a {@link GnssMeasurementCorrections} object with the GNSS |