diff options
author | Soonil Nagarkar <sooniln@google.com> | 2020-01-21 15:16:51 -0800 |
---|---|---|
committer | Soonil Nagarkar <sooniln@google.com> | 2020-01-22 17:22:54 +0000 |
commit | 4c0b85ba06b81206cdaa9d44e6d38f5ed61081d5 (patch) | |
tree | 8c682f8acad769b1b9303d877100f4eda4f2a835 /location | |
parent | b1f8ccfb122bca5931aa0e1fdfb775f5d75fd225 (diff) |
Overhaul FusedLocationProvider
Fix some minor bugs and ensure fused location provider correctly
supports location bypass. This is especially important for when
location bypass is invoked in direct boot.
The added UPDATE_DEVICE_STATS permission is necessary for FusedLocation
to correctly update WorkSources. FusedLocation receives work from LMS and
then further delegates that work to other location providers. The other
location providers should be informed of the correct applications for
battery blame, and should not be blaming the FusedLocation package.
1) This is the minimally scoped permission necessary to battery blame
correctly.
2) There is no way to attribute battery blame without this permission.
3) This is the correct permission - as required by LocationManager, and
this permission will likely never be removed (FusedLocation will always
need to battery blame).
Test: atest FusedLocationTests
Change-Id: If7126fffaae5577ddf8e366a0b5c17b3e5286582
Diffstat (limited to 'location')
-rw-r--r-- | location/java/com/android/internal/location/ProviderRequest.java | 31 | ||||
-rw-r--r-- | location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java | 1 |
2 files changed, 21 insertions, 11 deletions
diff --git a/location/java/com/android/internal/location/ProviderRequest.java b/location/java/com/android/internal/location/ProviderRequest.java index 8d8df4533ebe..b2314c585e6e 100644 --- a/location/java/com/android/internal/location/ProviderRequest.java +++ b/location/java/com/android/internal/location/ProviderRequest.java @@ -23,11 +23,10 @@ import android.os.Parcelable; import android.os.WorkSource; import android.util.TimeUtils; -import com.android.internal.util.Preconditions; - import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; /** @hide */ public final class ProviderRequest implements Parcelable { @@ -76,8 +75,8 @@ public final class ProviderRequest implements Parcelable { this.interval = interval; this.lowPowerMode = lowPowerMode; this.locationSettingsIgnored = locationSettingsIgnored; - this.locationRequests = Preconditions.checkNotNull(locationRequests); - this.workSource = Preconditions.checkNotNull(workSource); + this.locationRequests = Objects.requireNonNull(locationRequests); + this.workSource = Objects.requireNonNull(workSource); } public static final Parcelable.Creator<ProviderRequest> CREATOR = @@ -155,40 +154,50 @@ public final class ProviderRequest implements Parcelable { return mInterval; } - public void setInterval(long interval) { + /** Sets the request interval. */ + public Builder setInterval(long interval) { this.mInterval = interval; + return this; } public boolean isLowPowerMode() { return mLowPowerMode; } - public void setLowPowerMode(boolean lowPowerMode) { + /** Sets whether low power mode is enabled. */ + public Builder setLowPowerMode(boolean lowPowerMode) { this.mLowPowerMode = lowPowerMode; + return this; } public boolean isLocationSettingsIgnored() { return mLocationSettingsIgnored; } - public void setLocationSettingsIgnored(boolean locationSettingsIgnored) { + /** Sets whether location settings should be ignored. */ + public Builder setLocationSettingsIgnored(boolean locationSettingsIgnored) { this.mLocationSettingsIgnored = locationSettingsIgnored; + return this; } public List<LocationRequest> getLocationRequests() { return mLocationRequests; } - public void setLocationRequests(List<LocationRequest> locationRequests) { - this.mLocationRequests = Preconditions.checkNotNull(locationRequests); + /** Sets the {@link LocationRequest}s associated with this request. */ + public Builder setLocationRequests(List<LocationRequest> locationRequests) { + this.mLocationRequests = Objects.requireNonNull(locationRequests); + return this; } public WorkSource getWorkSource() { return mWorkSource; } - public void setWorkSource(WorkSource workSource) { - mWorkSource = Preconditions.checkNotNull(workSource); + /** Sets the work source. */ + public Builder setWorkSource(WorkSource workSource) { + mWorkSource = Objects.requireNonNull(workSource); + return this; } /** diff --git a/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java b/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java index d12d6b777856..b650efc91907 100644 --- a/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java +++ b/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java @@ -34,6 +34,7 @@ import java.util.List; * of this package for more information. */ public final class ProviderRequestUnbundled { + private final ProviderRequest mRequest; /** @hide */ |