Add patch to allow disabling presidential broadcasts from GrapheneOS

Signed-off-by: Tad <tad@spotco.us>
This commit is contained in:
Tad 2023-11-05 18:12:08 -05:00
parent 01e41a26f6
commit 095d222e87
No known key found for this signature in database
GPG Key ID: B286E9F57A07424B
4 changed files with 162 additions and 1 deletions

View File

@ -75,6 +75,10 @@ https://github.com/GrapheneOS/platform_packages_apps_Settings/commit/993f35ba0d4
https://github.com/GrapheneOS/platform_packages_apps_Settings/commit/9312b4b33dc4e3bfbb2869321cdd9e965df6409a
https://github.com/GrapheneOS/platform_packages_apps_Settings/commit/10a3b946b97fe73daa342952f56ed7217ffd22cc
[implemented] presidential alert toggle
14 https://github.com/GrapheneOS/platform_packages_apps_CellBroadcastReceiver/commit/1ecefab7fdf23f687446ff1e2d72064385721b7e
13 https://github.com/GrapheneOS/platform_packages_apps_CellBroadcastReceiver/commit/0ac1c1e654abcb39effc862b49ded02fcdf859e6
[implemented] tile restrictions
13 https://github.com/GrapheneOS/platform_frameworks_base/commit/6c3be72e795b4b2de830dd981787f197cc1aa7ee
12 https://github.com/GrapheneOS/platform_frameworks_base/commit/6f7cde6351b1ba2fb0513d713ad20d42e7f18745

View File

