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

Commit 66c7ea91 authored by Yu-Han Yang's avatar Yu-Han Yang
Browse files

Implements GNSS satellite blacklist

Bug: 38269641

Test: m -j ROBOTEST_FILTER=GnssSatelliteBlacklistHelperTest RunFrameworksServicesRoboTests
Test: atest SettingsBackupTest
Test: Tested with adb on device

Change-Id: Ifaa330bf74353ea5c8826f0000d1935258b8dbf2
parent 6a95a2cc
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -12541,6 +12541,19 @@ public final class Settings {
         */
         public static final String SWAP_ENABLED = "swap_enabled";

        /**
         * Blacklist of GNSS satellites.
         *
         * This is a list of integers separated by commas to represent pairs of (constellation,
         * svid). Thus, the number of integers should be even.
         *
         * E.g.: "3,0,5,24" denotes (constellation=3, svid=0) and (constellation=5, svid=24) are
         * blacklisted. Note that svid=0 denotes all svids in the
         * constellation are blacklisted.
         *
         * @hide
         */
        public static final String GNSS_SATELLITE_BLACKLIST = "gnss_satellite_blacklist";
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -451,6 +451,7 @@ message GlobalSettingsProto {
        // If set to 1, {@link Secure#LOCATION_MODE} will be set to {@link
        // Secure#LOCATION_MODE_OFF} temporarily for all users.
        optional SettingProto global_kill_switch = 5 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto gnss_satellite_blacklist = 6 [ (android.privacy).dest = DEST_AUTOMATIC ];
    }
    optional Location location = 69;

+1 −0
Original line number Diff line number Diff line
@@ -239,6 +239,7 @@ public class SettingsBackupTest {
                    Settings.Global.GLOBAL_HTTP_PROXY_HOST,
                    Settings.Global.GLOBAL_HTTP_PROXY_PAC,
                    Settings.Global.GLOBAL_HTTP_PROXY_PORT,
                    Settings.Global.GNSS_SATELLITE_BLACKLIST,
                    Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS,
                    Settings.Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
                    Settings.Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED,
+3 −0
Original line number Diff line number Diff line
@@ -742,6 +742,9 @@ class SettingsProtoDumpUtil {
        dumpSetting(s, p,
                Settings.Global.LOCATION_GLOBAL_KILL_SWITCH,
                GlobalSettingsProto.Location.GLOBAL_KILL_SWITCH);
        dumpSetting(s, p,
                Settings.Global.GNSS_SATELLITE_BLACKLIST,
                GlobalSettingsProto.Location.GNSS_SATELLITE_BLACKLIST);
        p.end(locationToken);

        final long lpmToken = p.start(GlobalSettingsProto.LOW_POWER_MODE);
+24 −5
Original line number Diff line number Diff line
@@ -83,7 +83,11 @@ import com.android.internal.location.GpsNetInitiatedHandler.GpsNiNotification;
import com.android.internal.location.ProviderProperties;
import com.android.internal.location.ProviderRequest;
import com.android.internal.location.gnssmetrics.GnssMetrics;
import com.android.server.location.GnssSatelliteBlacklistHelper.GnssSatelliteBlacklistCallback;
import com.android.server.location.NtpTimeHelper.InjectNtpTimeCallback;

import libcore.io.IoUtils;

import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
@@ -99,14 +103,13 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;

import libcore.io.IoUtils;

/**
 * A GNSS implementation of LocationProvider used by LocationManager.
 *
 * {@hide}
 */
public class GnssLocationProvider implements LocationProviderInterface, InjectNtpTimeCallback {
public class GnssLocationProvider implements LocationProviderInterface, InjectNtpTimeCallback,
        GnssSatelliteBlacklistCallback {

    private static final String TAG = "GnssLocationProvider";

@@ -308,7 +311,7 @@ public class GnssLocationProvider implements LocationProviderInterface, InjectNt
        }
    }

    private Object mLock = new Object();
    private final Object mLock = new Object();

    // current status
    private int mStatus = LocationProvider.TEMPORARILY_UNAVAILABLE;
@@ -411,6 +414,7 @@ public class GnssLocationProvider implements LocationProviderInterface, InjectNt
    private final ILocationManager mILocationManager;
    private final LocationExtras mLocationExtras = new LocationExtras();
    private final GnssStatusListenerHelper mListenerHelper;
    private final GnssSatelliteBlacklistHelper mGnssSatelliteBlacklistHelper;
    private final GnssMeasurementsProvider mGnssMeasurementsProvider;
    private final GnssNavigationMessageProvider mGnssNavigationMessageProvider;
    private final LocationChangeListener mNetworkLocationListener = new NetworkLocationListener();
@@ -577,6 +581,16 @@ public class GnssLocationProvider implements LocationProviderInterface, InjectNt
                }
            };

    /**
     * Implements {@link GnssSatelliteBlacklistCallback#onUpdateSatelliteBlacklist}.
     */
    @Override
    public void onUpdateSatelliteBlacklist(int[] constellations, int[] svids) {
        mHandler.post(()->{
            native_set_satellite_blacklist(constellations, svids);
        });
    }

    private void subscriptionOrSimChanged(Context context) {
        if (DEBUG) Log.d(TAG, "received SIM related action: ");
        TelephonyManager phone = (TelephonyManager)
@@ -869,7 +883,10 @@ public class GnssLocationProvider implements LocationProviderInterface, InjectNt
        };
        mGnssMetrics = new GnssMetrics(mBatteryStats);

        mNtpTimeHelper = new NtpTimeHelper(mContext, Looper.myLooper(), this);
        mNtpTimeHelper = new NtpTimeHelper(mContext, looper, this);
        mGnssSatelliteBlacklistHelper = new GnssSatelliteBlacklistHelper(mContext,
                looper, this);
        mHandler.post(mGnssSatelliteBlacklistHelper::updateSatelliteBlacklist);
    }

    /**
@@ -2900,6 +2917,8 @@ public class GnssLocationProvider implements LocationProviderInterface, InjectNt

    private static native boolean native_set_emergency_supl_pdn(int emergencySuplPdn);

    private static native boolean native_set_satellite_blacklist(int[] constellations, int[] svIds);

    // GNSS Batching
    private static native int native_get_batch_size();

Loading