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

Commit 6a5f0b77 authored by Yu-Han Yang's avatar Yu-Han Yang
Browse files

Remove mSingleShot

- The single-shot location request is already handled by 'receiver cleanup' in
LocationManagerService. Thus, the state mSingleShot is not needed.

Bug: 123326749
Change-Id: I0056c02d669f486bd7a7a0337247983fd7254c62
Fixes: 123326749
Test: tested on device
parent d70e1ad7
Loading
Loading
Loading
Loading
+6 −40
Original line number Original line Diff line number Diff line
@@ -332,9 +332,6 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
    // true if we started navigation
    // true if we started navigation
    private boolean mStarted;
    private boolean mStarted;


    // true if single shot request is in progress
    private boolean mSingleShot;

    // capabilities of the GPS engine
    // capabilities of the GPS engine
    private int mEngineCapabilities;
    private int mEngineCapabilities;


@@ -455,7 +452,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements


            switch (action) {
            switch (action) {
                case ALARM_WAKEUP:
                case ALARM_WAKEUP:
                    startNavigating(false);
                    startNavigating();
                    break;
                    break;
                case ALARM_TIMEOUT:
                case ALARM_TIMEOUT:
                    hibernate();
                    hibernate();
@@ -852,10 +849,9 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
     * allowed mode from properties.
     * allowed mode from properties.
     *
     *
     * @param agpsEnabled whether AGPS is enabled by settings value
     * @param agpsEnabled whether AGPS is enabled by settings value
     * @param singleShot  whether "singleshot" is needed
     * @return SUPL mode (MSA vs MSB vs STANDALONE)
     * @return SUPL mode (MSA vs MSB vs STANDALONE)
     */
     */
    private int getSuplMode(boolean agpsEnabled, boolean singleShot) {
    private int getSuplMode(boolean agpsEnabled) {
        if (agpsEnabled) {
        if (agpsEnabled) {
            int suplMode = mGnssConfiguration.getSuplMode(0);
            int suplMode = mGnssConfiguration.getSuplMode(0);
            if (suplMode == 0) {
            if (suplMode == 0) {
@@ -867,14 +863,6 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
            if (hasCapability(GPS_CAPABILITY_MSB) && (suplMode & AGPS_SUPL_MODE_MSB) != 0) {
            if (hasCapability(GPS_CAPABILITY_MSB) && (suplMode & AGPS_SUPL_MODE_MSB) != 0) {
                return GPS_POSITION_MODE_MS_BASED;
                return GPS_POSITION_MODE_MS_BASED;
            }
            }
            // for now, just as the legacy code did, we fallback to MS-Assisted if it is available,
            // do fallback only for single-shot requests, because it is too expensive to do for
            // periodic requests as well
            if (singleShot
                    && hasCapability(GPS_CAPABILITY_MSA)
                    && (suplMode & AGPS_SUPL_MODE_MSA) != 0) {
                return GPS_POSITION_MODE_MS_ASSISTED;
            }
        }
        }
        return GPS_POSITION_MODE_STANDALONE;
        return GPS_POSITION_MODE_STANDALONE;
    }
    }
@@ -965,22 +953,6 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
            return;
            return;
        }
        }


        boolean singleShot = false;

        // see if the request is for a single update
        if (mProviderRequest.locationRequests != null
                && mProviderRequest.locationRequests.size() > 0) {
            // if any request has zero or more than one updates
            // requested, then this is not single-shot mode
            singleShot = true;

            for (LocationRequest lr : mProviderRequest.locationRequests) {
                if (lr.getNumUpdates() != 1) {
                    singleShot = false;
                }
            }
        }

        if (DEBUG) Log.d(TAG, "setRequest " + mProviderRequest);
        if (DEBUG) Log.d(TAG, "setRequest " + mProviderRequest);
        if (mProviderRequest.reportLocation && !mDisableGps && isEnabled()) {
        if (mProviderRequest.reportLocation && !mDisableGps && isEnabled()) {
            // update client uids
            // update client uids
@@ -1003,7 +975,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
                }
                }
            } else if (!mStarted) {
            } else if (!mStarted) {
                // start GPS
                // start GPS
                startNavigating(singleShot);
                startNavigating();
            } else {
            } else {
                // GNSS Engine is already ON, but no GPS_CAPABILITY_SCHEDULING
                // GNSS Engine is already ON, but no GPS_CAPABILITY_SCHEDULING
                mAlarmManager.cancel(mTimeoutIntent);
                mAlarmManager.cancel(mTimeoutIntent);
@@ -1148,13 +1120,12 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        }
        }
    }
    }


    private void startNavigating(boolean singleShot) {
    private void startNavigating() {
        if (!mStarted) {
        if (!mStarted) {
            if (DEBUG) Log.d(TAG, "startNavigating, singleShot is " + singleShot);
            if (DEBUG) Log.d(TAG, "startNavigating");
            mTimeToFirstFix = 0;
            mTimeToFirstFix = 0;
            mLastFixTime = 0;
            mLastFixTime = 0;
            mStarted = true;
            mStarted = true;
            mSingleShot = singleShot;
            mPositionMode = GPS_POSITION_MODE_STANDALONE;
            mPositionMode = GPS_POSITION_MODE_STANDALONE;
            // Notify about suppressed output, if speed limit was previously exceeded.
            // Notify about suppressed output, if speed limit was previously exceeded.
            // Elsewhere, we check again with every speed output reported.
            // Elsewhere, we check again with every speed output reported.
@@ -1166,7 +1137,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
            boolean agpsEnabled =
            boolean agpsEnabled =
                    (Settings.Global.getInt(mContext.getContentResolver(),
                    (Settings.Global.getInt(mContext.getContentResolver(),
                            Settings.Global.ASSISTED_GPS_ENABLED, 1) != 0);
                            Settings.Global.ASSISTED_GPS_ENABLED, 1) != 0);
            mPositionMode = getSuplMode(agpsEnabled, singleShot);
            mPositionMode = getSuplMode(agpsEnabled);


            if (DEBUG) {
            if (DEBUG) {
                String mode;
                String mode;
@@ -1221,7 +1192,6 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        if (DEBUG) Log.d(TAG, "stopNavigating");
        if (DEBUG) Log.d(TAG, "stopNavigating");
        if (mStarted) {
        if (mStarted) {
            mStarted = false;
            mStarted = false;
            mSingleShot = false;
            native_stop();
            native_stop();
            mLastFixTime = 0;
            mLastFixTime = 0;
            // native_stop() may reset the position mode in hardware.
            // native_stop() may reset the position mode in hardware.
@@ -1300,10 +1270,6 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
            mGnssStatusListenerHelper.onFirstFix(mTimeToFirstFix);
            mGnssStatusListenerHelper.onFirstFix(mTimeToFirstFix);
        }
        }


        if (mSingleShot) {
            stopNavigating();
        }

        if (mStarted && mStatus != LocationProvider.AVAILABLE) {
        if (mStarted && mStatus != LocationProvider.AVAILABLE) {
            // For devices that use framework scheduling, a timer may be set to ensure we don't
            // For devices that use framework scheduling, a timer may be set to ensure we don't
            // spend too much power searching for a location, when the requested update rate is
            // spend too much power searching for a location, when the requested update rate is