mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2025-02-23 16:10:13 -05:00
Runtime control of CarrierConfig2
Signed-off-by: Tavi <tavi@divested.dev>
This commit is contained in:
parent
4328ec6c65
commit
2850ff678a
@ -4,6 +4,7 @@ Date: Wed, 20 Apr 2022 01:04:27 -0400
|
||||
Subject: [PATCH] Add a toggle for OpenEUICC enablement
|
||||
|
||||
Copy and pasted from the GrapheneOS exec spawning toggle patch
|
||||
TODO: MOVE OUT OF SECURITY CATEGORY
|
||||
|
||||
Change-Id: Ibea6ea9bed1c2ae3491f403d9e5c17c1d1c403f1
|
||||
Signed-off-by: Tad <tad@spotco.us>
|
||||
|
@ -0,0 +1,173 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tad <tad@spotco.us>
|
||||
Date: Wed, 20 Apr 2022 01:04:27 -0400
|
||||
Subject: [PATCH] Add a toggle for CarrierConfig2 enablement
|
||||
|
||||
Copy and pasted from the GrapheneOS exec spawning toggle patch
|
||||
TODO: MOVE OUT OF SECURITY CATEGORY
|
||||
|
||||
Change-Id: Ibea6ea9bed1c2ae3491f403d9e5c17c1d1c403f1
|
||||
Signed-off-by: Tad <tad@spotco.us>
|
||||
---
|
||||
res/values/strings.xml | 3 +
|
||||
res/xml/security_dashboard_settings.xml | 6 +
|
||||
.../CarrierConfig2PreferenceController.java | 106 ++++++++++++++++++
|
||||
.../settings/security/SecuritySettings.java | 1 +
|
||||
4 files changed, 116 insertions(+)
|
||||
create mode 100644 src/com/android/settings/security/CarrierConfig2PreferenceController.java
|
||||
|
||||
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
||||
index 751f4a4037..d8f4ed191a 100644
|
||||
--- a/res/values/strings.xml
|
||||
+++ b/res/values/strings.xml
|
||||
@@ -762,6 +762,9 @@
|
||||
<string name="openeuicc_title">Enable eUICC management</string>
|
||||
<string name="openeuicc_summary">Enables the OpenEUICC app to allow management of virtual (eSIM) and physical eUICC cards. Reboot required after toggling.</string>
|
||||
|
||||
+ <string name="carrierconfig2_title">Enable CarrierConfig2</string>
|
||||
+ <string name="carrierconfig2_summary">Use a larger Google database instead of the AOSP database for carrier specific configurations. May improve cellular network compatibility & functionality.</string>
|
||||
+
|
||||
<!-- Text shown for the title of the lock when trust lost option [CHAR LIMIT=40] -->
|
||||
<string name="trust_lost_locks_screen_title">Lock screen when trust is lost</string>
|
||||
<!-- Text shown for the description of the lock when trust lost option [CHAR LIMIT=NONE -->
|
||||
diff --git a/res/xml/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml
|
||||
index de90cec5bc..d8766ab41a 100644
|
||||
--- a/res/xml/security_dashboard_settings.xml
|
||||
+++ b/res/xml/security_dashboard_settings.xml
|
||||
@@ -98,6 +98,12 @@
|
||||
android:title="@string/openeuicc_title"
|
||||
android:summary="@string/openeuicc_summary"
|
||||
android:persistent="false" />
|
||||
+
|
||||
+ <SwitchPreference
|
||||
+ android:key="carrierconfig2"
|
||||
+ android:title="@string/carrierconfig2_title"
|
||||
+ android:summary="@string/carrierconfig2_summary"
|
||||
+ android:persistent="false" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
diff --git a/src/com/android/settings/security/CarrierConfig2PreferenceController.java b/src/com/android/settings/security/CarrierConfig2PreferenceController.java
|
||||
new file mode 100644
|
||||
index 0000000000..a3e5aa1759
|
||||
--- /dev/null
|
||||
+++ b/src/com/android/settings/security/CarrierConfig2PreferenceController.java
|
||||
@@ -0,0 +1,106 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2022 The Android Open Source Project
|
||||
+ *
|
||||
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+ * you may not use this file except in compliance with the License.
|
||||
+ * You may obtain a copy of the License at
|
||||
+ *
|
||||
+ * http://www.apache.org/licenses/LICENSE-2.0
|
||||
+ *
|
||||
+ * Unless required by applicable law or agreed to in writing, software
|
||||
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+ * See the License for the specific language governing permissions and
|
||||
+ * limitations under the License
|
||||
+ */
|
||||
+
|
||||
+package com.android.settings.security;
|
||||
+
|
||||
+import android.content.Context;
|
||||
+
|
||||
+import android.os.UserHandle;
|
||||
+import android.os.UserManager;
|
||||
+import android.os.SystemProperties;
|
||||
+
|
||||
+import android.provider.Settings;
|
||||
+
|
||||
+import androidx.preference.Preference;
|
||||
+import androidx.preference.PreferenceCategory;
|
||||
+import androidx.preference.PreferenceGroup;
|
||||
+import androidx.preference.PreferenceScreen;
|
||||
+import androidx.preference.TwoStatePreference;
|
||||
+import androidx.preference.SwitchPreference;
|
||||
+
|
||||
+import com.android.internal.widget.LockPatternUtils;
|
||||
+import com.android.settings.core.PreferenceControllerMixin;
|
||||
+import com.android.settingslib.core.AbstractPreferenceController;
|
||||
+import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||
+
|
||||
+public class CarrierConfig2PreferenceController extends AbstractPreferenceController
|
||||
+ implements PreferenceControllerMixin, OnResume, Preference.OnPreferenceChangeListener {
|
||||
+
|
||||
+ private static final String SYS_KEY_CARRIERCONFIG2_ENABLE = "persist.security.carrierconfig2";
|
||||
+ private static final String PREF_KEY_CARRIERCONFIG2_ENABLE = "carrierconfig2";
|
||||
+ private static final String PREF_KEY_SECURITY_CATEGORY = "security_category";
|
||||
+
|
||||
+ private PreferenceCategory mSecurityCategory;
|
||||
+ private SwitchPreference mCarrierConfig2Enable;
|
||||
+ private boolean mIsAdmin;
|
||||
+ private UserManager mUm;
|
||||
+
|
||||
+ public CarrierConfig2PreferenceController(Context context) {
|
||||
+ super(context);
|
||||
+ mUm = UserManager.get(context);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void displayPreference(PreferenceScreen screen) {
|
||||
+ super.displayPreference(screen);
|
||||
+ mSecurityCategory = screen.findPreference(PREF_KEY_SECURITY_CATEGORY);
|
||||
+ updatePreferenceState();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isAvailable() {
|
||||
+ mIsAdmin = mUm.isAdminUser();
|
||||
+ return mIsAdmin;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getPreferenceKey() {
|
||||
+ return PREF_KEY_CARRIERCONFIG2_ENABLE;
|
||||
+ }
|
||||
+
|
||||
+ // TODO: should we use onCreatePreferences() instead?
|
||||
+ private void updatePreferenceState() {
|
||||
+ if (mSecurityCategory == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (mIsAdmin) {
|
||||
+ mCarrierConfig2Enable = (SwitchPreference) mSecurityCategory.findPreference(PREF_KEY_CARRIERCONFIG2_ENABLE);
|
||||
+ mCarrierConfig2Enable.setChecked(SystemProperties.getInt(SYS_KEY_CARRIERCONFIG2_ENABLE, 0) == 1);
|
||||
+ } else {
|
||||
+ mSecurityCategory.removePreference(mSecurityCategory.findPreference(PREF_KEY_CARRIERCONFIG2_ENABLE));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onResume() {
|
||||
+ updatePreferenceState();
|
||||
+ if (mCarrierConfig2Enable != null) {
|
||||
+ boolean mode = mCarrierConfig2Enable.isChecked();
|
||||
+ SystemProperties.set(SYS_KEY_CARRIERCONFIG2_ENABLE, mode ? "1" : "0");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
+ final String key = preference.getKey();
|
||||
+ if (PREF_KEY_CARRIERCONFIG2_ENABLE.equals(key)) {
|
||||
+ final boolean mode = !mCarrierConfig2Enable.isChecked();
|
||||
+ SystemProperties.set(SYS_KEY_CARRIERCONFIG2_ENABLE, mode ? "1" : "0");
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/com/android/settings/security/SecuritySettings.java b/src/com/android/settings/security/SecuritySettings.java
|
||||
index ef92897f88..b1e27f6ce2 100644
|
||||
--- a/src/com/android/settings/security/SecuritySettings.java
|
||||
+++ b/src/com/android/settings/security/SecuritySettings.java
|
||||
@@ -111,6 +111,7 @@ public class SecuritySettings extends DashboardFragment {
|
||||
securityPreferenceControllers.add(new HostsPreferenceController(context));
|
||||
securityPreferenceControllers.add(new SigSpoofPreferenceController(context));
|
||||
securityPreferenceControllers.add(new OpenEuiccPreferenceController(context));
|
||||
+ securityPreferenceControllers.add(new CarrierConfig2PreferenceController(context));
|
||||
controllers.add(new PreferenceCategoryController(context, SECURITY_CATEGORY)
|
||||
.setChildren(securityPreferenceControllers));
|
||||
controllers.addAll(securityPreferenceControllers);
|
@ -0,0 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tavi <tavi@divested.dev>
|
||||
Date: Tue, 25 Jun 2024 02:39:28 -0400
|
||||
Subject: [PATCH] Runtime control of platform carrier config package
|
||||
|
||||
Change-Id: I8cc8f2bda264bd42fe83d5c96fa6382e63a88410
|
||||
Signed-off-by: Tavi <tavi@divested.dev>
|
||||
---
|
||||
src/com/android/phone/CarrierConfigLoader.java | 11 +++++++++--
|
||||
1 file changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
|
||||
index 9a0da4bee..749df35f7 100644
|
||||
--- a/src/com/android/phone/CarrierConfigLoader.java
|
||||
+++ b/src/com/android/phone/CarrierConfigLoader.java
|
||||
@@ -43,6 +43,7 @@ import android.os.PersistableBundle;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ResultReceiver;
|
||||
+import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.service.carrier.CarrierIdentifier;
|
||||
@@ -688,8 +689,14 @@ public class CarrierConfigLoader extends ICarrierConfigLoader.Stub {
|
||||
/* package */ CarrierConfigLoader(@NonNull Context context,
|
||||
@NonNull SubscriptionInfoUpdater subscriptionInfoUpdater, @NonNull Looper looper) {
|
||||
mContext = context;
|
||||
- mPlatformCarrierConfigPackage =
|
||||
- mContext.getString(R.string.platform_carrier_config_package);
|
||||
+ if (SystemProperties.getBoolean("persist.security.carrierconfig2", false)) {
|
||||
+ mPlatformCarrierConfigPackage = "app.grapheneos.carrierconfig2";
|
||||
+ } else {
|
||||
+ //mPlatformCarrierConfigPackage = "com.android.carrierconfig";
|
||||
+ mPlatformCarrierConfigPackage =
|
||||
+ mContext.getString(R.string.platform_carrier_config_package);
|
||||
+ }
|
||||
+ Log.d("CarrierConfigPackageOverride", "Provider: " + mPlatformCarrierConfigPackage);
|
||||
mHandler = new ConfigHandler(looper);
|
||||
|
||||
IntentFilter systemEventsFilter = new IntentFilter();
|
@ -264,6 +264,7 @@ git revert --no-edit 09577521a65e1cef0560a84085fca46b1cf53803; #Fix invisible bu
|
||||
fi;
|
||||
|
||||
if enterAndClear "packages/apps/CarrierConfig2"; then
|
||||
awk -i inplace '!/overrides/' Android.bp; #Don't replace CarrierConfig
|
||||
sed -i -e '31,35d;' AndroidManifest.xml; #Fixups
|
||||
rm src/app/grapheneos/carrierconfig2/TestActivity.java src/app/grapheneos/carrierconfig2/loader/CmpTest.java;
|
||||
if [ -d "$DOS_BUILD_BASE"/vendor/divested-carriersettings ]; then sed -i 's|etc/CarrierSettings|etc/CarrierSettings2|' src/app/grapheneos/carrierconfig2/loader/CSettingsDir.java; fi; #Alter the search path
|
||||
@ -320,6 +321,7 @@ applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0014-LTE_Only_Mode-2.pat
|
||||
applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0015-SUPL_Toggle.patch"; #Add a toggle for forcibly disabling SUPL (GrapheneOS)
|
||||
applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0016-microG_Toggle.patch"; #Add a toggle for microG enablement (heavily based off of a GrapheneOS patch)
|
||||
if [ "$DOS_DEBLOBBER_REMOVE_EUICC_FULL" = false ]; then applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0017-OpenEUICC_Toggle.patch"; fi; #Add a toggle for OpenEUICC enablement (heavily based off of a GrapheneOS patch)
|
||||
if [ -d "$DOS_BUILD_BASE"/vendor/divested-carriersettings ]; then applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0018-CC2_Toggle.patch"; fi; #Add a toggle for CarrierConfig2 enablement (heavily based off of a GrapheneOS patch)
|
||||
applyPatch "$DOS_PATCHES_COMMON/android_packages_apps_Settings/0001-disable_apps.patch"; #Add an ability to disable non-system apps from the "App info" screen (GrapheneOS)
|
||||
fi;
|
||||
|
||||
@ -384,7 +386,7 @@ applyPatch "$DOS_PATCHES/android_packages_providers_DownloadProvider/0001-Networ
|
||||
fi;
|
||||
|
||||
if enterAndClear "packages/services/Telephony"; then
|
||||
if [ -d "$DOS_BUILD_BASE"/vendor/divested-carriersettings ]; then sed -i 's|com.android.carrierconfig|app.grapheneos.carrierconfig2|' res/values/config.xml; fi; #Alter the provider
|
||||
if [ -d "$DOS_BUILD_BASE"/vendor/divested-carriersettings ]; then applyPatch "$DOS_PATCHES/android_packages_services_Telephony/0001-CC2.patch"; fi; #Runtime control of platform carrier config package (DivestOS)
|
||||
fi;
|
||||
|
||||
|
||||
@ -457,7 +459,7 @@ sed -i 's/wifi,cell/internet/' overlay/common/frameworks/base/packages/SystemUI/
|
||||
sed -i 's|system/etc|$(TARGET_COPY_OUT_PRODUCT)/etc|' divestos.mk;
|
||||
if [ -d "$DOS_BUILD_BASE"/vendor/divested-carriersettings ]; then
|
||||
echo "Including CarrierConfig2 & CarrierSettings2";
|
||||
echo "ifneq ($(BOARD_WITHOUT_RADIO),true)" >> divestos.mk;
|
||||
echo 'ifneq ($(BOARD_WITHOUT_RADIO),true)' >> divestos.mk;
|
||||
echo "PRODUCT_PACKAGES += CarrierConfig2" >> divestos.mk;
|
||||
echo "include vendor/divested-carriersettings/CarrierSettings2.mk" >> divestos.mk;
|
||||
echo "endif" >> divestos.mk;
|
||||
|
Loading…
x
Reference in New Issue
Block a user