Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d53ba017 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

GpsLocationProvider: Eliminate MIN_FIX_COUNT.



Now we stop after one fix rather than waiting for 10 when requesting occasional
fixes to conserve power.

Change-Id: Ic420f2d20780db983fc4db22246e0a486eecc58e
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 1879d284
Loading
Loading
Loading
Loading
+4 −13
Original line number Original line Diff line number Diff line
@@ -164,9 +164,6 @@ public class GpsLocationProvider implements LocationProviderInterface {
    // turn off GPS fix icon if we haven't received a fix in 10 seconds
    // turn off GPS fix icon if we haven't received a fix in 10 seconds
    private static final long RECENT_FIX_TIMEOUT = 10 * 1000;
    private static final long RECENT_FIX_TIMEOUT = 10 * 1000;


    // number of fixes to receive before disabling GPS
    private static final int MIN_FIX_COUNT = 10;

    // stop trying if we do not receive a fix within 60 seconds
    // stop trying if we do not receive a fix within 60 seconds
    private static final int NO_FIX_TIMEOUT = 60 * 1000;
    private static final int NO_FIX_TIMEOUT = 60 * 1000;


@@ -190,9 +187,6 @@ public class GpsLocationProvider implements LocationProviderInterface {
    // requested frequency of fixes, in milliseconds
    // requested frequency of fixes, in milliseconds
    private int mFixInterval = 1000;
    private int mFixInterval = 1000;


    // number of fixes we have received since we started navigating
    private int mFixCount;

    // true if we started navigation
    // true if we started navigation
    private boolean mStarted;
    private boolean mStarted;


@@ -908,7 +902,6 @@ public class GpsLocationProvider implements LocationProviderInterface {


            // reset SV count to zero
            // reset SV count to zero
            updateStatus(LocationProvider.TEMPORARILY_UNAVAILABLE, 0);
            updateStatus(LocationProvider.TEMPORARILY_UNAVAILABLE, 0);
            mFixCount = 0;
            mFixRequestTime = System.currentTimeMillis();
            mFixRequestTime = System.currentTimeMillis();
            if (!hasCapability(GPS_CAPABILITY_SCHEDULING)) {
            if (!hasCapability(GPS_CAPABILITY_SCHEDULING)) {
                // set timer to give up if we do not receive a fix within NO_FIX_TIMEOUT
                // set timer to give up if we do not receive a fix within NO_FIX_TIMEOUT
@@ -938,7 +931,6 @@ public class GpsLocationProvider implements LocationProviderInterface {
    private void hibernate() {
    private void hibernate() {
        // stop GPS until our next fix interval arrives
        // stop GPS until our next fix interval arrives
        stopNavigating();
        stopNavigating();
        mFixCount = 0;
        mAlarmManager.cancel(mTimeoutIntent);
        mAlarmManager.cancel(mTimeoutIntent);
        mAlarmManager.cancel(mWakeupIntent);
        mAlarmManager.cancel(mWakeupIntent);
        long now = SystemClock.elapsedRealtime();
        long now = SystemClock.elapsedRealtime();
@@ -1017,7 +1009,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
        }
        }


        if (mStarted && mStatus != LocationProvider.AVAILABLE) {
        if (mStarted && mStatus != LocationProvider.AVAILABLE) {
            // we still want to time out if we do not receive MIN_FIX_COUNT
            // we want to time out if we do not receive a fix
            // within the time out and we are requesting infrequent fixes
            // within the time out and we are requesting infrequent fixes
            if (!hasCapability(GPS_CAPABILITY_SCHEDULING) && mFixInterval < NO_FIX_TIMEOUT) {
            if (!hasCapability(GPS_CAPABILITY_SCHEDULING) && mFixInterval < NO_FIX_TIMEOUT) {
                mAlarmManager.cancel(mTimeoutIntent);
                mAlarmManager.cancel(mTimeoutIntent);
@@ -1030,9 +1022,8 @@ public class GpsLocationProvider implements LocationProviderInterface {
            updateStatus(LocationProvider.AVAILABLE, mSvCount);
            updateStatus(LocationProvider.AVAILABLE, mSvCount);
        }
        }


       if (!hasCapability(GPS_CAPABILITY_SCHEDULING) &&
       if (!hasCapability(GPS_CAPABILITY_SCHEDULING) && mFixInterval > 1000) {
                mFixCount++ >= MIN_FIX_COUNT && mFixInterval > 1000) {
            if (DEBUG) Log.d(TAG, "got fix, hibernating");
            if (DEBUG) Log.d(TAG, "exceeded MIN_FIX_COUNT");
            hibernate();
            hibernate();
        }
        }
   }
   }