From b041f23026536dd287c1a9a962642c84ebd10004 Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Mon, 7 May 2012 17:12:25 -0700 Subject: [PATCH] Increase interval threshold below which we just leave the GPS on. Hot TTTF is about 5 seconds, so don't cycle the GPS hardware until the interval is 10 seconds. Also add some more dumpsys logging. Bug: 6367964 Change-Id: I39402fc61f34458a1639c8814610a02606a8eb79 --- .../server/location/GpsLocationProvider.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java index 65b96278c8c68..ce534992bb415 100755 --- a/services/java/com/android/server/location/GpsLocationProvider.java +++ b/services/java/com/android/server/location/GpsLocationProvider.java @@ -192,6 +192,11 @@ public class GpsLocationProvider implements LocationProviderInterface { // stop trying if we do not receive a fix within 60 seconds private static final int NO_FIX_TIMEOUT = 60 * 1000; + // if the fix interval is below this we leave GPS on, + // if above then we cycle the GPS driver. + // Typical hot TTTF is ~5 seconds, so 10 seconds seems sane. + private static final int GPS_POLLING_THRESHOLD_INTERVAL = 10 * 1000; + // true if we are enabled private volatile boolean mEnabled; @@ -842,7 +847,18 @@ public class GpsLocationProvider implements LocationProviderInterface { } public String getInternalState() { - return native_get_internal_state(); + StringBuilder s = new StringBuilder(); + s.append(" mFixInterval=").append(mFixInterval).append("\n"); + s.append(" mEngineCapabilities=0x").append(Integer.toHexString(mEngineCapabilities)).append(" ("); + if (hasCapability(GPS_CAPABILITY_SCHEDULING)) s.append("SCHED "); + if (hasCapability(GPS_CAPABILITY_MSB)) s.append("MSB "); + if (hasCapability(GPS_CAPABILITY_MSA)) s.append("MSA "); + if (hasCapability(GPS_CAPABILITY_SINGLE_SHOT)) s.append("SINGLE_SHOT "); + if (hasCapability(GPS_CAPABILITY_ON_DEMAND_TIME)) s.append("ON_DEMAND_TIME "); + s.append(")\n"); + + s.append(native_get_internal_state()); + return s.toString(); } private final class Listener implements IBinder.DeathRecipient { @@ -1131,7 +1147,8 @@ public class GpsLocationProvider implements LocationProviderInterface { updateStatus(LocationProvider.AVAILABLE, mSvCount); } - if (!hasCapability(GPS_CAPABILITY_SCHEDULING) && mStarted && mFixInterval > 1000) { + if (!hasCapability(GPS_CAPABILITY_SCHEDULING) && mStarted && + mFixInterval > GPS_POLLING_THRESHOLD_INTERVAL) { if (DEBUG) Log.d(TAG, "got fix, hibernating"); hibernate(); }