Merge lp:~phablet-team/ofono/midori-support into lp:~phablet-team/ofono/ubuntu

Proposed by Alfonso Sanchez-Beato on 2016-06-28
Status: Merged
Approved by: Jim Hodapp on 2016-07-04
Approved revision: 6919
Merged at revision: 6916
Proposed branch: lp:~phablet-team/ofono/midori-support
Merge into: lp:~phablet-team/ofono/ubuntu
Diff against target: 3276 lines (+1954/-264)
48 files modified
Makefile.am (+14/-1)
debian/changelog (+17/-0)
drivers/mtk2modem/gprs.c (+88/-0)
drivers/mtk2modem/mtk2_constants.h (+148/-0)
drivers/mtk2modem/mtk2modem.c (+55/-0)
drivers/mtk2modem/mtk2modem.h (+28/-0)
drivers/mtk2modem/mtk2util.c (+275/-0)
drivers/mtk2modem/mtk2util.h (+39/-0)
drivers/mtk2modem/voicecall.c (+149/-0)
drivers/mtkmodem/mtkunsol.c (+17/-7)
drivers/qcommsimmodem/gprs.c (+118/-0)
drivers/qcommsimmodem/qcom_msim_constants.h (+2/-1)
drivers/qcommsimmodem/qcom_msim_modem.c (+2/-0)
drivers/qcommsimmodem/qcom_msim_modem.h (+3/-0)
drivers/rilmodem/call-barring.c (+1/-0)
drivers/rilmodem/call-forwarding.c (+1/-0)
drivers/rilmodem/call-settings.c (+1/-0)
drivers/rilmodem/call-volume.c (+1/-0)
drivers/rilmodem/devinfo.c (+1/-0)
drivers/rilmodem/gprs.c (+139/-53)
drivers/rilmodem/gprs.h (+2/-0)
drivers/rilmodem/network-registration.c (+2/-0)
drivers/rilmodem/phonebook.c (+1/-0)
drivers/rilmodem/radio-settings.c (+56/-4)
drivers/rilmodem/rilmodem.h (+0/-2)
drivers/rilmodem/sim.c (+3/-1)
drivers/rilmodem/sms.c (+1/-0)
drivers/rilmodem/ussd.c (+6/-2)
drivers/rilmodem/vendor.h (+2/-1)
drivers/rilmodem/voicecall.c (+1/-0)
gril/grilreply.c (+106/-5)
gril/grilreply.h (+12/-0)
gril/grilrequest.c (+34/-13)
gril/grilunsol.c (+11/-1)
gril/grilutil.c (+107/-1)
gril/grilutil.h (+2/-0)
gril/ril_constants.h (+70/-0)
include/modem.h (+0/-5)
plugins/infineon.c (+2/-1)
plugins/mtk.c (+1/-6)
plugins/mtk2.c (+93/-0)
plugins/qcom-msim.c (+16/-1)
plugins/ril.c (+291/-139)
plugins/ril.h (+8/-1)
plugins/rildev.c (+9/-2)
src/gprs.c (+10/-3)
src/modem.c (+0/-8)
src/voicecall.c (+9/-6)
To merge this branch: bzr merge lp:~phablet-team/ofono/midori-support
Reviewer Review Type Date Requested Status
Jim Hodapp (community) Approve on 2016-07-04
Konrad Zapałowicz (community) code 2016-06-28 Needs Information on 2016-06-29
Review via email: mp+298542@code.launchpad.net

Description of the change

