summaryrefslogtreecommitdiff
path: root/location
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-02-08 00:44:36 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-02-08 00:44:36 +0000
commitb146099bc5a9bdbdafd2b75fdbdc0bb1f4e3ef4e (patch)
treeee0ed6d94ff8000471e8e2ffa535104fb516f56c /location
parentc90bb01e0eb405b07227084cdfa3e1e603a890d7 (diff)
parentf5365989ff6f98a2014dee47a1b4acf8c042b87f (diff)
Merge "Add enableFullTracking to registerGnssMeasurementsCallback"
Diffstat (limited to 'location')
-rw-r--r--location/java/android/location/GnssRequest.aidl22
-rw-r--r--location/java/android/location/GnssRequest.java147
-rw-r--r--location/java/android/location/LocationManager.java24
3 files changed, 193 insertions, 0 deletions
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 1c10edb11293..7e6486cc933e 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -2196,6 +2196,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