diff --git a/Patches/LineageOS-17.1/android_frameworks_base/0007-Always_Restict_Serial.patch b/Patches/LineageOS-17.1/android_frameworks_base/0007-Always_Restict_Serial.patch index b6e41f5f..86c6bd6e 100644 --- a/Patches/LineageOS-17.1/android_frameworks_base/0007-Always_Restict_Serial.patch +++ b/Patches/LineageOS-17.1/android_frameworks_base/0007-Always_Restict_Serial.patch @@ -10,10 +10,10 @@ requiring the READ_PHONE_STATE permission. 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java -index f3c2777208ab..0560b7306a4e 100644 +index bb78408617b8..9148a09271f4 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java -@@ -4978,12 +4978,7 @@ public class ActivityManagerService extends IActivityManager.Stub +@@ -4981,12 +4981,7 @@ public class ActivityManagerService extends IActivityManager.Stub } } diff --git a/Patches/LineageOS-17.1/android_frameworks_base/0020-SUPL_Toggle.patch b/Patches/LineageOS-17.1/android_frameworks_base/0020-SUPL_Toggle.patch new file mode 100644 index 00000000..d6217387 --- /dev/null +++ b/Patches/LineageOS-17.1/android_frameworks_base/0020-SUPL_Toggle.patch @@ -0,0 +1,107 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dmitry Muhomor +Date: Fri, 10 Feb 2023 12:54:21 +0200 +Subject: [PATCH] add a setting for forcibly disabling SUPL + +Change-Id: I5c31c319d198f09ace493e601278f8224a259f05 +--- + core/java/android/provider/Settings.java | 9 +++++++++ + .../server/location/GnssConfiguration.java | 15 +++++++++++++++ + .../server/location/GnssLocationProvider.java | 15 +++++++++++++++ + 3 files changed, 39 insertions(+) + +diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java +index 9afbe9750e94..fd0d0e4abbaa 100644 +--- a/core/java/android/provider/Settings.java ++++ b/core/java/android/provider/Settings.java +@@ -15139,6 +15139,15 @@ public final class Settings { + * @hide + */ + public static final String SETTINGS_REBOOT_AFTER_TIMEOUT = "settings_reboot_after_timeout"; ++ ++ /** ++ * Force disable Secure User Plane Location (SUPL), 0 or 1. ++ * @hide ++ */ ++ public static final String FORCE_DISABLE_SUPL = "force_disable_supl"; ++ ++ /** @hide */ ++ public static final int FORCE_DISABLE_SUPL_DEFAULT = 0; + } + + /** +diff --git a/services/core/java/com/android/server/location/GnssConfiguration.java b/services/core/java/com/android/server/location/GnssConfiguration.java +index 18d9f69c9735..04c8c8e6d340 100644 +--- a/services/core/java/com/android/server/location/GnssConfiguration.java ++++ b/services/core/java/com/android/server/location/GnssConfiguration.java +@@ -19,10 +19,12 @@ package com.android.server.location; + import android.content.Context; + import android.os.PersistableBundle; + import android.os.SystemProperties; ++import android.provider.Settings; + import android.telephony.CarrierConfigManager; + import android.telephony.SubscriptionManager; + import android.text.TextUtils; + import android.util.Log; ++import android.util.Slog; + import android.util.StatsLog; + + import libcore.io.IoUtils; +@@ -231,6 +233,8 @@ class GnssConfiguration { + */ + loadPropertiesFromGpsDebugConfig(mProperties); + ++ applyConfigOverrides(mContext, mProperties); ++ + mEsExtensionSec = getRangeCheckedConfigEsExtensionSec(); + + logConfigurations(); +@@ -416,4 +420,15 @@ class GnssConfiguration { + private static native boolean native_set_satellite_blacklist(int[] constellations, int[] svIds); + + private static native boolean native_set_es_extension_sec(int emergencyExtensionSeconds); ++ ++ private static void applyConfigOverrides(Context ctx, Properties props) { ++ String key = Settings.Global.FORCE_DISABLE_SUPL; ++ int def = Settings.Global.FORCE_DISABLE_SUPL_DEFAULT; ++ if (Settings.Global.getInt(ctx.getContentResolver(), key, def) == 1) { ++ props.setProperty(CONFIG_SUPL_MODE, "0"); ++ Slog.d(TAG, "SUPL is force disabled"); ++ } else { ++ Slog.d(TAG, "SUPL is not force disabled"); ++ } ++ } + } +diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java +index 71fb465e8806..928e129f98d3 100644 +--- a/services/core/java/com/android/server/location/GnssLocationProvider.java ++++ b/services/core/java/com/android/server/location/GnssLocationProvider.java +@@ -64,6 +64,7 @@ import android.telephony.TelephonyManager; + import android.telephony.gsm.GsmCellLocation; + import android.text.TextUtils; + import android.util.Log; ++import android.util.Slog; + import android.util.StatsLog; + import android.util.TimeUtils; + +@@ -688,6 +689,20 @@ public class GnssLocationProvider extends AbstractLocationProvider implements + mGnssBatchingProvider = new GnssBatchingProvider(); + mGnssGeofenceProvider = new GnssGeofenceProvider(); + ++ mContext.getContentResolver().registerContentObserver( ++ Settings.Global.getUriFor(Settings.Global.FORCE_DISABLE_SUPL), ++ false, new ContentObserver(mHandler) { ++ @Override ++ public void onChange(boolean selfChange) { ++ ContentResolver cr = mContext.getContentResolver(); ++ String key = Settings.Global.FORCE_DISABLE_SUPL; ++ int def = Settings.Global.FORCE_DISABLE_SUPL_DEFAULT; ++ ++ Slog.d(TAG, "FORCE_DISABLE_SUPL changed, value: " + Settings.Global.getInt(cr, key, def)); ++ mGnssConfiguration.reloadGpsProperties(); ++ } ++ }); ++ + mContext.registerReceiverAsUser(new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { diff --git a/Patches/LineageOS-17.1/android_packages_apps_Settings/0013-SUPL_Toggle.patch b/Patches/LineageOS-17.1/android_packages_apps_Settings/0013-SUPL_Toggle.patch new file mode 100644 index 00000000..0f23cdd3 --- /dev/null +++ b/Patches/LineageOS-17.1/android_packages_apps_Settings/0013-SUPL_Toggle.patch @@ -0,0 +1,88 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dmitry Muhomor +Date: Fri, 10 Feb 2023 12:44:30 +0200 +Subject: [PATCH] add a toggle for forcibly disabling SUPL + +--- + res/values/strings.xml | 3 ++ + res/xml/location_settings.xml | 6 +++ + .../ForceDisableSuplPrefController.java | 41 +++++++++++++++++++ + 3 files changed, 50 insertions(+) + create mode 100644 src/com/android/settings/location/ForceDisableSuplPrefController.java + +diff --git a/res/values/strings.xml b/res/values/strings.xml +index a64940d793..f1ea003e3b 100644 +--- a/res/values/strings.xml ++++ b/res/values/strings.xml +@@ -11517,4 +11517,7 @@ + Don\u2019t connect + + Connect ++ ++ Force disable Secure User Plane Location (SUPL) ++ Always disable SUPL assisted location support regardless of carrier configuration (does not disable control plane A-GNSS and DivestOS does not send IMSI to the SUPL) + +diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml +index 136e6ab619..ae1a0e0f3e 100644 +--- a/res/xml/location_settings.xml ++++ b/res/xml/location_settings.xml +@@ -68,6 +68,12 @@ + android:title="@string/managed_profile_location_services" + android:key="location_services_managed_profile" /> + ++ ++ + + + +Date: Fri, 10 Feb 2023 12:54:21 +0200 +Subject: [PATCH] add a setting for forcibly disabling SUPL + +Change-Id: I5c31c319d198f09ace493e601278f8224a259f05 +--- + core/java/android/provider/Settings.java | 9 +++++++++ + .../server/location/gnss/GnssConfiguration.java | 15 +++++++++++++++ + .../location/gnss/GnssLocationProvider.java | 15 +++++++++++++++ + 3 files changed, 39 insertions(+) + +diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java +index 367c57526fe5..89002f0a3a9c 100755 +--- a/core/java/android/provider/Settings.java ++++ b/core/java/android/provider/Settings.java +@@ -14492,6 +14492,15 @@ public final class Settings { + * @hide + */ + public static final String SETTINGS_REBOOT_AFTER_TIMEOUT = "settings_reboot_after_timeout"; ++ ++ /** ++ * Force disable Secure User Plane Location (SUPL), 0 or 1. ++ * @hide ++ */ ++ public static final String FORCE_DISABLE_SUPL = "force_disable_supl"; ++ ++ /** @hide */ ++ public static final int FORCE_DISABLE_SUPL_DEFAULT = 0; + } + + /** +diff --git a/services/core/java/com/android/server/location/gnss/GnssConfiguration.java b/services/core/java/com/android/server/location/gnss/GnssConfiguration.java +index 14ab79e7ecde..f46a993336b3 100644 +--- a/services/core/java/com/android/server/location/gnss/GnssConfiguration.java ++++ b/services/core/java/com/android/server/location/gnss/GnssConfiguration.java +@@ -19,10 +19,12 @@ package com.android.server.location.gnss; + import android.content.Context; + import android.os.PersistableBundle; + import android.os.SystemProperties; ++import android.provider.Settings; + import android.telephony.CarrierConfigManager; + import android.telephony.SubscriptionManager; + import android.text.TextUtils; + import android.util.Log; ++import android.util.Slog; + + import com.android.internal.util.FrameworkStatsLog; + +@@ -232,6 +234,8 @@ class GnssConfiguration { + */ + loadPropertiesFromGpsDebugConfig(mProperties); + ++ applyConfigOverrides(mContext, mProperties); ++ + mEsExtensionSec = getRangeCheckedConfigEsExtensionSec(); + + logConfigurations(); +@@ -417,4 +421,15 @@ class GnssConfiguration { + private static native boolean native_set_satellite_blacklist(int[] constellations, int[] svIds); + + private static native boolean native_set_es_extension_sec(int emergencyExtensionSeconds); ++ ++ private static void applyConfigOverrides(Context ctx, Properties props) { ++ String key = Settings.Global.FORCE_DISABLE_SUPL; ++ int def = Settings.Global.FORCE_DISABLE_SUPL_DEFAULT; ++ if (Settings.Global.getInt(ctx.getContentResolver(), key, def) == 1) { ++ props.setProperty(CONFIG_SUPL_MODE, "0"); ++ Slog.d(TAG, "SUPL is force disabled"); ++ } else { ++ Slog.d(TAG, "SUPL is not force disabled"); ++ } ++ } + } +diff --git a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java +index 7c72a2016d15..fa2c063acd93 100644 +--- a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java ++++ b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java +@@ -64,6 +64,7 @@ import android.telephony.TelephonyManager; + import android.telephony.gsm.GsmCellLocation; + import android.text.TextUtils; + import android.util.Log; ++import android.util.Slog; + import android.util.TimeUtils; + + import com.android.internal.annotations.GuardedBy; +@@ -721,6 +722,20 @@ public class GnssLocationProvider extends AbstractLocationProvider implements + mGnssBatchingProvider = new GnssBatchingProvider(); + mGnssGeofenceProvider = new GnssGeofenceProvider(); + ++ mContext.getContentResolver().registerContentObserver( ++ Settings.Global.getUriFor(Settings.Global.FORCE_DISABLE_SUPL), ++ false, new ContentObserver(mHandler) { ++ @Override ++ public void onChange(boolean selfChange) { ++ ContentResolver cr = mContext.getContentResolver(); ++ String key = Settings.Global.FORCE_DISABLE_SUPL; ++ int def = Settings.Global.FORCE_DISABLE_SUPL_DEFAULT; ++ ++ Slog.d(TAG, "FORCE_DISABLE_SUPL changed, value: " + Settings.Global.getInt(cr, key, def)); ++ mGnssConfiguration.reloadGpsProperties(); ++ } ++ }); ++ + mContext.registerReceiverAsUser(new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { diff --git a/Patches/LineageOS-18.1/android_packages_apps_Settings/0014-SUPL_Toggle.patch b/Patches/LineageOS-18.1/android_packages_apps_Settings/0014-SUPL_Toggle.patch new file mode 100644 index 00000000..20ea3130 --- /dev/null +++ b/Patches/LineageOS-18.1/android_packages_apps_Settings/0014-SUPL_Toggle.patch @@ -0,0 +1,88 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dmitry Muhomor +Date: Fri, 10 Feb 2023 12:44:30 +0200 +Subject: [PATCH] add a toggle for forcibly disabling SUPL + +--- + res/values/strings.xml | 3 ++ + res/xml/location_settings.xml | 6 +++ + .../ForceDisableSuplPrefController.java | 41 +++++++++++++++++++ + 3 files changed, 50 insertions(+) + create mode 100644 src/com/android/settings/location/ForceDisableSuplPrefController.java + +diff --git a/res/values/strings.xml b/res/values/strings.xml +index 060f94a48f..2e6e2fc8b2 100644 +--- a/res/values/strings.xml ++++ b/res/values/strings.xml +@@ -12297,4 +12297,7 @@ + + Internet connectivity check + HTTP endpoints to use for performing internet connectivity checks. ++ ++ Force disable Secure User Plane Location (SUPL) ++ Always disable SUPL assisted location support regardless of carrier configuration (does not disable control plane A-GNSS and DivestOS does not send IMSI to the SUPL) + +diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml +index fb03f4c7f3..a66df8fea6 100644 +--- a/res/xml/location_settings.xml ++++ b/res/xml/location_settings.xml +@@ -77,6 +77,12 @@ + settings:forWork="true" + settings:controller="com.android.settings.location.LocationServiceForWorkPreferenceController"/> + ++ ++ + + +