@ -0,0 +1,154 @@
From 0ac1c1e654abcb39effc862b49ded02fcdf859e6 Mon Sep 17 00:00:00 2001
From: Daniel Micay <danielmicay@gmail.com>
Date: Sun, 13 Feb 2022 00:55:33 -0500
Subject: [PATCH] allow toggling presidential alerts
Squashed with
commit 9cf7c4504af4cf2fbe30557d488a0121939d0d4c
Author: r3g_5z <june@girlboss.ceo>
Date: Sun Mar 19 13:19:18 2023 -0400
use separate string to define presidential alerts
---
res/values/config.xml | 2 +-
res/values/strings.xml | 2 ++
res/xml/preferences.xml | 3 +--
.../CellBroadcastAlertService.java | 4 ++--
.../CellBroadcastChannelManager.java | 6 +++---
.../cellbroadcastreceiver/CellBroadcastReceiver.java | 8 ++++++++
.../cellbroadcastreceiver/CellBroadcastSettings.java | 11 ++++++++++-
7 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/res/values/config.xml b/res/values/config.xml
index c4fd6000f..09ef04845 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -22,7 +22,7 @@
<!-- Whether to show main switch settings at the top -->
<bool name="show_main_switch_settings">true</bool>
<!-- Whether to show presidential alert settings -->
- <bool name="show_presidential_alerts_settings">false</bool>
+ <bool name="show_presidential_alerts_settings">true</bool>
<!-- Whether to show extreme alert settings -->
<bool name="show_extreme_alert_settings">true</bool>
<!-- Whether to show severe alert settings -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 66a8a306c..10d43df0a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -392,4 +392,6 @@
<!-- Notification title and text when alerting user that their CB settings have changed -->
<string name="notification_cb_settings_changed_title">Settings changed by carrier</string>
<string name="notification_cb_settings_changed_text">Tap to see wireless emergency alert settings</string>
+
+ <string name="enable_cmas_presidential_alerts_summary_override">National warning messages.</string>
</resources>
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index fc0649e24..08c1ccf30 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -45,9 +45,8 @@
<!-- Show checkbox for Presidential alerts in settings -->
<SwitchPreference android:defaultValue="true"
- android:enabled="false"
android:key="enable_cmas_presidential_alerts"
- android:summary="@string/enable_cmas_presidential_alerts_summary"
+ android:summary="@string/enable_cmas_presidential_alerts_summary_override"
android:title="@string/enable_cmas_presidential_alerts_title"/>
<!-- Enable CMAS Extreme Threat alerts -->
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
index d8633bb20..70125a08d 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
@@ -522,8 +522,8 @@ && checkAlertConfigEnabled(subId,
}
// CMAS warning types
if (resourcesKey == R.array.cmas_presidential_alerts_channels_range_strings) {
- // always enabled
- return true;
+ return emergencyAlertEnabled && checkAlertConfigEnabled(
+ subId, CellBroadcastSettings.KEY_ENABLE_CMAS_PRESIDENTIAL_ALERTS, true);
}
if (resourcesKey == R.array.cmas_alert_extreme_channels_range_strings) {
return emergencyAlertEnabled && checkAlertConfigEnabled(
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java b/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java
index 973fab896..949cab2af 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java
@@ -271,9 +271,9 @@ public CellBroadcastChannelRange(Context context, int subId,
}
break;
case KEY_ALWAYS_ON:
- if (value.equalsIgnoreCase("true")) {
- mAlwaysOn = true;
- }
+ //if (value.equalsIgnoreCase("true")) {
+ //mAlwaysOn = true;
+ //}
break;
case KEY_SCREEN_ON_DURATION:
mScreenOnDuration = Integer.parseInt(value);
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
index 55f19f308..2c141d18d 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
@@ -579,6 +579,8 @@ public void handleCdmaSmsCbProgramData(ArrayList<CdmaSmsCbProgramData> programDa
break;
case CdmaSmsCbProgramData.OPERATION_CLEAR_CATEGORIES:
+ tryCdmaSetCategory(mContext,
+ CdmaSmsCbProgramData.CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT, false);
tryCdmaSetCategory(mContext,
CdmaSmsCbProgramData.CATEGORY_CMAS_EXTREME_THREAT, false);
tryCdmaSetCategory(mContext,
@@ -606,6 +608,12 @@ public void tryCdmaSetCategory(Context context, int category, boolean enable) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
switch (category) {
+ case CdmaSmsCbProgramData.CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT:
+ sharedPrefs.edit().putBoolean(
+ CellBroadcastSettings.KEY_ENABLE_CMAS_PRESIDENTIAL_ALERTS, enable)
+ .apply();
+ break;
+
case CdmaSmsCbProgramData.CATEGORY_CMAS_EXTREME_THREAT:
sharedPrefs.edit().putBoolean(
CellBroadcastSettings.KEY_ENABLE_CMAS_EXTREME_THREAT_ALERTS, enable)
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
index f8cdbb7e5..05e8af865 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
@@ -456,6 +456,9 @@ public boolean onPreferenceChange(Preference pref, Object newValue) {
if (mAreaUpdateInfoCheckBox != null) {
mAreaUpdateInfoCheckBox.setOnPreferenceChangeListener(startConfigServiceListener);
}
+ if (mPresidentialCheckBox != null) {
+ mPresidentialCheckBox.setOnPreferenceChangeListener(startConfigServiceListener);
+ }
if (mExtremeCheckBox != null) {
mExtremeCheckBox.setOnPreferenceChangeListener(startConfigServiceListener);
}
@@ -561,7 +564,9 @@ private void updatePreferenceVisibility() {
if (mPresidentialCheckBox != null) {
mPresidentialCheckBox.setVisible(
- res.getBoolean(R.bool.show_presidential_alerts_settings));
+ res.getBoolean(R.bool.show_presidential_alerts_settings)
+ && !channelManager.getCellBroadcastChannelRanges(
+ R.array.cmas_presidential_alerts_channels_range_strings).isEmpty());
}
if (mExtremeCheckBox != null) {
@@ -723,6 +728,10 @@ public boolean onPreferenceChange(Preference pref, Object newValue) {
private void setAlertsEnabled(boolean alertsEnabled) {
+ if (mPresidentialCheckBox != null) {
+ mPresidentialCheckBox.setEnabled(alertsEnabled);
+ mPresidentialCheckBox.setChecked(alertsEnabled);
+ }
if (mSevereCheckBox != null) {
mSevereCheckBox.setEnabled(alertsEnabled);
mSevereCheckBox.setChecked(alertsEnabled);

@ -1 +1 @@
Subproject commit 570ed4a10c151700210dd6b52f4f2ed62c59807c
Subproject commit b1813c51bbef0836e60871fea5e1a1880135ead3

View File

@ -275,6 +275,9 @@ fi;
#cp $DOS_PATCHES_COMMON/android_packages_apps_CarrierConfig/*.xml assets/;
#fi;
if enterAndClear "packages/apps/CellBroadcastReceiver"; then
applyPatch "$DOS_PATCHES/android_packages_apps_CellBroadcastReceiver/0001-presidential_alert_toggle.patch"; #Allow toggling presidential alertss (GrapheneOS)
if enterAndClear "packages/apps/Contacts"; then
applyPatch "$DOS_PATCHES_COMMON/android_packages_apps_Contacts/0001-No_Google_Links.patch"; #Remove Privacy Policy and Terms of Service links (GrapheneOS)
applyPatch "$DOS_PATCHES_COMMON/android_packages_apps_Contacts/0002-No_Google_Backup.patch"; #Backups are not sent to Google (GrapheneOS)