Loading location/java/android/location/flags/location.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -187,6 +187,16 @@ flag { is_fixed_read_only: true } flag { name: "limit_fused_gps" namespace: "location" description: "Limits when GPS can be used for fused location requests" bug: "401885179" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "gnss_assistance_interface_jni" namespace: "location" Loading packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java +11 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.location.fused; import static android.content.Intent.ACTION_USER_SWITCHED; import static android.location.LocationManager.GPS_PROVIDER; import static android.location.LocationManager.NETWORK_PROVIDER; import static android.location.LocationRequest.QUALITY_HIGH_ACCURACY; import static android.location.LocationRequest.QUALITY_LOW_POWER; import static android.location.provider.ProviderProperties.ACCURACY_FINE; import static android.location.provider.ProviderProperties.POWER_USAGE_LOW; Loading @@ -34,6 +35,7 @@ import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationRequest; import android.location.flags.Flags; import android.location.provider.LocationProviderBase; import android.location.provider.ProviderProperties; import android.location.provider.ProviderRequest; Loading Loading @@ -61,6 +63,9 @@ public class FusedLocationProvider extends LocationProviderBase { .build(); private static final long MAX_LOCATION_COMPARISON_NS = 11 * 1000000000L; // 11 seconds // Maximum request interval at which we will activate GPS (because GPS sometimes consumes // excessive power with large intervals). private static final long MAX_GPS_INTERVAL_MS = 5 * 1000; // 5 seconds private final Object mLock = new Object(); Loading Loading @@ -165,8 +170,13 @@ public class FusedLocationProvider extends LocationProviderBase { mNlpPresent = mLocationManager.hasProvider(NETWORK_PROVIDER); } boolean requestAllowsGps = Flags.limitFusedGps() ? mRequest.getQuality() == QUALITY_HIGH_ACCURACY && mRequest.getIntervalMillis() <= MAX_GPS_INTERVAL_MS : !mNlpPresent || mRequest.getQuality() < QUALITY_LOW_POWER; long gpsInterval = mGpsPresent && (!mNlpPresent || mRequest.getQuality() < QUALITY_LOW_POWER) mGpsPresent && requestAllowsGps ? mRequest.getIntervalMillis() : INTERVAL_DISABLED; long networkInterval = mNlpPresent ? mRequest.getIntervalMillis() : INTERVAL_DISABLED; Loading Loading
location/java/android/location/flags/location.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -187,6 +187,16 @@ flag { is_fixed_read_only: true } flag { name: "limit_fused_gps" namespace: "location" description: "Limits when GPS can be used for fused location requests" bug: "401885179" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "gnss_assistance_interface_jni" namespace: "location" Loading
packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java +11 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.location.fused; import static android.content.Intent.ACTION_USER_SWITCHED; import static android.location.LocationManager.GPS_PROVIDER; import static android.location.LocationManager.NETWORK_PROVIDER; import static android.location.LocationRequest.QUALITY_HIGH_ACCURACY; import static android.location.LocationRequest.QUALITY_LOW_POWER; import static android.location.provider.ProviderProperties.ACCURACY_FINE; import static android.location.provider.ProviderProperties.POWER_USAGE_LOW; Loading @@ -34,6 +35,7 @@ import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationRequest; import android.location.flags.Flags; import android.location.provider.LocationProviderBase; import android.location.provider.ProviderProperties; import android.location.provider.ProviderRequest; Loading Loading @@ -61,6 +63,9 @@ public class FusedLocationProvider extends LocationProviderBase { .build(); private static final long MAX_LOCATION_COMPARISON_NS = 11 * 1000000000L; // 11 seconds // Maximum request interval at which we will activate GPS (because GPS sometimes consumes // excessive power with large intervals). private static final long MAX_GPS_INTERVAL_MS = 5 * 1000; // 5 seconds private final Object mLock = new Object(); Loading Loading @@ -165,8 +170,13 @@ public class FusedLocationProvider extends LocationProviderBase { mNlpPresent = mLocationManager.hasProvider(NETWORK_PROVIDER); } boolean requestAllowsGps = Flags.limitFusedGps() ? mRequest.getQuality() == QUALITY_HIGH_ACCURACY && mRequest.getIntervalMillis() <= MAX_GPS_INTERVAL_MS : !mNlpPresent || mRequest.getQuality() < QUALITY_LOW_POWER; long gpsInterval = mGpsPresent && (!mNlpPresent || mRequest.getQuality() < QUALITY_LOW_POWER) mGpsPresent && requestAllowsGps ? mRequest.getIntervalMillis() : INTERVAL_DISABLED; long networkInterval = mNlpPresent ? mRequest.getIntervalMillis() : INTERVAL_DISABLED; Loading