summaryrefslogtreecommitdiff
path: root/location/java
diff options
context:
space:
mode:
author Soonil Nagarkar <sooniln@google.com> 2019-02-06 15:57:26 -0800
committer Soonil Nagarkar <sooniln@google.com> 2019-02-13 13:34:45 -0800
commit509580fbdfdbd6b1a129bd348d40f56b43a5a0f1 (patch)
tree8faba9fd22f8b711c1932fecc9a5fdaf95533b41 /location/java
parentd56355755b17db8a3c4ca58552747456671e32cc (diff)
Refactor API naming and add unbundled support
Rename APIs while there are no clients. Also prevent throttling when location settings are being ignored. Bug: 118883513 Test: manual Change-Id: I225c50b152e77ab181c959ecd9dc652333f59d5e
Diffstat (limited to 'location/java')
-rw-r--r--location/java/android/location/LocationRequest.java29
-rw-r--r--location/java/com/android/internal/location/ProviderRequest.java11
2 files changed, 23 insertions, 17 deletions
diff --git a/location/java/android/location/LocationRequest.java b/location/java/android/location/LocationRequest.java
index 0caa0c5b377a..b3953fddb622 100644
--- a/location/java/android/location/LocationRequest.java
+++ b/location/java/android/location/LocationRequest.java
@@ -184,8 +184,7 @@ public final class LocationRequest implements Parcelable {
* @return a new location request
*/
public static LocationRequest create() {
- LocationRequest request = new LocationRequest();
- return request;
+ return new LocationRequest();
}
/** @hide */
@@ -230,12 +229,10 @@ public final class LocationRequest implements Parcelable {
quality = ACCURACY_FINE;
break;
default: {
- switch (criteria.getPowerRequirement()) {
- case Criteria.POWER_HIGH:
- quality = POWER_HIGH;
- break;
- default:
- quality = POWER_LOW;
+ if (criteria.getPowerRequirement() == Criteria.POWER_HIGH) {
+ quality = POWER_HIGH;
+ } else {
+ quality = POWER_LOW;
}
}
}
@@ -288,7 +285,7 @@ public final class LocationRequest implements Parcelable {
*
* @param quality an accuracy or power constant
* @return the same object, so that setters can be chained
- * @throws InvalidArgumentException if the quality constant is not valid
+ * @throws IllegalArgumentException if the quality constant is not valid
*/
public LocationRequest setQuality(int quality) {
checkQuality(quality);
@@ -331,7 +328,7 @@ public final class LocationRequest implements Parcelable {
*
* @param millis desired interval in millisecond, inexact
* @return the same object, so that setters can be chained
- * @throws InvalidArgumentException if the interval is less than zero
+ * @throws IllegalArgumentException if the interval is less than zero
*/
public LocationRequest setInterval(long millis) {
checkInterval(millis);
@@ -433,7 +430,7 @@ public final class LocationRequest implements Parcelable {
*
* @param millis fastest interval for updates in milliseconds, exact
* @return the same object, so that setters can be chained
- * @throws InvalidArgumentException if the interval is less than zero
+ * @throws IllegalArgumentException if the interval is less than zero
*/
public LocationRequest setFastestInterval(long millis) {
checkInterval(millis);
@@ -528,7 +525,7 @@ public final class LocationRequest implements Parcelable {
*
* @param numUpdates the number of location updates requested
* @return the same object, so that setters can be chained
- * @throws InvalidArgumentException if numUpdates is 0 or less
+ * @throws IllegalArgumentException if numUpdates is 0 or less
*/
public LocationRequest setNumUpdates(int numUpdates) {
if (numUpdates <= 0) {
@@ -668,7 +665,7 @@ public final class LocationRequest implements Parcelable {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
private static void checkProvider(String name) {
if (name == null) {
- throw new IllegalArgumentException("invalid provider: " + name);
+ throw new IllegalArgumentException("invalid provider: null");
}
}
@@ -758,9 +755,11 @@ public final class LocationRequest implements Parcelable {
if (mNumUpdates != Integer.MAX_VALUE) {
s.append(" num=").append(mNumUpdates);
}
- s.append(" lowPowerMode=").append(mLowPowerMode);
+ if (mLowPowerMode) {
+ s.append(" lowPowerMode");
+ }
if (mLocationSettingsIgnored) {
- s.append(" ignoreSettings");
+ s.append(" locationSettingsIgnored");
}
s.append(']');
return s.toString();
diff --git a/location/java/com/android/internal/location/ProviderRequest.java b/location/java/com/android/internal/location/ProviderRequest.java
index a45c20d9d09d..af8123ac52f4 100644
--- a/location/java/com/android/internal/location/ProviderRequest.java
+++ b/location/java/com/android/internal/location/ProviderRequest.java
@@ -40,7 +40,7 @@ public final class ProviderRequest implements Parcelable {
* restrictions or any other restricting factors and always satisfy this request to the best of
* their ability. This flag should only be used in event of an emergency.
*/
- public boolean forceLocation = false;
+ public boolean locationSettingsIgnored = false;
/**
* Whether provider shall make stronger than normal tradeoffs to substantially restrict power
@@ -70,6 +70,7 @@ public final class ProviderRequest implements Parcelable {
request.reportLocation = in.readInt() == 1;
request.interval = in.readLong();
request.lowPowerMode = in.readBoolean();
+ request.locationSettingsIgnored = in.readBoolean();
int count = in.readInt();
for (int i = 0; i < count; i++) {
request.locationRequests.add(LocationRequest.CREATOR.createFromParcel(in));
@@ -93,6 +94,7 @@ public final class ProviderRequest implements Parcelable {
parcel.writeInt(reportLocation ? 1 : 0);
parcel.writeLong(interval);
parcel.writeBoolean(lowPowerMode);
+ parcel.writeBoolean(locationSettingsIgnored);
parcel.writeInt(locationRequests.size());
for (LocationRequest request : locationRequests) {
request.writeToParcel(parcel, flags);
@@ -107,7 +109,12 @@ public final class ProviderRequest implements Parcelable {
s.append("ON");
s.append(" interval=");
TimeUtils.formatDuration(interval, s);
- s.append(" lowPowerMode=" + lowPowerMode);
+ if (lowPowerMode) {
+ s.append(" lowPowerMode");
+ }
+ if (locationSettingsIgnored) {
+ s.append(" locationSettingsIgnored");
+ }
} else {
s.append("OFF");
}