[ Ratchanan Srirattanamet ]
* qcommsimmodem: fix slot selection for cellular data
[ Alfonso Sanchez-Beato ]
* gril: update requests to M
* ril: refactor management of radio power states
* mtk2: new driver to support midori
* Fix cellular data switch in turbo (LP: #1592258)
* Fix ofono re-starts on boot in turbo (LP: #1580908)
[ Rex Tsai ]
voicecall: add emergency numbers required for China Market

To post a comment you must log in.
Konrad Zapałowicz (kzapalowicz) wrote :

LGTM however I have a few uncertainties - check the questions in comments.

review: Needs Information (code)
6917. By Alfonso Sanchez-Beato on 2016-06-30

Create radio settings atom in pre-sim state so we can set FastDormancy and
enter low power state even when there is no SIM.

@Konrad, thanks for the comments, I have answered them below. Note however that for historical reasons in ofono we do usually the reviews in our github repo, and import the code to bzr when merged there. For this branch, we had PR https://github.com/rilmodem/ofono/pull/240 . Usually here we just make sure that changelog and other contents in debian/ (which are not in github) are good.

6918. By Alfonso Sanchez-Beato on 2016-06-30

Fix turbo regressions

6919. By Alfonso Sanchez-Beato on 2016-07-01

[ Rex Tsai ]
voicecall: add emergency numbers required for China Market

Jim Hodapp (jhodapp) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2016-03-14 08:16:40 +0000
3+++ Makefile.am 2016-07-01 17:24:58 +0000
4@@ -135,6 +135,9 @@
5 builtin_modules += mtk
6 builtin_sources += plugins/mtk.c
7
8+builtin_modules += mtk2
9+builtin_sources += plugins/mtk2.c
10+
11 builtin_modules += infineon
12 builtin_sources += plugins/infineon.c
13
14@@ -160,6 +163,15 @@
15 drivers/mtkmodem/radio-settings.c \
16 drivers/mtkmodem/mtksettings.c
17
18+builtin_modules += mtk2modem
19+builtin_sources += drivers/mtk2modem/mtk2modem.h \
20+ drivers/mtk2modem/mtk2modem.c \
21+ drivers/mtk2modem/mtk2_constants.h \
22+ drivers/mtk2modem/mtk2util.h \
23+ drivers/mtk2modem/mtk2util.c \
24+ drivers/mtk2modem/voicecall.c \
25+ drivers/mtk2modem/gprs.c
26+
27 builtin_modules += rilmodem
28 builtin_sources += drivers/rilmodem/rilmodem.h \
29 drivers/rilmodem/vendor.h \
30@@ -183,7 +195,8 @@
31
32 builtin_modules += qcommsimmodem
33 builtin_sources += drivers/qcommsimmodem/qcom_msim_modem.c \
34- drivers/qcommsimmodem/radio-settings.c
35+ drivers/qcommsimmodem/radio-settings.c \
36+ drivers/qcommsimmodem/gprs.c
37 endif
38
39 if ISIMODEM
40
41=== modified file 'debian/changelog'
42--- debian/changelog 2016-04-13 14:43:54 +0000
43+++ debian/changelog 2016-07-01 17:24:58 +0000
44@@ -1,3 +1,20 @@
45+ofono (1.17.bzr6919+16.10.20160701.1-0ubuntu1) UNRELEASED; urgency=medium
46+
47+ [ Ratchanan Srirattanamet ]
48+ * qcommsimmodem: fix slot selection for cellular data
49+
50+ [ Alfonso Sanchez-Beato ]
51+ * gril: update requests to M
52+ * ril: refactor management of radio power states
53+ * mtk2: new driver to support midori
54+ * Fix cellular data switch in turbo (LP: #1592258)
55+ * Fix ofono re-starts on boot in turbo (LP: #1580908)
56+
57+ [ Rex Tsai ]
58+ * voicecall: add emergency numbers required for China Market
59+
60+ -- Alfonso Sanchez-Beato (email Canonical) <alfonso.sanchez-beato@canonical.com> Fri, 01 Jul 2016 17:17:05 +0200
61+
62 ofono (1.17.bzr6914+16.04.20160413.1-0ubuntu1) xenial; urgency=medium
63
64 [ Alfonso Sanchez-Beato (email Canonical) ]
65
66=== added directory 'drivers/mtk2modem'
67=== added file 'drivers/mtk2modem/gprs.c'
68--- drivers/mtk2modem/gprs.c 1970-01-01 00:00:00 +0000
69+++ drivers/mtk2modem/gprs.c 2016-07-01 17:24:58 +0000
70@@ -0,0 +1,88 @@
71+/*
72+ *
73+ * oFono - Open Source Telephony
74+ *
75+ * Copyright (C) 2016 Canonical Ltd.
76+ *
77+ * This program is free software; you can redistribute it and/or modify
78+ * it under the terms of the GNU General Public License version 2 as
79+ * published by the Free Software Foundation.
80+ *
81+ * This program is distributed in the hope that it will be useful,
82+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
83+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84+ * GNU General Public License for more details.
85+ *
86+ * You should have received a copy of the GNU General Public License
87+ * along with this program; if not, write to the Free Software
88+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
89+ *
90+ */
91+
92+#ifdef HAVE_CONFIG_H
93+#include <config.h>
94+#endif
95+
96+#define _GNU_SOURCE
97+#include <errno.h>
98+
99+#include <glib.h>
100+
101+#include <ofono/modem.h>
102+#include <ofono/gprs.h>
103+
104+#include "common.h"
105+
106+#include "mtk2util.h"
107+#include "mtk2modem.h"
108+#include "mtk2_constants.h"
109+#include "drivers/mtkmodem/mtkunsol.h"
110+#include "drivers/rilmodem/rilutil.h"
111+#include "drivers/rilmodem/gprs.h"
112+
113+/*
114+ * This module is the ofono_gprs_driver implementation for mtk2modem. Most of
115+ * the implementation can be found in the rilmodem gprs atom. The main reason
116+ * for creating a new atom is the need to handle specific MTK requests.
117+ */
118+
119+static int mtk2_gprs_probe(struct ofono_gprs *gprs,
120+ unsigned int vendor, void *data)
121+{
122+ struct ril_gprs_driver_data *driver_data = data;
123+ struct ril_gprs_data *gd;
124+
125+ gd = g_try_new0(struct ril_gprs_data, 1);
126+ if (gd == NULL)
127+ return -ENOMEM;
128+
129+ ril_gprs_start(driver_data, gprs, gd);
130+
131+ /*
132+ * In MTK the event emitted when the gprs state changes is different
133+ * from the one in AOSP ril. Overwrite the one set in parent.
134+ */
135+ gd->state_changed_unsol =
136+ MTK2_RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED;
137+
138+ return 0;
139+}
140+
141+static struct ofono_gprs_driver driver = {
142+ .name = MTK2MODEM,
143+ .probe = mtk2_gprs_probe,
144+ .remove = ril_gprs_remove,
145+ .set_attached = ril_gprs_set_attached,
146+ .attached_status = ril_gprs_registration_status,
147+ .set_ia_apn = ril_gprs_set_ia_apn,
148+};
149+
150+void mtk2_gprs_init(void)
151+{
152+ ofono_gprs_driver_register(&driver);
153+}
154+
155+void mtk2_gprs_exit(void)
156+{
157+ ofono_gprs_driver_unregister(&driver);
158+}
159
160=== added file 'drivers/mtk2modem/mtk2_constants.h'
161--- drivers/mtk2modem/mtk2_constants.h 1970-01-01 00:00:00 +0000
162+++ drivers/mtk2modem/mtk2_constants.h 2016-07-01 17:24:58 +0000
163@@ -0,0 +1,148 @@
164+/*
165+ *
166+ * RIL constants for MTK modem
167+ *
168+ * Copyright (C) 2016 Canonical Ltd.
169+ *
170+ * This program is free software; you can redistribute it and/or modify
171+ * it under the terms of the GNU General Public License version 2 as
172+ * published by the Free Software Foundation.
173+ *
174+ * This program is distributed in the hope that it will be useful,
175+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
176+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
177+ * GNU General Public License for more details.
178+ *
179+ * You should have received a copy of the GNU General Public License
180+ * along with this program; if not, write to the Free Software
181+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
182+ *
183+ */
184+
185+#ifndef MTK2_CONSTANTS_H
186+#define MTK2_CONSTANTS_H
187+
188+/* RIL Request Messages */
189+#define MTK2_RIL_REQUEST_MODEM_POWEROFF 2010
190+#define MTK2_RIL_REQUEST_DUAL_SIM_MODE_SWITCH 2011
191+#define MTK2_RIL_REQUEST_SET_GPRS_CONNECT_TYPE 2015
192+#define MTK2_RIL_REQUEST_SET_GPRS_TRANSFER_TYPE 2016
193+#define MTK2_RIL_REQUEST_MODEM_POWERON 2028
194+#define MTK2_RIL_REQUEST_SET_CALL_INDICATION 2086
195+#define MTK2_RIL_REQUEST_GET_PHONE_CAPABILITY 2030
196+#define MTK2_RIL_REQUEST_SET_PHONE_CAPABILITY 2031
197+#define MTK2_RIL_REQUEST_SET_TRM 2043
198+#define MTK2_RIL_REQUEST_SET_FD_MODE 2061
199+#define MTK2_RIL_REQUEST_RESUME_REGISTRATION 2065
200+#define MTK2_RIL_REQUEST_STORE_MODEM_TYPE 2066
201+#define MTK2_RIL_REQUEST_QUERY_MODEM_TYPE 2067
202+#define MTK2_RIL_REQUEST_SET_DATA_ON_TO_MD 2111
203+
204+/* RIL Unsolicited Messages */
205+#define MTK2_RIL_UNSOL_MTK_BASE 3000
206+
207+#define MTK2_RIL_UNSOL_NEIGHBORING_CELL_INFO (MTK2_RIL_UNSOL_MTK_BASE + 0)
208+#define MTK2_RIL_UNSOL_NETWORK_INFO (MTK2_RIL_UNSOL_MTK_BASE + 1)
209+#define MTK2_RIL_UNSOL_PHB_READY_NOTIFICATION (MTK2_RIL_UNSOL_MTK_BASE + 2)
210+#define MTK2_RIL_UNSOL_SIM_INSERTED_STATUS (MTK2_RIL_UNSOL_MTK_BASE + 3)
211+#define MTK2_RIL_UNSOL_RADIO_TEMPORARILY_UNAVAILABLE (MTK2_RIL_UNSOL_MTK_BASE + 4)
212+#define MTK2_RIL_UNSOL_ME_SMS_STORAGE_FULL (MTK2_RIL_UNSOL_MTK_BASE + 5)
213+#define MTK2_RIL_UNSOL_SMS_READY_NOTIFICATION (MTK2_RIL_UNSOL_MTK_BASE + 6)
214+#define MTK2_RIL_UNSOL_SCRI_RESULT (MTK2_RIL_UNSOL_MTK_BASE + 7)
215+#define MTK2_RIL_UNSOL_SIM_MISSING (MTK2_RIL_UNSOL_MTK_BASE + 8)
216+#define MTK2_RIL_UNSOL_GPRS_DETACH (MTK2_RIL_UNSOL_MTK_BASE + 9)
217+#define MTK2_RIL_UNSOL_ATCI_RESPONSE (MTK2_RIL_UNSOL_MTK_BASE + 10)
218+#define MTK2_RIL_UNSOL_SIM_RECOVERY (MTK2_RIL_UNSOL_MTK_BASE + 11)
219+#define MTK2_RIL_UNSOL_VIRTUAL_SIM_ON (MTK2_RIL_UNSOL_MTK_BASE + 12)
220+#define MTK2_RIL_UNSOL_VIRTUAL_SIM_OFF (MTK2_RIL_UNSOL_MTK_BASE + 13)
221+#define MTK2_RIL_UNSOL_INVALID_SIM (MTK2_RIL_UNSOL_MTK_BASE + 14)
222+#define MTK2_RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED (MTK2_RIL_UNSOL_MTK_BASE + 15)
223+#define MTK2_RIL_UNSOL_RESPONSE_ACMT (MTK2_RIL_UNSOL_MTK_BASE + 16)
224+#define MTK2_RIL_UNSOL_EF_CSP_PLMN_MODE_BIT (MTK2_RIL_UNSOL_MTK_BASE + 17)
225+#define MTK2_RIL_UNSOL_IMEI_LOCK (MTK2_RIL_UNSOL_MTK_BASE + 18)
226+#define MTK2_RIL_UNSOL_RESPONSE_MMRR_STATUS_CHANGED (MTK2_RIL_UNSOL_MTK_BASE + 19)
227+#define MTK2_RIL_UNSOL_SIM_PLUG_OUT (MTK2_RIL_UNSOL_MTK_BASE + 20)
228+#define MTK2_RIL_UNSOL_SIM_PLUG_IN (MTK2_RIL_UNSOL_MTK_BASE + 21)
229+#define MTK2_RIL_UNSOL_RESPONSE_ETWS_NOTIFICATION (MTK2_RIL_UNSOL_MTK_BASE + 22)
230+#define MTK2_RIL_UNSOL_RESPONSE_PLMN_CHANGED (MTK2_RIL_UNSOL_MTK_BASE + 23)
231+#define MTK2_RIL_UNSOL_RESPONSE_REGISTRATION_SUSPENDED (MTK2_RIL_UNSOL_MTK_BASE + 24)
232+#define MTK2_RIL_UNSOL_STK_EVDL_CALL (MTK2_RIL_UNSOL_MTK_BASE + 25)
233+#define MTK2_RIL_UNSOL_DATA_PACKETS_FLUSH (MTK2_RIL_UNSOL_MTK_BASE + 26)
234+#define MTK2_RIL_UNSOL_FEMTOCELL_INFO (MTK2_RIL_UNSOL_MTK_BASE + 27)
235+#define MTK2_RIL_UNSOL_STK_SETUP_MENU_RESET (MTK2_RIL_UNSOL_MTK_BASE + 28)
236+#define MTK2_RIL_UNSOL_APPLICATION_SESSION_ID_CHANGED (MTK2_RIL_UNSOL_MTK_BASE + 29)
237+#define MTK2_RIL_UNSOL_ECONF_SRVCC_INDICATION (MTK2_RIL_UNSOL_MTK_BASE + 30)
238+#define MTK2_RIL_UNSOL_IMS_ENABLE_DONE (MTK2_RIL_UNSOL_MTK_BASE + 31)
239+#define MTK2_RIL_UNSOL_IMS_DISABLE_DONE (MTK2_RIL_UNSOL_MTK_BASE + 32)
240+#define MTK2_RIL_UNSOL_IMS_REGISTRATION_INFO (MTK2_RIL_UNSOL_MTK_BASE + 33)
241+#define MTK2_RIL_UNSOL_DEDICATE_BEARER_ACTIVATED (MTK2_RIL_UNSOL_MTK_BASE + 34)
242+#define MTK2_RIL_UNSOL_DEDICATE_BEARER_MODIFIED (MTK2_RIL_UNSOL_MTK_BASE + 35)
243+#define MTK2_RIL_UNSOL_DEDICATE_BEARER_DEACTIVATED (MTK2_RIL_UNSOL_MTK_BASE + 36)
244+#define MTK2_RIL_UNSOL_RAC_UPDATE (MTK2_RIL_UNSOL_MTK_BASE + 37)
245+#define MTK2_RIL_UNSOL_ECONF_RESULT_INDICATION (MTK2_RIL_UNSOL_MTK_BASE + 38)
246+#define MTK2_RIL_UNSOL_MELOCK_NOTIFICATION (MTK2_RIL_UNSOL_MTK_BASE + 39)
247+#define MTK2_RIL_UNSOL_CALL_FORWARDING (MTK2_RIL_UNSOL_MTK_BASE + 40)
248+#define MTK2_RIL_UNSOL_CRSS_NOTIFICATION (MTK2_RIL_UNSOL_MTK_BASE + 41)
249+#define MTK2_RIL_UNSOL_INCOMING_CALL_INDICATION (MTK2_RIL_UNSOL_MTK_BASE + 42)
250+#define MTK2_RIL_UNSOL_CIPHER_INDICATION (MTK2_RIL_UNSOL_MTK_BASE + 43)
251+#define MTK2_RIL_UNSOL_CNAP (MTK2_RIL_UNSOL_MTK_BASE + 44)
252+#define MTK2_RIL_UNSOL_SIM_COMMON_SLOT_NO_CHANGED (MTK2_RIL_UNSOL_MTK_BASE + 45)
253+#define MTK2_RIL_UNSOL_DATA_ALLOWED (MTK2_RIL_UNSOL_MTK_BASE + 46)
254+#define MTK2_RIL_UNSOL_STK_CALL_CTRL (MTK2_RIL_UNSOL_MTK_BASE + 47)
255+#define MTK2_RIL_UNSOL_VOLTE_EPS_NETWORK_FEATURE_SUPPORT (MTK2_RIL_UNSOL_MTK_BASE + 48)
256+#define MTK2_RIL_UNSOL_CALL_INFO_INDICATION (MTK2_RIL_UNSOL_MTK_BASE + 49)
257+#define MTK2_RIL_UNSOL_VOLTE_EPS_NETWORK_FEATURE_INFO (MTK2_RIL_UNSOL_MTK_BASE + 50)
258+#define MTK2_RIL_UNSOL_SRVCC_HANDOVER_INFO_INDICATION (MTK2_RIL_UNSOL_MTK_BASE + 51)
259+#define MTK2_RIL_UNSOL_SPEECH_CODEC_INFO (MTK2_RIL_UNSOL_MTK_BASE + 52)
260+#define MTK2_RIL_UNSOL_MD_STATE_CHANGE (MTK2_RIL_UNSOL_MTK_BASE + 53)
261+#define MTK2_RIL_UNSOL_REMOVE_RESTRICT_EUTRAN (MTK2_RIL_UNSOL_MTK_BASE + 54)
262+#define MTK2_RIL_UNSOL_MO_DATA_BARRING_INFO (MTK2_RIL_UNSOL_MTK_BASE + 55)
263+#define MTK2_RIL_UNSOL_SSAC_BARRING_INFO (MTK2_RIL_UNSOL_MTK_BASE + 56)
264+#define MTK2_RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR (MTK2_RIL_UNSOL_MTK_BASE + 57)
265+#define MTK2_RIL_UNSOL_ABNORMAL_EVENT (MTK2_RIL_UNSOL_MTK_BASE + 58)
266+#define MTK2_RIL_UNSOL_EMERGENCY_BEARER_SUPPORT_NOTIFY (MTK2_RIL_UNSOL_MTK_BASE + 59)
267+#define MTK2_RIL_UNSOL_INTER_3GPP_IRAT_STATE_CHANGE (MTK2_RIL_UNSOL_MTK_BASE + 60)
268+#define MTK2_RIL_UNSOL_LTE_BG_SEARCH_STATUS (MTK2_RIL_UNSOL_MTK_BASE + 61)
269+#define MTK2_RIL_UNSOL_GMSS_RAT_CHANGED (MTK2_RIL_UNSOL_MTK_BASE + 62)
270+#define MTK2_RIL_UNSOL_CDMA_CARD_TYPE (MTK2_RIL_UNSOL_MTK_BASE + 63)
271+#define MTK2_RIL_UNSOL_IMS_ENABLE_START (MTK2_RIL_UNSOL_MTK_BASE + 64)
272+#define MTK2_RIL_UNSOL_IMS_DISABLE_START (MTK2_RIL_UNSOL_MTK_BASE + 65)
273+#define MTK2_RIL_UNSOL_IMSI_REFRESH_DONE (MTK2_RIL_UNSOL_MTK_BASE + 66)
274+#define MTK2_RIL_UNSOL_EUSIM_READY (MTK2_RIL_UNSOL_MTK_BASE + 67)
275+#define MTK2_RIL_UNSOL_STK_BIP_PROACTIVE_COMMAND (MTK2_RIL_UNSOL_MTK_BASE + 68)
276+#define MTK2_RIL_UNSOL_WORLD_MODE_CHANGED (MTK2_RIL_UNSOL_MTK_BASE + 69)
277+#define MTK2_RIL_UNSOL_VT_STATUS_INFO (MTK2_RIL_UNSOL_MTK_BASE + 70)
278+#define MTK2_RIL_UNSOL_VT_RING_INFO (MTK2_RIL_UNSOL_MTK_BASE + 71)
279+#define MTK2_RIL_UNSOL_VSIM_OPERATION_INDICATION (MTK2_RIL_UNSOL_MTK_BASE + 72)
280+#define MTK2_RIL_UNSOL_SET_ATTACH_APN (MTK2_RIL_UNSOL_MTK_BASE + 73)
281+#define MTK2_RIL_UNSOL_MAL_AT_INFO (MTK2_RIL_UNSOL_MTK_BASE + 74)
282+#define MTK2_RIL_UNSOL_MAIN_SIM_INFO (MTK2_RIL_UNSOL_MTK_BASE + 75)
283+#define MTK2_RIL_UNSOL_TRAY_PLUG_IN (MTK2_RIL_UNSOL_MTK_BASE + 76)
284+#define MTK2_RIL_UNSOL_CALLMOD_CHANGE_INDICATOR (MTK2_RIL_UNSOL_MTK_BASE + 77)
285+#define MTK2_RIL_UNSOL_VIDEO_CAPABILITY_INDICATOR (MTK2_RIL_UNSOL_MTK_BASE + 78)
286+#define MTK2_RIL_UNSOL_LTE_ACCESS_STRATUM_STATE_CHANGE (MTK2_RIL_UNSOL_MTK_BASE + 79)
287+#define MTK2_RIL_UNSOL_SETUP_DATA_CALL_RESPONSE (MTK2_RIL_UNSOL_MTK_BASE + 80)
288+#define MTK2_RIL_UNSOL_ON_USSI (MTK2_RIL_UNSOL_MTK_BASE + 81)
289+#define MTK2_RIL_UNSOL_CDMA_CALL_ACCEPTED (MTK2_RIL_UNSOL_MTK_BASE + 82)
290+#define MTK2_RIL_UNSOL_UTK_SESSION_END (MTK2_RIL_UNSOL_MTK_BASE + 83)
291+#define MTK2_RIL_UNSOL_UTK_PROACTIVE_COMMAND (MTK2_RIL_UNSOL_MTK_BASE + 84)
292+#define MTK2_RIL_UNSOL_UTK_EVENT_NOTIFY (MTK2_RIL_UNSOL_MTK_BASE + 85)
293+#define MTK2_RIL_UNSOL_VIA_GPS_EVENT (MTK2_RIL_UNSOL_MTK_BASE + 86)
294+#define MTK2_RIL_UNSOL_VIA_NETWORK_TYPE_CHANGE (MTK2_RIL_UNSOL_MTK_BASE + 87)
295+#define MTK2_RIL_UNSOL_CDMA_PLMN_CHANGED (MTK2_RIL_UNSOL_MTK_BASE + 88)
296+#define MTK2_RIL_UNSOL_VIA_INVALID_SIM_DETECTED (MTK2_RIL_UNSOL_MTK_BASE + 89)
297+#define MTK2_RIL_UNSOL_ENG_MODE_NETWORK_INFO (MTK2_RIL_UNSOL_MTK_BASE + 90)
298+#define MTK2_RIL_UNSOL_RESPONSE_DATA_NETWORK_TYPE_CHANGED (MTK2_RIL_UNSOL_MTK_BASE + 91)
299+#define MTK2_RIL_UNSOL_LTE_EARFCN_INFO (MTK2_RIL_UNSOL_MTK_BASE + 92)
300+#define MTK2_RIL_UNSOL_CDMA_IMSI_READY (MTK2_RIL_UNSOL_MTK_BASE + 93)
301+#define MTK2_RIL_UNSOL_CDMA_SIGNAL_FADE (MTK2_RIL_UNSOL_MTK_BASE + 94)
302+#define MTK2_RIL_UNSOL_CDMA_TONE_SIGNALS (MTK2_RIL_UNSOL_MTK_BASE + 95)
303+#define MTK2_RIL_UNSOL_NETWORK_EXIST (MTK2_RIL_UNSOL_MTK_BASE + 96)
304+#define MTK2_RIL_UNSOL_MODULATION_INFO (MTK2_RIL_UNSOL_MTK_BASE + 97)
305+#define MTK2_RIL_UNSOL_NETWORK_EVENT (MTK2_RIL_UNSOL_MTK_BASE + 98)
306+#define MTK2_RIL_UNSOL_MBIM_RESPONSE (MTK2_RIL_UNSOL_MTK_BASE + 99)
307+#define MTK2_RIL_UNSOL_MAL_DATA_CALL_LIST_CHANGED (MTK2_RIL_UNSOL_MTK_BASE + 100)
308+#define MTK2_RIL_UNSOL_EMBMS_AT_INFO (MTK2_RIL_UNSOL_MTK_BASE + 101)
309+#define MTK2_RIL_UNSOL_RADIO_CAPABILITY_SWITCH_START (MTK2_RIL_UNSOL_MTK_BASE + 102)
310+
311+#endif /* MTK2_CONSTANTS_H */
312
313=== added file 'drivers/mtk2modem/mtk2modem.c'
314--- drivers/mtk2modem/mtk2modem.c 1970-01-01 00:00:00 +0000
315+++ drivers/mtk2modem/mtk2modem.c 2016-07-01 17:24:58 +0000
316@@ -0,0 +1,55 @@
317+/*
318+ *
319+ * oFono - Open Source Telephony - RIL Modem Support
320+ *
321+ * Copyright (C) 2016 Canonical, Ltd. All rights reserved.
322+ *
323+ * This program is free software; you can redistribute it and/or modify
324+ * it under the terms of the GNU General Public License version 2 as
325+ * published by the Free Software Foundation.
326+ *
327+ * This program is distributed in the hope that it will be useful,
328+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
329+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
330+ * GNU General Public License for more details.
331+ *
332+ * You should have received a copy of the GNU General Public License
333+ * along with this program; if not, write to the Free Software
334+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
335+ *
336+ */
337+
338+#ifdef HAVE_CONFIG_H
339+#include <config.h>
340+#endif
341+
342+#include <glib.h>
343+#include <gril.h>
344+
345+#define OFONO_API_SUBJECT_TO_CHANGE
346+#include <ofono/plugin.h>
347+#include <ofono/log.h>
348+#include <ofono/types.h>
349+
350+#include "mtk2modem.h"
351+
352+static int mtk2modem_init(void)
353+{
354+ DBG("");
355+
356+ mtk2_voicecall_init();
357+ mtk2_gprs_init();
358+
359+ return 0;
360+}
361+
362+static void mtk2modem_exit(void)
363+{
364+ DBG("");
365+
366+ mtk2_voicecall_exit();
367+ mtk2_gprs_exit();
368+}
369+
370+OFONO_PLUGIN_DEFINE(mtk2modem, "MTK2 modem driver", VERSION,
371+ OFONO_PLUGIN_PRIORITY_DEFAULT, mtk2modem_init, mtk2modem_exit)
372
373=== added file 'drivers/mtk2modem/mtk2modem.h'
374--- drivers/mtk2modem/mtk2modem.h 1970-01-01 00:00:00 +0000
375+++ drivers/mtk2modem/mtk2modem.h 2016-07-01 17:24:58 +0000
376@@ -0,0 +1,28 @@
377+/*
378+ *
379+ * oFono - Open Source Telephony - RIL Modem Support
380+ *
381+ * Copyright (C) 2016 Canonical Ltd.
382+ *
383+ * This program is free software; you can redistribute it and/or modify
384+ * it under the terms of the GNU General Public License version 2 as
385+ * published by the Free Software Foundation.
386+ *
387+ * This program is distributed in the hope that it will be useful,
388+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
389+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
390+ * GNU General Public License for more details.
391+ *
392+ * You should have received a copy of the GNU General Public License
393+ * along with this program; if not, write to the Free Software
394+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
395+ *
396+ */
397+
398+#define MTK2MODEM "mtk2modem"
399+
400+extern void mtk2_voicecall_init(void);
401+extern void mtk2_voicecall_exit(void);
402+
403+extern void mtk2_gprs_init(void);
404+extern void mtk2_gprs_exit(void);
405
406=== added file 'drivers/mtk2modem/mtk2util.c'
407--- drivers/mtk2modem/mtk2util.c 1970-01-01 00:00:00 +0000
408+++ drivers/mtk2modem/mtk2util.c 2016-07-01 17:24:58 +0000
409@@ -0,0 +1,275 @@
410+/*
411+ *
412+ * MTK2 driver for ofono/rilmodem
413+ *
414+ * Copyright (C) 2016 Canonical Ltd.
415+ *
416+ * This program is free software; you can redistribute it and/or modify
417+ * it under the terms of the GNU General Public License version 2 as
418+ * published by the Free Software Foundation.
419+ *
420+ * This program is distributed in the hope that it will be useful,
421+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
422+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
423+ * GNU General Public License for more details.
424+ *
425+ * You should have received a copy of the GNU General Public License
426+ * along with this program; if not, write to the Free Software
427+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
428+ *
429+ */
430+
431+#include <stddef.h>
432+
433+#include "mtk2util.h"
434+#include "mtk2_constants.h"
435+
436+const char *mtk2_request_id_to_string(int req)
437+{
438+ switch (req) {
439+ case MTK2_RIL_REQUEST_MODEM_POWEROFF:
440+ return "MTK2_RIL_REQUEST_MODEM_POWEROFF";
441+ case MTK2_RIL_REQUEST_DUAL_SIM_MODE_SWITCH:
442+ return "MTK2_RIL_REQUEST_DUAL_SIM_MODE_SWITCH";
443+ case MTK2_RIL_REQUEST_SET_GPRS_CONNECT_TYPE:
444+ return "MTK2_RIL_REQUEST_SET_GPRS_CONNECT_TYPE";
445+ case MTK2_RIL_REQUEST_SET_GPRS_TRANSFER_TYPE:
446+ return "MTK2_RIL_REQUEST_SET_GPRS_TRANSFER_TYPE";
447+ case MTK2_RIL_REQUEST_MODEM_POWERON:
448+ return "MTK2_RIL_REQUEST_MODEM_POWERON";
449+ case MTK2_RIL_REQUEST_SET_CALL_INDICATION:
450+ return "MTK2_RIL_REQUEST_SET_CALL_INDICATION";
451+ case MTK2_RIL_REQUEST_GET_PHONE_CAPABILITY:
452+ return "MTK2_RIL_REQUEST_GET_PHONE_CAPABILITY";
453+ case MTK2_RIL_REQUEST_SET_PHONE_CAPABILITY:
454+ return "MTK2_RIL_REQUEST_SET_PHONE_CAPABILITY";
455+ case MTK2_RIL_REQUEST_SET_TRM:
456+ return "MTK2_RIL_REQUEST_SET_TRM";
457+ case MTK2_RIL_REQUEST_SET_FD_MODE:
458+ return "MTK2_RIL_REQUEST_SET_FD_MODE";
459+ case MTK2_RIL_REQUEST_STORE_MODEM_TYPE:
460+ return "MTK2_RIL_REQUEST_STORE_MODEM_TYPE";
461+ case MTK2_RIL_REQUEST_RESUME_REGISTRATION:
462+ return "MTK2_RIL_REQUEST_RESUME_REGISTRATION";
463+ case MTK2_RIL_REQUEST_QUERY_MODEM_TYPE:
464+ return "MTK2_RIL_REQUEST_QUERY_MODEM_TYPE";
465+ case MTK2_RIL_REQUEST_SET_DATA_ON_TO_MD:
466+ return "MTK2_RIL_REQUEST_SET_DATA_ON_TO_MD";
467+ default:
468+ return NULL;
469+ }
470+}
471+
472+const char *mtk2_unsol_request_to_string(int req)
473+{
474+ switch (req) {
475+ case MTK2_RIL_UNSOL_NEIGHBORING_CELL_INFO:
476+ return "MTK2_RIL_UNSOL_NEIGHBORING_CELL_INFO";
477+ case MTK2_RIL_UNSOL_NETWORK_INFO:
478+ return "MTK2_RIL_UNSOL_NETWORK_INFO";
479+ case MTK2_RIL_UNSOL_PHB_READY_NOTIFICATION:
480+ return "MTK2_RIL_UNSOL_PHB_READY_NOTIFICATION";
481+ case MTK2_RIL_UNSOL_SIM_INSERTED_STATUS:
482+ return "MTK2_RIL_UNSOL_SIM_INSERTED_STATUS";
483+ case MTK2_RIL_UNSOL_RADIO_TEMPORARILY_UNAVAILABLE:
484+ return "MTK2_RIL_UNSOL_RADIO_TEMPORARILY_UNAVAILABLE";
485+ case MTK2_RIL_UNSOL_ME_SMS_STORAGE_FULL:
486+ return "MTK2_RIL_UNSOL_ME_SMS_STORAGE_FULL";
487+ case MTK2_RIL_UNSOL_SMS_READY_NOTIFICATION:
488+ return "MTK2_RIL_UNSOL_SMS_READY_NOTIFICATION";
489+ case MTK2_RIL_UNSOL_SCRI_RESULT:
490+ return "MTK2_RIL_UNSOL_SCRI_RESULT";
491+ case MTK2_RIL_UNSOL_SIM_MISSING:
492+ return "MTK2_RIL_UNSOL_SIM_MISSING";
493+ case MTK2_RIL_UNSOL_GPRS_DETACH:
494+ return "MTK2_RIL_UNSOL_GPRS_DETACH";
495+ case MTK2_RIL_UNSOL_ATCI_RESPONSE:
496+ return "MTK2_RIL_UNSOL_ATCI_RESPONSE";
497+ case MTK2_RIL_UNSOL_SIM_RECOVERY:
498+ return "MTK2_RIL_UNSOL_SIM_RECOVERY";
499+ case MTK2_RIL_UNSOL_VIRTUAL_SIM_ON:
500+ return "MTK2_RIL_UNSOL_VIRTUAL_SIM_ON";
501+ case MTK2_RIL_UNSOL_VIRTUAL_SIM_OFF:
502+ return "MTK2_RIL_UNSOL_VIRTUAL_SIM_OFF";
503+ case MTK2_RIL_UNSOL_INVALID_SIM:
504+ return "MTK2_RIL_UNSOL_INVALID_SIM";
505+ case MTK2_RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED:
506+ return "MTK2_RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED";
507+ case MTK2_RIL_UNSOL_RESPONSE_ACMT:
508+ return "MTK2_RIL_UNSOL_RESPONSE_ACMT";
509+ case MTK2_RIL_UNSOL_EF_CSP_PLMN_MODE_BIT:
510+ return "MTK2_RIL_UNSOL_EF_CSP_PLMN_MODE_BIT";
511+ case MTK2_RIL_UNSOL_IMEI_LOCK:
512+ return "MTK2_RIL_UNSOL_IMEI_LOCK";
513+ case MTK2_RIL_UNSOL_RESPONSE_MMRR_STATUS_CHANGED:
514+ return "MTK2_RIL_UNSOL_RESPONSE_MMRR_STATUS_CHANGED";
515+ case MTK2_RIL_UNSOL_SIM_PLUG_OUT:
516+ return "MTK2_RIL_UNSOL_SIM_PLUG_OUT";
517+ case MTK2_RIL_UNSOL_SIM_PLUG_IN:
518+ return "MTK2_RIL_UNSOL_SIM_PLUG_IN";
519+ case MTK2_RIL_UNSOL_RESPONSE_ETWS_NOTIFICATION:
520+ return "MTK2_RIL_UNSOL_RESPONSE_ETWS_NOTIFICATION";
521+ case MTK2_RIL_UNSOL_RESPONSE_PLMN_CHANGED:
522+ return "MTK2_RIL_UNSOL_RESPONSE_PLMN_CHANGED";
523+ case MTK2_RIL_UNSOL_RESPONSE_REGISTRATION_SUSPENDED:
524+ return "MTK2_RIL_UNSOL_RESPONSE_REGISTRATION_SUSPENDED";
525+ case MTK2_RIL_UNSOL_STK_EVDL_CALL:
526+ return "MTK2_RIL_UNSOL_STK_EVDL_CALL";
527+ case MTK2_RIL_UNSOL_DATA_PACKETS_FLUSH:
528+ return "MTK2_RIL_UNSOL_DATA_PACKETS_FLUSH";
529+ case MTK2_RIL_UNSOL_FEMTOCELL_INFO:
530+ return "MTK2_RIL_UNSOL_FEMTOCELL_INFO";
531+ case MTK2_RIL_UNSOL_STK_SETUP_MENU_RESET:
532+ return "MTK2_RIL_UNSOL_STK_SETUP_MENU_RESET";
533+ case MTK2_RIL_UNSOL_APPLICATION_SESSION_ID_CHANGED:
534+ return "MTK2_RIL_UNSOL_APPLICATION_SESSION_ID_CHANGED";
535+ case MTK2_RIL_UNSOL_ECONF_SRVCC_INDICATION:
536+ return "MTK2_RIL_UNSOL_ECONF_SRVCC_INDICATION";
537+ case MTK2_RIL_UNSOL_IMS_ENABLE_DONE:
538+ return "MTK2_RIL_UNSOL_IMS_ENABLE_DONE";
539+ case MTK2_RIL_UNSOL_IMS_DISABLE_DONE:
540+ return "MTK2_RIL_UNSOL_IMS_DISABLE_DONE";
541+ case MTK2_RIL_UNSOL_IMS_REGISTRATION_INFO:
542+ return "MTK2_RIL_UNSOL_IMS_REGISTRATION_INFO";
543+ case MTK2_RIL_UNSOL_DEDICATE_BEARER_ACTIVATED:
544+ return "MTK2_RIL_UNSOL_DEDICATE_BEARER_ACTIVATED";
545+ case MTK2_RIL_UNSOL_DEDICATE_BEARER_MODIFIED:
546+ return "MTK2_RIL_UNSOL_DEDICATE_BEARER_MODIFIED";
547+ case MTK2_RIL_UNSOL_DEDICATE_BEARER_DEACTIVATED:
548+ return "MTK2_RIL_UNSOL_DEDICATE_BEARER_DEACTIVATED";
549+ case MTK2_RIL_UNSOL_RAC_UPDATE:
550+ return "MTK2_RIL_UNSOL_RAC_UPDATE";
551+ case MTK2_RIL_UNSOL_ECONF_RESULT_INDICATION:
552+ return "MTK2_RIL_UNSOL_ECONF_RESULT_INDICATION";
553+ case MTK2_RIL_UNSOL_MELOCK_NOTIFICATION:
554+ return "MTK2_RIL_UNSOL_MELOCK_NOTIFICATION";
555+ case MTK2_RIL_UNSOL_CALL_FORWARDING:
556+ return "MTK2_RIL_UNSOL_CALL_FORWARDING";
557+ case MTK2_RIL_UNSOL_CRSS_NOTIFICATION:
558+ return "MTK2_RIL_UNSOL_CRSS_NOTIFICATION";
559+ case MTK2_RIL_UNSOL_INCOMING_CALL_INDICATION:
560+ return "MTK2_RIL_UNSOL_INCOMING_CALL_INDICATION";
561+ case MTK2_RIL_UNSOL_CIPHER_INDICATION:
562+ return "MTK2_RIL_UNSOL_CIPHER_INDICATION";
563+ case MTK2_RIL_UNSOL_CNAP:
564+ return "MTK2_RIL_UNSOL_CNAP";
565+ case MTK2_RIL_UNSOL_SIM_COMMON_SLOT_NO_CHANGED:
566+ return "MTK2_RIL_UNSOL_SIM_COMMON_SLOT_NO_CHANGED";
567+ case MTK2_RIL_UNSOL_DATA_ALLOWED:
568+ return "MTK2_RIL_UNSOL_DATA_ALLOWED";
569+ case MTK2_RIL_UNSOL_STK_CALL_CTRL:
570+ return "MTK2_RIL_UNSOL_STK_CALL_CTRL";
571+ case MTK2_RIL_UNSOL_VOLTE_EPS_NETWORK_FEATURE_SUPPORT:
572+ return "MTK2_RIL_UNSOL_VOLTE_EPS_NETWORK_FEATURE_SUPPORT";
573+ case MTK2_RIL_UNSOL_CALL_INFO_INDICATION:
574+ return "MTK2_RIL_UNSOL_CALL_INFO_INDICATION";
575+ case MTK2_RIL_UNSOL_VOLTE_EPS_NETWORK_FEATURE_INFO:
576+ return "MTK2_RIL_UNSOL_VOLTE_EPS_NETWORK_FEATURE_INFO";
577+ case MTK2_RIL_UNSOL_SRVCC_HANDOVER_INFO_INDICATION:
578+ return "MTK2_RIL_UNSOL_SRVCC_HANDOVER_INFO_INDICATION";
579+ case MTK2_RIL_UNSOL_SPEECH_CODEC_INFO:
580+ return "MTK2_RIL_UNSOL_SPEECH_CODEC_INFO";
581+ case MTK2_RIL_UNSOL_MD_STATE_CHANGE:
582+ return "MTK2_RIL_UNSOL_MD_STATE_CHANGE";
583+ case MTK2_RIL_UNSOL_REMOVE_RESTRICT_EUTRAN:
584+ return "MTK2_RIL_UNSOL_REMOVE_RESTRICT_EUTRAN";
585+ case MTK2_RIL_UNSOL_MO_DATA_BARRING_INFO:
586+ return "MTK2_RIL_UNSOL_MO_DATA_BARRING_INFO";
587+ case MTK2_RIL_UNSOL_SSAC_BARRING_INFO:
588+ return "MTK2_RIL_UNSOL_SSAC_BARRING_INFO";
589+ case MTK2_RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR:
590+ return "MTK2_RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR";
591+ case MTK2_RIL_UNSOL_ABNORMAL_EVENT:
592+ return "MTK2_RIL_UNSOL_ABNORMAL_EVENT";
593+ case MTK2_RIL_UNSOL_EMERGENCY_BEARER_SUPPORT_NOTIFY:
594+ return "MTK2_RIL_UNSOL_EMERGENCY_BEARER_SUPPORT_NOTIFY";
595+ case MTK2_RIL_UNSOL_INTER_3GPP_IRAT_STATE_CHANGE:
596+ return "MTK2_RIL_UNSOL_INTER_3GPP_IRAT_STATE_CHANGE";
597+ case MTK2_RIL_UNSOL_LTE_BG_SEARCH_STATUS:
598+ return "MTK2_RIL_UNSOL_LTE_BG_SEARCH_STATUS";
599+ case MTK2_RIL_UNSOL_GMSS_RAT_CHANGED:
600+ return "MTK2_RIL_UNSOL_GMSS_RAT_CHANGED";
601+ case MTK2_RIL_UNSOL_CDMA_CARD_TYPE:
602+ return "MTK2_RIL_UNSOL_CDMA_CARD_TYPE";
603+ case MTK2_RIL_UNSOL_IMS_ENABLE_START:
604+ return "MTK2_RIL_UNSOL_IMS_ENABLE_START";
605+ case MTK2_RIL_UNSOL_IMS_DISABLE_START:
606+ return "MTK2_RIL_UNSOL_IMS_DISABLE_START";
607+ case MTK2_RIL_UNSOL_IMSI_REFRESH_DONE:
608+ return "MTK2_RIL_UNSOL_IMSI_REFRESH_DONE";
609+ case MTK2_RIL_UNSOL_EUSIM_READY:
610+ return "MTK2_RIL_UNSOL_EUSIM_READY";
611+ case MTK2_RIL_UNSOL_STK_BIP_PROACTIVE_COMMAND:
612+ return "MTK2_RIL_UNSOL_STK_BIP_PROACTIVE_COMMAND";
613+ case MTK2_RIL_UNSOL_WORLD_MODE_CHANGED:
614+ return "MTK2_RIL_UNSOL_WORLD_MODE_CHANGED";
615+ case MTK2_RIL_UNSOL_VT_STATUS_INFO:
616+ return "MTK2_RIL_UNSOL_VT_STATUS_INFO";
617+ case MTK2_RIL_UNSOL_VT_RING_INFO:
618+ return "MTK2_RIL_UNSOL_VT_RING_INFO";
619+ case MTK2_RIL_UNSOL_VSIM_OPERATION_INDICATION:
620+ return "MTK2_RIL_UNSOL_VSIM_OPERATION_INDICATION";
621+ case MTK2_RIL_UNSOL_SET_ATTACH_APN:
622+ return "MTK2_RIL_UNSOL_SET_ATTACH_APN";
623+ case MTK2_RIL_UNSOL_MAL_AT_INFO:
624+ return "MTK2_RIL_UNSOL_MAL_AT_INFO";
625+ case MTK2_RIL_UNSOL_MAIN_SIM_INFO:
626+ return "MTK2_RIL_UNSOL_MAIN_SIM_INFO";
627+ case MTK2_RIL_UNSOL_TRAY_PLUG_IN:
628+ return "MTK2_RIL_UNSOL_TRAY_PLUG_IN";
629+ case MTK2_RIL_UNSOL_CALLMOD_CHANGE_INDICATOR:
630+ return "MTK2_RIL_UNSOL_CALLMOD_CHANGE_INDICATOR";
631+ case MTK2_RIL_UNSOL_VIDEO_CAPABILITY_INDICATOR:
632+ return "MTK2_RIL_UNSOL_VIDEO_CAPABILITY_INDICATOR";
633+ case MTK2_RIL_UNSOL_LTE_ACCESS_STRATUM_STATE_CHANGE:
634+ return "MTK2_RIL_UNSOL_LTE_ACCESS_STRATUM_STATE_CHANGE";
635+ case MTK2_RIL_UNSOL_SETUP_DATA_CALL_RESPONSE:
636+ return "MTK2_RIL_UNSOL_SETUP_DATA_CALL_RESPONSE";
637+ case MTK2_RIL_UNSOL_ON_USSI:
638+ return "MTK2_RIL_UNSOL_ON_USSI";
639+ case MTK2_RIL_UNSOL_CDMA_CALL_ACCEPTED:
640+ return "MTK2_RIL_UNSOL_CDMA_CALL_ACCEPTED";
641+ case MTK2_RIL_UNSOL_UTK_SESSION_END:
642+ return "MTK2_RIL_UNSOL_UTK_SESSION_END";
643+ case MTK2_RIL_UNSOL_UTK_PROACTIVE_COMMAND:
644+ return "MTK2_RIL_UNSOL_UTK_PROACTIVE_COMMAND";
645+ case MTK2_RIL_UNSOL_UTK_EVENT_NOTIFY:
646+ return "MTK2_RIL_UNSOL_UTK_EVENT_NOTIFY";
647+ case MTK2_RIL_UNSOL_VIA_GPS_EVENT:
648+ return "MTK2_RIL_UNSOL_VIA_GPS_EVENT";
649+ case MTK2_RIL_UNSOL_VIA_NETWORK_TYPE_CHANGE:
650+ return "MTK2_RIL_UNSOL_VIA_NETWORK_TYPE_CHANGE";
651+ case MTK2_RIL_UNSOL_CDMA_PLMN_CHANGED:
652+ return "MTK2_RIL_UNSOL_CDMA_PLMN_CHANGED";
653+ case MTK2_RIL_UNSOL_VIA_INVALID_SIM_DETECTED:
654+ return "MTK2_RIL_UNSOL_VIA_INVALID_SIM_DETECTED";
655+ case MTK2_RIL_UNSOL_ENG_MODE_NETWORK_INFO:
656+ return "MTK2_RIL_UNSOL_ENG_MODE_NETWORK_INFO";
657+ case MTK2_RIL_UNSOL_RESPONSE_DATA_NETWORK_TYPE_CHANGED:
658+ return "MTK2_RIL_UNSOL_RESPONSE_DATA_NETWORK_TYPE_CHANGED";
659+ case MTK2_RIL_UNSOL_LTE_EARFCN_INFO:
660+ return "MTK2_RIL_UNSOL_LTE_EARFCN_INFO";
661+ case MTK2_RIL_UNSOL_CDMA_IMSI_READY:
662+ return "MTK2_RIL_UNSOL_CDMA_IMSI_READY";
663+ case MTK2_RIL_UNSOL_CDMA_SIGNAL_FADE:
664+ return "MTK2_RIL_UNSOL_CDMA_SIGNAL_FADE";
665+ case MTK2_RIL_UNSOL_CDMA_TONE_SIGNALS:
666+ return "MTK2_RIL_UNSOL_CDMA_TONE_SIGNALS";
667+ case MTK2_RIL_UNSOL_NETWORK_EXIST:
668+ return "MTK2_RIL_UNSOL_NETWORK_EXIST";
669+ case MTK2_RIL_UNSOL_MODULATION_INFO:
670+ return "MTK2_RIL_UNSOL_MODULATION_INFO";
671+ case MTK2_RIL_UNSOL_NETWORK_EVENT:
672+ return "MTK2_RIL_UNSOL_NETWORK_EVENT";
673+ case MTK2_RIL_UNSOL_MBIM_RESPONSE:
674+ return "MTK2_RIL_UNSOL_MBIM_RESPONSE";
675+ case MTK2_RIL_UNSOL_MAL_DATA_CALL_LIST_CHANGED:
676+ return "MTK2_RIL_UNSOL_MAL_DATA_CALL_LIST_CHANGED";
677+ case MTK2_RIL_UNSOL_EMBMS_AT_INFO :
678+ return "MTK2_RIL_UNSOL_EMBMS_AT_INFO ";
679+ case MTK2_RIL_UNSOL_RADIO_CAPABILITY_SWITCH_START:
680+ return "MTK2_RIL_UNSOL_RADIO_CAPABILITY_SWITCH_START";
681+ default:
682+ return NULL;
683+ }
684+}
685
686=== added file 'drivers/mtk2modem/mtk2util.h'
687--- drivers/mtk2modem/mtk2util.h 1970-01-01 00:00:00 +0000
688+++ drivers/mtk2modem/mtk2util.h 2016-07-01 17:24:58 +0000
689@@ -0,0 +1,39 @@
690+/*
691+ *
692+ * MTK2 driver for ofono/rilmodem
693+ *
694+ * Copyright (C) 2016 Canonical Ltd.
695+ *
696+ * This program is free software; you can redistribute it and/or modify
697+ * it under the terms of the GNU General Public License version 2 as
698+ * published by the Free Software Foundation.
699+ *
700+ * This program is distributed in the hope that it will be useful,
701+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
702+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
703+ * GNU General Public License for more details.
704+ *
705+ * You should have received a copy of the GNU General Public License
706+ * along with this program; if not, write to the Free Software
707+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
708+ *
709+ */
710+
711+#ifndef MTK2UTIL_H
712+#define MTK2UTIL_H
713+
714+#include <ofono/types.h>
715+#include <gril.h>
716+
717+#ifdef __cplusplus
718+extern "C" {
719+#endif
720+
721+const char *mtk2_request_id_to_string(int req);
722+const char *mtk2_unsol_request_to_string(int req);
723+
724+#ifdef __cplusplus
725+}
726+#endif
727+
728+#endif /* MTK2UTIL_H */
729
730=== added file 'drivers/mtk2modem/voicecall.c'
731--- drivers/mtk2modem/voicecall.c 1970-01-01 00:00:00 +0000
732+++ drivers/mtk2modem/voicecall.c 2016-07-01 17:24:58 +0000
733@@ -0,0 +1,149 @@
734+/*
735+ *
736+ * oFono - Open Source Telephony
737+ *
738+ * Copyright (C) 2016 Canonical Ltd.
739+ *
740+ * This program is free software; you can redistribute it and/or modify
741+ * it under the terms of the GNU General Public License version 2 as
742+ * published by the Free Software Foundation.
743+ *
744+ * This program is distributed in the hope that it will be useful,
745+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
746+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
747+ * GNU General Public License for more details.
748+ *
749+ * You should have received a copy of the GNU General Public License
750+ * along with this program; if not, write to the Free Software
751+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
752+ *
753+ */
754+#ifdef HAVE_CONFIG_H
755+#include <config.h>
756+#endif
757+
758+#define _GNU_SOURCE
759+#include <string.h>
760+#include <stdlib.h>
761+#include <stdio.h>
762+#include <errno.h>
763+
764+#include <glib.h>
765+
766+#include <ofono/log.h>
767+#include <ofono/modem.h>
768+#include <ofono/voicecall.h>
769+
770+#include "mtk2_constants.h"
771+#include "drivers/mtkmodem/mtkunsol.h"
772+#include "drivers/mtkmodem/mtkrequest.h"
773+
774+#include "common.h"
775+#include "mtk2modem.h"
776+#include "drivers/rilmodem/rilutil.h"
777+#include "drivers/rilmodem/voicecall.h"
778+
779+/*
780+ * This is the voicecall atom implementation for mtk2modem. Most of the
781+ * implementation can be found in the rilmodem atom. The main reason for
782+ * creating a new atom is the need to handle specific MTK requests and
783+ * unsolicited events.
784+ */
785+
786+static void mtk2_set_indication_cb(struct ril_msg *message, gpointer user_data)
787+{
788+ struct ofono_voicecall *vc = user_data;
789+ struct ril_voicecall_data *vd = ofono_voicecall_get_data(vc);
790+
791+ if (message->error == RIL_E_SUCCESS)
792+ g_ril_print_response_no_args(vd->ril, message);
793+ else
794+ ofono_error("%s: RIL error %s", __func__,
795+ ril_error_to_string(message->error));
796+}
797+
798+static void mtk2_incoming_notify(struct ril_msg *message, gpointer user_data)
799+{
800+ struct ofono_voicecall *vc = user_data;
801+ struct ril_voicecall_data *vd = ofono_voicecall_get_data(vc);
802+ struct parcel rilp;
803+ struct unsol_call_indication *call_ind;
804+
805+ call_ind = g_mtk_unsol_parse_incoming_call_indication(vd->ril, message);
806+ if (call_ind == NULL) {
807+ ofono_error("%s: error parsing event", __func__);
808+ return;
809+ }
810+
811+ g_mtk_request_set_call_indication(vd->ril, MTK_CALL_INDIC_MODE_AVAIL,
812+ call_ind->call_id,
813+ call_ind->seq_number, &rilp);
814+
815+ if (g_ril_send(vd->ril, MTK2_RIL_REQUEST_SET_CALL_INDICATION,
816+ &rilp, mtk2_set_indication_cb, vc, NULL) == 0)
817+ ofono_error("%s: cannot send indication", __func__);
818+
819+ g_mtk_unsol_free_call_indication(call_ind);
820+}
821+
822+static gboolean mtk2_delayed_register(gpointer user_data)
823+{
824+ struct ofono_voicecall *vc = user_data;
825+ struct ril_voicecall_data *vd = ofono_voicecall_get_data(vc);
826+
827+ /* Indicates incoming call, before telling the network our state */
828+ g_ril_register(vd->ril, MTK2_RIL_UNSOL_INCOMING_CALL_INDICATION,
829+ mtk2_incoming_notify, vc);
830+
831+ /* This makes the timeout a single-shot */
832+ return FALSE;
833+}
834+
835+static int mtk2_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor,
836+ void *data)
837+{
838+ struct ril_voicecall_driver_data *driver_data = data;
839+ struct ril_voicecall_data *vd;
840+
841+ vd = g_try_new0(struct ril_voicecall_data, 1);
842+ if (vd == NULL)
843+ return -ENOMEM;
844+
845+ ril_voicecall_start(driver_data, vc, vendor, vd);
846+
847+ /*
848+ * Register events after ofono_voicecall_register() is called from
849+ * ril_delayed_register().
850+ */
851+ g_idle_add(mtk2_delayed_register, vc);
852+
853+ return 0;
854+}
855+
856+static struct ofono_voicecall_driver driver = {
857+ .name = MTK2MODEM,
858+ .probe = mtk2_voicecall_probe,
859+ .remove = ril_voicecall_remove,
860+ .dial = ril_dial,
861+ .answer = ril_answer,
862+ .hangup_all = ril_hangup_all,
863+ .release_specific = ril_hangup_specific,
864+ .send_tones = ril_send_dtmf,
865+ .create_multiparty = ril_create_multiparty,
866+ .private_chat = ril_private_chat,
867+ .swap_without_accept = ril_swap_without_accept,
868+ .hold_all_active = ril_hold_all_active,
869+ .release_all_held = ril_release_all_held,
870+ .set_udub = ril_set_udub,
871+ .release_all_active = ril_release_all_active,
872+};
873+
874+void mtk2_voicecall_init(void)
875+{
876+ ofono_voicecall_driver_register(&driver);
877+}
878+
879+void mtk2_voicecall_exit(void)
880+{
881+ ofono_voicecall_driver_unregister(&driver);
882+}
883
884=== modified file 'drivers/mtkmodem/mtkunsol.c'
885--- drivers/mtkmodem/mtkunsol.c 2015-03-30 09:50:34 +0000
886+++ drivers/mtkmodem/mtkunsol.c 2016-07-01 17:24:58 +0000
887@@ -45,7 +45,8 @@
888 struct parcel rilp;
889 int numstr;
890 struct unsol_call_indication *unsol;
891- char *call_id, *phone, *mystery, *call_mode, *seq_num;
892+ char *call_id, *phone, *address_type, *call_mode, *seq_num;
893+ char *fw_address = NULL;
894 char *endp;
895
896 unsol = g_try_malloc0(sizeof(*unsol));
897@@ -57,19 +58,26 @@
898 g_ril_init_parcel(message, &rilp);
899
900 numstr = parcel_r_int32(&rilp);
901- if (numstr != 5) {
902+ if (numstr < 5) {
903 ofono_error("%s: wrong array size (%d)", __func__, numstr);
904 goto error;
905 }
906
907 call_id = parcel_r_string(&rilp);
908 phone = parcel_r_string(&rilp);
909- mystery = parcel_r_string(&rilp);
910+ address_type = parcel_r_string(&rilp);
911 call_mode = parcel_r_string(&rilp);
912 seq_num = parcel_r_string(&rilp);
913+ if (numstr > 5)
914+ fw_address = parcel_r_string(&rilp);
915
916- g_ril_append_print_buf(gril, "{%s,%s,%s,%s,%s}", call_id, phone,
917- mystery, call_mode, seq_num);
918+ g_ril_append_print_buf(gril, "{%s,%s,%s,%s,%s,%s}",
919+ PRINTABLE_STR(call_id),
920+ PRINTABLE_STR(phone),
921+ PRINTABLE_STR(address_type),
922+ PRINTABLE_STR(call_mode),
923+ PRINTABLE_STR(seq_num),
924+ PRINTABLE_STR(fw_address));
925
926 g_ril_print_unsol(gril, message);
927
928@@ -113,18 +121,20 @@
929
930 g_free(call_id);
931 g_free(phone);
932- g_free(mystery);
933+ g_free(address_type);
934 g_free(call_mode);
935 g_free(seq_num);
936+ g_free(fw_address);
937
938 return unsol;
939
940 err_conv:
941 g_free(call_id);
942 g_free(phone);
943- g_free(mystery);
944+ g_free(address_type);
945 g_free(call_mode);
946 g_free(seq_num);
947+ g_free(fw_address);
948
949 error:
950 g_free(unsol);
951
952=== added file 'drivers/qcommsimmodem/gprs.c'
953--- drivers/qcommsimmodem/gprs.c 1970-01-01 00:00:00 +0000
954+++ drivers/qcommsimmodem/gprs.c 2016-07-01 17:24:58 +0000
955@@ -0,0 +1,118 @@
956+/*
957+ *
958+ * oFono - Open Source Telephony
959+ *
960+ * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
961+ * Copyright (C) 2010 ST-Ericsson AB.
962+ * Copyright (C) 2013-2014 Canonical Ltd.
963+ * Copyright (C) 2013 Jolla Ltd.
964+ * Copyright (C) 2016 Ratchanan Srirattanamet.
965+ *
966+ * This program is free software; you can redistribute it and/or modify
967+ * it under the terms of the GNU General Public License version 2 as
968+ * published by the Free Software Foundation.
969+ *
970+ * This program is distributed in the hope that it will be useful,
971+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
972+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
973+ * GNU General Public License for more details.
974+ *
975+ * You should have received a copy of the GNU General Public License
976+ * along with this program; if not, write to the Free Software
977+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
978+ *
979+ */
980+
981+#include <glib.h>
982+
983+#include <ofono/log.h>
984+#include <ofono/modem.h>
985+#include <ofono/gprs.h>
986+
987+#include "gril.h"
988+
989+#include "drivers/rilmodem/rilutil.h"
990+#include "drivers/rilmodem/gprs.h"
991+#include "qcom_msim_modem.h"
992+#include "qcom_msim_constants.h"
993+
994+static void set_data_sub_cb(struct ril_msg *message, gpointer user_data)
995+{
996+ struct cb_data *cbd = user_data;
997+ ofono_gprs_cb_t cb = cbd->cb;
998+ struct ril_gprs_data *gd = cbd->user;
999+
1000+ if (message->error == RIL_E_SUCCESS) {
1001+ g_ril_print_response_no_args(gd->ril, message);
1002+
1003+ gd->ofono_attached = 1;
1004+
1005+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
1006+ } else {
1007+ ofono_error("%s: RIL error %s", __func__,
1008+ ril_error_to_string(message->error));
1009+ CALLBACK_WITH_FAILURE(cb, cbd->data);
1010+ }
1011+}
1012+
1013+static void qcom_msim_gprs_set_attached(struct ofono_gprs *gprs, int attached,
1014+ ofono_gprs_cb_t cb, void *data)
1015+{
1016+ struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);
1017+ struct cb_data *cbd = cb_data_new(cb, data, gd);
1018+
1019+ DBG("attached: %d", attached);
1020+
1021+ /*
1022+ * This modem use RIL_REQUEST_SET_DATA_SUBSCRIPTION to select which SIM
1023+ * is used for data connection. We still doesn't have actual control
1024+ * over 'attached' state. So, we still use the same trick as rilmodem's
1025+ * gprs atom (save the desired state, and use it to override the actual
1026+ * modem's state in the 'attached_status' function).
1027+ *
1028+ * The core gprs code calls driver->set_attached() when a netreg
1029+ * notificaiton is received and any configured roaming conditions
1030+ * are met.
1031+ */
1032+
1033+ if (attached) {
1034+ /*
1035+ * We don't have a request to see if we're a selected SIM slot.
1036+ * So, we just send this request. There's no harm sending this
1037+ * repeatedly anyway.
1038+ */
1039+ g_ril_send(gd->ril, QCOM_MSIM_RIL_REQUEST_SET_DATA_SUBSCRIPTION
1040+ , NULL, set_data_sub_cb, cbd, NULL);
1041+ } else {
1042+ /*
1043+ * We don't actually have a request to unselect the slot.
1044+ * So, just do nothing.
1045+ */
1046+ gd->ofono_attached = attached;
1047+
1048+ /*
1049+ * Call from idle loop, so core can set driver_attached before
1050+ * the callback is invoked.
1051+ */
1052+ g_idle_add(ril_gprs_set_attached_cb, cbd);
1053+ }
1054+}
1055+
1056+static struct ofono_gprs_driver driver = {
1057+ .name = QCOMMSIMMODEM,
1058+ .probe = ril_gprs_probe,
1059+ .remove = ril_gprs_remove,
1060+ .set_attached = qcom_msim_gprs_set_attached,
1061+ .attached_status = ril_gprs_registration_status,
1062+ .set_ia_apn = ril_gprs_set_ia_apn,
1063+};
1064+
1065+void qcom_msim_gprs_init(void)
1066+{
1067+ ofono_gprs_driver_register(&driver);
1068+}
1069+
1070+void qcom_msim_gprs_exit(void)
1071+{
1072+ ofono_gprs_driver_unregister(&driver);
1073+}
1074
1075=== modified file 'drivers/qcommsimmodem/qcom_msim_constants.h'
1076--- drivers/qcommsimmodem/qcom_msim_constants.h 2015-06-11 16:14:06 +0000
1077+++ drivers/qcommsimmodem/qcom_msim_constants.h 2016-07-01 17:24:58 +0000
1078@@ -24,6 +24,7 @@
1079
1080 #define QCOMMSIM_NUM_SLOTS_MAX 2
1081
1082-#define QCOM_MSIM_RIL_REQUEST_SET_UICC_SUBSCRIPTION 115
1083+#define QCOM_MSIM_RIL_REQUEST_SET_UICC_SUBSCRIPTION 115
1084+#define QCOM_MSIM_RIL_REQUEST_SET_DATA_SUBSCRIPTION 116
1085
1086 #endif /* QCOM_MSIM_CONSTANTS_H */
1087
1088=== modified file 'drivers/qcommsimmodem/qcom_msim_modem.c'
1089--- drivers/qcommsimmodem/qcom_msim_modem.c 2015-06-11 16:14:06 +0000
1090+++ drivers/qcommsimmodem/qcom_msim_modem.c 2016-07-01 17:24:58 +0000
1091@@ -40,6 +40,7 @@
1092 DBG("");
1093
1094 qcom_msim_radio_settings_init();
1095+ qcom_msim_gprs_init();
1096
1097 return 0;
1098 }
1099@@ -49,6 +50,7 @@
1100 DBG("");
1101
1102 qcom_msim_radio_settings_exit();
1103+ qcom_msim_gprs_exit();
1104 }
1105
1106 OFONO_PLUGIN_DEFINE(qcommsimmodem, "Qualcomm multi-sim modem driver", VERSION,
1107
1108=== modified file 'drivers/qcommsimmodem/qcom_msim_modem.h'
1109--- drivers/qcommsimmodem/qcom_msim_modem.h 2015-06-11 16:14:06 +0000
1110+++ drivers/qcommsimmodem/qcom_msim_modem.h 2016-07-01 17:24:58 +0000
1111@@ -23,3 +23,6 @@
1112
1113 extern void qcom_msim_radio_settings_init(void);
1114 extern void qcom_msim_radio_settings_exit(void);
1115+
1116+extern void qcom_msim_gprs_init(void);
1117+extern void qcom_msim_gprs_exit(void);
1118
1119=== modified file 'drivers/rilmodem/call-barring.c'
1120--- drivers/rilmodem/call-barring.c 2016-01-05 14:42:38 +0000
1121+++ drivers/rilmodem/call-barring.c 2016-07-01 17:24:58 +0000
1122@@ -33,6 +33,7 @@
1123 #include "call-barring.h"
1124 #include "rilmodem.h"
1125 #include "ril_constants.h"
1126+#include "rilutil.h"
1127
1128 struct barring_data {
1129 GRil *ril;
1130
1131=== modified file 'drivers/rilmodem/call-forwarding.c'
1132--- drivers/rilmodem/call-forwarding.c 2015-09-29 08:46:51 +0000
1133+++ drivers/rilmodem/call-forwarding.c 2016-07-01 17:24:58 +0000
1134@@ -42,6 +42,7 @@
1135 #include "grilreply.h"
1136 #include "grilunsol.h"
1137
1138+#include "rilutil.h"
1139 #include "rilmodem.h"
1140
1141 #include "common.h"
1142
1143=== modified file 'drivers/rilmodem/call-settings.c'
1144--- drivers/rilmodem/call-settings.c 2013-12-10 09:44:10 +0000
1145+++ drivers/rilmodem/call-settings.c 2016-07-01 17:24:58 +0000
1146@@ -44,6 +44,7 @@
1147 #include "grilreply.h"
1148
1149 #include "rilmodem.h"
1150+#include "rilutil.h"
1151 #include "ril_constants.h"
1152 #include "common.h"
1153
1154
1155=== modified file 'drivers/rilmodem/call-volume.c'
1156--- drivers/rilmodem/call-volume.c 2013-12-09 17:09:20 +0000
1157+++ drivers/rilmodem/call-volume.c 2016-07-01 17:24:58 +0000
1158@@ -41,6 +41,7 @@
1159 #include "common.h"
1160
1161 #include "rilmodem.h"
1162+#include "rilutil.h"
1163 #include "parcel.h"
1164 #include "grilrequest.h"
1165 #include "grilreply.h"
1166
1167=== modified file 'drivers/rilmodem/devinfo.c'
1168--- drivers/rilmodem/devinfo.c 2013-12-09 17:09:20 +0000
1169+++ drivers/rilmodem/devinfo.c 2016-07-01 17:24:58 +0000
1170@@ -39,6 +39,7 @@
1171 #include "gril.h"
1172
1173 #include "rilmodem.h"
1174+#include "rilutil.h"
1175 #include "grilreply.h"
1176
1177 /*
1178
1179=== modified file 'drivers/rilmodem/gprs.c'
1180--- drivers/rilmodem/gprs.c 2016-04-13 14:35:57 +0000
1181+++ drivers/rilmodem/gprs.c 2016-07-01 17:24:58 +0000
1182@@ -38,6 +38,7 @@
1183 #include <ofono/modem.h>
1184 #include <ofono/gprs.h>
1185 #include <ofono/types.h>
1186+#include <ofono.h>
1187
1188 #include "gril.h"
1189 #include "grilutil.h"
1190@@ -49,9 +50,13 @@
1191 #include "grilunsol.h"
1192 #include "gprs.h"
1193
1194+#include "plugins/ril.h"
1195+
1196 /* Time between get data status retries */
1197 #define GET_STATUS_TIMER_MS 5000
1198
1199+static void send_allow_data(struct cb_data *cbd, GRil *ril, int attached);
1200+
1201 /*
1202 * This module is the ofono_gprs_driver implementation for rilmodem.
1203 *
1204@@ -78,6 +83,7 @@
1205 case RADIO_TECH_EDGE:
1206 return PACKET_BEARER_EGPRS;
1207 case RADIO_TECH_UMTS:
1208+ case RADIO_TECH_TD_SCDMA:
1209 return PACKET_BEARER_UMTS;
1210 case RADIO_TECH_HSDPA:
1211 return PACKET_BEARER_HSDPA;
1212@@ -162,6 +168,75 @@
1213 ril_gprs_registration_status(gprs, NULL, NULL);
1214 }
1215
1216+struct gprs_attach_data {
1217+ struct ril_gprs_data *gd;
1218+ GRil *ril;
1219+ gboolean set_attached;
1220+ gboolean detaching_other_slot;
1221+};
1222+
1223+static void free_attach_cbd(struct cb_data *cbd)
1224+{
1225+ g_free(cbd->user);
1226+ g_free(cbd);
1227+}
1228+
1229+static void gprs_allow_data_cb(struct ril_msg *message, gpointer user_data)
1230+{
1231+ struct cb_data *cbd = user_data;
1232+ ofono_gprs_cb_t cb = cbd->cb;
1233+ struct gprs_attach_data *attach_data = cbd->user;
1234+ struct ril_gprs_data *gd = attach_data->gd;
1235+
1236+ g_ril_print_response_no_args(attach_data->ril, message);
1237+
1238+ /*
1239+ * We do not care if detaching the other slot fails. This happens in
1240+ * turbo when the other slot is empty, for instance.
1241+ */
1242+ if (attach_data->detaching_other_slot) {
1243+ attach_data->ril = gd->ril;
1244+ attach_data->detaching_other_slot = FALSE;
1245+
1246+ send_allow_data(cbd, gd->ril, attach_data->set_attached);
1247+ return;
1248+ }
1249+
1250+ if (message->error != RIL_E_SUCCESS) {
1251+ ofono_error("%s: RIL error %s", __func__,
1252+ ril_error_to_string(message->error));
1253+ CALLBACK_WITH_FAILURE(cb, cbd->data);
1254+ free_attach_cbd(cbd);
1255+ return;
1256+ }
1257+
1258+ gd->ofono_attached = attach_data->set_attached;
1259+
1260+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
1261+
1262+ free_attach_cbd(cbd);
1263+}
1264+
1265+static void send_allow_data(struct cb_data *cbd, GRil *ril, int attached)
1266+{
1267+ ofono_gprs_cb_t cb = cbd->cb;
1268+ struct parcel rilp;
1269+
1270+ /* ALLOW_DATA payload: int[] with attach value */
1271+ parcel_init(&rilp);
1272+ parcel_w_int32(&rilp, 1);
1273+ parcel_w_int32(&rilp, attached);
1274+
1275+ g_ril_append_print_buf(ril, "(%d)", attached);
1276+
1277+ if (g_ril_send(ril, RIL_REQUEST_ALLOW_DATA, &rilp,
1278+ gprs_allow_data_cb, cbd, NULL) == 0) {
1279+ ofono_error("%s: send failed", __func__);
1280+ free_attach_cbd(cbd);
1281+ CALLBACK_WITH_FAILURE(cb, cbd->data);
1282+ }
1283+}
1284+
1285 gboolean ril_gprs_set_attached_cb(gpointer user_data)
1286 {
1287 struct cb_data *cbd = user_data;
1288@@ -176,44 +251,55 @@
1289 return FALSE;
1290 }
1291
1292-static void ril_gprs_set_attached(struct ofono_gprs *gprs, int attached,
1293- ofono_gprs_cb_t cb, void *data)
1294+void ril_gprs_set_attached(struct ofono_gprs *gprs, int attached,
1295+ ofono_gprs_cb_t cb, void *data)
1296 {
1297 struct cb_data *cbd = cb_data_new(cb, data, NULL);
1298 struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);
1299+ struct gprs_attach_data *attach_data;
1300+ int attach_aux = attached;
1301
1302 DBG("attached: %d", attached);
1303
1304- /*
1305- * As RIL offers no actual control over the GPRS 'attached'
1306- * state, we save the desired state, and use it to override
1307- * the actual modem's state in the 'attached_status' function.
1308- * This is similar to the way the core ofono gprs code handles
1309- * data roaming ( see src/gprs.c gprs_netreg_update().
1310- *
1311- * The core gprs code calls driver->set_attached() when a netreg
1312- * notificaiton is received and any configured roaming conditions
1313- * are met.
1314- */
1315- gd->ofono_attached = attached;
1316-
1317- /*
1318- * Call from idle loop, so core can set driver_attached before
1319- * the callback is invoked.
1320- */
1321- g_idle_add(ril_gprs_set_attached_cb, cbd);
1322-}
1323-
1324-static gboolean ril_get_status_retry(gpointer user_data)
1325-{
1326- struct ofono_gprs *gprs = user_data;
1327- struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);
1328-
1329- gd->status_retry_cb_id = 0;
1330-
1331- ril_gprs_registration_status(gprs, NULL, NULL);
1332-
1333- return FALSE;
1334+ if (g_ril_get_version(gd->ril) < 10) {
1335+ /*
1336+ * Older RILs offer no actual control over the GPRS 'attached'
1337+ * state, we save the desired state, and use it to override
1338+ * the actual modem's state in the 'attached_status' function.
1339+ * This is similar to the way the core ofono gprs code handles
1340+ * data roaming ( see src/gprs.c gprs_netreg_update() ).
1341+ *
1342+ * The core gprs code calls driver->set_attached() when a netreg
1343+ * notificaiton is received and any configured roaming
1344+ * conditions are met.
1345+ */
1346+ gd->ofono_attached = attached;
1347+
1348+ /*
1349+ * Call from idle loop, so core can set driver_attached before
1350+ * the callback is invoked.
1351+ */
1352+ g_idle_add(ril_gprs_set_attached_cb, cbd);
1353+ return;
1354+ }
1355+
1356+ attach_data = g_new0(struct gprs_attach_data, 1);
1357+ attach_data->gd = gd;
1358+ attach_data->ril = gd->ril;
1359+ attach_data->set_attached = attached;
1360+ attach_data->detaching_other_slot = FALSE;
1361+
1362+ /* If we want to attach we have to detach the other slot */
1363+ if (attached && ril_get_gril_complement(gd->modem)) {
1364+ attach_data->ril = ril_get_gril_complement(gd->modem);
1365+ attach_data->detaching_other_slot = TRUE;
1366+
1367+ attach_aux = !attached;
1368+ }
1369+
1370+ cbd = cb_data_new(cb, data, attach_data);
1371+
1372+ send_allow_data(cbd, attach_data->ril, attach_aux);
1373 }
1374
1375 static void ril_data_reg_cb(struct ril_msg *message, gpointer user_data)
1376@@ -229,17 +315,32 @@
1377
1378 old_status = gd->rild_status;
1379
1380- if (message->error != RIL_E_SUCCESS) {
1381+ if (message->error == RIL_E_SUCCESS) {
1382+ reply = g_ril_reply_parse_data_reg_state(gd->ril, message);
1383+ if (reply == NULL) {
1384+ if (cb)
1385+ CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
1386+ return;
1387+ }
1388+ } else {
1389+ /*
1390+ * If we get a RIL error (say, radio not available) it is better
1391+ * to return unknown values than to call cb with failure status.
1392+ * If we do the last, ConnectionManager would not be created if
1393+ * this is the first time we retrieve data status, or we can
1394+ * even create infinite loops as the status in gprs atom would
1395+ * not be refreshed. When we finally register we will get events
1396+ * so we will try to retrieve data state again.
1397+ */
1398 ofono_error("%s: DATA_REGISTRATION_STATE reply failure: %s",
1399 __func__,
1400 ril_error_to_string(message->error));
1401- goto error;
1402+
1403+ reply = g_malloc0(sizeof(*reply));
1404+ reply->reg_state.status = NETWORK_REGISTRATION_STATUS_UNKNOWN;
1405+ reply->reg_state.tech = RADIO_TECH_UNKNOWN;
1406 }
1407
1408- reply = g_ril_reply_parse_data_reg_state(gd->ril, message);
1409- if (reply == NULL)
1410- goto error;
1411-
1412 /*
1413 * There are three cases that can result in this callback
1414 * running:
1415@@ -344,21 +445,6 @@
1416 CALLBACK_WITH_SUCCESS(cb, reply->reg_state.status, cbd->data);
1417
1418 g_free(reply);
1419-
1420- return;
1421-error:
1422-
1423- /*
1424- * For some modems DATA_REGISTRATION_STATE will return an error until we
1425- * are registered in the voice network.
1426- */
1427- if (old_status == -1 && message->error == RIL_E_GENERIC_FAILURE)
1428- gd->status_retry_cb_id =
1429- g_timeout_add(GET_STATUS_TIMER_MS,
1430- ril_get_status_retry, gprs);
1431-
1432- if (cb)
1433- CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
1434 }
1435
1436 void ril_gprs_registration_status(struct ofono_gprs *gprs,
1437
1438=== modified file 'drivers/rilmodem/gprs.h'
1439--- drivers/rilmodem/gprs.h 2015-01-29 14:50:30 +0000
1440+++ drivers/rilmodem/gprs.h 2016-07-01 17:24:58 +0000
1441@@ -38,6 +38,8 @@
1442 void ril_gprs_start(struct ril_gprs_driver_data *driver_data,
1443 struct ofono_gprs *gprs, struct ril_gprs_data *gd);
1444 gboolean ril_gprs_set_attached_cb(gpointer user_data);
1445+void ril_gprs_set_attached(struct ofono_gprs *gprs, int attached,
1446+ ofono_gprs_cb_t cb, void *data);
1447 void ril_gprs_registration_status(struct ofono_gprs *gprs,
1448 ofono_gprs_status_cb_t cb, void *data);
1449 void ril_gprs_set_ia_apn(struct ofono_gprs *gprs, const char *apn,
1450
1451=== modified file 'drivers/rilmodem/network-registration.c'
1452--- drivers/rilmodem/network-registration.c 2015-09-29 08:46:51 +0000
1453+++ drivers/rilmodem/network-registration.c 2016-07-01 17:24:58 +0000
1454@@ -40,6 +40,7 @@
1455
1456 #include "common.h"
1457 #include "gril.h"
1458+#include "rilutil.h"
1459 #include "rilmodem.h"
1460
1461 #include "grilreply.h"
1462@@ -81,6 +82,7 @@
1463 case RADIO_TECH_EDGE:
1464 return ACCESS_TECHNOLOGY_GSM_EGPRS;
1465 case RADIO_TECH_UMTS:
1466+ case RADIO_TECH_TD_SCDMA:
1467 return ACCESS_TECHNOLOGY_UTRAN;
1468 case RADIO_TECH_HSDPA:
1469 return ACCESS_TECHNOLOGY_UTRAN_HSDPA;
1470
1471=== modified file 'drivers/rilmodem/phonebook.c'
1472--- drivers/rilmodem/phonebook.c 2015-09-10 07:16:24 +0000
1473+++ drivers/rilmodem/phonebook.c 2016-07-01 17:24:58 +0000
1474@@ -48,6 +48,7 @@
1475 #include "simutil.h"
1476 #include "common.h"
1477
1478+#include "rilutil.h"
1479 #include "rilmodem.h"
1480
1481 #define UNUSED 0xFF
1482
1483=== modified file 'drivers/rilmodem/radio-settings.c'
1484--- drivers/rilmodem/radio-settings.c 2015-09-29 08:46:51 +0000
1485+++ drivers/rilmodem/radio-settings.c 2016-07-01 17:24:58 +0000
1486@@ -39,6 +39,7 @@
1487
1488 #include "gril.h"
1489
1490+#include "rilutil.h"
1491 #include "rilmodem.h"
1492
1493 #include "grilrequest.h"
1494@@ -229,23 +230,74 @@
1495 return FALSE;
1496 }
1497
1498+static void get_radio_caps_cb(struct ril_msg *message, gpointer user_data)
1499+{
1500+ unsigned int available_rats = 0;
1501+ struct cb_data *cbd = user_data;
1502+ ofono_radio_settings_available_rats_query_cb_t cb = cbd->cb;
1503+ struct ofono_radio_settings *rs = cbd->user;
1504+ struct radio_data *rd = ofono_radio_settings_get_data(rs);
1505+ struct reply_radio_capability *caps;
1506+
1507+ if (message->error != RIL_E_SUCCESS) {
1508+ ofono_error("%s: error %s", __func__,
1509+ ril_error_to_string(message->error));
1510+ CALLBACK_WITH_FAILURE(cb, 0, cbd->data);
1511+ return;
1512+ }
1513+
1514+ caps = g_ril_reply_parse_get_radio_capability(rd->ril, message);
1515+ if (caps == NULL) {
1516+ ofono_error("%s: parse error", __func__);
1517+ CALLBACK_WITH_FAILURE(cb, 0, cbd->data);
1518+ return;
1519+ }
1520+
1521+ if (caps->rat & RIL_RAF_GSM)
1522+ available_rats |= OFONO_RADIO_ACCESS_MODE_GSM;
1523+
1524+ if (caps->rat & (RIL_RAF_UMTS | RIL_RAF_TD_SCDMA))
1525+ available_rats |= OFONO_RADIO_ACCESS_MODE_UMTS;
1526+
1527+ if (caps->rat & RIL_RAF_LTE)
1528+ available_rats |= OFONO_RADIO_ACCESS_MODE_LTE;
1529+
1530+ g_free(caps);
1531+
1532+ CALLBACK_WITH_SUCCESS(cb, available_rats, cbd->data);
1533+}
1534+
1535 void ril_query_available_rats(struct ofono_radio_settings *rs,
1536 ofono_radio_settings_available_rats_query_cb_t cb,
1537 void *data)
1538 {
1539+ struct radio_data *rd = ofono_radio_settings_get_data(rs);
1540 struct cb_data *cbd = cb_data_new(cb, data, rs);
1541
1542- g_idle_add(query_available_rats_cb, cbd);
1543+ if (g_ril_get_version(rd->ril) < 11) {
1544+ g_idle_add(query_available_rats_cb, cbd);
1545+ return;
1546+ }
1547+
1548+ if (g_ril_send(rd->ril, RIL_REQUEST_GET_RADIO_CAPABILITY, NULL,
1549+ get_radio_caps_cb, cbd, g_free) <= 0) {
1550+ g_free(cbd);
1551+ CALLBACK_WITH_FAILURE(cb, 0, data);
1552+ }
1553 }
1554
1555 void ril_delayed_register(const struct ofono_error *error, void *user_data)
1556 {
1557 struct ofono_radio_settings *rs = user_data;
1558
1559- if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
1560- ofono_radio_settings_register(rs);
1561- else
1562+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
1563 ofono_error("%s: cannot set default fast dormancy", __func__);
1564+
1565+ /*
1566+ * We register in all cases, setting FD some times fails until radio is
1567+ * available (this happens on turbo and maybe in other devices).
1568+ */
1569+ ofono_radio_settings_register(rs);
1570 }
1571
1572 static int ril_radio_settings_probe(struct ofono_radio_settings *rs,
1573
1574=== modified file 'drivers/rilmodem/rilmodem.h'
1575--- drivers/rilmodem/rilmodem.h 2014-10-29 15:59:10 +0000
1576+++ drivers/rilmodem/rilmodem.h 2016-07-01 17:24:58 +0000
1577@@ -20,8 +20,6 @@
1578 *
1579 */
1580
1581-#include "rilutil.h"
1582-
1583 #define RILMODEM "rilmodem"
1584
1585 /* Shared constants */
1586
1587=== modified file 'drivers/rilmodem/sim.c'
1588--- drivers/rilmodem/sim.c 2016-03-14 08:16:40 +0000
1589+++ drivers/rilmodem/sim.c 2016-07-01 17:24:58 +0000
1590@@ -46,6 +46,7 @@
1591 #include "grilutil.h"
1592 #include "parcel.h"
1593 #include "ril_constants.h"
1594+#include "rilutil.h"
1595 #include "rilmodem.h"
1596
1597 #include "grilreply.h"
1598@@ -943,7 +944,8 @@
1599 g_free(cbd);
1600 CALLBACK_WITH_FAILURE(cb, NULL, data);
1601 }
1602- } else if (sd->vendor == OFONO_RIL_VENDOR_MTK) {
1603+ } else if (sd->vendor == OFONO_RIL_VENDOR_MTK ||
1604+ sd->vendor == OFONO_RIL_VENDOR_MTK2) {
1605 struct cb_data *cbd = cb_data_new(cb, data, sd);
1606 struct parcel rilp;
1607 const char *at_epinc[] = { "AT+EPINC", "+EPINC:" };
1608
1609=== modified file 'drivers/rilmodem/sms.c'
1610--- drivers/rilmodem/sms.c 2016-03-14 08:16:40 +0000
1611+++ drivers/rilmodem/sms.c 2016-07-01 17:24:58 +0000
1612@@ -42,6 +42,7 @@
1613 #include "util.h"
1614
1615 #include "rilmodem.h"
1616+#include "rilutil.h"
1617 #include "grilrequest.h"
1618 #include "grilreply.h"
1619 #include "grilunsol.h"
1620
1621=== modified file 'drivers/rilmodem/ussd.c'
1622--- drivers/rilmodem/ussd.c 2014-05-12 14:21:13 +0000
1623+++ drivers/rilmodem/ussd.c 2016-07-01 17:24:58 +0000
1624@@ -43,6 +43,7 @@
1625 #include "grilrequest.h"
1626 #include "grilunsol.h"
1627
1628+#include "rilutil.h"
1629 #include "rilmodem.h"
1630
1631 #include "ril_constants.h"
1632@@ -170,6 +171,7 @@
1633 struct ofono_ussd *ussd = user_data;
1634 struct ussd_data *ud = ofono_ussd_get_data(ussd);
1635 struct unsol_ussd *unsol;
1636+ enum ofono_ril_vendor vendor;
1637
1638 unsol = g_ril_unsol_parse_ussd(ud->ril, message);
1639 if (unsol == NULL) {
1640@@ -178,8 +180,10 @@
1641 }
1642
1643 /* To fix bug in MTK: USSD-Notify arrive with type 2 instead of 0 */
1644- if (g_ril_vendor(ud->ril) == OFONO_RIL_VENDOR_MTK &&
1645- unsol->message != NULL && unsol->type == 2)
1646+ vendor = g_ril_vendor(ud->ril);
1647+ if ((vendor == OFONO_RIL_VENDOR_MTK ||
1648+ vendor == OFONO_RIL_VENDOR_MTK2)
1649+ && unsol->message != NULL && unsol->type == 2)
1650 unsol->type = 0;
1651
1652 /*
1653
1654=== modified file 'drivers/rilmodem/vendor.h'
1655--- drivers/rilmodem/vendor.h 2015-04-23 13:08:30 +0000
1656+++ drivers/rilmodem/vendor.h 2016-07-01 17:24:58 +0000
1657@@ -26,7 +26,8 @@
1658 OFONO_RIL_VENDOR_AOSP = 0,
1659 OFONO_RIL_VENDOR_MTK,
1660 OFONO_RIL_VENDOR_INFINEON,
1661- OFONO_RIL_VENDOR_QCOM_MSIM
1662+ OFONO_RIL_VENDOR_QCOM_MSIM,
1663+ OFONO_RIL_VENDOR_MTK2
1664 };
1665
1666 #endif /* RILMODEM_VENDOR_H */
1667
1668=== modified file 'drivers/rilmodem/voicecall.c'
1669--- drivers/rilmodem/voicecall.c 2015-10-07 07:14:11 +0000
1670+++ drivers/rilmodem/voicecall.c 2016-07-01 17:24:58 +0000
1671@@ -45,6 +45,7 @@
1672 #include "grilunsol.h"
1673
1674 #include "common.h"
1675+#include "rilutil.h"
1676 #include "rilmodem.h"
1677 #include "voicecall.h"
1678
1679
1680=== modified file 'gril/grilreply.c'
1681--- gril/grilreply.c 2016-03-14 08:16:40 +0000
1682+++ gril/grilreply.c 2016-07-01 17:24:58 +0000
1683@@ -84,8 +84,9 @@
1684 unsigned int num_ops, num_strings;
1685 unsigned int i;
1686 int strings_per_opt;
1687+ enum ofono_ril_vendor vendor = g_ril_vendor(gril);
1688
1689- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
1690+ if (vendor == OFONO_RIL_VENDOR_MTK)
1691 strings_per_opt = 5;
1692 else
1693 strings_per_opt = 4;
1694@@ -142,7 +143,7 @@
1695 * MTK: additional string with technology: 2G/3G are the only
1696 * valid values currently.
1697 */
1698- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) {
1699+ if (vendor == OFONO_RIL_VENDOR_MTK) {
1700 char *tech = parcel_r_string(&rilp);
1701 if (strcmp(tech, "3G") == 0)
1702 operator->tech = RADIO_TECH_UMTS;
1703@@ -336,7 +337,8 @@
1704 g_ril_append_print_buf(gril, "%s%s", print_buf,
1705 ril_radio_tech_to_string(val));
1706
1707- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) {
1708+ if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK ||
1709+ g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK2) {
1710 switch (val) {
1711 case MTK_RADIO_TECH_HSDPAP:
1712 case MTK_RADIO_TECH_HSDPAP_UPA:
1713@@ -452,7 +454,8 @@
1714 * MTK modem does not return max_cids, string for this index
1715 * actually contains the maximum data bearer capability.
1716 */
1717- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
1718+ if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK ||
1719+ g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK2)
1720 reply->max_cids = MTK_MODEM_MAX_CIDS;
1721 else
1722 reply->max_cids = val;
1723@@ -1182,7 +1185,8 @@
1724 net_type = parcel_net_type;
1725
1726 /* Try to translate special MTK settings */
1727- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) {
1728+ if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK ||
1729+ g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK2) {
1730 switch (net_type) {
1731 /* 4G preferred */
1732 case MTK_PREF_NET_TYPE_LTE_GSM_WCDMA:
1733@@ -1325,6 +1329,7 @@
1734 g_ril_append_print_buf(gril, "{%d}", retries[passwd_type]);
1735 break;
1736 case OFONO_RIL_VENDOR_MTK:
1737+ case OFONO_RIL_VENDOR_MTK2:
1738 /*
1739 * Some versions of MTK modem return just the retries for the
1740 * password just entered while others return the retries for all
1741@@ -1456,3 +1461,99 @@
1742 out:
1743 return str_arr;
1744 }
1745+
1746+struct reply_radio_capability *g_ril_reply_parse_get_radio_capability(
1747+ GRil *gril, const struct ril_msg *message)
1748+{
1749+ struct reply_radio_capability *reply;
1750+ struct parcel rilp;
1751+ char *modem_uuid;
1752+
1753+ reply = g_new0(struct reply_radio_capability, 1);
1754+ g_ril_init_parcel(message, &rilp);
1755+
1756+ reply->version = parcel_r_int32(&rilp);
1757+ reply->session = parcel_r_int32(&rilp);
1758+ reply->phase = parcel_r_int32(&rilp);
1759+ reply->rat = parcel_r_int32(&rilp);
1760+ modem_uuid = parcel_r_string(&rilp);
1761+ if (modem_uuid != NULL)
1762+ strcpy(reply->modem_uuid, modem_uuid);
1763+
1764+ reply->status = parcel_r_int32(&rilp);
1765+
1766+ if (rilp.malformed) {
1767+ ofono_error("%s: malformed parcel", __func__);
1768+ g_free(reply);
1769+ reply = NULL;
1770+ goto end;
1771+ }
1772+
1773+ g_ril_append_print_buf(gril, "{%d,%d,%s,[",
1774+ reply->version, reply->session,
1775+ ril_rc_phase_to_string(reply->phase));
1776+
1777+ if (reply->rat & RIL_RAF_UNKNOWN)
1778+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1779+ ril_radio_tech_to_string(RADIO_TECH_UNKNOWN));
1780+ if (reply->rat & RIL_RAF_GPRS)
1781+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1782+ ril_radio_tech_to_string(RADIO_TECH_GPRS));
1783+ if (reply->rat & RIL_RAF_EDGE)
1784+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1785+ ril_radio_tech_to_string(RADIO_TECH_EDGE));
1786+ if (reply->rat & RIL_RAF_UMTS)
1787+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1788+ ril_radio_tech_to_string(RADIO_TECH_UMTS));
1789+ if (reply->rat & RIL_RAF_IS95A)
1790+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1791+ ril_radio_tech_to_string(RADIO_TECH_IS95A));
1792+ if (reply->rat & RIL_RAF_IS95B)
1793+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1794+ ril_radio_tech_to_string(RADIO_TECH_IS95B));
1795+ if (reply->rat & RIL_RAF_1xRTT)
1796+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1797+ ril_radio_tech_to_string(RADIO_TECH_1xRTT));
1798+ if (reply->rat & RIL_RAF_EVDO_0)
1799+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1800+ ril_radio_tech_to_string(RADIO_TECH_EVDO_0));
1801+ if (reply->rat & RIL_RAF_EVDO_A)
1802+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1803+ ril_radio_tech_to_string(RADIO_TECH_EVDO_A));
1804+ if (reply->rat & RIL_RAF_HSDPA)
1805+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1806+ ril_radio_tech_to_string(RADIO_TECH_HSDPA));
1807+ if (reply->rat & RIL_RAF_HSUPA)
1808+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1809+ ril_radio_tech_to_string(RADIO_TECH_HSUPA));
1810+ if (reply->rat & RIL_RAF_HSPA)
1811+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1812+ ril_radio_tech_to_string(RADIO_TECH_HSPA));
1813+ if (reply->rat & RIL_RAF_EVDO_B)
1814+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1815+ ril_radio_tech_to_string(RADIO_TECH_EVDO_B));
1816+ if (reply->rat & RIL_RAF_EHRPD)
1817+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1818+ ril_radio_tech_to_string(RADIO_TECH_EHRPD));
1819+ if (reply->rat & RIL_RAF_LTE)
1820+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1821+ ril_radio_tech_to_string(RADIO_TECH_LTE));
1822+ if (reply->rat & RIL_RAF_HSPAP)
1823+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1824+ ril_radio_tech_to_string(RADIO_TECH_HSPAP));
1825+ if (reply->rat & RIL_RAF_GSM)
1826+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1827+ ril_radio_tech_to_string(RADIO_TECH_GSM));
1828+ if (reply->rat & RIL_RAF_TD_SCDMA)
1829+ g_ril_append_print_buf(gril, "%s%s,", print_buf,
1830+ ril_radio_tech_to_string(RADIO_TECH_TD_SCDMA));
1831+
1832+ g_ril_append_print_buf(gril, "%s],%s,%s}", print_buf,
1833+ reply->modem_uuid,
1834+ ril_rc_status_to_string(reply->status));
1835+
1836+ g_ril_print_response(gril, message);
1837+
1838+end:
1839+ return reply;
1840+}
1841
1842=== modified file 'gril/grilreply.h'
1843--- gril/grilreply.h 2015-03-18 14:05:58 +0000
1844+++ gril/grilreply.h 2016-07-01 17:24:58 +0000
1845@@ -97,6 +97,15 @@
1846 void *data;
1847 };
1848
1849+struct reply_radio_capability {
1850+ int version;
1851+ int session;
1852+ int phase;
1853+ int rat;
1854+ char modem_uuid[RIL_MAX_UUID_LENGTH];
1855+ int status;
1856+};
1857+
1858 void g_ril_reply_free_avail_ops(struct reply_avail_ops *reply);
1859
1860 struct reply_avail_ops *g_ril_reply_parse_avail_ops(GRil *gril,
1861@@ -178,6 +187,9 @@
1862 struct parcel_str_array *g_ril_reply_oem_hook_strings(GRil *gril,
1863 const struct ril_msg *message);
1864
1865+struct reply_radio_capability *g_ril_reply_parse_get_radio_capability(
1866+ GRil *gril, const struct ril_msg *message);
1867+
1868 #ifdef __cplusplus
1869 }
1870 #endif
1871
1872=== modified file 'gril/grilrequest.c'
1873--- gril/grilrequest.c 2015-09-29 08:47:19 +0000
1874+++ gril/grilrequest.c 2016-07-01 17:24:58 +0000
1875@@ -112,6 +112,7 @@
1876 unsigned char *comm_path = db_path;
1877 char *hex_path = NULL;
1878 int len = 0;
1879+ enum ofono_ril_vendor vendor = g_ril_vendor(ril);
1880
1881 if (path_len > 0 && path_len < 7) {
1882 memcpy(db_path, path, path_len);
1883@@ -133,7 +134,8 @@
1884 * ETSI TS 102 221, section 8.4.2 (we are accessing the card in mode
1885 * "select by path from MF", see 3gpp 27.007, +CRSM).
1886 */
1887- if (g_ril_vendor(ril) == OFONO_RIL_VENDOR_MTK && len >= (int) ROOTMF_SZ
1888+ if ((vendor == OFONO_RIL_VENDOR_MTK || vendor == OFONO_RIL_VENDOR_MTK2)
1889+ && len >= (int) ROOTMF_SZ
1890 && memcmp(db_path, ROOTMF, ROOTMF_SZ) == 0) {
1891 comm_path = db_path + ROOTMF_SZ;
1892 len -= ROOTMF_SZ;
1893@@ -242,10 +244,11 @@
1894 gchar *auth_str;
1895 gchar *profile_str;
1896 int num_param = SETUP_DATA_CALL_PARAMS;
1897+ enum ofono_ril_vendor vendor = g_ril_vendor(gril);
1898
1899 DBG("");
1900
1901- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
1902+ if (vendor == OFONO_RIL_VENDOR_MTK || vendor == OFONO_RIL_VENDOR_MTK2)
1903 num_param = SETUP_DATA_CALL_PARAMS + 1;
1904
1905 /*
1906@@ -281,7 +284,7 @@
1907 profile_str = DATA_PROFILE_CBS_STR;
1908 break;
1909 case RIL_DATA_PROFILE_MTK_MMS:
1910- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) {
1911+ if (vendor == OFONO_RIL_VENDOR_MTK) {
1912 profile_str = DATA_PROFILE_MTK_MMS_STR;
1913 break;
1914 }
1915@@ -335,7 +338,7 @@
1916 auth_str,
1917 protocol_str);
1918
1919- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) {
1920+ if (vendor == OFONO_RIL_VENDOR_MTK || vendor == OFONO_RIL_VENDOR_MTK2) {
1921 /* MTK request_cid parameter */
1922 char cid_str[MAX_CID_DIGITS + 1];
1923
1924@@ -361,6 +364,8 @@
1925 const struct req_sim_read_info *req,
1926 struct parcel *rilp)
1927 {
1928+ enum ofono_ril_vendor vendor = g_ril_vendor(gril);
1929+
1930 parcel_init(rilp);
1931
1932 parcel_w_int32(rilp, CMD_GET_RESPONSE);
1933@@ -396,7 +401,7 @@
1934 * It looks like this field selects one or another SIM application, but
1935 * we use only one at a time so using zero here seems safe.
1936 */
1937- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
1938+ if (vendor == OFONO_RIL_VENDOR_MTK || vendor == OFONO_RIL_VENDOR_MTK2)
1939 parcel_w_int32(rilp, 0);
1940
1941 return TRUE;
1942@@ -409,6 +414,8 @@
1943 const struct req_sim_read_binary *req,
1944 struct parcel *rilp)
1945 {
1946+ enum ofono_ril_vendor vendor = g_ril_vendor(gril);
1947+
1948 g_ril_append_print_buf(gril,
1949 "(cmd=0x%.2X,efid=0x%.4X,",
1950 CMD_READ_BINARY,
1951@@ -430,7 +437,7 @@
1952 parcel_w_string(rilp, req->aid_str);
1953
1954 /* sessionId, specific to latest MTK modems (harmless for older ones) */
1955- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
1956+ if (vendor == OFONO_RIL_VENDOR_MTK || vendor == OFONO_RIL_VENDOR_MTK2)
1957 parcel_w_int32(rilp, 0);
1958
1959 return TRUE;
1960@@ -443,6 +450,8 @@
1961 const struct req_sim_read_record *req,
1962 struct parcel *rilp)
1963 {
1964+ enum ofono_ril_vendor vendor = g_ril_vendor(gril);
1965+
1966 parcel_init(rilp);
1967 parcel_w_int32(rilp, CMD_READ_RECORD);
1968 parcel_w_int32(rilp, req->fileid);
1969@@ -464,7 +473,7 @@
1970 parcel_w_string(rilp, req->aid_str); /* AID (Application ID) */
1971
1972 /* sessionId, specific to latest MTK modems (harmless for older ones) */
1973- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
1974+ if (vendor == OFONO_RIL_VENDOR_MTK || vendor == OFONO_RIL_VENDOR_MTK2)
1975 parcel_w_int32(rilp, 0);
1976
1977 return TRUE;
1978@@ -477,6 +486,7 @@
1979 const struct req_sim_write_binary *req,
1980 struct parcel *rilp)
1981 {
1982+ enum ofono_ril_vendor vendor = g_ril_vendor(gril);
1983 char *hex_data;
1984 int p1, p2;
1985
1986@@ -503,7 +513,7 @@
1987 parcel_w_string(rilp, req->aid_str); /* AID (Application ID) */
1988
1989 /* sessionId, specific to latest MTK modems (harmless for older ones) */
1990- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
1991+ if (vendor == OFONO_RIL_VENDOR_MTK || vendor == OFONO_RIL_VENDOR_MTK2)
1992 parcel_w_int32(rilp, 0);
1993
1994 g_ril_append_print_buf(gril,
1995@@ -543,6 +553,7 @@
1996 const struct req_sim_write_record *req,
1997 struct parcel *rilp)
1998 {
1999+ enum ofono_ril_vendor vendor = g_ril_vendor(gril);
2000 char *hex_data;
2001 int p2;
2002
2003@@ -568,7 +579,7 @@
2004 parcel_w_string(rilp, req->aid_str); /* AID (Application ID) */
2005
2006 /* sessionId, specific to latest MTK modems (harmless for older ones) */
2007- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
2008+ if (vendor == OFONO_RIL_VENDOR_MTK || vendor == OFONO_RIL_VENDOR_MTK2)
2009 parcel_w_int32(rilp, 0);
2010
2011 g_ril_append_print_buf(gril,
2012@@ -1103,6 +1114,7 @@
2013 const char *mccmnc,
2014 struct parcel *rilp)
2015 {
2016+ enum ofono_ril_vendor vendor = g_ril_vendor(gril);
2017 const char *proto_str;
2018 const int auth_type = RIL_AUTH_ANY;
2019
2020@@ -1121,12 +1133,21 @@
2021 ril_authtype_to_string(auth_type),
2022 user, passwd);
2023
2024- if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) {
2025+ if (vendor == OFONO_RIL_VENDOR_MTK || vendor == OFONO_RIL_VENDOR_MTK2) {
2026 parcel_w_string(rilp, mccmnc);
2027- g_ril_append_print_buf(gril, "%s,%s)", print_buf, mccmnc);
2028- } else {
2029- g_ril_append_print_buf(gril, "%s)", print_buf);
2030+ g_ril_append_print_buf(gril, "%s,%s", print_buf, mccmnc);
2031+ if (vendor == OFONO_RIL_VENDOR_MTK2) {
2032+ int can_handle_ims = 0;
2033+
2034+ parcel_w_int32(rilp, can_handle_ims);
2035+ /* dualApnPlmnList */
2036+ parcel_w_string(rilp, NULL);
2037+ g_ril_append_print_buf(gril, "%s,%d,(null)", print_buf,
2038+ can_handle_ims);
2039+ }
2040 }
2041+
2042+ g_ril_append_print_buf(gril, "%s)", print_buf);
2043 }
2044
2045 void g_ril_request_set_uicc_subscription(GRil *gril, int slot_id,
2046
2047=== modified file 'gril/grilunsol.c'
2048--- gril/grilunsol.c 2016-03-11 04:20:17 +0000
2049+++ gril/grilunsol.c 2016-07-01 17:24:58 +0000
2050@@ -61,12 +61,22 @@
2051 size = parcel_r_int32(&rilp);
2052 version = parcel_r_int32(&rilp);
2053
2054+ /*
2055+ * For something that looks like a bug we get an extra int in mtk2
2056+ * modems. RIL version is the second integer in this case. This
2057+ * happens when we get duplicated connected events, which should
2058+ * not happen either. In these cases the first event has the right
2059+ * size, but not those appearing after.
2060+ */
2061+ if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK2 && size > 1)
2062+ version = parcel_r_int32(&rilp);
2063+
2064 if (rilp.malformed) {
2065 ofono_error("%s: malformed parcel", __func__);
2066 version = RIL_VERSION_UNSPECIFIED;
2067 }
2068
2069- g_ril_append_print_buf(gril, "{size:%d, [%d, ...]}", size, version);
2070+ g_ril_append_print_buf(gril, "{size: %d, [%d]}", size, version);
2071 g_ril_print_unsol(gril, message);
2072
2073 return version;
2074
2075=== modified file 'gril/grilutil.c'
2076--- gril/grilutil.c 2015-11-10 09:12:03 +0000
2077+++ gril/grilutil.c 2016-07-01 17:24:58 +0000
2078@@ -268,6 +268,10 @@
2079 return "HSPAP";
2080 case RADIO_TECH_GSM:
2081 return "GSM";
2082+ case RADIO_TECH_TD_SCDMA:
2083+ return "TD_SCDMA";
2084+ case RADIO_TECH_IWLAN:
2085+ return "IWLAN";
2086 case MTK_RADIO_TECH_HSDPAP:
2087 return "MTK_HSDPAP";
2088 case MTK_RADIO_TECH_HSDPAP_UPA:
2089@@ -517,6 +521,54 @@
2090 return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
2091 case RIL_REQUEST_SET_INITIAL_ATTACH_APN:
2092 return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
2093+ case RIL_REQUEST_IMS_REGISTRATION_STATE:
2094+ return "RIL_REQUEST_IMS_REGISTRATION_STATE";
2095+ case RIL_REQUEST_IMS_SEND_SMS:
2096+ return "RIL_REQUEST_IMS_SEND_SMS";
2097+ case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC:
2098+ return "RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC";
2099+ case RIL_REQUEST_SIM_OPEN_CHANNEL:
2100+ return "RIL_REQUEST_SIM_OPEN_CHANNEL";
2101+ case RIL_REQUEST_SIM_CLOSE_CHANNEL:
2102+ return "RIL_REQUEST_SIM_CLOSE_CHANNEL";
2103+ case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL:
2104+ return "RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL";
2105+ case RIL_REQUEST_NV_READ_ITEM:
2106+ return "RIL_REQUEST_NV_READ_ITEM";
2107+ case RIL_REQUEST_NV_WRITE_ITEM:
2108+ return "RIL_REQUEST_NV_WRITE_ITEM";
2109+ case RIL_REQUEST_NV_WRITE_CDMA_PRL:
2110+ return "RIL_REQUEST_NV_WRITE_CDMA_PRL";
2111+ case RIL_REQUEST_NV_RESET_CONFIG:
2112+ return "RIL_REQUEST_NV_RESET_CONFIG";
2113+ case RIL_REQUEST_SET_UICC_SUBSCRIPTION :
2114+ return "RIL_REQUEST_SET_UICC_SUBSCRIPTION ";
2115+ case RIL_REQUEST_ALLOW_DATA :
2116+ return "RIL_REQUEST_ALLOW_DATA ";
2117+ case RIL_REQUEST_GET_HARDWARE_CONFIG:
2118+ return "RIL_REQUEST_GET_HARDWARE_CONFIG";
2119+ case RIL_REQUEST_SIM_AUTHENTICATION:
2120+ return "RIL_REQUEST_SIM_AUTHENTICATION";
2121+ case RIL_REQUEST_GET_DC_RT_INFO:
2122+ return "RIL_REQUEST_GET_DC_RT_INFO";
2123+ case RIL_REQUEST_SET_DC_RT_INFO_RATE:
2124+ return "RIL_REQUEST_SET_DC_RT_INFO_RATE";
2125+ case RIL_REQUEST_SET_DATA_PROFILE:
2126+ return "RIL_REQUEST_SET_DATA_PROFILE";
2127+ case RIL_REQUEST_SHUTDOWN:
2128+ return "RIL_REQUEST_SHUTDOWN";
2129+ case RIL_REQUEST_GET_RADIO_CAPABILITY:
2130+ return "RIL_REQUEST_GET_RADIO_CAPABILITY";
2131+ case RIL_REQUEST_SET_RADIO_CAPABILITY:
2132+ return "RIL_REQUEST_SET_RADIO_CAPABILITY";
2133+ case RIL_REQUEST_START_LCE:
2134+ return "RIL_REQUEST_START_LCE";
2135+ case RIL_REQUEST_STOP_LCE:
2136+ return "RIL_REQUEST_STOP_LCE";
2137+ case RIL_REQUEST_PULL_LCEDATA:
2138+ return "RIL_REQUEST_PULL_LCEDATA";
2139+ case RIL_REQUEST_GET_ACTIVITY_INFO:
2140+ return "RIL_REQUEST_GET_ACTIVITY_INFO";
2141 default:
2142 return "<INVALID>";
2143 }
2144@@ -595,8 +647,30 @@
2145 return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
2146 case RIL_UNSOL_RIL_CONNECTED:
2147 return "UNSOL_RIL_CONNECTED";
2148+ case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED:
2149+ return "RIL_UNSOL_VOICE_RADIO_TECH_CHANGED";
2150+ case RIL_UNSOL_CELL_INFO_LIST:
2151+ return "RIL_UNSOL_CELL_INFO_LIST";
2152+ case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:
2153+ return "RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED";
2154+ case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED:
2155+ return "RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
2156+ case RIL_UNSOL_SRVCC_STATE_NOTIFY:
2157+ return "RIL_UNSOL_SRVCC_STATE_NOTIFY";
2158+ case RIL_UNSOL_HARDWARE_CONFIG_CHANGED:
2159+ return "RIL_UNSOL_HARDWARE_CONFIG_CHANGED";
2160+ case RIL_UNSOL_DC_RT_INFO_CHANGED:
2161+ return "RIL_UNSOL_DC_RT_INFO_CHANGED";
2162+ case RIL_UNSOL_RADIO_CAPABILITY:
2163+ return "RIL_UNSOL_RADIO_CAPABILITY";
2164+ case RIL_UNSOL_ON_SS:
2165+ return "RIL_UNSOL_ON_SS";
2166+ case RIL_UNSOL_STK_CC_ALPHA_NOTIFY:
2167+ return "RIL_UNSOL_STK_CC_ALPHA_NOTIFY";
2168+ case RIL_UNSOL_LCEDATA_RECV:
2169+ return "RIL_UNSOL_LCEDATA_RECV";
2170 default:
2171- return "<unknown request>";
2172+ return "<unknown event>";
2173 }
2174 }
2175
2176@@ -660,6 +734,38 @@
2177 }
2178 }
2179
2180+const char *ril_rc_phase_to_string(int phase)
2181+{
2182+ switch (phase) {
2183+ case RIL_RC_PHASE_CONFIGURED:
2184+ return "RIL_RC_PHASE_CONFIGURED";
2185+ case RIL_RC_PHASE_START:
2186+ return "RIL_RC_PHASE_START";
2187+ case RIL_RC_PHASE_APPLY:
2188+ return "RIL_RC_PHASE_APPLY";
2189+ case RIL_RC_PHASE_UNSOL_RSP:
2190+ return "RIL_RC_PHASE_UNSOL_RSP";
2191+ case RIL_RC_PHASE_FINISH:
2192+ return "RIL_RC_PHASE_FINISH";
2193+ default:
2194+ return "<UNKNOWN RC PHASE>";
2195+ }
2196+}
2197+
2198+const char *ril_rc_status_to_string(int status)
2199+{
2200+ switch (status) {
2201+ case RIL_RC_STATUS_NONE:
2202+ return "RC_STATUS_NONE";
2203+ case RIL_RC_STATUS_SUCCESS:
2204+ return "RC_STATUS_SUCCESS";
2205+ case RIL_RC_STATUS_FAIL:
2206+ return "RC_STATUS_FAIL";
2207+ default:
2208+ return "<UNKNOWN RC STATUS>";
2209+ }
2210+}
2211+
2212 void g_ril_util_debug_hexdump(gboolean in, const unsigned char *buf, gsize len,
2213 GRilDebugFunc debugf, gpointer user_data)
2214 {
2215
2216=== modified file 'gril/grilutil.h'
2217--- gril/grilutil.h 2015-11-10 09:11:52 +0000
2218+++ gril/grilutil.h 2016-07-01 17:24:58 +0000
2219@@ -44,6 +44,8 @@
2220 const char *ril_request_id_to_string(int req);
2221 const char *ril_unsol_request_to_string(int request);
2222 const char *ril_pdp_fail_to_string(int status);
2223+const char *ril_rc_phase_to_string(int phase);
2224+const char *ril_rc_status_to_string(int status);
2225
2226 void g_ril_util_debug_hexdump(gboolean in, const unsigned char *buf, gsize len,
2227 GRilDebugFunc debugf, gpointer user_data);
2228
2229=== modified file 'gril/ril_constants.h'
2230--- gril/ril_constants.h 2016-03-11 04:20:17 +0000
2231+++ gril/ril_constants.h 2016-07-01 17:24:58 +0000
2232@@ -26,6 +26,8 @@
2233
2234 #define RIL_VERSION_UNSPECIFIED 0
2235
2236+#define RIL_MAX_UUID_LENGTH 64
2237+
2238 /* Error Codes */
2239 #define RIL_E_SUCCESS 0
2240 #define RIL_E_RADIO_NOT_AVAILABLE 1
2241@@ -140,6 +142,8 @@
2242 #define RADIO_TECH_LTE 14
2243 #define RADIO_TECH_HSPAP 15
2244 #define RADIO_TECH_GSM 16
2245+#define RADIO_TECH_TD_SCDMA 17
2246+#define RADIO_TECH_IWLAN 18
2247 /* MTK specific values for radio technologies */
2248 #define MTK_RADIO_TECH_BASE 128
2249 #define MTK_RADIO_TECH_HSDPAP (MTK_RADIO_TECH_BASE + 1)
2250@@ -372,6 +376,30 @@
2251 #define RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS 107
2252 #define RIL_REQUEST_VOICE_RADIO_TECH 108
2253 #define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111
2254+#define RIL_REQUEST_IMS_REGISTRATION_STATE 112
2255+#define RIL_REQUEST_IMS_SEND_SMS 113
2256+#define RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC 114
2257+#define RIL_REQUEST_SIM_OPEN_CHANNEL 115
2258+#define RIL_REQUEST_SIM_CLOSE_CHANNEL 116
2259+#define RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL 117
2260+#define RIL_REQUEST_NV_READ_ITEM 118
2261+#define RIL_REQUEST_NV_WRITE_ITEM 119
2262+#define RIL_REQUEST_NV_WRITE_CDMA_PRL 120
2263+#define RIL_REQUEST_NV_RESET_CONFIG 121
2264+#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 122
2265+#define RIL_REQUEST_ALLOW_DATA 123
2266+#define RIL_REQUEST_GET_HARDWARE_CONFIG 124
2267+#define RIL_REQUEST_SIM_AUTHENTICATION 125
2268+#define RIL_REQUEST_GET_DC_RT_INFO 126
2269+#define RIL_REQUEST_SET_DC_RT_INFO_RATE 127
2270+#define RIL_REQUEST_SET_DATA_PROFILE 128
2271+#define RIL_REQUEST_SHUTDOWN 129
2272+#define RIL_REQUEST_GET_RADIO_CAPABILITY 130
2273+#define RIL_REQUEST_SET_RADIO_CAPABILITY 131
2274+#define RIL_REQUEST_START_LCE 132
2275+#define RIL_REQUEST_STOP_LCE 133
2276+#define RIL_REQUEST_PULL_LCEDATA 134
2277+#define RIL_REQUEST_GET_ACTIVITY_INFO 135
2278
2279 /* RIL Unsolicited Messages */
2280 #define RIL_UNSOL_RESPONSE_BASE 1000
2281@@ -411,6 +439,16 @@
2282 #define RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE 1033
2283 #define RIL_UNSOL_RIL_CONNECTED 1034
2284 #define RIL_UNSOL_VOICE_RADIO_TECH_CHANGED 1035
2285+#define RIL_UNSOL_CELL_INFO_LIST 1036
2286+#define RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED 1037
2287+#define RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED 1038
2288+#define RIL_UNSOL_SRVCC_STATE_NOTIFY 1039
2289+#define RIL_UNSOL_HARDWARE_CONFIG_CHANGED 1040
2290+#define RIL_UNSOL_DC_RT_INFO_CHANGED 1041
2291+#define RIL_UNSOL_RADIO_CAPABILITY 1042
2292+#define RIL_UNSOL_ON_SS 1043
2293+#define RIL_UNSOL_STK_CC_ALPHA_NOTIFY 1044
2294+#define RIL_UNSOL_LCEDATA_RECV 1045
2295
2296 /* Suplementary services Service class*/
2297 #define SERVICE_CLASS_NONE 0
2298@@ -427,4 +465,36 @@
2299 #define RIL_REG_STATE_EMERGENCY_DENIED 13
2300 #define RIL_REG_STATE_EMERGENCY_UNKNOWN 14
2301
2302+/* Radio capability phases */
2303+#define RIL_RC_PHASE_CONFIGURED 0
2304+#define RIL_RC_PHASE_START 1
2305+#define RIL_RC_PHASE_APPLY 2
2306+#define RIL_RC_PHASE_UNSOL_RSP 3
2307+#define RIL_RC_PHASE_FINISH 4
2308+
2309+/* Radio access family, as flag */
2310+#define RIL_RAF_UNKNOWN (1 << RADIO_TECH_UNKNOWN)
2311+#define RIL_RAF_GPRS (1 << RADIO_TECH_GPRS)
2312+#define RIL_RAF_EDGE (1 << RADIO_TECH_EDGE)
2313+#define RIL_RAF_UMTS (1 << RADIO_TECH_UMTS)
2314+#define RIL_RAF_IS95A (1 << RADIO_TECH_IS95A)
2315+#define RIL_RAF_IS95B (1 << RADIO_TECH_IS95B)
2316+#define RIL_RAF_1xRTT (1 << RADIO_TECH_1xRTT)
2317+#define RIL_RAF_EVDO_0 (1 << RADIO_TECH_EVDO_0)
2318+#define RIL_RAF_EVDO_A (1 << RADIO_TECH_EVDO_A)
2319+#define RIL_RAF_HSDPA (1 << RADIO_TECH_HSDPA)
2320+#define RIL_RAF_HSUPA (1 << RADIO_TECH_HSUPA)
2321+#define RIL_RAF_HSPA (1 << RADIO_TECH_HSPA)
2322+#define RIL_RAF_EVDO_B (1 << RADIO_TECH_EVDO_B)
2323+#define RIL_RAF_EHRPD (1 << RADIO_TECH_EHRPD)
2324+#define RIL_RAF_LTE (1 << RADIO_TECH_LTE)
2325+#define RIL_RAF_HSPAP (1 << RADIO_TECH_HSPAP)
2326+#define RIL_RAF_GSM (1 << RADIO_TECH_GSM)
2327+#define RIL_RAF_TD_SCDMA (1 << RADIO_TECH_TD_SCDMA)
2328+
2329+/* Radio capability status */
2330+#define RIL_RC_STATUS_NONE 0
2331+#define RIL_RC_STATUS_SUCCESS 1
2332+#define RIL_RC_STATUS_FAIL 2
2333+
2334 #endif /*__RIL_CONSTANTS_H*/
2335
2336=== modified file 'include/modem.h'
2337--- include/modem.h 2015-07-31 12:37:46 +0000
2338+++ include/modem.h 2016-07-01 17:24:58 +0000
2339@@ -72,9 +72,6 @@
2340
2341 /* Populate the atoms available online */
2342 void (*post_online)(struct ofono_modem *modem);
2343-
2344- /* Is it a multi-SIM standby modem? */
2345- ofono_bool_t (*is_standby)(struct ofono_modem *modem);
2346 };
2347
2348 void ofono_modem_add_interface(struct ofono_modem *modem,
2349@@ -122,8 +119,6 @@
2350 ofono_bool_t value);
2351 ofono_bool_t ofono_modem_get_driver_watches_sim(struct ofono_modem *modem);
2352
2353-ofono_bool_t ofono_modem_is_standby(struct ofono_modem *modem);
2354-
2355 int ofono_modem_driver_register(const struct ofono_modem_driver *);
2356 void ofono_modem_driver_unregister(const struct ofono_modem_driver *);
2357
2358
2359=== modified file 'plugins/infineon.c'
2360--- plugins/infineon.c 2015-09-29 08:48:01 +0000
2361+++ plugins/infineon.c 2016-07-01 17:24:58 +0000
2362@@ -32,11 +32,12 @@
2363 #include "ofono.h"
2364
2365 #include "drivers/rilmodem/vendor.h"
2366+#include "gril.h"
2367 #include "ril.h"
2368
2369 static int inf_probe(struct ofono_modem *modem)
2370 {
2371- return ril_create(modem, OFONO_RIL_VENDOR_INFINEON);
2372+ return ril_create(modem, OFONO_RIL_VENDOR_INFINEON, NULL, NULL, NULL);
2373 }
2374
2375 static struct ofono_modem_driver infineon_driver = {
2376
2377=== modified file 'plugins/mtk.c'
2378--- plugins/mtk.c 2015-09-29 08:48:01 +0000
2379+++ plugins/mtk.c 2016-07-01 17:24:58 +0000
2380@@ -62,6 +62,7 @@
2381 #include <grilrequest.h>
2382 #include <grilunsol.h>
2383
2384+#include "drivers/rilmodem/rilutil.h"
2385 #include "drivers/rilmodem/rilmodem.h"
2386 #include "drivers/rilmodem/vendor.h"
2387
2388@@ -1669,11 +1670,6 @@
2389 return 0;
2390 }
2391
2392-static ofono_bool_t mtk_is_standby(struct ofono_modem *modem)
2393-{
2394- return TRUE;
2395-}
2396-
2397 static struct ofono_modem_driver mtk_driver = {
2398 .name = "mtk",
2399 .probe = mtk_probe,
2400@@ -1684,7 +1680,6 @@
2401 .post_sim = mtk_post_sim,
2402 .post_online = mtk_post_online,
2403 .set_online = mtk_set_online,
2404- .is_standby = mtk_is_standby,
2405 };
2406
2407 static int mtk_init(void)
2408
2409=== added file 'plugins/mtk2.c'
2410--- plugins/mtk2.c 1970-01-01 00:00:00 +0000
2411+++ plugins/mtk2.c 2016-07-01 17:24:58 +0000
2412@@ -0,0 +1,93 @@
2413+/*
2414+ *
2415+ * oFono - Open Source Telephony - RIL-based devices
2416+ *
2417+ * Copyright (C) 2016 Canonical Ltd.
2418+ *
2419+ * This program is free software; you can redistribute it and/or modify
2420+ * it under the terms of the GNU General Public License version 2 as
2421+ * published by the Free Software Foundation.
2422+ *
2423+ * This program is distributed in the hope that it will be useful,
2424+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2425+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2426+ * GNU General Public License for more details.
2427+ *
2428+ * You should have received a copy of the GNU General Public License
2429+ * along with this program; if not, write to the Free Software
2430+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2431+ *
2432+ */
2433+
2434+#ifdef HAVE_CONFIG_H
2435+#include <config.h>
2436+#endif
2437+
2438+#define OFONO_API_SUBJECT_TO_CHANGE
2439+
2440+#include <ofono/plugin.h>
2441+#include <ofono/log.h>
2442+#include <ofono/modem.h>
2443+
2444+#include "ofono.h"
2445+
2446+#include "drivers/rilmodem/rilmodem.h"
2447+#include "drivers/rilmodem/vendor.h"
2448+#include "drivers/mtk2modem/mtk2modem.h"
2449+#include "drivers/mtk2modem/mtk2util.h"
2450+#include "gril.h"
2451+#include "ril.h"
2452+
2453+static const char *mtk2_get_driver_type(enum ofono_atom_type atom)
2454+{
2455+ switch (atom) {
2456+ case OFONO_ATOM_TYPE_VOICECALL:
2457+ case OFONO_ATOM_TYPE_GPRS:
2458+ return MTK2MODEM;
2459+ default:
2460+ return RILMODEM;
2461+ }
2462+}
2463+
2464+static int mtk2_probe(struct ofono_modem *modem)
2465+{
2466+ return ril_create(modem, OFONO_RIL_VENDOR_MTK2,
2467+ mtk2_request_id_to_string,
2468+ mtk2_unsol_request_to_string,
2469+ mtk2_get_driver_type);
2470+}
2471+
2472+static struct ofono_modem_driver mtk2_driver = {
2473+ .name = "mtk2",
2474+ .probe = mtk2_probe,
2475+ .remove = ril_remove,
2476+ .enable = ril_enable,
2477+ .disable = ril_disable,
2478+ .pre_sim = ril_pre_sim,
2479+ .post_sim = ril_post_sim,
2480+ .post_online = ril_post_online,
2481+ .set_online = ril_set_online,
2482+};
2483+
2484+/*
2485+ * This plugin is a device plugin for MTK modems. It can handle newer modems
2486+ * than those that use the old mtk.c plugin, therefore the name mtk2.
2487+ */
2488+static int mtk2_init(void)
2489+{
2490+ int retval = ofono_modem_driver_register(&mtk2_driver);
2491+
2492+ if (retval)
2493+ DBG("ofono_modem_driver_register returned: %d", retval);
2494+
2495+ return retval;
2496+}
2497+
2498+static void mtk2_exit(void)
2499+{
2500+ DBG("");
2501+ ofono_modem_driver_unregister(&mtk2_driver);
2502+}
2503+
2504+OFONO_PLUGIN_DEFINE(mtk2, "MTK v2 modem plugin",
2505+ VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT, mtk2_init, mtk2_exit)
2506
2507=== modified file 'plugins/qcom-msim.c'
2508--- plugins/qcom-msim.c 2016-03-10 10:15:39 +0000
2509+++ plugins/qcom-msim.c 2016-07-01 17:24:58 +0000
2510@@ -31,9 +31,23 @@
2511
2512 #include "ofono.h"
2513
2514+#include "drivers/rilmodem/rilmodem.h"
2515 #include "drivers/rilmodem/vendor.h"
2516+#include "drivers/qcommsimmodem/qcom_msim_modem.h"
2517+#include "gril.h"
2518 #include "ril.h"
2519
2520+static const char *qcom_msim_get_driver_type(enum ofono_atom_type atom)
2521+{
2522+ switch (atom) {
2523+ case OFONO_ATOM_TYPE_GPRS:
2524+ case OFONO_ATOM_TYPE_RADIO_SETTINGS:
2525+ return QCOMMSIMMODEM;
2526+ default:
2527+ return RILMODEM;
2528+ }
2529+}
2530+
2531 static int qcom_msim_probe(struct ofono_modem *modem)
2532 {
2533 int slot_id = ofono_modem_get_integer(modem, "Slot");
2534@@ -48,7 +62,8 @@
2535 g_free(socket);
2536 }
2537
2538- return ril_create(modem, OFONO_RIL_VENDOR_QCOM_MSIM);
2539+ return ril_create(modem, OFONO_RIL_VENDOR_QCOM_MSIM, NULL, NULL,
2540+ qcom_msim_get_driver_type);
2541 }
2542
2543 static struct ofono_modem_driver qcom_msim_driver = {
2544
2545=== modified file 'plugins/ril.c'
2546--- plugins/ril.c 2016-03-14 08:16:40 +0000
2547+++ plugins/ril.c 2016-07-01 17:24:58 +0000
2548@@ -64,9 +64,13 @@
2549
2550 #include "ril.h"
2551 #include "drivers/rilmodem/rilmodem.h"
2552+#include "drivers/rilmodem/rilutil.h"
2553 #include "drivers/rilmodem/vendor.h"
2554 #include "drivers/qcommsimmodem/qcom_msim_modem.h"
2555
2556+#define MULTISIM_SLOT_0 0
2557+#define MULTISIM_SLOT_1 1
2558+
2559 #define MAX_SIM_STATUS_RETRIES 15
2560
2561 /* this gives 30s for rild to initialize */
2562@@ -77,14 +81,37 @@
2563 GRil *ril;
2564 enum ofono_ril_vendor vendor;
2565 int sim_status_retries;
2566- ofono_bool_t connected;
2567+ ofono_bool_t init_state;
2568 ofono_bool_t ofono_online;
2569 int radio_state;
2570 struct ofono_sim *sim;
2571- struct ofono_radio_settings *radio_settings;
2572 int rild_connect_retries;
2573+ GRilMsgIdToStrFunc request_id_to_string;
2574+ GRilMsgIdToStrFunc unsol_request_to_string;
2575+ ril_get_driver_type_func get_driver_type;
2576+ struct cb_data *set_online_cbd;
2577 };
2578
2579+/*
2580+ * Some times we need to access slot B from slot A in dual-SIM modems, so we
2581+ * need these global variables.
2582+ */
2583+static struct ril_data *ril_data_0;
2584+static struct ril_data *ril_data_1;
2585+
2586+/* Get complementary GRil */
2587+GRil *ril_get_gril_complement(struct ofono_modem *modem)
2588+{
2589+ struct ril_data *rd = ofono_modem_get_data(modem);
2590+
2591+ if (rd == ril_data_0 && ril_data_1 != NULL)
2592+ return ril_data_1->ril;
2593+ else if (rd == ril_data_1 && ril_data_0 != NULL)
2594+ return ril_data_0->ril;
2595+
2596+ return NULL;
2597+}
2598+
2599 static void ril_debug(const char *str, void *user_data)
2600 {
2601 struct ril_data *rd = user_data;
2602@@ -92,6 +119,46 @@
2603 ofono_info("Device %d: %s", g_ril_get_slot(rd->ril), str);
2604 }
2605
2606+static const char *get_driver_type(struct ril_data *rd,
2607+ enum ofono_atom_type atom)
2608+{
2609+ if (rd->get_driver_type != NULL)
2610+ return rd->get_driver_type(atom);
2611+
2612+ return RILMODEM;
2613+}
2614+
2615+static void ril_send_power(struct ril_data *rd, ofono_bool_t online,
2616+ GRilResponseFunc func, gpointer user_data)
2617+{
2618+ struct parcel rilp;
2619+
2620+ DBG("(online = 1, offline = 0)): %d", online);
2621+
2622+ g_ril_request_power(rd->ril, (const gboolean) online, &rilp);
2623+
2624+ if (g_ril_send(rd->ril, RIL_REQUEST_RADIO_POWER, &rilp,
2625+ func, user_data, NULL) == 0 && func != NULL) {
2626+ ofono_error("%s: could not set radio to %d", __func__, online);
2627+ func(NULL, user_data);
2628+ }
2629+}
2630+
2631+static void ril_set_powered_off_cb(struct ril_msg *message, gpointer user_data)
2632+{
2633+ struct ofono_modem *modem = user_data;
2634+ struct ril_data *rd = ofono_modem_get_data(modem);
2635+
2636+ if (message == NULL)
2637+ return;
2638+
2639+ if (message->error == RIL_E_SUCCESS)
2640+ g_ril_print_response_no_args(rd->ril, message);
2641+ else
2642+ ofono_error("%s: RIL error %s", __func__,
2643+ ril_error_to_string(message->error));
2644+}
2645+
2646 static void ril_radio_state_changed(struct ril_msg *message, gpointer user_data)
2647 {
2648 struct ofono_modem *modem = user_data;
2649@@ -99,63 +166,76 @@
2650 int radio_state = g_ril_unsol_parse_radio_state_changed(rd->ril,
2651 message);
2652
2653- if (radio_state != rd->radio_state) {
2654-
2655- ofono_info("%s: state: %s rd->ofono_online: %d",
2656- __func__,
2657- ril_radio_state_to_string(radio_state),
2658- rd->ofono_online);
2659-
2660- rd->radio_state = radio_state;
2661-
2662- switch (radio_state) {
2663- case RADIO_STATE_ON:
2664-
2665- if (rd->radio_settings == NULL) {
2666- char *rs_driver;
2667- struct ril_radio_settings_driver_data
2668- rs_data = { rd->ril, modem };
2669-
2670- if (rd->vendor == OFONO_RIL_VENDOR_QCOM_MSIM)
2671- rs_driver = QCOMMSIMMODEM;
2672- else
2673- rs_driver = RILMODEM;
2674-
2675- rd->radio_settings =
2676- ofono_radio_settings_create(modem,
2677- rd->vendor, rs_driver,
2678- &rs_data);
2679- }
2680-
2681- break;
2682-
2683- case RADIO_STATE_UNAVAILABLE:
2684- case RADIO_STATE_OFF:
2685-
2686- /*
2687- * Unexpected radio state change, as we are supposed to
2688- * be online. UNAVAILABLE has been seen occassionally
2689- * when powering off the phone. We wait 5 secs to avoid
2690- * too fast re-spawns, then exit with error to make
2691- * upstart re-start ofono.
2692- */
2693- if (rd->ofono_online) {
2694- ofono_error("%s: radio self-powered off!",
2695- __func__);
2696- sleep(5);
2697- exit(1);
2698- }
2699- break;
2700- default:
2701- /* Malformed parcel; no radio state == broken rild */
2702- g_assert(FALSE);
2703+ ofono_info("%s: state: %s, init: %d, rd->ofono_online: %d",
2704+ __func__, ril_radio_state_to_string(radio_state),
2705+ rd->init_state, rd->ofono_online);
2706+
2707+ rd->radio_state = radio_state;
2708+
2709+ /*
2710+ * Before showing the modem as powered we make sure the radio is off so
2711+ * we start in a sane state (as in AOSP). Note that we must always
2712+ * receive an event with the current radio state on initialization
2713+ * and also that power state has changed effectively when the event with
2714+ * the new radio state has been received (we cannot rely on the reply to
2715+ * RIL_REQUEST_RADIO_POWER). Finally, note that powering off on start is
2716+ * a must for turbo devices (otherwise radio state never moves from
2717+ * unavailable).
2718+ */
2719+ if (rd->init_state) {
2720+ if (radio_state != RADIO_STATE_OFF) {
2721+ DBG("powering off radio on init");
2722+
2723+ ril_send_power(rd, FALSE, ril_set_powered_off_cb, modem);
2724+ } else {
2725+ DBG("calling set_powered(TRUE)");
2726+ rd->init_state = FALSE;
2727+
2728+ /* Note that modem hw is powered, but radio is off */
2729+ ofono_modem_set_powered(modem, TRUE);
2730 }
2731+ return;
2732+ }
2733+
2734+ /* We process pending callbacks */
2735+ if (rd->set_online_cbd != NULL && (
2736+ (rd->ofono_online && radio_state == RADIO_STATE_ON) ||
2737+ (!rd->ofono_online && radio_state == RADIO_STATE_OFF))
2738+ ) {
2739+ ofono_modem_online_cb_t cb = rd->set_online_cbd->cb;
2740+
2741+ DBG("%s: set_online OK: rd->ofono_online: %d",
2742+ __func__, rd->ofono_online);
2743+ CALLBACK_WITH_SUCCESS(cb, rd->set_online_cbd->data);
2744+
2745+ g_free(rd->set_online_cbd);
2746+ rd->set_online_cbd = NULL;
2747+ }
2748+
2749+ if ((radio_state == RADIO_STATE_UNAVAILABLE ||
2750+ radio_state == RADIO_STATE_OFF)
2751+ && rd->ofono_online
2752+ && rd->vendor != OFONO_RIL_VENDOR_MTK2) {
2753+ /*
2754+ * Unexpected radio state change, as we are supposed to
2755+ * be online. UNAVAILABLE has been seen occassionally
2756+ * when powering off the phone. We wait 5 secs to avoid
2757+ * too fast re-spawns, then exit with error to make
2758+ * upstart re-start ofono. In midori we receive an OFF
2759+ * event and immediately after that an ON event when we
2760+ * enter the SIM PIN, so do nothing for that device.
2761+ */
2762+ ofono_error("%s: radio self-powered off!", __func__);
2763+ sleep(5);
2764+ exit(1);
2765 }
2766 }
2767
2768-int ril_create(struct ofono_modem *modem, enum ofono_ril_vendor vendor)
2769+int ril_create(struct ofono_modem *modem, enum ofono_ril_vendor vendor,
2770+ GRilMsgIdToStrFunc request_id_to_string,
2771+ GRilMsgIdToStrFunc unsol_request_to_string,
2772+ ril_get_driver_type_func get_driver_type)
2773 {
2774- ofono_bool_t lte_cap;
2775 struct ril_data *rd = g_try_new0(struct ril_data, 1);
2776 if (rd == NULL) {
2777 errno = ENOMEM;
2778@@ -167,9 +247,10 @@
2779 rd->vendor = vendor;
2780 rd->ofono_online = FALSE;
2781 rd->radio_state = RADIO_STATE_UNAVAILABLE;
2782-
2783- lte_cap = getenv("OFONO_RIL_RAT_LTE") ? TRUE : FALSE;
2784- ofono_modem_set_boolean(modem, MODEM_PROP_LTE_CAPABLE, lte_cap);
2785+ rd->request_id_to_string = request_id_to_string;
2786+ rd->unsol_request_to_string = unsol_request_to_string;
2787+ rd->get_driver_type = get_driver_type;
2788+ rd->init_state = TRUE;
2789
2790 ofono_modem_set_data(modem, rd);
2791
2792@@ -183,7 +264,7 @@
2793
2794 static int ril_probe(struct ofono_modem *modem)
2795 {
2796- return ril_create(modem, OFONO_RIL_VENDOR_AOSP);
2797+ return ril_create(modem, OFONO_RIL_VENDOR_AOSP, NULL, NULL, NULL);
2798 }
2799
2800 void ril_remove(struct ofono_modem *modem)
2801@@ -205,42 +286,84 @@
2802 struct ril_data *rd = ofono_modem_get_data(modem);
2803 struct ril_voicecall_driver_data vc_data = { rd->ril, modem };
2804 struct ril_sim_data sim_data;
2805+ struct ril_radio_settings_driver_data rs_data = { rd->ril, modem };
2806
2807 DBG("");
2808
2809- ofono_devinfo_create(modem, rd->vendor, RILMODEM, rd->ril);
2810- ofono_voicecall_create(modem, rd->vendor, RILMODEM, &vc_data);
2811- ofono_call_volume_create(modem, rd->vendor, RILMODEM, rd->ril);
2812+ ofono_devinfo_create(modem, rd->vendor,
2813+ get_driver_type(rd, OFONO_ATOM_TYPE_DEVINFO),
2814+ rd->ril);
2815+ ofono_voicecall_create(modem, rd->vendor,
2816+ get_driver_type(rd, OFONO_ATOM_TYPE_VOICECALL),
2817+ &vc_data);
2818+ ofono_call_volume_create(modem, rd->vendor,
2819+ get_driver_type(rd, OFONO_ATOM_TYPES_CALL_VOLUME),
2820+ rd->ril);
2821
2822 sim_data.gril = rd->ril;
2823 sim_data.modem = modem;
2824 sim_data.ril_state_watch = NULL;
2825
2826- rd->sim = ofono_sim_create(modem, rd->vendor, RILMODEM, &sim_data);
2827- g_assert(rd->sim != NULL);
2828+ rd->sim = ofono_sim_create(modem, rd->vendor,
2829+ get_driver_type(rd, OFONO_ATOM_TYPE_SIM), &sim_data);
2830+
2831+ /*
2832+ * We need to create radio settings here so FastDormancy property is
2833+ * available even when there is no SIM (no SIM -> post_sim and
2834+ * post_online are not called) so we can make the modem enter low power
2835+ * state in that case.
2836+ */
2837+ ofono_radio_settings_create(modem, rd->vendor,
2838+ get_driver_type(rd, OFONO_ATOM_TYPE_RADIO_SETTINGS),
2839+ &rs_data);
2840 }
2841
2842 void ril_post_sim(struct ofono_modem *modem)
2843 {
2844 struct ril_data *rd = ofono_modem_get_data(modem);
2845+ struct ofono_message_waiting *mw;
2846+
2847+ ofono_sms_create(modem, rd->vendor,
2848+ get_driver_type(rd, OFONO_ATOM_TYPE_SMS), rd->ril);
2849+
2850+ mw = ofono_message_waiting_create(modem);
2851+ if (mw)
2852+ ofono_message_waiting_register(mw);
2853+
2854+ ofono_phonebook_create(modem, rd->vendor,
2855+ get_driver_type(rd, OFONO_ATOM_TYPE_PHONEBOOK), modem);
2856+}
2857+
2858+static void create_post_online_atoms(struct ofono_modem *modem)
2859+{
2860+ struct ril_data *rd = ofono_modem_get_data(modem);
2861 struct ofono_gprs *gprs;
2862 struct ofono_gprs_context *gc;
2863- struct ofono_message_waiting *mw;
2864 struct ril_gprs_driver_data gprs_data = { rd->ril, modem };
2865 struct ril_gprs_context_data
2866 inet_ctx = { rd->ril, modem, OFONO_GPRS_CONTEXT_TYPE_INTERNET };
2867 struct ril_gprs_context_data
2868 mms_ctx = { rd->ril, modem, OFONO_GPRS_CONTEXT_TYPE_MMS };
2869
2870- /* TODO: this function should setup:
2871- * - phonebook
2872- * - stk ( SIM toolkit )
2873- * - radio_settings
2874- */
2875- ofono_sms_create(modem, rd->vendor, RILMODEM, rd->ril);
2876-
2877- gprs = ofono_gprs_create(modem, rd->vendor, RILMODEM, &gprs_data);
2878- gc = ofono_gprs_context_create(modem, rd->vendor, RILMODEM, &inet_ctx);
2879+ ofono_netreg_create(modem, rd->vendor,
2880+ get_driver_type(rd, OFONO_ATOM_TYPE_NETREG), rd->ril);
2881+ ofono_ussd_create(modem, rd->vendor,
2882+ get_driver_type(rd, OFONO_ATOM_TYPE_USSD), rd->ril);
2883+ ofono_call_settings_create(modem, rd->vendor,
2884+ get_driver_type(rd, OFONO_ATOM_TYPE_CALL_SETTINGS),
2885+ rd->ril);
2886+ ofono_call_barring_create(modem, rd->vendor,
2887+ get_driver_type(rd, OFONO_ATOM_TYPE_CALL_BARRING),
2888+ rd->ril);
2889+ ofono_call_forwarding_create(modem, rd->vendor,
2890+ get_driver_type(rd, OFONO_ATOM_TYPE_CALL_FORWARDING),
2891+ rd->ril);
2892+ gprs = ofono_gprs_create(modem, rd->vendor,
2893+ get_driver_type(rd, OFONO_ATOM_TYPE_GPRS),
2894+ &gprs_data);
2895+ gc = ofono_gprs_context_create(modem, rd->vendor,
2896+ get_driver_type(rd, OFONO_ATOM_TYPE_GPRS_CONTEXT),
2897+ &inet_ctx);
2898
2899 if (gc) {
2900 ofono_gprs_context_set_type(gc,
2901@@ -248,69 +371,93 @@
2902 ofono_gprs_add_context(gprs, gc);
2903 }
2904
2905- gc = ofono_gprs_context_create(modem, rd->vendor, RILMODEM, &mms_ctx);
2906+ gc = ofono_gprs_context_create(modem, rd->vendor,
2907+ get_driver_type(rd, OFONO_ATOM_TYPE_GPRS_CONTEXT),
2908+ &mms_ctx);
2909
2910 if (gc) {
2911 ofono_gprs_context_set_type(gc,
2912 OFONO_GPRS_CONTEXT_TYPE_MMS);
2913 ofono_gprs_add_context(gprs, gc);
2914 }
2915-
2916- mw = ofono_message_waiting_create(modem);
2917- if (mw)
2918- ofono_message_waiting_register(mw);
2919-
2920- ofono_call_forwarding_create(modem, rd->vendor, RILMODEM, rd->ril);
2921-
2922- ofono_phonebook_create(modem, rd->vendor, RILMODEM, modem);
2923+}
2924+
2925+static void get_radio_caps_cb(struct ril_msg *message, gpointer user_data)
2926+{
2927+ struct ofono_modem *modem = user_data;
2928+ struct ril_data *rd = ofono_modem_get_data(modem);
2929+ struct reply_radio_capability *caps;
2930+
2931+ if (message->error == RIL_E_SUCCESS) {
2932+ caps = g_ril_reply_parse_get_radio_capability(rd->ril, message);
2933+ if (caps != NULL && (caps->rat & RIL_RAF_LTE)) {
2934+ ofono_modem_set_boolean(modem,
2935+ MODEM_PROP_LTE_CAPABLE, TRUE);
2936+ g_free(caps);
2937+ }
2938+ } else {
2939+ ofono_error("%s: RIL error %s", __func__,
2940+ ril_error_to_string(message->error));
2941+ }
2942+
2943+ create_post_online_atoms(modem);
2944 }
2945
2946 void ril_post_online(struct ofono_modem *modem)
2947 {
2948 struct ril_data *rd = ofono_modem_get_data(modem);
2949-
2950- ofono_netreg_create(modem, rd->vendor, RILMODEM, rd->ril);
2951- ofono_ussd_create(modem, rd->vendor, RILMODEM, rd->ril);
2952- ofono_call_settings_create(modem, rd->vendor, RILMODEM, rd->ril);
2953- ofono_call_barring_create(modem, rd->vendor, RILMODEM, rd->ril);
2954+ ofono_bool_t lte_cap;
2955+
2956+ /* Radio ON -> we can ask for capabilities */
2957+ if (g_ril_get_version(rd->ril) >= 11) {
2958+ if (g_ril_send(rd->ril, RIL_REQUEST_GET_RADIO_CAPABILITY, NULL,
2959+ get_radio_caps_cb, modem, NULL))
2960+ return;
2961+
2962+ ofono_error("%s: error sending GET_RADIO_CAPABILITY", __func__);
2963+ }
2964+
2965+ lte_cap = getenv("OFONO_RIL_RAT_LTE") ? TRUE : FALSE;
2966+ ofono_modem_set_boolean(modem, MODEM_PROP_LTE_CAPABLE, lte_cap);
2967+
2968+ create_post_online_atoms(modem);
2969 }
2970
2971 static void ril_set_online_cb(struct ril_msg *message, gpointer user_data)
2972 {
2973+ struct ril_data *rd = user_data;
2974+
2975+ if (message != NULL && message->error == RIL_E_SUCCESS) {
2976+ g_ril_print_response_no_args(rd->ril, message);
2977+
2978+ /*
2979+ * Wait for radio state change event now, as that is the real
2980+ * moment when radio state changes.
2981+ */
2982+ } else {
2983+ ofono_modem_online_cb_t cb = rd->set_online_cbd->cb;
2984+
2985+ ofono_error("%s: set_online: %d failed", __func__,
2986+ rd->ofono_online);
2987+ CALLBACK_WITH_FAILURE(cb, rd->set_online_cbd->data);
2988+
2989+ g_free(rd->set_online_cbd);
2990+ rd->set_online_cbd = NULL;
2991+ }
2992+}
2993+
2994+static gboolean set_online_done_cb(gpointer user_data)
2995+{
2996 struct cb_data *cbd = user_data;
2997 struct ril_data *rd = cbd->user;
2998 ofono_modem_online_cb_t cb = cbd->cb;
2999
3000- if (message != NULL && message->error == RIL_E_SUCCESS) {
3001- g_ril_print_response_no_args(rd->ril, message);
3002-
3003- DBG("%s: set_online OK: rd->ofono_online: %d", __func__,
3004- rd->ofono_online);
3005- CALLBACK_WITH_SUCCESS(cb, cbd->data);
3006- } else {
3007- ofono_error("%s: set_online: %d failed", __func__,
3008- rd->ofono_online);
3009- CALLBACK_WITH_FAILURE(cb, cbd->data);
3010- }
3011-
3012+ DBG("%s: set_online OK: rd->ofono_online: %d",
3013+ __func__, rd->ofono_online);
3014+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
3015 g_free(cbd);
3016-}
3017-
3018-static void ril_send_power(struct ril_data *rd, ofono_bool_t online,
3019- GRilResponseFunc func,
3020- gpointer user_data)
3021-{
3022- struct parcel rilp;
3023-
3024- DBG("(online = 1, offline = 0)): %i", online);
3025-
3026- g_ril_request_power(rd->ril, (const gboolean) online, &rilp);
3027-
3028- if (g_ril_send(rd->ril, RIL_REQUEST_RADIO_POWER, &rilp,
3029- func, user_data, NULL) == 0 && func != NULL) {
3030-
3031- func(NULL, user_data);
3032- }
3033+
3034+ return FALSE;
3035 }
3036
3037 void ril_set_online(struct ofono_modem *modem, ofono_bool_t online,
3038@@ -323,20 +470,13 @@
3039
3040 DBG("setting rd->ofono_online to: %d", online);
3041
3042- ril_send_power(rd, online, ril_set_online_cb, cbd);
3043-}
3044-
3045-static void ril_set_powered_off_cb(struct ril_msg *message, gpointer user_data)
3046-{
3047- struct ofono_modem *modem = user_data;
3048- struct ril_data *rd = ofono_modem_get_data(modem);
3049-
3050- if (message != NULL && message->error == RIL_E_SUCCESS)
3051- g_ril_print_response_no_args(rd->ril, message);
3052-
3053- DBG("calling set_powered(TRUE)");
3054-
3055- ofono_modem_set_powered(modem, TRUE);
3056+ if ((online && rd->radio_state == RADIO_STATE_ON) ||
3057+ (!online && rd->radio_state == RADIO_STATE_OFF)) {
3058+ g_idle_add(set_online_done_cb, cbd);
3059+ } else {
3060+ rd->set_online_cbd = cbd;
3061+ ril_send_power(rd, online, ril_set_online_cb, rd);
3062+ }
3063 }
3064
3065 static void ril_connected(struct ril_msg *message, gpointer user_data)
3066@@ -345,18 +485,21 @@
3067 struct ril_data *rd = ofono_modem_get_data(modem);
3068 int version;
3069
3070+ /*
3071+ * We will use RIL version to check for presence of some features. The
3072+ * version is updated in AOSP after major changes. For instance:
3073+ *
3074+ * Version 9 -> AOSP 4.4
3075+ * Version 10 -> AOSP 5.0.0
3076+ * Version 11 -> AOSP 6.0.0
3077+ *
3078+ * Note that all Ubuntu phones are based on BSP >= 4.4.
3079+ */
3080 version = g_ril_unsol_parse_connected(rd->ril, message);
3081 g_ril_set_version(rd->ril, version);
3082
3083 ofono_info("[%d,UNSOL]< %s, version %d", g_ril_get_slot(rd->ril),
3084 g_ril_unsol_request_to_string(rd->ril, message->req), version);
3085-
3086- /* TODO: need a disconnect function to restart things! */
3087- rd->connected = TRUE;
3088-
3089- DBG("calling set_powered(FALSE) on connected");
3090-
3091- ril_send_power(rd, FALSE, ril_set_powered_off_cb, modem);
3092 }
3093
3094 static int create_gril(struct ofono_modem *modem)
3095@@ -368,19 +511,28 @@
3096 ofono_info("Using %s as socket for slot %d.", socket, slot_id);
3097 rd->ril = g_ril_new(socket, rd->vendor);
3098
3099- /* NOTE: Since AT modems open a tty, and then call
3100+ /*
3101+ * NOTE: Since AT modems open a tty, and then call
3102 * g_at_chat_new(), they're able to return -EIO if
3103 * the first fails, and -ENOMEM if the second fails.
3104 * in our case, we already return -EIO if the ril_new
3105 * fails. If this is important, we can create a ril_socket
3106 * abstraction... ( probaby not a bad idea ).
3107 */
3108-
3109 if (rd->ril == NULL) {
3110 ofono_error("g_ril_new() failed to create modem!");
3111 return -EIO;
3112 }
3113+
3114+ if (slot_id == MULTISIM_SLOT_0)
3115+ ril_data_0 = rd;
3116+ else
3117+ ril_data_1 = rd;
3118+
3119 g_ril_set_slot(rd->ril, slot_id);
3120+ g_ril_set_vendor_print_msg_id_funcs(rd->ril,
3121+ rd->request_id_to_string,
3122+ rd->unsol_request_to_string);
3123
3124 if (getenv("OFONO_RIL_TRACE"))
3125 g_ril_set_trace(rd->ril, TRUE);
3126
3127=== modified file 'plugins/ril.h'
3128--- plugins/ril.h 2014-07-14 12:47:48 +0000
3129+++ plugins/ril.h 2016-07-01 17:24:58 +0000
3130@@ -19,7 +19,12 @@
3131 *
3132 */
3133
3134-int ril_create(struct ofono_modem *modem, enum ofono_ril_vendor vendor);
3135+typedef const char *(*ril_get_driver_type_func)(enum ofono_atom_type atom);
3136+
3137+int ril_create(struct ofono_modem *modem, enum ofono_ril_vendor vendor,
3138+ GRilMsgIdToStrFunc request_id_to_string,
3139+ GRilMsgIdToStrFunc unsol_request_to_string,
3140+ ril_get_driver_type_func get_driver_type);
3141 void ril_remove(struct ofono_modem *modem);
3142 int ril_enable(struct ofono_modem *modem);
3143 int ril_disable(struct ofono_modem *modem);
3144@@ -28,3 +33,5 @@
3145 void ril_post_online(struct ofono_modem *modem);
3146 void ril_set_online(struct ofono_modem *modem, ofono_bool_t online,
3147 ofono_modem_online_cb_t callback, void *data);
3148+
3149+GRil *ril_get_gril_complement(struct ofono_modem *modem);
3150
3151=== modified file 'plugins/rildev.c'
3152--- plugins/rildev.c 2016-03-09 10:35:25 +0000
3153+++ plugins/rildev.c 2016-07-01 17:24:58 +0000
3154@@ -55,10 +55,14 @@
3155 return -ENODEV;
3156 }
3157
3158- modem_list = g_slist_prepend(modem_list, modem);
3159-
3160 ofono_modem_set_integer(modem, "Slot", slot);
3161
3162+ /*
3163+ * We assume all slots of this type belong to a single physical modem
3164+ * that works in standby mode.
3165+ */
3166+ ofono_modem_set_string(modem, "StandbyGroup", ril_type);
3167+
3168 /* AOSP has socket path "rild", "rild2"..., while others may differ */
3169 if (slot != 0)
3170 socket = g_strdup_printf("/dev/socket/rild%d", slot + 1);
3171@@ -73,9 +77,12 @@
3172 if (retval != 0) {
3173 ofono_error("%s: ofono_modem_register returned: %d",
3174 __func__, retval);
3175+ ofono_modem_remove(modem);
3176 return retval;
3177 }
3178
3179+ modem_list = g_slist_prepend(modem_list, modem);
3180+
3181 /*
3182 * kickstart the modem:
3183 * causes core modem code to call
3184
3185=== modified file 'src/gprs.c'
3186--- src/gprs.c 2016-04-13 14:35:57 +0000
3187+++ src/gprs.c 2016-07-01 17:24:58 +0000
3188@@ -1824,11 +1824,17 @@
3189 struct ofono_modem *modem_notif = data;
3190 DBusConnection *conn;
3191 const char *path = ofono_modem_get_path(modem);
3192+ const char *standby_group, *modem_group;
3193
3194 if (strcmp(path, ofono_modem_get_path(modem_notif)) == 0)
3195 return;
3196
3197- if (!ofono_modem_is_standby(modem))
3198+ standby_group = ofono_modem_get_string(modem_notif, "StandbyGroup");
3199+ if (standby_group == NULL)
3200+ return;
3201+
3202+ modem_group = ofono_modem_get_string(modem, "StandbyGroup");
3203+ if (g_strcmp0(standby_group, modem_group) != 0)
3204 return;
3205
3206 atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_GPRS);
3207@@ -1984,9 +1990,10 @@
3208 gprs->settings);
3209 }
3210
3211- gprs_netreg_update(gprs);
3212-
3213 notify_powered_change(gprs);
3214+
3215+ gprs_netreg_update(gprs);
3216+
3217 } else {
3218 return __ofono_error_invalid_args(msg);
3219 }
3220
3221=== modified file 'src/modem.c'
3222--- src/modem.c 2015-11-02 09:18:14 +0000
3223+++ src/modem.c 2016-07-01 17:24:58 +0000
3224@@ -2278,11 +2278,3 @@
3225 out:
3226 modem->emergency--;
3227 }
3228-
3229-ofono_bool_t ofono_modem_is_standby(struct ofono_modem *modem)
3230-{
3231- if (modem->driver->is_standby == NULL)
3232- return FALSE;
3233-
3234- return modem->driver->is_standby(modem);
3235-}
3236
3237=== modified file 'src/voicecall.c'
3238--- src/voicecall.c 2016-03-14 08:16:40 +0000
3239+++ src/voicecall.c 2016-07-01 17:24:58 +0000
3240@@ -118,7 +118,7 @@
3241
3242 static const char *default_en_list[] = { "911", "112", NULL };
3243 static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",
3244- "08", "000", NULL };
3245+ "08", "000", "120", "122", NULL };
3246
3247 static void send_ciev_after_swap_callback(const struct ofono_error *error,
3248 void *data);
3249@@ -2504,10 +2504,6 @@
3250 vc->en_list = g_hash_table_new_full(g_str_hash, g_str_equal,
3251 g_free, NULL);
3252
3253- /* Emergency numbers from modem/network */
3254- if (vc->nw_en_list)
3255- add_to_en_list(vc, vc->nw_en_list);
3256-
3257 /* Emergency numbers read from SIM */
3258 if (vc->flags & VOICECALL_FLAG_SIM_ECC_READY) {
3259 GSList *l;
3260@@ -2515,9 +2511,16 @@
3261 for (l = vc->sim_en_list; l; l = l->next)
3262 g_hash_table_insert(vc->en_list, g_strdup(l->data),
3263 NULL);
3264- } else
3265+ }
3266+
3267+ /* add the default emergency number, if there no number from SIM */
3268+ if (g_hash_table_size(vc->en_list) == 0)
3269 add_to_en_list(vc, (char **) default_en_list_no_sim);
3270
3271+ /* Emergency numbers from modem/network */
3272+ if (vc->nw_en_list)
3273+ add_to_en_list(vc, vc->nw_en_list);
3274+
3275 /* Default emergency numbers */
3276 add_to_en_list(vc, (char **) default_en_list);
3277

Subscribers

People subscribed via source and target branches

to all changes: