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

Commit ce970134 authored by Yu-Han Yang's avatar Yu-Han Yang Committed by Automerger Merge Worker
Browse files

Merge "Correct getExtras("satellites")" into udc-dev am: f9f55380

parents d3a1087c f9f55380
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -831,7 +831,9 @@ public class Location implements Parcelable {
     * will be present for any location.
     *
     * <ul>
     * <li> satellites - the number of satellites used to derive a GNSS fix
     * <li> satellites - the number of satellites used to derive a GNSS fix. This key was deprecated
     * in API 34 because the information can be obtained through more accurate means, such as by
     * referencing {@link GnssStatus#usedInFix}.
     * </ul>
     */
    public @Nullable Bundle getExtras() {
+5 −1
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
import android.util.Pair;
import android.util.TimeUtils;

import com.android.internal.annotations.GuardedBy;
@@ -1396,11 +1397,14 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
            Log.v(TAG, "SV count: " + gnssStatus.getSatelliteCount());
        }

        Set<Pair<Integer, Integer>> satellites = new HashSet<>();
        int usedInFixCount = 0;
        int maxCn0 = 0;
        int meanCn0 = 0;
        for (int i = 0; i < gnssStatus.getSatelliteCount(); i++) {
            if (gnssStatus.usedInFix(i)) {
                satellites.add(
                        new Pair<>(gnssStatus.getConstellationType(i), gnssStatus.getSvid(i)));
                ++usedInFixCount;
                if (gnssStatus.getCn0DbHz(i) > maxCn0) {
                    maxCn0 = (int) gnssStatus.getCn0DbHz(i);
@@ -1413,7 +1417,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
            meanCn0 /= usedInFixCount;
        }
        // return number of sats used in fix instead of total reported
        mLocationExtras.set(usedInFixCount, meanCn0, maxCn0);
        mLocationExtras.set(satellites.size(), meanCn0, maxCn0);

        mGnssMetrics.logSvStatus(gnssStatus);
    }