summaryrefslogtreecommitdiff
path: root/location/java
diff options
context:
space:
mode:
authorBrian Orr <brianorr@google.com>2021-06-15 12:47:53 -0700
committerDaniel Norman <danielnorman@google.com>2021-06-17 13:37:54 -0700
commit71c831703ae59baf47e0afe611fecd714c481cdf (patch)
tree06731a987032723085b9e1a65951cf96abbc19cf /location/java
parent065c9e9a6e9d61d4383a91721eb56a3de253bdbe (diff)
parent81833820d54b9a6b27894f9f8dfd72222d416992 (diff)
Merge SP1A.210604.001
Change-Id: I5200ee05285ae422d5e9c1c00f45709a5d6188be
Diffstat (limited to 'location/java')
-rw-r--r--location/java/android/location/ILocationManager.aidl3
-rw-r--r--location/java/android/location/LocationDeviceConfig.java51
-rw-r--r--location/java/android/location/LocationManager.java15
-rw-r--r--location/java/android/location/SatellitePvt.java109
4 files changed, 154 insertions, 24 deletions
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl
index 6fa6536997c4..c9e4e0a9cb92 100644
--- a/location/java/android/location/ILocationManager.aidl
+++ b/location/java/android/location/ILocationManager.aidl
@@ -41,6 +41,7 @@ import android.location.provider.IProviderRequestListener;
import android.location.provider.ProviderProperties;
import android.os.Bundle;
import android.os.ICancellationSignal;
+import android.os.PackageTagsList;
/**
* System private API for talking with the location service.
@@ -133,5 +134,5 @@ interface ILocationManager
// used by gts tests to verify whitelists
String[] getBackgroundThrottlingWhitelist();
- String[] getIgnoreSettingsWhitelist();
+ PackageTagsList getIgnoreSettingsAllowlist();
}
diff --git a/location/java/android/location/LocationDeviceConfig.java b/location/java/android/location/LocationDeviceConfig.java
new file mode 100644
index 000000000000..c55eed9211f7
--- /dev/null
+++ b/location/java/android/location/LocationDeviceConfig.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2021 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;
+
+/**
+ * DeviceConfig keys within the location namespace.
+ *
+ * @hide
+ */
+public final class LocationDeviceConfig {
+
+ /**
+ * Package/tag combinations that are allowedlisted for ignoring location settings (may retrieve
+ * location even when user location settings are off, and may ignore throttling, etc), for
+ * emergency purposes only.
+ *
+ * <p>Package/tag combinations are separated by commas (","), and with in each combination is a
+ * package name followed by 0 or more attribution tags, separated by semicolons (";"). If a
+ * package is followed by 0 attribution tags, this is interpreted the same as the wildcard
+ * value. There are two special interpreted values for attribution tags, the wildcard value
+ * ("*") which represents all attribution tags, and the null value ("null"), which is converted
+ * to the null string (since attribution tags may be null). This format implies that attribution
+ * tags which should be on this list may not contain semicolons.
+ *
+ * <p>Examples of valid entries:
+ *
+ * <ul>
+ * <li>android</li>
+ * <li>android;*</li>
+ * <li>android;*,com.example.app;null;my_attr</li>
+ * <li>android;*,com.example.app;null;my_attr,com.example.otherapp;my_attr</li>
+ * </ul>
+ */
+ public static final String IGNORE_SETTINGS_ALLOWLIST = "ignore_settings_allowlist";
+
+ private LocationDeviceConfig() {}
+}
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index bb7dbf4931a7..4853664d08a5 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -58,6 +58,7 @@ import android.os.HandlerExecutor;
import android.os.ICancellationSignal;
import android.os.IRemoteCallback;
import android.os.Looper;
+import android.os.PackageTagsList;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -447,12 +448,23 @@ public class LocationManager {
}
/**
+ * @deprecated Do not use.
* @hide
*/
+ @Deprecated
@TestApi
public @NonNull String[] getIgnoreSettingsWhitelist() {
+ return new String[0];
+ }
+
+ /**
+ * For testing purposes only.
+ * @hide
+ */
+ @TestApi
+ public @NonNull PackageTagsList getIgnoreSettingsAllowlist() {
try {
- return mService.getIgnoreSettingsWhitelist();
+ return mService.getIgnoreSettingsAllowlist();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -1826,6 +1838,7 @@ public class LocationManager {
* @deprecated Use {@link #isProviderPackage(String, String, String)} instead.
*
* @hide
+ * @removed
*/
@Deprecated
@SystemApi
diff --git a/location/java/android/location/SatellitePvt.java b/location/java/android/location/SatellitePvt.java
index 1456f74ef6d4..794a8d0731f9 100644
--- a/location/java/android/location/SatellitePvt.java
+++ b/location/java/android/location/SatellitePvt.java
@@ -45,8 +45,41 @@ import android.os.Parcelable;
*/
@SystemApi
public final class SatellitePvt implements Parcelable {
+ /**
+ * Bit mask for {@link #mFlags} indicating valid satellite position, velocity and clock info
+ * fields are stored in the SatellitePvt.
+ */
+ private static final int HAS_POSITION_VELOCITY_CLOCK_INFO = 1 << 0;
+
+ /**
+ * Bit mask for {@link #mFlags} indicating a valid iono delay field is stored in the
+ * SatellitePvt.
+ */
+ private static final int HAS_IONO = 1 << 1;
+
+ /**
+ * Bit mask for {@link #mFlags} indicating a valid tropo delay field is stored in the
+ * SatellitePvt.
+ */
+ private static final int HAS_TROPO = 1 << 2;
+
+ /**
+ * A bitfield of flags indicating the validity of the fields in this SatellitePvt.
+ * The bit masks are defined in the constants with prefix HAS_*
+ *
+ * <p>Fields for which there is no corresponding flag must be filled in with a valid value.
+ * For convenience, these are marked as mandatory.
+ *
+ * <p>Others fields may have invalid information in them, if not marked as valid by the
+ * corresponding bit in flags.
+ */
+ private final int mFlags;
+
+ @Nullable
private final PositionEcef mPositionEcef;
+ @Nullable
private final VelocityEcef mVelocityEcef;
+ @Nullable
private final ClockInfo mClockInfo;
private final double mIonoDelayMeters;
private final double mTropoDelayMeters;
@@ -351,20 +384,13 @@ public final class SatellitePvt implements Parcelable {
}
private SatellitePvt(
- @NonNull PositionEcef positionEcef,
- @NonNull VelocityEcef velocityEcef,
- @NonNull ClockInfo clockInfo,
+ int flags,
+ @Nullable PositionEcef positionEcef,
+ @Nullable VelocityEcef velocityEcef,
+ @Nullable ClockInfo clockInfo,
double ionoDelayMeters,
double tropoDelayMeters) {
- if (positionEcef == null) {
- throw new IllegalArgumentException("Position Ecef cannot be null.");
- }
- if (velocityEcef == null) {
- throw new IllegalArgumentException("Velocity Ecef cannot be null.");
- }
- if (clockInfo == null) {
- throw new IllegalArgumentException("Clock Info cannot be null.");
- }
+ mFlags = flags;
mPositionEcef = positionEcef;
mVelocityEcef = velocityEcef;
mClockInfo = clockInfo;
@@ -376,7 +402,7 @@ public final class SatellitePvt implements Parcelable {
* Returns a {@link PositionEcef} object that contains estimates of the satellite
* position fields in ECEF coordinate frame.
*/
- @NonNull
+ @Nullable
public PositionEcef getPositionEcef() {
return mPositionEcef;
}
@@ -385,7 +411,7 @@ public final class SatellitePvt implements Parcelable {
* Returns a {@link VelocityEcef} object that contains estimates of the satellite
* velocity fields in the ECEF coordinate frame.
*/
- @NonNull
+ @Nullable
public VelocityEcef getVelocityEcef() {
return mVelocityEcef;
}
@@ -394,7 +420,7 @@ public final class SatellitePvt implements Parcelable {
* Returns a {@link ClockInfo} object that contains estimates of the satellite
* clock info.
*/
- @NonNull
+ @Nullable
public ClockInfo getClockInfo() {
return mClockInfo;
}
@@ -415,11 +441,29 @@ public final class SatellitePvt implements Parcelable {
return mTropoDelayMeters;
}
+ /** Returns {@code true} if {@link #getPositionEcef()}, {@link #getVelocityEcef()},
+ * and {@link #getClockInfo()} are valid.
+ */
+ public boolean hasPositionVelocityClockInfo() {
+ return (mFlags & HAS_POSITION_VELOCITY_CLOCK_INFO) != 0;
+ }
+
+ /** Returns {@code true} if {@link #getIonoDelayMeters()} is valid. */
+ public boolean hasIono() {
+ return (mFlags & HAS_IONO) != 0;
+ }
+
+ /** Returns {@code true} if {@link #getTropoDelayMeters()} is valid. */
+ public boolean hasTropo() {
+ return (mFlags & HAS_TROPO) != 0;
+ }
+
public static final @android.annotation.NonNull Creator<SatellitePvt> CREATOR =
new Creator<SatellitePvt>() {
@Override
@Nullable
public SatellitePvt createFromParcel(Parcel in) {
+ int flags = in.readInt();
ClassLoader classLoader = getClass().getClassLoader();
PositionEcef positionEcef = in.readParcelable(classLoader);
VelocityEcef velocityEcef = in.readParcelable(classLoader);
@@ -428,6 +472,7 @@ public final class SatellitePvt implements Parcelable {
double tropoDelayMeters = in.readDouble();
return new SatellitePvt(
+ flags,
positionEcef,
velocityEcef,
clockInfo,
@@ -448,6 +493,7 @@ public final class SatellitePvt implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel parcel, int flags) {
+ parcel.writeInt(mFlags);
parcel.writeParcelable(mPositionEcef, flags);
parcel.writeParcelable(mVelocityEcef, flags);
parcel.writeParcelable(mClockInfo, flags);
@@ -458,7 +504,8 @@ public final class SatellitePvt implements Parcelable {
@Override
public String toString() {
return "SatellitePvt{"
- + "PositionEcef=" + mPositionEcef
+ + "Flags=" + mFlags
+ + ", PositionEcef=" + mPositionEcef
+ ", VelocityEcef=" + mVelocityEcef
+ ", ClockInfo=" + mClockInfo
+ ", IonoDelayMeters=" + mIonoDelayMeters
@@ -470,9 +517,14 @@ public final class SatellitePvt implements Parcelable {
* Builder class for SatellitePvt.
*/
public static final class Builder {
- private PositionEcef mPositionEcef;
- private VelocityEcef mVelocityEcef;
- private ClockInfo mClockInfo;
+ /**
+ * For documentation of below fields, see corresponding fields in {@link
+ * SatellitePvt}.
+ */
+ private int mFlags;
+ @Nullable private PositionEcef mPositionEcef;
+ @Nullable private VelocityEcef mVelocityEcef;
+ @Nullable private ClockInfo mClockInfo;
private double mIonoDelayMeters;
private double mTropoDelayMeters;
@@ -486,6 +538,7 @@ public final class SatellitePvt implements Parcelable {
public Builder setPositionEcef(
@NonNull PositionEcef positionEcef) {
mPositionEcef = positionEcef;
+ updateFlags();
return this;
}
@@ -499,6 +552,7 @@ public final class SatellitePvt implements Parcelable {
public Builder setVelocityEcef(
@NonNull VelocityEcef velocityEcef) {
mVelocityEcef = velocityEcef;
+ updateFlags();
return this;
}
@@ -512,9 +566,16 @@ public final class SatellitePvt implements Parcelable {
public Builder setClockInfo(
@NonNull ClockInfo clockInfo) {
mClockInfo = clockInfo;
+ updateFlags();
return this;
}
+ private void updateFlags() {
+ if (mPositionEcef != null && mVelocityEcef != null && mClockInfo != null) {
+ mFlags = (byte) (mFlags | HAS_POSITION_VELOCITY_CLOCK_INFO);
+ }
+ }
+
/**
* Set ionospheric delay in meters.
*
@@ -522,8 +583,10 @@ public final class SatellitePvt implements Parcelable {
* @return Builder builder object
*/
@NonNull
- public Builder setIonoDelayMeters(@FloatRange() double ionoDelayMeters) {
+ public Builder setIonoDelayMeters(
+ @FloatRange(from = 0.0f, to = 100.0f) double ionoDelayMeters) {
mIonoDelayMeters = ionoDelayMeters;
+ mFlags = (byte) (mFlags | HAS_IONO);
return this;
}
@@ -534,8 +597,10 @@ public final class SatellitePvt implements Parcelable {
* @return Builder builder object
*/
@NonNull
- public Builder setTropoDelayMeters(@FloatRange() double tropoDelayMeters) {
+ public Builder setTropoDelayMeters(
+ @FloatRange(from = 0.0f, to = 100.0f) double tropoDelayMeters) {
mTropoDelayMeters = tropoDelayMeters;
+ mFlags = (byte) (mFlags | HAS_TROPO);
return this;
}
@@ -546,7 +611,7 @@ public final class SatellitePvt implements Parcelable {
*/
@NonNull
public SatellitePvt build() {
- return new SatellitePvt(mPositionEcef, mVelocityEcef, mClockInfo,
+ return new SatellitePvt(mFlags, mPositionEcef, mVelocityEcef, mClockInfo,
mIonoDelayMeters, mTropoDelayMeters);
}
}