Skip to content

Commit 2278ad8

Browse files
committed
modemmanager: add TA SMS Storage support
Add support to store SMS messages on the device so they remain available across reboots, modem resets and SIM changes. Signed-off-by: Akula Susmitha <asusmith@qti.qualcomm.com>
1 parent f69d17b commit 2278ad8

11 files changed

Lines changed: 2115 additions & 0 deletions

dynamic-layers/openembedded-layer/recipes-connectivity/modemmanager/files/0001-iface-modem-messaging-sms-Add-TA-storage-support-for.patch

Lines changed: 956 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From 3011b7aaf23fb526ee9264fbaed937fec3b38512 Mon Sep 17 00:00:00 2001
2+
From: Dan Williams <dan@ioncontrol.co>
3+
Date: Tue, 17 Jun 2025 08:32:24 -0500
4+
Subject: [PATCH 02/10] fixup: move json-glib dep to root meson.build; add to
5+
libmmbase deps
6+
7+
Upstream-Status: Submitted [https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1263]
8+
---
9+
meson.build | 2 ++
10+
1 file changed, 2 insertions(+)
11+
12+
diff --git a/meson.build b/meson.build
13+
index 2a0b9734..eda009ce 100644
14+
--- a/meson.build
15+
+++ b/meson.build
16+
@@ -296,6 +296,8 @@ if enable_gir
17+
dependency('gobject-introspection-1.0', version: '>= 0.9.6')
18+
endif
19+
20+
+json_glib_dep = dependency('json-glib-1.0', version: '>= 1.0')
21+
+
22+
# vala support
23+
enable_vapi = get_option('vapi')
24+
25+
--
26+
2.34.1
27+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From aa13b855374e86acf61aedc6ba14c274e386a1f0 Mon Sep 17 00:00:00 2001
2+
From: Dan Williams <dan@ioncontrol.co>
3+
Date: Mon, 23 Jun 2025 09:45:06 -0500
4+
Subject: [PATCH 03/10] whitespace cleanup
5+
6+
Upstream-Status: Submitted [https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1263]
7+
---
8+
src/mm-iface-modem-messaging.c | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c
12+
index 593cc95b..6b184c9e 100644
13+
--- a/src/mm-iface-modem-messaging.c
14+
+++ b/src/mm-iface-modem-messaging.c
15+
@@ -1070,7 +1070,7 @@ interface_enabling_step (GTask *task)
16+
17+
/* Update storage with default_storage variable */
18+
if (!mm_sms_update_default_storage_type (default_storage, &error)) {
19+
- mm_obj_warn (self, "could not update default_storage in storage: %s", error->message);
20+
+ mm_obj_warn (self, "could not update default_storage in storage: %s", error->message);
21+
}
22+
23+
if (default_storage == MM_SMS_STORAGE_UNKNOWN)
24+
--
25+
2.34.1
26+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
From 94b072b2bfc766b9c8d2288d324d77d3a4ebcef6 Mon Sep 17 00:00:00 2001
2+
From: Dan Williams <dan@ioncontrol.co>
3+
Date: Mon, 23 Jun 2025 09:46:01 -0500
4+
Subject: [PATCH 04/10] whitespace cleanup; fix error freeing
5+
6+
Need to have the error freed each element of the list, rather than once
7+
for all of them.
8+
9+
Upstream-Status: Submitted [https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1263]
10+
---
11+
src/mm-broadband-modem-qmi.c | 66 ++++++++++++++++++++----------------
12+
1 file changed, 37 insertions(+), 29 deletions(-)
13+
14+
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
15+
index 746d98f7..6c871458 100644
16+
--- a/src/mm-broadband-modem-qmi.c
17+
+++ b/src/mm-broadband-modem-qmi.c
18+
@@ -8187,44 +8187,52 @@ mm_create_sms_part_from_pdu (guint index,
19+
static void
20+
load_messages_from_ta_storage (GTask *task)
21+
{
22+
- MMBroadbandModemQmi *self;
23+
+ MMBroadbandModemQmi *self;
24+
LoadInitialSmsPartsContext *ctx;
25+
- GList *indexs, *l;
26+
- gchar *pdu;
27+
- MMSmsState state;
28+
- g_autoptr(GError) error = NULL;
29+
+ GList *indexes, *l;
30+
+ gchar *pdu;
31+
+ MMSmsState state;
32+
33+
self = g_task_get_source_object (task);
34+
ctx = g_task_get_task_data (task);
35+
mm_obj_dbg (self, "load_messages_from_ta_storage");
36+
+
37+
/* read all indexes from storage */
38+
- indexs = mm_sms_storage_read_all_indexes (&error);
39+
+ indexes = mm_sms_storage_read_all_indexes (&error);
40+
+ for (l = indexes; l; l = g_list_next (l)) {
41+
+ guint msg_index = GPOINTER_TO_UINT (l->data);
42+
+ MMSmsPart *part;
43+
+ g_autoptr(GError) error = NULL;
44+
+
45+
+ if (!mm_sms_storage_read_message (msg_index, &pdu, &state, &error)) {
46+
+ mm_obj_warn (self,
47+
+ "Failed to read the SMS (%d) from storage: %s",
48+
+ msg_index,
49+
+ error->message);
50+
+ continue;
51+
+ }
52+
53+
- for (l = indexs; l; l = g_list_next (l))
54+
- {
55+
- guint msg_index = GPOINTER_TO_UINT (l->data);
56+
- if (mm_sms_storage_read_message (msg_index, &pdu, &state, &error)) {
57+
-
58+
- MMSmsPart *part;
59+
- part = mm_create_sms_part_from_pdu (msg_index, (const char *)pdu, state, self, &error);
60+
- if (part) {
61+
- mm_obj_dbg (self, "correctly parsed PDU (%d)", msg_index);
62+
- mm_iface_modem_messaging_take_part (MM_IFACE_MODEM_MESSAGING (self),
63+
- mm_broadband_modem_create_sms (MM_BROADBAND_MODEM (MM_IFACE_MODEM_MESSAGING(self))),
64+
- part,
65+
- state != MM_SMS_STATE_UNKNOWN ? state: MM_SMS_STATE_STORED,
66+
- ctx->storage,
67+
- &error);
68+
- } else {
69+
- /* Don't treat the error as critical */
70+
- mm_obj_dbg (self, "error parsing PDU (%d): %s", msg_index, error->message);
71+
- }
72+
- } else {
73+
- mm_obj_warn (self, "Failed to read the messages");
74+
+ part = mm_create_sms_part_from_pdu (msg_index, pdu, state, self, &error);
75+
+ if (!part) {
76+
+ /* Don't treat the error as critical */
77+
+ mm_obj_dbg (self, "error parsing SMS (%d) PDU: %s", msg_index, error->message);
78+
+ continue;
79+
}
80+
- }
81+
82+
- g_task_return_boolean (task, TRUE);
83+
+ mm_obj_dbg (self, "parsed SMS (%d) PDU", msg_index);
84+
+ if (!mm_iface_modem_messaging_take_part (MM_IFACE_MODEM_MESSAGING (self),
85+
+ part,
86+
+ state != MM_SMS_STATE_UNKNOWN ? state : MM_SMS_STATE_STORED,
87+
+ ctx->storage)) {
88+
+ /* Don't treat the error as critical */
89+
+ mm_obj_dbg (self,
90+
+ "error adding SMS (%d): %s",
91+
+ msg_index,
92+
+ error->message);
93+
+ }
94+
+ }
95+
+
96+
+ g_task_return_boolean (task, TRUE);
97+
}
98+
99+
static void
100+
--
101+
2.34.1
102+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
From 6fe58b58a302696625082bba48b3cbb70684c551 Mon Sep 17 00:00:00 2001
2+
From: Dan Williams <dan@ioncontrol.co>
3+
Date: Mon, 23 Jun 2025 09:47:24 -0500
4+
Subject: [PATCH 05/10] remove dead code
5+
6+
Upstream-Status: Submitted [https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1263]
7+
---
8+
src/mm-broadband-modem-qmi.c | 21 ---------------------
9+
1 file changed, 21 deletions(-)
10+
11+
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
12+
index 6c871458..76761c20 100644
13+
--- a/src/mm-broadband-modem-qmi.c
14+
+++ b/src/mm-broadband-modem-qmi.c
15+
@@ -8162,28 +8162,7 @@ wms_list_messages_ready (QmiClientWms *client,
16+
ctx->i = 0;
17+
read_next_sms_part (task);
18+
}
19+
-#if 0
20+
-static MMSmsPart *
21+
-mm_create_sms_part_from_pdu (guint index,
22+
- const gchar *hexpdu,
23+
- MMSmsState state,
24+
- gpointer log_object,
25+
- GError **error)
26+
-{
27+
- g_autofree guint8 *pdu = NULL;
28+
- gsize pdu_len;
29+
-
30+
- /* Convert PDU from hex to binary */
31+
- pdu = mm_utils_hexstr2bin (hexpdu, -1, &pdu_len, error);
32+
- if (!pdu) {
33+
- g_prefix_error (error, "Couldn't convert 3GPP PDU from hex to binary: ");
34+
- return NULL;
35+
- }
36+
37+
- return mm_sms_part_3gpp_new_from_binary_pdu (index, pdu, pdu_len, log_object,
38+
- state == MM_SMS_STATE_RECEIVED, error);
39+
-}
40+
-#endif
41+
static void
42+
load_messages_from_ta_storage (GTask *task)
43+
{
44+
--
45+
2.34.1
46+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From eaff75d8dacaf438dd0cceaadbc071d4baa14af0 Mon Sep 17 00:00:00 2001
2+
From: Dan Williams <dan@ioncontrol.co>
3+
Date: Mon, 23 Jun 2025 10:34:16 -0500
4+
Subject: [PATCH 06/10] qmi error free fixup
5+
6+
Upstream-Status: Submitted [https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1263]
7+
---
8+
src/mm-broadband-modem-qmi.c | 8 +++++++-
9+
1 file changed, 7 insertions(+), 1 deletion(-)
10+
11+
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
12+
index 76761c20..1a0040d8 100644
13+
--- a/src/mm-broadband-modem-qmi.c
14+
+++ b/src/mm-broadband-modem-qmi.c
15+
@@ -8171,13 +8171,19 @@ load_messages_from_ta_storage (GTask *task)
16+
GList *indexes, *l;
17+
gchar *pdu;
18+
MMSmsState state;
19+
+ g_autoptr(GError) read_error = NULL;
20+
21+
self = g_task_get_source_object (task);
22+
ctx = g_task_get_task_data (task);
23+
mm_obj_dbg (self, "load_messages_from_ta_storage");
24+
25+
/* read all indexes from storage */
26+
- indexes = mm_sms_storage_read_all_indexes (&error);
27+
+ indexes = mm_sms_storage_read_all_indexes (&read_error);
28+
+ if (read_error) {
29+
+ mm_obj_warn (self, "Failed to load SMS storage: %s", read_error->message);
30+
+ return;
31+
+ }
32+
+
33+
for (l = indexes; l; l = g_list_next (l)) {
34+
guint msg_index = GPOINTER_TO_UINT (l->data);
35+
MMSmsPart *part;
36+
--
37+
2.34.1
38+

0 commit comments

Comments
 (0)