summaryrefslogtreecommitdiffstats
path: root/packages/FusedLocation
diff options
context:
space:
mode:
authorSoonil Nagarkar <sooniln@google.com>2015-09-23 01:58:11 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-23 01:58:11 +0000
commitfd5cb76ed654998df466147c19ec985115749e70 (patch)
treedd9d8f31dc40ce3816b55204d6205f50b42edd35 /packages/FusedLocation
parent6da88610cea1e5f815e2d56979f54808c02a652f (diff)
parent79490dbacd90a851ed8d03d64acedbf3616adba4 (diff)
downloadframeworks_base-fd5cb76ed654998df466147c19ec985115749e70.zip
frameworks_base-fd5cb76ed654998df466147c19ec985115749e70.tar.gz
frameworks_base-fd5cb76ed654998df466147c19ec985115749e70.tar.bz2
am 79490dba: Merge "Fix reintroduction of b/10845061" into mnc-dr-dev
* commit '79490dbacd90a851ed8d03d64acedbf3616adba4': Fix reintroduction of b/10845061
Diffstat (limited to 'packages/FusedLocation')
-rw-r--r--packages/FusedLocation/src/com/android/location/fused/FusionEngine.java54
1 files changed, 21 insertions, 33 deletions
diff --git a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
index 5e9ec10..7a49524 100644
--- a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
+++ b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
@@ -37,7 +37,7 @@ import android.util.Log;
public class FusionEngine implements LocationListener {
public interface Callback {
- public void reportLocation(Location location);
+ void reportLocation(Location location);
}
private static final String TAG = "FusedLocation";
@@ -45,7 +45,7 @@ public class FusionEngine implements LocationListener {
private static final String GPS = LocationManager.GPS_PROVIDER;
private static final String FUSED = LocationProviderBase.FUSED_PROVIDER;
- public static final long SWITCH_ON_FRESHNESS_CLIFF_NS = 11 * 1000000000; // 11 seconds
+ public static final long SWITCH_ON_FRESHNESS_CLIFF_NS = 11 * 1000000000L; // 11 seconds
private final Context mContext;
private final LocationManager mLocationManager;
@@ -60,7 +60,7 @@ public class FusionEngine implements LocationListener {
private boolean mEnabled;
private ProviderRequestUnbundled mRequest;
- private final HashMap<String, ProviderStats> mStats = new HashMap<String, ProviderStats>();
+ private final HashMap<String, ProviderStats> mStats = new HashMap<>();
public FusionEngine(Context context, Looper looper) {
mContext = context;
@@ -72,9 +72,7 @@ public class FusionEngine implements LocationListener {
mLooper = looper;
mStats.put(GPS, new ProviderStats());
- mStats.get(GPS).available = mLocationManager.isProviderEnabled(GPS);
mStats.put(NETWORK, new ProviderStats());
- mStats.get(NETWORK).available = mLocationManager.isProviderEnabled(NETWORK);
}
@@ -119,35 +117,35 @@ public class FusionEngine implements LocationListener {
}
private static class ProviderStats {
- public boolean available;
public boolean requested;
public long requestTime;
public long minTime;
@Override
public String toString() {
- StringBuilder s = new StringBuilder();
- s.append(available ? "AVAILABLE" : "UNAVAILABLE");
- s.append(requested ? " REQUESTED" : " ---");
- return s.toString();
+ return (requested ? " REQUESTED" : " ---");
}
}
private void enableProvider(String name, long minTime) {
ProviderStats stats = mStats.get(name);
+ if (stats == null) return;
- if (!stats.requested) {
- stats.requestTime = SystemClock.elapsedRealtime();
- stats.requested = true;
- stats.minTime = minTime;
- mLocationManager.requestLocationUpdates(name, minTime, 0, this, mLooper);
- } else if (stats.minTime != minTime) {
- stats.minTime = minTime;
- mLocationManager.requestLocationUpdates(name, minTime, 0, this, mLooper);
+ if (mLocationManager.isProviderEnabled(name)) {
+ if (!stats.requested) {
+ stats.requestTime = SystemClock.elapsedRealtime();
+ stats.requested = true;
+ stats.minTime = minTime;
+ mLocationManager.requestLocationUpdates(name, minTime, 0, this, mLooper);
+ } else if (stats.minTime != minTime) {
+ stats.minTime = minTime;
+ mLocationManager.requestLocationUpdates(name, minTime, 0, this, mLooper);
+ }
}
}
private void disableProvider(String name) {
ProviderStats stats = mStats.get(name);
+ if (stats == null) return;
if (stats.requested) {
stats.requested = false;
@@ -156,7 +154,7 @@ public class FusionEngine implements LocationListener {
}
private void updateRequirements() {
- if (mEnabled == false || mRequest == null) {
+ if (!mEnabled || mRequest == null) {
mRequest = null;
disableProvider(NETWORK);
disableProvider(GPS);
@@ -248,7 +246,7 @@ public class FusionEngine implements LocationListener {
mFusedLocation.setExtras(dstExtras);
}
dstExtras.putParcelable(LocationProviderBase.EXTRA_NO_GPS_LOCATION,
- (Location) srcParcelable);
+ srcParcelable);
}
}
}
@@ -278,25 +276,15 @@ public class FusionEngine implements LocationListener {
/** Called on mLooper thread */
@Override
- public void onProviderEnabled(String provider) {
- ProviderStats stats = mStats.get(provider);
- if (stats == null) return;
-
- stats.available = true;
- }
+ public void onProviderEnabled(String provider) { }
/** Called on mLooper thread */
@Override
- public void onProviderDisabled(String provider) {
- ProviderStats stats = mStats.get(provider);
- if (stats == null) return;
-
- stats.available = false;
- }
+ public void onProviderDisabled(String provider) { }
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
StringBuilder s = new StringBuilder();
- s.append("mEnabled=" + mEnabled).append(' ').append(mRequest).append('\n');
+ s.append("mEnabled=").append(mEnabled).append(' ').append(mRequest).append('\n');
s.append("fused=").append(mFusedLocation).append('\n');
s.append(String.format("gps %s\n", mGpsLocation));
s.append(" ").append(mStats.get(GPS)).append('\n');