DivestOS/Patches/LineageOS-17.1/android_packages_apps_Settings/0013-SUPL_Toggle.patch

89 lines
3.5 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dmitry Muhomor <muhomor.dmitry@gmail.com>
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 b5dbdc7d81f..a5aab8e5d08 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -11517,4 +11517,7 @@
<string name="bluetooth_connect_access_dialog_negative">Don\u2019t connect</string>
<!-- Strings for Dialog connect button -->
<string name="bluetooth_connect_access_dialog_positive">Connect</string>
+
+ <string name="force_disable_supl_title">Force disable Secure User Plane Location (SUPL)</string>
+ <string name="force_disable_supl_summary">Always disable SUPL assisted location support regardless of carrier configuration or emergency call status (does not disable control plane A-GNSS and DivestOS does not send IMSI to the SUPL)</string>
</resources>
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index 136e6ab6195..ae1a0e0f3e2 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" />
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="force_disable_supl"
+ android:title="@string/force_disable_supl_title"
+ android:summary="@string/force_disable_supl_summary"
+ settings:controller="com.android.settings.location.ForceDisableSuplPrefController"/>
+
</PreferenceCategory>
<PreferenceCategory
diff --git a/src/com/android/settings/location/ForceDisableSuplPrefController.java b/src/com/android/settings/location/ForceDisableSuplPrefController.java
new file mode 100644
index 00000000000..1cfae3f3a65
--- /dev/null
+++ b/src/com/android/settings/location/ForceDisableSuplPrefController.java
@@ -0,0 +1,41 @@
+package com.android.settings.location;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.os.Process;
+import android.provider.Settings;
+
+import com.android.settings.core.TogglePreferenceController;
+
+public class ForceDisableSuplPrefController extends TogglePreferenceController {
+
+ public ForceDisableSuplPrefController(Context ctx, String key) {
+ super(ctx, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (!Process.myUserHandle().isSystem()) {
+ return DISABLED_FOR_USER;
+ }
+
+ return AVAILABLE;
+ }
+
+ @Override
+ public boolean isChecked() {
+ ContentResolver cr = mContext.getContentResolver();
+ String key = Settings.Global.FORCE_DISABLE_SUPL;
+ int def = Settings.Global.FORCE_DISABLE_SUPL_DEFAULT;
+
+ return Settings.Global.getInt(cr, key, def) == 1;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ ContentResolver cr = mContext.getContentResolver();
+ String key = Settings.Global.FORCE_DISABLE_SUPL;
+
+ return Settings.Global.putInt(cr, key, isChecked ? 1 : 0);
+ }
+}